:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f0f2f5;
  --text: #17191c;
  --muted: #5d6673;
  --border: #dde1e7;
  --accent: #2d5be3;
  --accent-hover: #2149c0;
  --on-accent: #ffffff;
  --accent-soft: #e9efff;
  --danger: #c0262d;
  --on-danger: #ffffff;
  --danger-soft: #fdeceb;
  --success: #1d7a4b;
  --success-soft: #e5f4ea;
  --warning: #8f5a00;
  --warning-soft: #fcf1dc;
  --focus: #2d5be3;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.05), 0 4px 16px rgb(15 23 42 / 0.06);
  --radius: 14px;
  --radius-small: 9px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  accent-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-muted: #1f232b;
    --text: #e7e9ee;
    --muted: #9ba3b0;
    --border: #2b3039;
    --accent: #7d9cff;
    --accent-hover: #9cb4ff;
    --on-accent: #0a1022;
    --accent-soft: #1b2648;
    --danger: #ff8a85;
    --on-danger: #2b0b0b;
    --danger-soft: #3b1d1d;
    --success: #6fd6a0;
    --success-soft: #15301f;
    --warning: #f2c063;
    --warning-soft: #33280f;
    --focus: #9cb4ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.25;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.3;
}

h3 {
  font-size: 1rem;
}

a {
  color: var(--accent);
}

svg {
  flex: none;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.stack {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.stack-lg {
  display: grid;
  gap: 2rem;
}

.centered {
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem;
}

.narrow {
  width: 100%;
  max-width: 30rem;
}

.wide {
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-small);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 500;
}

/* Forms */

.field {
  display: grid;
  gap: 0.35rem;
  align-content: start;
}

label,
legend {
  font-weight: 600;
  font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input::placeholder {
  color: var(--muted);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.password {
  display: flex;
  gap: 0.5rem;
}

.password input {
  flex: 1;
  min-width: 0;
}

fieldset {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  display: grid;
  gap: 1rem;
  min-width: 0;
}

legend {
  padding: 0 0.35rem;
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 500;
}

.check input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
}

/* Buttons */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--surface-muted);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}

button.danger-ghost {
  background: transparent;
  color: var(--danger);
}

button.danger-ghost:hover {
  background: var(--danger-soft);
}

button.ghost {
  background: transparent;
  border-color: transparent;
}

button.ghost:hover {
  background: var(--surface-muted);
}

button.small {
  min-height: 2.25rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.875rem;
}

button.large {
  min-height: 3.25rem;
  font-size: 1.05rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Sign-in and public pages */

.brand-mark,
.file-badge {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1rem;
  background: var(--accent-soft);
  color: var(--accent);
}

.brand-mark svg,
.file-badge svg {
  width: 1.9rem;
  height: 1.9rem;
}

.file-badge.is-muted {
  background: var(--surface-muted);
  color: var(--muted);
}

.download {
  justify-items: center;
  text-align: center;
}

.file-name {
  overflow-wrap: anywhere;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  width: 100%;
  margin: 0;
}

.facts div {
  padding: 0.75rem;
  border-radius: var(--radius-small);
  background: var(--surface-muted);
}

.facts dt {
  font-size: 0.8rem;
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-weight: 600;
}

.download form {
  width: 100%;
  text-align: start;
}

.download button[type="submit"] {
  width: 100%;
}

/* Dashboard */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.brand svg {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--accent);
}

.storage {
  font-size: 0.875rem;
}

.dropzone {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  padding: 2rem 1rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}

.dropzone svg {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--accent);
}

.is-dragging .dropzone {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.queue,
.links {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.queue:empty {
  display: none;
}

.upload {
  display: grid;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.upload-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
}

.upload-name {
  margin-right: auto;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.upload.is-done .upload-status {
  color: var(--success);
}

.upload.is-error .upload-status {
  color: var(--danger);
}

progress {
  --progress-radius: 999px;
  --progress-fill: var(--accent);
  appearance: none;
  border: 0 solid;
  overflow: clip;
  width: 100%;
  height: 0.5rem;
  border-radius: var(--progress-radius);
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--border);
}

.upload.is-done progress {
  --progress-fill: var(--success);
}

.upload.is-error progress {
  --progress-fill: var(--danger);
}

progress::-webkit-progress-bar {
  background: transparent;
}

progress::-webkit-progress-value {
  background: var(--progress-fill);
  border-radius: var(--progress-radius);
  transition: inline-size 0.2s;
}

progress::-moz-progress-bar {
  background: var(--progress-fill);
  border-radius: var(--progress-radius);
}

.copy {
  display: flex;
  gap: 0.5rem;
}

.copy input {
  flex: 1;
  min-width: 0;
  min-height: 2.25rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.file {
  display: grid;
  gap: 1rem;
}

.file-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem 1rem;
}

.file-title {
  flex: 1 1 16rem;
  min-width: 0;
}

.file-title h3 {
  overflow-wrap: anywhere;
}

.link {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.5rem 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-small);
  background: var(--surface-muted);
}

.link-body {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.link-url {
  font-family: var(--mono);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
  text-decoration: line-through;
}

.badge {
  justify-self: start;
  margin-top: 0.4rem;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-active {
  background: var(--success-soft);
  color: var(--success);
}

.badge-expired,
.badge-exhausted {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-revoked {
  background: var(--danger-soft);
  color: var(--danger);
}

.note {
  color: var(--warning);
}

.empty {
  padding: 2rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.history summary {
  padding: 0.5rem 0;
  font-weight: 600;
  cursor: pointer;
}

.history[open] summary {
  margin-bottom: 1rem;
}

.file.is-deleted h3 {
  color: var(--muted);
}

dialog {
  width: min(34rem, calc(100% - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.25);
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgb(10 12 16 / 0.55);
  overflow: hidden;
  overscroll-behavior: contain;
}

dialog .actions {
  justify-content: flex-end;
}

@media (max-width: 40rem) {
  .card {
    padding: 1.15rem;
  }

  .link {
    grid-template-columns: minmax(0, 1fr);
  }

  .link > button {
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
