:root {
  color-scheme: dark;
  --bg: #000000;
  --bg-soft: #0a0a0a;
  --surface: #121212;
  --surface-raised: #1b1b1b;
  --surface-hover: #242424;
  --border: #303030;
  --border-soft: #232323;
  --text: #f2f2f2;
  --text-soft: #bcbcbc;
  --muted: #909090;
  --muted-strong: #ababab;
  --accent: #eeeeee;
  --accent-bright: #ffffff;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --accent-border: rgba(255, 255, 255, 0.18);
  --primary-text: #080808;
  --file-image-color: #bcbcbc;
  --file-image-bg: #202020;
  --file-video-color: #bcbcbc;
  --file-video-bg: #222222;
  --file-audio-color: #bcbcbc;
  --file-audio-bg: #1b1b1b;
  --file-archive-color: #bcbcbc;
  --file-archive-bg: #191919;
  --cyan: #4dbac7;
  --success: #42b883;
  --danger: #e5534b;
  --danger-hover: #ec655e;
  --danger-soft: rgba(229, 83, 75, 0.15);
  --warning: #d8b66b;
  --warning-soft: rgba(229, 174, 75, 0.08);
  --warning-border: rgba(229, 174, 75, 0.35);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  --radius-sm: 5px;
  --radius: 9px;
  --radius-lg: 14px;
  --sidebar-width: 240px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="warm"] {
  --bg: #171715;
  --bg-soft: #1b1b18;
  --surface: #22221f;
  --surface-raised: #2c2c27;
  --surface-hover: #35352e;
  --border: #3e3e35;
  --border-soft: #30302a;
  --text: #efeee6;
  --text-soft: #c0beb2;
  --muted: #97968b;
  --muted-strong: #b0aea1;
  --accent: #d8b780;
  --accent-bright: #e7c99d;
  --accent-soft: rgba(216, 183, 128, 0.1);
  --accent-border: rgba(216, 183, 128, 0.3);
  --primary-text: #241e14;
  --file-image-color: #b5c5cd;
  --file-image-bg: #2c3335;
  --file-video-color: #c9afbf;
  --file-video-bg: #342c31;
  --file-audio-color: #b0bd9c;
  --file-audio-bg: #292d24;
  --file-archive-color: #c9b59a;
  --file-archive-bg: #27251f;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6f4;
  --bg-soft: #f0f0ed;
  --surface: #ffffff;
  --surface-raised: #eeeeec;
  --surface-hover: #e6e6e2;
  --border: #d1d1ca;
  --border-soft: #e4e4de;
  --text: #202020;
  --text-soft: #515151;
  --muted: #666666;
  --muted-strong: #555555;
  --accent: #222222;
  --accent-bright: #090909;
  --accent-soft: rgba(0, 0, 0, 0.05);
  --accent-border: rgba(0, 0, 0, 0.15);
  --primary-text: #ffffff;
  --file-image-color: #49616b;
  --file-image-bg: #e8eff1;
  --file-video-color: #73586a;
  --file-video-bg: #f1e9ee;
  --file-audio-color: #546445;
  --file-audio-bg: #ecf0e7;
  --file-archive-color: #72604a;
  --file-archive-bg: #f0ece5;
  --success: #27805d;
  --danger: #b9433b;
  --danger-hover: #a7352e;
  --danger-soft: rgba(185, 67, 59, 0.1);
  --warning: #805b16;
  --warning-soft: rgba(128, 91, 22, 0.06);
  --warning-border: rgba(128, 91, 22, 0.3);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:is(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  color: var(--bg);
  background: var(--accent);
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] {
  display: none !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Shared controls */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.brand strong {
  color: var(--text-soft);
  font-weight: 500;
}

.brand-mark {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
}

.brand-mark--large {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  font-size: 14px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 200ms var(--ease-out), box-shadow 200ms ease;
}

.button svg {
  width: 16px;
  height: 16px;
}

.button:hover:not(:disabled) {
  background: var(--surface-hover);
}

.button:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.button:focus-visible,
.icon-button:focus-visible,
.nav-item:focus-visible,
.mobile-nav button:focus-visible,
.auth-tab:focus-visible,
.upload-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

.button--primary:hover:not(:disabled) {
  background: var(--accent-bright);
  box-shadow: 0 3px 12px var(--accent-soft);
}

.button--secondary {
  border-color: var(--border);
  color: var(--text-soft);
  background: var(--surface);
}

.button--secondary:hover:not(:disabled) {
  border-color: var(--muted);
  color: var(--text);
  background: var(--surface-raised);
}

.button--danger {
  border-color: transparent;
  color: #fff;
  background: var(--danger);
}

.button--danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.button--wide {
  width: 100%;
}

.button-arrow {
  margin-left: auto;
  font-size: 16px;
  font-weight: 400;
  transition: transform 200ms var(--ease-out);
}

.button:hover:not(:disabled) .button-arrow {
  transform: translateX(3px);
}

.button.is-busy::before {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: spin 700ms linear infinite;
}

.icon-button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 200ms var(--ease-out);
}

.icon-button:hover {
  border-color: var(--border);
  color: var(--text);
  background: var(--surface-hover);
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.icon-button:active {
  transform: scale(0.9);
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.field > span,
.share-result > label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
}

.field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.field input,
.field select,
.field textarea,
.share-result input {
  width: 100%;
  height: 38px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text);
  background: var(--bg);
  font-size: 13px;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.field textarea {
  height: 110px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.field select {
  cursor: pointer;
}

.field input::placeholder,
.field textarea::placeholder,
.share-result input::placeholder {
  color: var(--muted);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.share-result input:focus {
  border-color: var(--accent);
  background: var(--bg-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Initial loader */
.loading-view {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: var(--bg);
}

.loading-line {
  width: 80px;
  height: 2px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--border);
}

.loading-line span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: loading-slide 1s ease-in-out infinite alternate;
}

.loading-view.is-error {
  max-width: none;
  padding: 24px;
  text-align: center;
}

.loading-error-message {
  max-width: 360px;
  margin: 0;
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.6;
}

.noscript-message {
  position: fixed;
  z-index: 1100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--text-soft);
  background: var(--bg);
  font-size: 14px;
  text-align: center;
}

@keyframes loading-slide {
  to { transform: translateX(150%); }
}

/* One appearance control moves into the active view's navigation. */
.theme-public-slot {
  position: fixed;
  z-index: 30;
  top: max(20px, env(safe-area-inset-top));
  right: max(24px, env(safe-area-inset-right));
}

.theme-control { position: relative; }
.theme-trigger {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  color: var(--text-soft);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}
.theme-trigger:hover,
.theme-trigger[aria-expanded="true"] { color: var(--text); border-color: var(--accent-border); background: var(--surface-raised); }
.theme-trigger svg { width: 17px; height: 17px; flex-shrink: 0; transition: transform 240ms var(--ease-out); }
.theme-trigger .theme-chevron { width: 13px; height: 13px; color: var(--muted); }
.theme-trigger[aria-expanded="true"] .theme-chevron { transform: rotate(180deg); }
.theme-trigger[aria-expanded="true"] .theme-current-icon { transform: rotate(-12deg) scale(1.08); }
.theme-trigger-caption { display: none; }
[data-theme-slot="sidebar"] .theme-trigger { width: 100%; }
[data-theme-slot="sidebar"] .theme-trigger-caption { display: inline; }
[data-theme-slot="sidebar"] .theme-current-name { margin-left: auto; color: var(--muted); font-size: 11px; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.header-actions .theme-trigger { width: 42px; justify-content: center; padding: 0; }
.header-actions .theme-current-name,
.header-actions .theme-chevron { display: none; }

.theme-menu {
  position: fixed;
  /* Never fall back to the trigger's static position before JS measures the popover. */
  inset: 20px 12px auto auto;
  width: 264px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 32px);
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;
  transition: opacity 180ms ease, transform 220ms var(--ease-out), display 220ms allow-discrete, overlay 220ms allow-discrete;
}
.theme-menu[data-side="above"] { transform-origin: bottom left; transform: translateY(8px) scale(0.96); }
.theme-menu:popover-open { opacity: 1; transform: translateY(0) scale(1); }
@starting-style {
  .theme-menu:popover-open { opacity: 0; transform: translateY(-8px) scale(0.96); }
  .theme-menu[data-side="above"]:popover-open { transform: translateY(8px) scale(0.96); }
}
.theme-menu-heading { margin: 4px 8px 8px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.theme-option,
.theme-motion-option {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-soft);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: color 160ms ease, background 160ms ease;
}
.theme-option:hover,
.theme-option:focus-visible,
.theme-motion-option:hover:not(:disabled),
.theme-motion-option:focus-visible { color: var(--text); background: var(--surface-hover); }
.theme-option:focus-visible,
.theme-motion-option:focus-visible { outline-offset: -2px; }
.theme-option[aria-checked="true"] { color: var(--text); background: var(--accent-soft); }
.theme-option > svg { width: 18px; height: 18px; flex-shrink: 0; }
.theme-option > span,
.theme-motion-option > span:first-child { display: grid; flex: 1; min-width: 0; gap: 3px; }
.theme-menu strong { font-size: 12px; font-weight: 500; }
.theme-menu small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.theme-option .theme-option-check { width: 14px; height: 14px; opacity: 0; transform: scale(0.65); transition: opacity 180ms ease, transform 220ms var(--ease-out); }
.theme-option[aria-checked="true"] .theme-option-check { opacity: 1; transform: scale(1); }
.theme-menu-divider { height: 1px; margin: 8px 4px; background: var(--border-soft); }
.theme-motion-option { min-height: 48px; }
.theme-motion-option:disabled { cursor: default; opacity: 0.65; }
.theme-motion-switch { position: relative; width: 28px; height: 16px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-hover); transition: background 180ms ease; }
.theme-motion-switch::after { position: absolute; top: 3px; left: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); content: ""; transition: transform 200ms var(--ease-out), background 180ms ease; }
.theme-motion-option[aria-checked="true"] .theme-motion-switch { background: var(--accent-soft); border-color: var(--accent-border); }
.theme-motion-option[aria-checked="true"] .theme-motion-switch::after { transform: translateX(12px); background: var(--accent); }

/* SVG clocks/geometry, with stationary canvas frames for Firefox's SVG snapping bug. */
.ambient-background {
  --ambient-ink: color-mix(in srgb, var(--accent), transparent 82%);
  --ambient-track: color-mix(in srgb, var(--accent), transparent 94%);
  position: fixed;
  z-index: 0;
  inset: 0;
  display: none;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}
body:is([data-view="auth"], [data-view="app"]) .ambient-background {
  display: block;
}

.ambient-system {
  position: absolute;
  width: clamp(340px, 34vw, 500px);
  aspect-ratio: 1;
  color: var(--ambient-ink);
}

.ambient-system--one {
  top: -110px;
  left: -150px;
}

.ambient-system--two {
  right: -120px;
  bottom: -120px;
  width: clamp(320px, 31vw, 460px);
}

.ambient-system--three {
  top: 4%;
  left: 51%;
  width: 160px;
}

.ambient-system--four {
  bottom: 3%;
  left: 39%;
  width: 110px;
}

.ambient-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ambient-system--canvas .ambient-scene { visibility: hidden; }

.ambient-canvas {
  position: absolute;
  inset: -24px;
  width: calc(100% + 48px);
  height: calc(100% + 48px);
  pointer-events: none;
}

.ambient-planet {
  width: 60%;
  height: 60%;
  stroke-width: 1;
}

.ambient-planet--ringed {
  width: 70%;
  height: 70%;
}

.ambient-planet-surface {
  fill: var(--bg-soft);
}

.ambient-planet-detail,
.ambient-ring-detail {
  opacity: 0.6;
}

.ambient-orbit-track {
  stroke: var(--ambient-track);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.ambient-orbit--inner .ambient-orbit-track {
  stroke-dasharray: 3 6;
}

.ambient-moon {
  fill: var(--bg-soft);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.ambient-star {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ambient-ink);
  animation: ambient-star-twinkle 8s ease-in-out infinite alternate;
}

.ambient-star--one { left: 25%; top: 12%; }
.ambient-star--two { right: 18%; top: 66%; animation-delay: -3s; }
.ambient-star--three { left: 31%; bottom: 15%; animation-delay: -6s; }
.ambient-star--four { right: 8%; top: 19%; animation-delay: -4s; }

.ambient-background .ambient-star {
  animation-play-state: paused;
}

html[data-ambient-motion="on"][data-page-visibility="visible"] body:is([data-view="auth"], [data-view="app"]) .ambient-background .ambient-star {
  animation-play-state: running;
}

@keyframes ambient-star-twinkle {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* Authentication */
.auth-view,
.share-view {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.auth-view {
  z-index: 1;
  display: flex;
  min-height: 100svh;
  flex-direction: column;
  background: transparent;
}

.auth-main {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(1040px, calc(100% - 48px));
  min-height: 0;
  flex: 1 0 auto;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 88px;
  margin: 0 auto;
  padding: 88px 0 72px;
}

.auth-intro {
  position: relative;
  max-width: 520px;
}

.card-kicker,
.page-overline {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.auth-intro h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(42px, 5.5vw, 68px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1.06;
}

.auth-intro h1 em {
  display: inline-block;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: -0.04em;
  transition: opacity 220ms ease, transform 220ms var(--ease-out);
}

.headline-window {
  display: block;
  min-height: 1.2em;
  /* Let italic ascenders/descenders extend beyond the line box on fallback fonts. */
  line-height: 1.16;
}

.headline-window em.is-exiting {
  opacity: 0;
  transform: translateY(-0.15em);
}

.headline-window em.is-entering {
  opacity: 0;
  transform: translateY(0.15em);
  transition: none;
}

.auth-intro > p {
  max-width: 480px;
  margin: 22px 0 0;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.7;
}

.landing-stats {
  display: grid;
  width: min(370px, 100%);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  padding-top: 20px;
  margin: 28px 0 0;
  border-top: 1px solid var(--border-soft);
}

.landing-stats > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.landing-stats dt {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.landing-stats dd {
  order: -1;
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.file-stack {
  position: relative;
  width: min(370px, 100%);
  height: 210px;
  margin-top: 36px;
}

.stack-file {
  position: absolute;
  top: var(--card-top);
  left: var(--card-left);
  display: flex;
  width: 300px;
  height: 82px;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
  transform: rotate(var(--card-rotation));
  transition: transform 500ms var(--ease-out), border-color 200ms ease;
}

.stack-file--archive {
  --card-top: 8px;
  --card-left: 20px;
  --card-rotation: -7deg;
  --card-lift: -12px;
  --card-delay: 120ms;
  color: var(--file-archive-color);
  background: var(--file-archive-bg);
}

.stack-file--notes {
  --card-top: 54px;
  --card-left: 46px;
  --card-rotation: 5deg;
  --card-lift: -6px;
  --card-delay: 200ms;
  color: var(--file-audio-color);
  background: var(--file-audio-bg);
}

.stack-file--photo {
  --card-top: 108px;
  --card-left: 8px;
  --card-rotation: -3deg;
  --card-lift: 4px;
  --card-delay: 280ms;
  color: var(--file-image-color);
  background: var(--file-image-bg);
}

.stack-file-icon {
  display: grid;
  width: 38px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 4px;
}

.stack-file-icon svg {
  width: 20px;
  height: 20px;
}

.stack-file-copy {
  display: grid;
  flex: 1;
  gap: 5px;
  text-align: left;
}

.stack-file-copy strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.stack-file-copy small {
  color: var(--text-soft);
  font-size: 11px;
}

.stack-file-type {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.03em;
}

.auth-card {
  position: relative;
  padding: 32px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.auth-card-heading {
  margin-bottom: 24px;
}

.auth-card-heading h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.auth-card-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-tabs {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 2px;
  margin-bottom: 24px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.auth-tabs::before {
  position: absolute;
  z-index: -1;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  border-radius: 3px;
  content: "";
  background: var(--surface-raised);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 300ms var(--ease-out);
}

.auth-tabs.is-register::before {
  transform: translateX(100%);
}

.auth-tab {
  height: 36px;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 120ms ease, color 120ms ease;
}

.auth-tab.is-active {
  color: var(--text);
}

.auth-form {
  display: grid;
  gap: 18px;
}

.auth-form .field input {
  height: 44px;
}

.auth-form .button {
  min-height: 44px;
  margin-top: 6px;
}

.form-alert {
  padding: 10px 12px;
  border: 1px solid var(--danger-soft);
  border-radius: var(--radius-sm);
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 12px;
  line-height: 1.4;
}

.consent-field {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.consent-field input {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.consent-field a {
  color: var(--accent-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.landing-footer {
  display: flex;
  width: min(1040px, calc(100% - 48px));
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0 64px;
  margin: 0 auto;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 11px;
}

.landing-footer nav {
  display: flex;
  gap: 18px;
}

.landing-footer a:hover {
  color: var(--text);
}

/* Landing announcements */
.landing-announcements {
  display: grid;
  gap: 10px;
  width: min(520px, 100%);
  margin: 24px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

.landing-announcements-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.announcements-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.announcement-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.announcement-level {
  justify-self: start;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text);
  background: var(--surface-raised);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.announcement-item:has(.announcement-level--info) { border-left-color: var(--cyan); }
.announcement-item:has(.announcement-level--warning) { border-left-color: var(--warning); }
.announcement-item:has(.announcement-level--critical) { border-left-color: var(--danger); }
.announcement-level--info { color: var(--cyan); }
.announcement-level--warning { color: var(--warning); }
.announcement-level--critical { color: var(--danger); }

.announcement-item p {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.announcement-item small {
  color: var(--muted);
  font-size: 11px;
}

.announcement-display-options {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.announcement-display-options legend { padding: 0 5px; color: var(--text-soft); font-size: 12px; }
.announcement-display-options .dialog-note { margin: 0; }
.announcement-display-settings {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.announcement-display-settings .consent-field { margin: 0; }
.announcement-delete-button { justify-self: start; margin-top: 8px; }
.announcement-delete-preview { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }
#announcement-popup-dialog .dialog-card,
#announcement-delete-dialog .dialog-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 24px);
}
#announcement-popup-dialog .dialog-body,
#announcement-delete-dialog .dialog-body { min-height: 0; overflow-y: auto; }
#announcement-popup-dialog .dialog-header,
#announcement-delete-dialog .dialog-header,
#announcement-popup-dialog .dialog-actions,
#announcement-delete-dialog .dialog-actions { flex-shrink: 0; }
#announcement-delete-dialog .dialog-header p { white-space: normal; }
#announcement-delete-dialog .dialog-actions { flex-wrap: wrap; }

/* Leaderboard */
.leaderboard-list-wrap {
  padding: 4px 0;
}

.leaderboard-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) repeat(2, minmax(64px, auto));
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.leaderboard-rank {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.leaderboard-rank.is-top {
  color: var(--accent);
}

.leaderboard-identity {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.leaderboard-identity strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-identity small {
  color: var(--muted);
  font-size: 11px;
}

.leaderboard-metric {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.leaderboard-metric small {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.leaderboard-metric strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.leaderboard-empty {
  padding: 18px;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* Chat */
.chat-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}

.chat-mode-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.chat-mode-switch button {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.chat-mode-switch button[aria-pressed="true"] {
  color: var(--text);
  background: var(--surface-hover);
}

.chat-badge-field {
  min-width: 140px;
  max-width: 220px;
}

.chat-badge-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.chat-status {
  margin: 0;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

#chat-live-status {
  margin-left: auto;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.chat-users-panel,
.chat-thread-panel {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.chat-users-panel {
  overflow: hidden;
}

.chat-user-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 8px;
  list-style: none;
  max-height: 560px;
  overflow-y: auto;
}

.chat-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background 160ms ease, border-color 160ms ease;
}

.chat-user-row:hover,
.chat-user-row:focus-within {
  background: var(--surface-hover);
  border-color: var(--border-soft);
  outline: none;
}

.chat-user-button {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.chat-user-button[aria-pressed="true"] {
  background: var(--accent-soft);
}

.chat-profile-button { flex-shrink: 0; }

.chat-room-header { padding: 14px 14px 0; }
.chat-room-header h2 { margin: 0 0 5px; font-size: 16px; }
.chat-room-header p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.chat-layout .chat-member-search,
.chat-layout .chat-message-search { width: calc(100% - 24px); margin: 0 12px; min-width: 0; }
.chat-layout .search-field input { min-width: 0; }
.chat-placeholder { color: var(--muted); font-size: 13px; }

.chat-user-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.chat-user-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-user-copy small {
  color: var(--muted);
  font-size: 11px;
}

.chat-thread-panel {
  display: grid;
  gap: 12px;
  overflow: hidden;
}

.chat-thread {
  min-height: 320px;
  max-height: 480px;
  overflow-y: auto;
  padding: 14px;
}

.chat-messages {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chat-message {
  display: grid;
  gap: 4px;
  justify-items: start;
  max-width: 78%;
}

.chat-message.is-own {
  justify-self: end;
}

.chat-message-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.chat-message-sender {
  max-width: 100%;
  padding: 0;
  background: transparent;
  color: var(--text-soft);
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.chat-message-sender:hover { color: var(--text); text-decoration: underline; }
.chat-message-meta .profile-badge { padding: 2px 6px; font-size: 10px; }
.chat-profile-bio { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; }
.chat-profile-heading { margin: 8px 0 0; font-size: 13px; }

.chat-message p {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-message.is-own p {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--text);
}

.chat-composer {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
}

.chat-composer input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.chat-composer input:disabled { opacity: 0.6; }

/* Admin announcements form */
.announcement-form {
  display: grid;
  gap: 14px;
  max-width: 560px;
}

.announcement-form textarea {
  min-height: 90px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  resize: vertical;
}

.announcement-form select,
.announcement-form textarea {
  width: 100%;
}

/* FAQ and terms */
.legal-view {
  min-height: 100vh;
  background: var(--bg);
}

.legal-header,
.legal-footer {
  display: flex;
  width: min(920px, calc(100% - 40px));
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0;
  margin: 0 auto;
  border-bottom: 1px solid var(--border-soft);
}

.legal-main {
  width: min(760px, calc(100% - 40px));
  padding: 64px 0 80px;
  margin: 0 auto;
}

.legal-main--terms {
  width: min(820px, calc(100% - 40px));
}

.legal-title {
  margin-bottom: 32px;
}

.legal-title h1 {
  margin: 8px 0 10px;
  font-size: clamp(30px, 5vw, 44px);
  letter-spacing: -0.03em;
}

.legal-title > p:last-child,
.terms-content p,
.terms-content li,
.faq-list p {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.7;
}

.faq-list {
  display: grid;
  gap: 10px;
}

.faq-list details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 160ms ease;
}

.faq-list details[open] {
  border-color: var(--accent-border);
}

.faq-list summary {
  padding: 16px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  list-style: none;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  display: inline-block;
  margin-left: 12px;
  float: right;
  color: var(--muted);
  font-weight: 400;
  content: "+";
  transition: transform 200ms var(--ease-out);
}

.faq-list details[open] summary::after {
  transform: rotate(45deg);
}

.faq-list p {
  padding: 0 18px 17px;
  margin: 0;
}

.legal-notice {
  padding: 14px 16px;
  margin-bottom: 28px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  color: var(--warning);
  background: var(--warning-soft);
  font-size: 12px;
  line-height: 1.6;
}

.terms-content {
  display: grid;
  gap: 28px;
}

.terms-content section {
  scroll-margin-top: 20px;
}

.terms-content h2 {
  margin: 0 0 9px;
  font-size: 17px;
}

.terms-content p {
  margin: 0 0 10px;
}

.terms-content ul {
  display: grid;
  gap: 8px;
  padding-left: 20px;
}

.terms-prohibited {
  padding: 20px;
  border: 1px solid rgba(229, 83, 75, 0.35);
  border-radius: var(--radius);
  background: var(--danger-soft);
}

.legal-footer {
  justify-content: flex-end;
  gap: 18px;
  border-top: 1px solid var(--border-soft);
  border-bottom: 0;
  color: var(--muted);
  font-size: 11px;
  padding: 20px 0 64px;
}

.legal-footer a:hover {
  color: var(--text);
}

/* Signed-in application */
.app-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  background: transparent;
}

.sidebar {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  overflow-y: auto;
  padding: 20px 16px;
  border-right: 1px solid var(--border-soft);
  background: var(--bg-soft);
}

.sidebar-brand {
  padding: 0 4px;
}

.sidebar-nav {
  display: grid;
  flex-shrink: 0;
  gap: 4px;
  margin-top: 32px;
}

.nav-label {
  padding: 0 8px 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: flex;
  width: 100%;
  height: 38px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 160ms ease, color 160ms ease;
}

.nav-item::before {
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: -5px;
  width: 2px;
  border-radius: 2px;
  content: "";
  background: var(--accent);
  transform: scaleY(0);
  transition: transform 250ms var(--ease-out);
}

.nav-item svg {
  width: 16px;
  height: 16px;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-item.is-active {
  color: var(--text);
  background: var(--accent-soft);
}

.nav-item.is-active::before {
  transform: scaleY(1);
}

.sidebar-bottom {
  display: grid;
  gap: 12px;
  margin-top: auto;
  flex-shrink: 0;
  padding-top: 16px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-top: 1px solid var(--border-soft);
}

.avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-raised);
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-copy {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 2px;
}

.account-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy small {
  color: var(--muted);
  font-size: 11px;
}

.workspace {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.workspace-main {
  width: min(1100px, calc(100% - 48px));
  margin: 0 auto;
  padding: 36px 0 60px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-overline {
  margin: 0 0 4px;
}

.page-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.page-header > div > p:last-child {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.stat-card {
  position: relative;
  min-width: 0;
  min-height: 110px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-card--accent {
  background: var(--surface);
  border-color: var(--accent-border);
}

.stat-card--accent > strong {
  color: var(--accent-bright);
}

.stat-card--accent::after {
  display: none;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.stat-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-raised);
}

.stat-icon svg {
  width: 14px;
  height: 14px;
}

.stat-card > strong {
  display: block;
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-card > small {
  color: var(--muted);
  font-size: 11px;
}

.progress-track {
  width: 100%;
  height: 4px;
  margin: 6px 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--border-soft);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 500ms var(--ease-out);
}

.upload-zone {
  position: relative;
  display: grid;
  min-height: 80px;
  place-items: center;
  padding: 16px 20px;
  margin-bottom: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  outline: none;
  color: var(--text-soft);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.upload-zone:hover,
.upload-zone.is-dragging {
  border-color: var(--accent);
  background: var(--surface-raised);
}

.upload-zone.is-uploading {
  cursor: wait;
}

.upload-zone.is-dragging {
  box-shadow: inset 0 0 0 3px var(--accent-soft);
}

.upload-zone.is-complete {
  animation: upload-complete 900ms ease-out;
}

.upload-idle {
  display: flex;
  align-items: center;
  gap: 12px;
}

.upload-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-raised);
  transition: transform 300ms var(--ease-out), color 200ms ease;
}

.upload-zone:is(:hover, .is-dragging) .upload-icon {
  color: var(--accent);
  transform: translateY(-3px);
}

.upload-icon svg {
  width: 18px;
  height: 18px;
}

.upload-idle > div {
  display: grid;
  gap: 2px;
}

.upload-idle strong {
  font-size: 13px;
  font-weight: 500;
}

.upload-idle strong span {
  color: var(--text);
  text-decoration: underline;
}

.upload-idle small {
  color: var(--muted);
  font-size: 11px;
}

.upload-progress-wrap {
  width: min(500px, 100%);
}

.upload-progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 12px;
}

.upload-progress-copy strong {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress-copy span {
  color: var(--muted);
  font-size: 11px;
}

.progress-track--large {
  height: 4px;
  margin: 0;
}

.files-panel,
.admin-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-header {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-header > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.panel-header h2,
.section-heading h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.panel-header > div > span {
  color: var(--muted);
  font-size: 11px;
}

.search-field {
  position: relative;
  display: flex;
  width: min(220px, 40vw);
  height: 32px;
  align-items: center;
}

.search-field svg {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  height: 100%;
  padding: 0 10px 0 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text);
  background: var(--bg);
  font-size: 12px;
}

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

.search-field input:focus {
  border-color: var(--accent);
}

.table-wrap {
  overflow-x: auto;
}

.files-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.files-table th {
  height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--bg-soft);
  font-size: 11px;
  font-weight: 500;
  text-align: left;
}

.files-table th:first-child,
.files-table td:first-child {
  width: 45%;
  padding-left: 16px;
}

.files-table th:nth-child(2),
.files-table td:nth-child(2) {
  width: 15%;
}

.files-table th:nth-child(3),
.files-table td:nth-child(3) {
  width: 15%;
}

.files-table th:nth-child(4),
.files-table td:nth-child(4) {
  width: 10%;
}

.files-table th:last-child,
.files-table td:last-child {
  width: 15%;
  padding-right: 16px;
  text-align: right;
}

.files-table td {
  height: 52px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-soft);
  font-size: 12px;
}

.files-table tbody tr {
  transition: background 100ms ease;
}

.files-table tbody tr:hover {
  background: var(--surface-raised);
}

.file-name-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.file-badge {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: var(--surface-raised);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.file-badge.is-image {
  border-color: color-mix(in srgb, var(--file-image-color), transparent 65%);
  color: var(--file-image-color);
  background: var(--file-image-bg);
}

.file-badge.is-video {
  border-color: color-mix(in srgb, var(--file-video-color), transparent 65%);
  color: var(--file-video-color);
  background: var(--file-video-bg);
}

.file-badge.is-audio {
  border-color: color-mix(in srgb, var(--file-audio-color), transparent 65%);
  color: var(--file-audio-color);
  background: var(--file-audio-bg);
}

.file-badge.is-archive {
  border-color: color-mix(in srgb, var(--file-archive-color), transparent 65%);
  color: var(--file-archive-color);
  background: var(--file-archive-bg);
}

.file-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.file-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-copy small {
  color: var(--muted);
  font-size: 11px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 11px;
  font-weight: 500;
}

.status-pill::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  content: "";
  background: var(--muted);
}

.status-pill.is-shared {
  color: var(--success);
  background: rgba(66, 184, 131, 0.1);
}

.status-pill.is-shared::before {
  background: var(--success);
}

.file-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.file-actions .icon-button {
  width: 28px;
  height: 28px;
}

.file-actions .icon-button svg {
  width: 14px;
  height: 14px;
}

.file-actions .delete-action:hover {
  border-color: var(--danger-soft);
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  align-content: center;
  padding: 32px 20px;
  text-align: center;
}

.empty-state--small {
  min-height: 160px;
}

.empty-illustration {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-raised);
}

.empty-illustration svg {
  width: 20px;
  height: 20px;
}

.empty-state h3 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.empty-state p {
  max-width: 300px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.mobile-header,
.mobile-nav {
  display: none;
}

/* Profile and tickets */
.restricted-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 1px solid rgba(229, 83, 75, 0.35);
  border-radius: var(--radius);
  color: var(--danger);
  background: var(--danger-soft);
}

.restricted-banner > svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.restricted-banner strong {
  display: block;
  margin-bottom: 3px;
}

.restricted-banner p {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.5;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.profile-avatar-editor {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  font-size: 22px;
}

.profile-avatar-editor > div {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 3px;
}

.profile-avatar-editor strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-avatar-editor span {
  color: var(--muted);
  font-size: 11px;
}

.profile-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.profile-form .field:nth-child(3),
.profile-form .button {
  grid-column: 1 / -1;
}

.color-field input[type="color"] {
  padding: 4px;
  cursor: pointer;
}

.profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 18px;
}

.profile-badge {
  --badge-color: var(--accent);
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--badge-color), transparent 45%);
  border-radius: 14px;
  color: color-mix(in srgb, var(--badge-color), white 30%);
  background: color-mix(in srgb, var(--badge-color), transparent 86%);
  font-size: 10px;
  font-weight: 600;
}

.shared-links-status { margin: 0; padding: 14px 20px; color: var(--muted); font-size: 12px; }
.shared-links-status:empty { display: none; }
.shared-links-list { display: grid; }
.shared-link-row { display: grid; min-width: 0; gap: 12px; padding: 20px; border-bottom: 1px solid var(--border-soft); }
.shared-link-row:last-child { border-bottom: 0; }
.shared-link-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.shared-link-heading > div { display: grid; min-width: 0; gap: 6px; }
.shared-link-heading h3 { margin: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 500; }
.shared-link-heading small, .shared-link-unavailable { color: var(--muted); font-size: 11px; line-height: 1.6; }
.shared-link-unavailable { margin: 0; }
.shared-link-url { display: flex; min-width: 0; flex-wrap: wrap; gap: 8px; }
.shared-link-url input { flex: 1 1 180px; width: 0; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-soft); background: var(--bg-soft); font-size: 12px; }
.shared-link-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
#share-result { margin-top: 0; margin-bottom: 20px; }
#retry-share-button { margin-bottom: 16px; }

.tickets-layout {
  display: grid;
  min-height: 540px;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.tickets-list-panel {
  border-right: 1px solid var(--border-soft);
  background: var(--bg-soft);
}

.tickets-list {
  display: grid;
}

.ticket-list-item {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.ticket-list-item:hover,
.ticket-list-item.is-active {
  background: var(--surface-raised);
}

.ticket-list-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ticket-list-top strong,
.ticket-list-subject {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-list-subject {
  font-size: 13px;
  font-weight: 550;
}

.ticket-list-item small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-thread-panel {
  min-width: 0;
}

.ticket-thread-panel > .empty-state {
  min-height: 540px;
}

#ticket-thread {
  display: flex;
  height: 540px;
  flex-direction: column;
}

.ticket-thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.ticket-thread-header > div {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.ticket-thread-header h2 {
  overflow: hidden;
  margin: 0;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-thread-header small {
  color: var(--muted);
  font-size: 10px;
}

.ticket-thread-header select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 11px;
}

.ticket-ban-context {
  display: grid;
  gap: 3px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(229, 83, 75, 0.25);
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 11px;
}

.ticket-ban-context span {
  color: var(--text);
  font-weight: 600;
}

.ticket-ban-context small,
.ticket-ban-context p {
  margin: 0;
  color: var(--text-soft);
  font-size: 10px;
  line-height: 1.45;
}

.ticket-ban-context p {
  padding-top: 5px;
  border-top: 1px solid rgba(229, 83, 75, 0.2);
}

.appeal-actions {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.ticket-messages {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow-y: auto;
}

.ticket-message {
  max-width: 82%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.ticket-message.is-own {
  align-self: flex-end;
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.ticket-message header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

.ticket-message strong,
.ticket-message time {
  font-size: 10px;
}

.ticket-message time {
  color: var(--muted);
}

.ticket-message p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.ticket-reply-form {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border-soft);
}

.ticket-reply-form textarea {
  min-height: 40px;
  flex: 1;
  padding: 10px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text);
  background: var(--bg);
}

#ticket-closed-note {
  margin: 12px;
}

/* Admin */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.admin-card {
  min-width: 0;
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.section-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-raised);
}

.section-icon svg {
  width: 16px;
  height: 16px;
}

.section-heading > div {
  display: grid;
  gap: 2px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.invite-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 16px;
}

.invite-form .button {
  grid-column: 1 / -1;
}

.generated-invite {
  display: grid;
  gap: 6px;
  padding: 12px;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.generated-invite > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.generated-invite > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.generated-invite code {
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: monospace;
  font-size: 12px;
}

.generated-invite small {
  color: var(--muted);
  font-size: 11px;
}

.invites-list {
  display: grid;
}

.invite-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(190px, auto) auto auto auto;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--border-soft);
}

.invite-hidden-code {
  color: var(--text-soft);
  font-family: monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.invite-row:last-child {
  border-bottom: 0;
}

.invite-row > div:first-child {
  display: grid;
  gap: 2px;
}

.invite-row strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.invite-row small {
  color: var(--muted);
  font-size: 11px;
}

.invite-uses {
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 11px;
}

.mini-empty {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-users-panel {
  overflow: hidden;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.users-table th {
  height: 36px;
  padding: 0 14px;
  color: var(--muted);
  background: var(--bg-soft);
  font-size: 10px;
  font-weight: 600;
  text-align: left;
}

.users-table td {
  min-height: 62px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
  vertical-align: middle;
}

.users-table th:first-child,
.users-table td:first-child {
  width: 23%;
  padding-left: 18px;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
  width: 14%;
}

.users-table th:nth-child(3),
.users-table td:nth-child(3) {
  width: 18%;
}

.users-table th:nth-child(4),
.users-table td:nth-child(4) {
  width: 13%;
}

.users-table th:nth-child(5),
.users-table td:nth-child(5) {
  width: 12%;
}

.users-table th:last-child,
.users-table td:last-child {
  width: 20%;
  padding-right: 18px;
  text-align: right;
}

.user-account-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.user-account-cell > span:last-child,
.user-rank-cell,
.user-storage-cell,
.user-status-cell {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.user-account-cell strong,
.user-rank-cell strong,
.user-storage-cell strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-account-cell small,
.user-rank-cell small,
.user-storage-cell small,
.user-status-cell small,
.self-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-summary-button {
  padding: 4px 7px;
  border-radius: var(--radius-sm);
  color: var(--accent-bright);
  background: var(--accent-soft);
  cursor: pointer;
  font-size: 10px;
}

.status-pill.is-banned {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-pill.is-banned::before {
  background: var(--danger);
}

.user-admin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.badge-admin-card {
  margin-top: 16px;
}

.badge-form {
  display: grid;
  grid-template-columns: 0.8fr 1.4fr 110px auto;
  align-items: end;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-soft);
}

.badges-list {
  display: grid;
}

.badge-library-row {
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.badge-library-copy {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 2px;
}

.badge-library-copy strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-library-copy small {
  color: var(--muted);
  font-size: 10px;
}

.badge-options {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.badge-option {
  cursor: pointer;
}

.badge-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.badge-option input:not(:checked) + .profile-badge {
  opacity: 0.42;
  filter: grayscale(1);
}

.badge-option input:focus-visible + .profile-badge {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button--small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 11px;
}

.button--danger-outline {
  border-color: rgba(229, 83, 75, 0.35);
  color: var(--danger);
  background: transparent;
}

.button--danger-outline:hover:not(:disabled) {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.reports-summary-grid {
  grid-template-columns: repeat(3, 1fr);
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.reports-table th,
.reports-table td {
  padding: 11px 13px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  text-align: left;
}

.reports-table th {
  height: 36px;
  border-top: 0;
  color: var(--muted);
  background: var(--bg-soft);
  font-size: 10px;
}

.reports-table th:first-child,
.reports-table td:first-child { width: 27%; padding-left: 18px; }
.reports-table th:nth-child(2),
.reports-table td:nth-child(2) { width: 15%; }
.reports-table th:nth-child(3),
.reports-table td:nth-child(3) { width: 18%; }
.reports-table th:nth-child(4),
.reports-table td:nth-child(4) { width: 17%; }
.reports-table th:nth-child(5),
.reports-table td:nth-child(5) { width: 12%; }
.reports-table th:last-child,
.reports-table td:last-child { width: 11%; padding-right: 18px; text-align: right; }

.report-file-cell {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.report-file-cell strong,
.report-file-cell small,
.report-owner {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-file-cell strong {
  font-size: 12px;
}

.report-file-cell small,
.report-date {
  color: var(--muted);
  font-size: 10px;
}

.report-category {
  display: inline-flex;
  padding: 3px 7px;
  border-radius: 12px;
  color: var(--text-soft);
  background: var(--surface-raised);
  font-size: 10px;
}

.report-category.is-critical {
  color: var(--danger);
  background: var(--danger-soft);
}

.report-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.report-detail-grid > span,
.report-details {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.report-detail-grid small,
.report-details > span {
  color: var(--muted);
  font-size: 10px;
}

.report-detail-grid strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-details p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.dialog-actions--spread {
  align-items: center;
  justify-content: space-between;
}

.dialog-actions--spread > div {
  display: flex;
  gap: 8px;
}

/* Public share page */
.share-main {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(480px, calc(100% - 32px));
  min-height: 100svh;
  grid-template-columns: minmax(0, 1fr);
  place-content: center;
  justify-items: center;
  gap: 20px;
  padding: 64px 0 104px;
  margin: 0 auto;
}

.public-share-card {
  position: relative;
  width: 100%;
  padding: 36px 28px 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.public-file-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  margin: 0 auto 20px;
  color: var(--accent);
}

.public-file-icon svg {
  width: 44px;
  height: 44px;
}

.public-share-card h1 {
  overflow-wrap: anywhere;
  margin: 12px 0 8px;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.public-share-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.public-file-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 16px 0;
  margin: 20px 0 16px;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.public-file-meta.is-owner-hidden {
  grid-template-columns: repeat(2, 1fr);
}

.public-file-meta > span {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.public-file-meta small {
  color: var(--muted);
  font-size: 11px;
}

.public-file-meta strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-share-card .public-report-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  transition: color 160ms ease;
}

.public-report-button:hover:not(:disabled) {
  color: var(--danger);
}

.public-report-button:disabled {
  cursor: default;
  opacity: 0.5;
}

.public-share-card > .button {
  min-height: 44px;
}

.public-report-button svg {
  width: 13px;
  height: 13px;
}

.back-link {
  color: var(--muted);
  font-size: 12px;
  transition: color 120ms ease;
}

.back-link:hover {
  color: var(--text);
}

.back-link span {
  margin-left: 4px;
  color: var(--text);
}

/* Dialogs */
.dialog {
  width: min(440px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  overflow: visible;
  border: 0;
  outline: none;
  color: var(--text);
  background: transparent;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  animation: fade-in 180ms ease-out;
}

.dialog-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--border-soft);
}

.dialog-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-raised);
}

.dialog-icon--danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.dialog-icon svg {
  width: 16px;
  height: 16px;
}

.dialog-header > div {
  min-width: 0;
  flex: 1;
}

.dialog-header h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.dialog-header p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-header .icon-button {
  margin: -2px -2px 0 0;
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-note {
  padding: 10px 12px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: var(--bg);
  font-size: 12px;
  line-height: 1.4;
}

.share-result {
  display: grid;
  gap: 6px;
  padding-top: 2px;
}

.share-result > div {
  display: flex;
  gap: 8px;
}

.share-result .button {
  flex: 0 0 auto;
}

.share-result small {
  color: var(--muted);
  font-size: 11px;
}

.dialog-footer {
  display: flex;
  justify-content: center;
  padding: 12px 18px;
  border-top: 1px solid var(--border-soft);
}

.text-button {
  padding: 2px;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 12px;
}

.text-button--danger {
  color: var(--danger);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border-soft);
}

.delete-file-name {
  padding: 10px 12px;
  margin: 0;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--bg);
  font-size: 12px;
}

/* Toasts */
.toast-region {
  position: fixed;
  z-index: 1001;
  right: 16px;
  bottom: 16px;
  display: grid;
  width: min(320px, calc(100% - 32px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.4;
  animation: toast-in 300ms var(--ease-out);
}

.toast::before {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  content: "";
  background: var(--success);
}

.toast.is-error::before {
  background: var(--danger);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(4px);
  transition: 120ms ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
}

/* Brief state-driven entrances; headline cycling only runs on the visible landing view. */
.auth-view:not([hidden]) .auth-intro h1,
.auth-view:not([hidden]) .auth-intro > p,
.auth-view:not([hidden]) .landing-stats,
.auth-view:not([hidden]) .auth-card,
.share-view:not([hidden]) .public-share-card,
.legal-view:not([hidden]) .legal-title,
.page:not([hidden]) > * {
  animation: enter-up 500ms var(--ease-out) backwards;
}

.auth-view:not([hidden]) .auth-intro > p {
  animation-delay: 70ms;
}

.auth-view:not([hidden]) .auth-card {
  animation-delay: 120ms;
}

.auth-view:not([hidden]) .landing-stats {
  animation-delay: 140ms;
}

.auth-view:not([hidden]) .stack-file {
  animation: stack-arrive 700ms var(--ease-out) var(--card-delay) backwards;
}

.auth-form:not([hidden]),
.share-result:not([hidden]),
.form-alert:not([hidden]),
.faq-list details[open] > p {
  animation: enter-up 240ms var(--ease-out) backwards;
}

.page:not([hidden]) > :nth-child(2) { animation-delay: 40ms; }
.page:not([hidden]) > :nth-child(3) { animation-delay: 80ms; }
.page:not([hidden]) > :nth-child(4) { animation-delay: 120ms; }

.files-table tr.is-new {
  animation: row-arrive 350ms var(--ease-out) var(--row-delay, 0ms) backwards;
}

.dialog[open] .dialog-card {
  animation: dialog-in 250ms var(--ease-out);
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .file-stack:hover .stack-file {
    border-color: var(--muted);
    transform: translateY(var(--card-lift)) rotate(var(--card-rotation));
  }

  .button:hover:not(:disabled) {
    transform: translateY(-1px);
  }

  .button:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes enter-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes stack-arrive {
  from { opacity: 0; transform: translateY(24px) rotate(0deg); }
  to { opacity: 1; transform: translateY(0) rotate(var(--card-rotation)); }
}

@keyframes row-arrive {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes upload-complete {
  0%, 35% { border-color: var(--success); background: rgba(66, 184, 131, 0.08); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1050px) {
  .auth-main {
    gap: 40px;
  }

  .auth-intro h1 {
    font-size: 56px;
  }

  .workspace-main {
    width: min(100% - 36px, 1040px);
  }

  .users-table {
    min-width: 880px;
  }

  .reports-table {
    min-width: 760px;
  }
}

@media (max-width: 850px) {
  .auth-main {
    width: min(440px, calc(100% - 32px));
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 88px 0 48px;
    margin: 0 auto;
  }

  .auth-intro {
    text-align: center;
  }

  .auth-intro h1 {
    font-size: 48px;
  }

  .auth-intro > p {
    margin-right: auto;
    margin-left: auto;
  }

  .file-stack {
    margin: 28px auto 0;
  }

  .landing-stats {
    margin-right: auto;
    margin-left: auto;
  }

  .sidebar {
    width: 200px;
  }

  .workspace {
    margin-left: 200px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card--accent {
    grid-column: 1 / -1;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .admin-summary-grid .stat-card--accent {
    grid-column: 1 / -1;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-user-list {
    max-height: 160px;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .badge-form {
    grid-template-columns: 1fr 1fr;
  }

  .files-table th:nth-child(3),
  .files-table td:nth-child(3) {
    display: none;
  }

  .files-table th:first-child,
  .files-table td:first-child {
    width: 50%;
  }

  .files-table th:nth-child(2),
  .files-table td:nth-child(2) {
    width: 15%;
  }

  .files-table th:nth-child(4),
  .files-table td:nth-child(4) {
    width: 15%;
  }

  .files-table th:last-child,
  .files-table td:last-child {
    width: 20%;
  }
}

@media (max-width: 680px) {
  .auth-main {
    padding-top: 88px;
  }

  .auth-intro h1 {
    font-size: 44px;
  }

  .auth-intro > p {
    margin-top: 16px;
    font-size: 14px;
  }

  .file-stack {
    display: none;
  }

  .auth-card {
    padding: 24px;
  }

  .landing-footer {
    width: calc(100% - 28px);
    align-items: flex-start;
    flex-direction: column;
  }

  .legal-header,
  .legal-footer,
  .legal-main,
  .legal-main--terms {
    width: calc(100% - 28px);
  }

  .legal-header .brand > span:last-child {
    display: none;
  }

  .legal-main {
    padding: 42px 0 60px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    margin-left: 0;
  }

  .tickets-layout {
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .chat-composer {
    flex-direction: column;
  }

  .chat-composer .button {
    width: 100%;
  }

  .leaderboard-row {
    grid-template-columns: 28px minmax(0, 1fr) repeat(2, auto);
    gap: 10px;
  }

  .tickets-list-panel {
    max-height: 210px;
    overflow-y: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }

  #ticket-thread,
  .ticket-thread-panel > .empty-state {
    height: 480px;
    min-height: 480px;
  }

  .profile-avatar-editor {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .profile-form,
  .badge-form {
    grid-template-columns: 1fr;
  }

  .profile-form .field,
  .profile-form .button {
    grid-column: auto;
  }

  .mobile-header {
    position: sticky;
    z-index: 15;
    top: 0;
    display: flex;
    height: 56px;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-soft);
  }

  .workspace-main {
    width: calc(100% - 24px);
    padding: 24px 0 140px;
  }

  .page-header {
    align-items: center;
    margin-bottom: 20px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .page-header > div > p:last-child {
    display: none;
  }

  .page-header .button span {
    display: none;
  }

  .page-header .button {
    width: 38px;
    padding: 0;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .stats-grid .stat-card--accent {
    grid-column: auto;
  }

  .stats-grid .stat-top {
    min-height: 26px;
    margin-bottom: 6px;
    font-size: 11px;
  }

  .stats-grid .stat-icon,
  .stats-grid .stat-card:not(.stat-card--accent) > small {
    display: none;
  }

  .stat-card {
    min-height: 100px;
    padding: 12px;
  }

  .stat-card > strong {
    font-size: 18px;
  }

  .upload-zone {
    min-height: 72px;
    padding: 12px;
  }

  .upload-idle {
    gap: 10px;
  }

  .upload-icon {
    width: 32px;
    height: 32px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
  }

  .search-field {
    width: 100%;
  }

  .files-table th:nth-child(2),
  .files-table td:nth-child(2),
  .files-table th:nth-child(4),
  .files-table td:nth-child(4) {
    display: none;
  }

  .files-table th:first-child,
  .files-table td:first-child {
    width: 70%;
    padding-left: 12px;
  }

  .files-table th:last-child,
  .files-table td:last-child {
    width: 30%;
    padding-right: 12px;
  }

  .file-actions {
    gap: 2px;
  }

  .file-actions .icon-button {
    width: 26px;
  }

  .mobile-nav {
    position: fixed;
    z-index: 25;
    right: 12px;
    bottom: 12px;
    left: 12px;
    display: flex;
    min-height: 52px;
    align-items: center;
    justify-content: flex-start;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow-x: auto;
  }

  .mobile-nav button {
    display: flex;
    min-width: 64px;
    flex: 1 0 64px;
    height: 40px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    background: transparent;
    font-size: 10px;
    transition: color 160ms ease, background 160ms ease;
  }

  .mobile-nav button svg {
    width: 16px;
    height: 16px;
  }

  .mobile-nav button.is-active {
    color: var(--accent-bright);
    background: var(--accent-soft);
  }

  .admin-card {
    padding: 16px;
  }

  .invite-row {
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    padding: 10px 0;
  }

  .invite-info {
    grid-column: 1 / -1;
  }

  .invite-hidden-code {
    grid-column: 1 / 2;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .admin-summary-grid {
    grid-template-columns: 1fr;
  }

  .admin-summary-grid .stat-card--accent {
    grid-column: auto;
  }

  .reports-summary-grid {
    grid-template-columns: 1fr;
  }

  .report-detail-grid {
    grid-template-columns: 1fr;
  }

  .dialog-actions--spread {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-actions--spread > div {
    flex-direction: column;
  }

  .invite-form {
    grid-template-columns: 1fr;
  }

  .public-share-card {
    padding: 24px 16px 20px;
  }

  .public-file-meta,
  .public-file-meta.is-owner-hidden {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .public-file-meta > span {
    grid-template-columns: 1fr 1fr;
    text-align: left;
  }

  .public-file-meta > span strong {
    text-align: right;
  }

  .dialog {
    max-height: calc(100vh - 16px);
  }

  .dialog-card {
    border-radius: var(--radius);
  }

  .toast-region {
    right: 12px;
    bottom: 12px;
    width: calc(100% - 24px);
  }

  body[data-view="app"] .toast-region {
    bottom: 76px;
  }

  .theme-public-slot { top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); }
  .header-actions { gap: 6px; }
  .ambient-system--one { width: 360px; top: -96px; left: -130px; }
  .ambient-system--two { width: 380px; right: -180px; bottom: -92px; }
  .ambient-system--three { width: 120px; top: 24%; left: 60%; }
  .ambient-system--four { display: none; }
}

@media (max-width: 420px) {
  .auth-intro h1 {
    font-size: 40px;
  }

  .landing-stats {
    gap: 12px;
  }

  .landing-stats dt {
    font-size: 10px;
  }

  .landing-stats dd {
    font-size: 18px;
  }

  .stats-grid .stat-card {
    padding: 10px;
  }

  .upload-idle small {
    display: none;
  }

  .share-result > div {
    align-items: stretch;
    flex-direction: column;
  }

  .leaderboard-row {
    grid-template-columns: 24px minmax(0, 1fr) repeat(2, 50px);
    gap: 6px;
    padding: 10px 6px;
  }

  .leaderboard-metric small { font-size: 8px; }
  .chat-badge-field { max-width: 150px; min-width: 120px; }
  .chat-toolbar { gap: 8px; }
  .chat-mode-switch button { padding: 10px 12px; }
  #chat-live-status { margin-left: 0; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-background .ambient-star {
    animation-play-state: paused !important;
  }
  .theme-menu { transition: none !important; }
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
  /* Preserve ambient phase/durations when pausing, rather than snapping to a reset frame. */
  *:not(.ambient-star),
  *::before,
  *::after {
    animation-delay: 0ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
