/* Design system: tokens, ambient light, glass materials and shared controls.
   Loaded before every surface file, so surface rules refine what lives here. */

:root {
  color-scheme: light dark;

  --bg: #f2f4f8;
  --surface: rgba(255, 255, 255, 0.74);
  --surface-solid: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.52);
  --surface-tint: rgba(60, 60, 67, 0.07);
  --ink: #111114;
  --ink-soft: #2c2c31;
  --muted: #50505a;
  --muted-light: #4b4b54;
  --placeholder: #86868f;
  --line: rgba(60, 60, 67, 0.12);
  --line-strong: rgba(60, 60, 67, 0.18);
  --line-hover: rgba(60, 60, 67, 0.3);

  --brand: #004bb3;
  --brand-dark: #003f96;
  --brand-soft: rgba(0, 110, 255, 0.11);
  --brand-ink: #003f96;
  --brand-ring: rgba(0, 110, 255, 0.24);
  --focus: #0a6cff;
  --on-ink: #ffffff;

  --green: #1d7a3a;
  --green-soft: rgba(52, 199, 89, 0.15);
  --green-ink: #135e2b;
  --green-line: rgba(52, 199, 89, 0.32);
  --red: #c4202b;
  --red-soft: rgba(255, 59, 48, 0.11);
  --red-ink: #a1141e;
  --red-line: rgba(255, 59, 48, 0.28);
  --amber: #8f5000;
  --amber-soft: rgba(255, 179, 0, 0.17);
  --amber-line: rgba(230, 150, 0, 0.34);
  --violet: #5b36c4;
  --violet-soft: rgba(120, 90, 240, 0.12);
  --pink: #b0275f;
  --pink-soft: rgba(255, 45, 125, 0.1);
  --switch-on: #34c759;

  --glass-bar: rgba(255, 255, 255, 0.6);
  --glass-card: rgba(255, 255, 255, 0.5);
  --glass-control: rgba(255, 255, 255, 0.62);
  --glass-control-hover: rgba(255, 255, 255, 0.86);
  --glass-sheet: rgba(255, 255, 255, 0.82);
  --blur-bar: blur(24px) saturate(190%);
  --blur-card: blur(34px) saturate(180%);
  --blur-control: blur(14px) saturate(170%);
  --lens: radial-gradient(120% 70% at 18% -10%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 58%);
  --lens-soft: radial-gradient(140% 90% at 12% -20%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 60%);
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.95), inset 0 0 0 1px rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(20, 30, 60, 0.05);
  --edge-soft: inset 0 1px 0 rgba(255, 255, 255, 0.85), inset 0 0 0 1px rgba(255, 255, 255, 0.45);

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 14px -6px rgba(16, 24, 40, 0.12);
  --shadow-md: 0 1px 2px rgba(16, 24, 40, 0.05), 0 16px 40px -16px rgba(16, 24, 48, 0.22);
  --shadow-lg: 0 2px 6px rgba(16, 24, 40, 0.06), 0 30px 80px -24px rgba(16, 24, 48, 0.32);

  --ink-button: linear-gradient(180deg, #2e2e33 0%, #111114 100%);
  --ink-button-hover: linear-gradient(180deg, #3a3a40 0%, #1b1b1f 100%);
  --ink-edge: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 0 0 1px rgba(0, 0, 0, 0.35),
    0 1px 2px rgba(10, 14, 30, 0.2), 0 8px 20px -8px rgba(10, 14, 30, 0.4);

  --radius-xs: 8px;
  --radius-sm: 11px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-xl: 30px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  --text-xs: 12.5px;
  --text-sm: 13.5px;
  --text-base: 15px;
  --text-md: 16px;
  --text-lg: 19px;
  --text-xl: 24px;
  --text-2xl: 30px;

  --control-h: 44px;
  --btn-h: 42px;
  --btn-h-sm: 34px;

  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 260ms;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.3, 0.64, 1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --reader-bg: #e6e8ee;
  --paper: #ffffff;
  --bar-solid: rgba(255, 255, 255, 0.97);

  --amb-base: #f3f5fa;
  --amb-1: #a4ccff;
  --amb-2: #c5b8ff;
  --amb-3: #a3e3d3;
  --amb-4: #ffc4d8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0c;
    --surface: rgba(30, 30, 34, 0.66);
    --surface-solid: #1c1c1f;
    --surface-soft: rgba(255, 255, 255, 0.05);
    --surface-tint: rgba(255, 255, 255, 0.08);
    --ink: #f5f5f7;
    --ink-soft: #e3e3e8;
    --muted: #a6a6b0;
    --muted-light: #a6a6b0;
    --placeholder: #7c7c85;
    --line: rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.16);
    --line-hover: rgba(255, 255, 255, 0.26);

    --brand: #5aa7ff;
    --brand-dark: #82bcff;
    --brand-soft: rgba(64, 156, 255, 0.17);
    --brand-ink: #9ccaff;
    --brand-ring: rgba(64, 156, 255, 0.34);
    --focus: #6cb2ff;
    --on-ink: #111114;

    --green: #4fd673;
    --green-soft: rgba(48, 209, 88, 0.16);
    --green-ink: #8be6a3;
    --green-line: rgba(48, 209, 88, 0.32);
    --red: #ff6961;
    --red-soft: rgba(255, 69, 58, 0.16);
    --red-ink: #ffa39e;
    --red-line: rgba(255, 69, 58, 0.32);
    --amber: #ffc94d;
    --amber-soft: rgba(255, 204, 0, 0.15);
    --amber-line: rgba(255, 204, 0, 0.3);
    --violet: #c2b2ff;
    --violet-soft: rgba(160, 140, 255, 0.16);
    --pink: #ff9cc5;
    --pink-soft: rgba(255, 100, 160, 0.15);
    --switch-on: #30d158;

    --glass-bar: rgba(28, 28, 32, 0.56);
    --glass-card: rgba(32, 32, 36, 0.44);
    --glass-control: rgba(255, 255, 255, 0.09);
    --glass-control-hover: rgba(255, 255, 255, 0.15);
    --glass-sheet: rgba(26, 26, 30, 0.84);
    --lens: radial-gradient(120% 70% at 18% -10%, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 58%);
    --lens-soft: radial-gradient(140% 90% at 12% -20%, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 60%);
    --edge: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.09),
      inset 0 -1px 0 rgba(0, 0, 0, 0.25);
    --edge-soft: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.07);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px -6px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -16px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.3), 0 30px 80px -24px rgba(0, 0, 0, 0.75);

    --ink-button: linear-gradient(180deg, #ffffff 0%, #e8e8ed 100%);
    --ink-button-hover: linear-gradient(180deg, #ffffff 0%, #f2f2f6 100%);
    --ink-edge: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 0 0 1px rgba(255, 255, 255, 0.2),
      0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -8px rgba(0, 0, 0, 0.6);

    --reader-bg: #111113;
    --bar-solid: rgba(24, 24, 27, 0.97);

    --amb-base: #07080b;
    --amb-1: #123a70;
    --amb-2: #2c2066;
    --amb-3: #0c4640;
    --amb-4: #4a1a3e;
  }
}

/* Moods: each context has its own light. */
html[data-mood="sky"] {
  --amb-base: #f2f4f8;
  --amb-1: #b4d4f7;
  --amb-2: #b3e3da;
  --amb-3: #d9d4fb;
  --amb-4: #cfe1fb;
}

html[data-mood="calm"] {
  --amb-base: #f3f6f9;
  --amb-1: #b6d6f7;
  --amb-2: #b4e5db;
  --amb-3: #ddd5fb;
  --amb-4: #ffd6e2;
}

html[data-mood="dusk"] {
  --amb-base: #f4f3fa;
  --amb-1: #c9bff5;
  --amb-2: #a9caf2;
  --amb-3: #f6c3d7;
  --amb-4: #bfe5f0;
}

html[data-mood="tide"] {
  --amb-base: #f1f6f7;
  --amb-1: #9ad8d3;
  --amb-2: #b0cff3;
  --amb-3: #c6ebd7;
  --amb-4: #d6d1fa;
}

@media (prefers-color-scheme: dark) {
  html[data-mood="sky"] {
    --amb-base: #08090c;
    --amb-1: #112e52;
    --amb-2: #0d3a36;
    --amb-3: #251f52;
    --amb-4: #14284a;
  }

  html[data-mood="calm"] {
    --amb-base: #07090b;
    --amb-1: #10345e;
    --amb-2: #0c3f3a;
    --amb-3: #271f58;
    --amb-4: #40183a;
  }

  html[data-mood="dusk"] {
    --amb-base: #09080d;
    --amb-1: #2c2264;
    --amb-2: #14315a;
    --amb-3: #4a1a3c;
    --amb-4: #0e3a47;
  }

  html[data-mood="tide"] {
    --amb-base: #060a0b;
    --amb-1: #0d4542;
    --amb-2: #13305a;
    --amb-3: #0f3d2c;
    --amb-4: #262058;
  }
}

/* Where the glass cannot blur, or the person asks for less transparency or
   more contrast, every material becomes solid and the light stays still. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root {
    --glass-bar: var(--surface-solid);
    --glass-card: var(--surface-solid);
    --glass-sheet: var(--surface-solid);
    --surface: var(--surface-solid);
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --glass-bar: var(--surface-solid);
    --glass-card: var(--surface-solid);
    --glass-sheet: var(--surface-solid);
    --glass-control: var(--surface-solid);
    --glass-control-hover: var(--surface-solid);
    --surface: var(--surface-solid);
    --blur-bar: none;
    --blur-card: none;
    --blur-control: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --glass-bar: var(--surface-solid);
    --glass-card: var(--surface-solid);
    --glass-sheet: var(--surface-solid);
    --glass-control: var(--surface-solid);
    --glass-control-hover: var(--surface-solid);
    --surface: var(--surface-solid);
    --blur-bar: none;
    --blur-card: none;
    --blur-control: none;
    --lens: none;
    --lens-soft: none;
    --muted: var(--ink-soft);
    --muted-light: var(--ink-soft);
    --line: var(--line-hover);
    --line-strong: var(--ink-soft);
    --edge: inset 0 0 0 1px var(--ink-soft);
    --edge-soft: inset 0 0 0 1px var(--ink-soft);
  }
}

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

html {
  background: var(--amb-base);
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  letter-spacing: -0.006em;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background: transparent;
  overflow-x: hidden;
}

/* Ambient light: soft colour fields that drift on the compositor. */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--amb-base);
  pointer-events: none;
  contain: strict;
  transition: background-color 900ms ease;
}

.ambient i {
  position: absolute;
  width: 78vmax;
  height: 78vmax;
  border-radius: 50%;
  opacity: 0.9;
  will-change: transform;
  animation: amb-a 46s ease-in-out infinite alternate;
}

.ambient i:nth-child(1) {
  top: -34vmax;
  left: -26vmax;
  background: radial-gradient(closest-side, var(--amb-1), transparent);
}

.ambient i:nth-child(2) {
  top: -22vmax;
  right: -36vmax;
  background: radial-gradient(closest-side, var(--amb-2), transparent);
  animation-name: amb-b;
  animation-duration: 54s;
}

.ambient i:nth-child(3) {
  bottom: -40vmax;
  left: -10vmax;
  background: radial-gradient(closest-side, var(--amb-3), transparent);
  animation-name: amb-c;
  animation-duration: 60s;
}

.ambient i:nth-child(4) {
  right: -30vmax;
  bottom: -34vmax;
  background: radial-gradient(closest-side, var(--amb-4), transparent);
  animation-name: amb-b;
  animation-duration: 70s;
  animation-direction: alternate-reverse;
}

.ambient b {
  position: absolute;
  top: -20vmax;
  left: 20%;
  width: 60vmax;
  height: 40vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.55), transparent);
  will-change: transform;
  animation: amb-sun 38s ease-in-out infinite alternate;
}

.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.07;
}

@media (prefers-color-scheme: dark) {
  .ambient b {
    background: radial-gradient(closest-side, rgba(190, 215, 255, 0.07), transparent);
  }

  .ambient::after {
    opacity: 0.12;
  }
}

@keyframes amb-a {
  to {
    transform: translate3d(14vmax, 10vmax, 0) scale(1.12);
  }
}

@keyframes amb-b {
  to {
    transform: translate3d(-16vmax, 12vmax, 0) scale(0.9);
  }
}

@keyframes amb-c {
  to {
    transform: translate3d(10vmax, -14vmax, 0) scale(1.15);
  }
}

@keyframes amb-sun {
  to {
    transform: translate3d(-24vmax, 8vmax, 0);
  }
}

html[data-idle] .ambient i,
html[data-idle] .ambient b,
html[data-still] .ambient i,
html[data-still] .ambient b {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .ambient i,
  .ambient b {
    animation: none;
  }
}

@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .ambient i,
  .ambient b {
    animation: none;
    opacity: 0.55;
  }
}

/* Glass materials. Bars and sheets blur; cards are frosted without blur so
   long lists stay cheap to scroll. */
.glass,
.glass-bar,
.glass-control {
  position: relative;
  -webkit-backdrop-filter: var(--blur-card);
  backdrop-filter: var(--blur-card);
  background: var(--lens), var(--glass-card);
  box-shadow: var(--edge), var(--shadow-md);
}

.glass-bar {
  -webkit-backdrop-filter: var(--blur-bar);
  backdrop-filter: var(--blur-bar);
  background: var(--lens-soft), var(--glass-bar);
  box-shadow: var(--edge-soft), var(--shadow-sm);
}

.glass-control {
  -webkit-backdrop-filter: var(--blur-control);
  backdrop-filter: var(--blur-control);
  background: var(--lens-soft), var(--glass-control);
  box-shadow: var(--edge-soft), var(--shadow-xs);
}

a {
  color: inherit;
  text-decoration: none;
  touch-action: manipulation;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
}

:where(a, button, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

h1,
h2 {
  text-wrap: balance;
}

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

p {
  text-wrap: pretty;
}

h1 {
  font-size: var(--text-2xl);
  line-height: 1.12;
  letter-spacing: -0.028em;
  font-weight: 700;
}

h2 {
  font-size: var(--text-lg);
  line-height: 1.25;
  letter-spacing: -0.018em;
  font-weight: 650;
}

h3 {
  font-size: var(--text-md);
  line-height: 1.35;
  letter-spacing: -0.01em;
  font-weight: 600;
}

::selection {
  background: var(--brand-ring);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

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

.small {
  font-size: var(--text-xs);
  line-height: 1.45;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-width: 0;
}

.col {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.grow {
  flex: 1;
  min-width: 0;
}

.spacer {
  flex: 1;
}

/* Brand mark: a file whose lower half has set solid, the seal rising. */
.mark {
  display: block;
  flex: none;
  overflow: visible;
}

.mark-stop-a {
  stop-color: var(--amb-2);
}

.mark-stop-b {
  stop-color: var(--amb-1);
}

.mark-sheet {
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 0.8;
}

.mark-seal {
  fill: var(--ink);
}

.mark-fold {
  fill: rgba(255, 255, 255, 0.92);
}

.mark-seam {
  fill: rgba(255, 255, 255, 0.95);
}

@media (prefers-color-scheme: dark) {
  .mark-stop-a {
    stop-color: color-mix(in srgb, var(--amb-2) 45%, #fff);
  }

  .mark-stop-b {
    stop-color: color-mix(in srgb, var(--amb-1) 45%, #fff);
  }

  .mark-seam {
    fill: var(--amb-base);
  }
}

.brand-mark {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: none;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.brand-word {
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 650;
  letter-spacing: -0.02em;
}

/* Buttons: capsules. One ink button per screen, everything else glass. */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: var(--btn-h);
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background-color var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease,
    color var(--dur-fast) ease,
    opacity var(--dur-fast) ease,
    transform var(--dur) var(--ease-spring);
}

.btn svg {
  flex: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.96);
  transition-duration: 70ms;
}

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

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn:disabled:active,
.btn[aria-busy="true"]:active {
  transform: none;
}

.btn[aria-busy="true"] {
  cursor: progress;
  opacity: 0.85;
}

.btn-primary,
.btn-dark {
  background: var(--ink-button);
  color: var(--on-ink);
  box-shadow: var(--ink-edge);
}

.btn-secondary {
  -webkit-backdrop-filter: var(--blur-control);
  backdrop-filter: var(--blur-control);
  background: var(--lens-soft), var(--glass-control);
  color: var(--ink);
  box-shadow: var(--edge-soft), var(--shadow-xs), inset 0 0 0 1px var(--line);
}

.btn-ghost {
  color: var(--ink-soft);
}

.btn-danger {
  background: linear-gradient(180deg, #f2443a 0%, #d0202a 100%);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(150, 10, 20, 0.22),
    0 8px 20px -8px rgba(200, 20, 30, 0.45);
}

.btn-sm {
  height: var(--btn-h-sm);
  gap: 6px;
  padding: 0 13px;
  font-size: var(--text-xs);
}

.btn-lg {
  height: 52px;
  padding: 0 24px;
  font-size: var(--text-md);
}

.btn-icon {
  width: var(--btn-h);
  padding: 0;
}

.btn-block {
  width: 100%;
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled),
  .btn-dark:hover:not(:disabled) {
    background: var(--ink-button-hover);
  }

  .btn-secondary:hover:not(:disabled) {
    background: var(--lens-soft), var(--glass-control-hover);
  }

  .btn-ghost:hover:not(:disabled) {
    background: var(--surface-tint);
    color: var(--ink);
  }

  .btn-danger:hover:not(:disabled) {
    filter: brightness(1.06);
  }
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.label {
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.4;
}

.input,
.textarea,
.select {
  width: 100%;
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 10px 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--glass-control);
  color: var(--ink);
  font-size: var(--text-base);
  line-height: 1.4;
  outline: none;
  box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 1px 2px rgba(16, 24, 40, 0.05);
  transition:
    background-color var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--placeholder);
}

.select {
  padding-right: 36px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238c8479' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.select option {
  background: var(--surface-solid);
  color: var(--ink);
}

.textarea {
  height: auto;
  min-height: 96px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.55;
}

@media (hover: hover) and (pointer: fine) {
  .input:hover:not(:disabled):not(:focus),
  .textarea:hover:not(:disabled):not(:focus),
  .select:hover:not(:disabled):not(:focus) {
    box-shadow: inset 0 0 0 1px var(--line-hover), inset 0 1px 2px rgba(16, 24, 40, 0.05);
  }
}

.input:focus,
.textarea:focus,
.select:focus {
  background-color: var(--glass-control-hover);
  box-shadow: inset 0 0 0 1.5px var(--brand), 0 0 0 4px var(--brand-ring);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  background-color: var(--surface-tint);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 1;
}

.input:disabled::placeholder,
.textarea:disabled::placeholder {
  color: var(--muted-light);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"],
.select[aria-invalid="true"],
.input.invalid,
.textarea.invalid,
.select.invalid {
  box-shadow: inset 0 0 0 1.5px var(--red);
}

.input[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus,
.select[aria-invalid="true"]:focus,
.input.invalid:focus,
.textarea.invalid:focus,
.select.invalid:focus {
  box-shadow: inset 0 0 0 1.5px var(--red), 0 0 0 4px var(--red-soft);
}

@media (forced-colors: active) {
  .input,
  .textarea,
  .select {
    border: 1px solid;
  }

  .input:focus,
  .textarea:focus,
  .select:focus {
    outline: 2px solid;
    outline-offset: 1px;
  }
}

.file-input {
  height: auto;
  padding: 7px 10px;
  color: var(--muted);
  font-size: var(--text-xs);
  cursor: pointer;
}

.file-input::file-selector-button {
  height: 30px;
  margin-right: 10px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--edge-soft), inset 0 0 0 1px var(--line);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}

.file-input::file-selector-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.hint {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.error-text {
  color: var(--red-ink);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.hidden-input {
  display: none !important;
}

.copy-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.copy-field .input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* Surfaces */
.card {
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--lens-soft), var(--surface);
  box-shadow: var(--edge), var(--shadow-sm);
}

.card-pad {
  padding: var(--space-5);
}

.panel-title {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.card-header h2,
.card-header h3 {
  font-size: var(--text-md);
  font-weight: 650;
  letter-spacing: -0.014em;
  line-height: 1.35;
}

.divider {
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--line);
}

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

.page-header > div {
  min-width: 0;
}

.page-header h1 {
  font-size: 34px;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.page-header p {
  max-width: 68ch;
  margin-top: 6px;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: 24px;
}

.stat-card {
  min-width: 0;
  padding: 16px 18px 18px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--lens), var(--surface);
  box-shadow: var(--edge), var(--shadow-sm);
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

.stat-label {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  color: var(--muted-light);
}

.stat-value {
  margin-top: 8px;
  font-family: var(--font-round);
  font-size: 32px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat-sub {
  margin-top: 6px;
  color: var(--muted-light);
  font-size: var(--text-xs);
  line-height: 1.4;
}

/* Empty state: one line and the one action. */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px var(--space-6);
  text-align: center;
}

.empty-icon {
  display: flex;
  width: 52px;
  height: 52px;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-2);
  border-radius: 16px;
  background: var(--lens), var(--glass-control);
  box-shadow: var(--edge), var(--shadow-sm);
  color: var(--ink-soft);
}

.empty h3 {
  font-size: var(--text-md);
  font-weight: 650;
  letter-spacing: -0.012em;
}

.empty p {
  max-width: 40ch;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* Loading */
.loading-block {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-7);
  color: var(--muted);
  font-size: var(--text-sm);
  text-align: center;
}

.loading-block .spinner {
  width: 22px;
  height: 22px;
}

.page-loader {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--muted);
  font-size: var(--text-sm);
}

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-tint) 25%, var(--surface-soft) 37%, var(--surface-tint) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

.spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ink);
  border-radius: 999px;
  animation: spin 0.65s linear infinite;
}

.spinner-light {
  border-color: color-mix(in srgb, var(--on-ink) 30%, transparent);
  border-top-color: var(--on-ink);
}

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

/* Error panel */
.error-panel {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--lens-soft), var(--red-soft), var(--surface);
  box-shadow: var(--edge-soft), inset 0 0 0 1px var(--red-line);
}

.error-panel-icon {
  display: flex;
  width: 34px;
  height: 34px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--red-soft);
  color: var(--red);
}

.error-panel-title {
  color: var(--red-ink);
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.4;
}

.error-panel-text {
  margin-top: 2px;
  color: var(--red-ink);
  font-size: var(--text-xs);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.error-panel .btn {
  flex: none;
}

/* Toasts: glass capsules. */
.toast-stack {
  position: fixed;
  right: var(--space-5);
  bottom: max(var(--space-5), env(safe-area-inset-bottom));
  z-index: 120;
  display: flex;
  max-width: calc(100vw - 40px);
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 240px;
  max-width: 380px;
  padding: 13px 18px;
  border: 0;
  border-radius: 22px;
  -webkit-backdrop-filter: var(--blur-bar);
  backdrop-filter: var(--blur-bar);
  background: var(--lens), var(--glass-sheet);
  color: var(--ink);
  box-shadow: var(--edge), var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 550;
  line-height: 1.45;
  overflow-wrap: anywhere;
  opacity: 1;
  transform: none;
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-spring);
}

@starting-style {
  .toast {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
}

.toast.error {
  color: var(--red-ink);
  box-shadow: var(--edge), var(--shadow-lg), inset 0 0 0 1px var(--red-line);
}

.toast.success {
  color: var(--green-ink);
  box-shadow: var(--edge), var(--shadow-lg), inset 0 0 0 1px var(--green-line);
}

/* Badges: a dot of colour and a word. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
}

.badge-slate {
  background: var(--surface-tint);
  color: var(--ink-soft);
}

.badge-blue {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.badge-green {
  background: var(--green-soft);
  color: var(--green-ink);
}

.badge-red {
  background: var(--red-soft);
  color: var(--red-ink);
}

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

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

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

/* File badge: every stored file is a sealed block of glass. */
.file-badge {
  position: relative;
  display: inline-flex;
  width: 38px;
  height: 44px;
  flex: none;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  padding-bottom: 6px;
  border-radius: 10px 15px 10px 10px;
  background: var(--lens), var(--glass-control);
  box-shadow: var(--edge), var(--shadow-xs);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}

.file-badge::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 46%;
  background: var(--fb, var(--surface-tint));
}

.file-badge::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-bottom-left-radius: 5px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: -1px 1px 2px rgba(16, 24, 40, 0.12);
}

.file-badge > * {
  position: relative;
}

.file-badge.red {
  --fb: linear-gradient(180deg, #ff6a5f, #e0322a);
  color: #fff;
}

.file-badge.blue {
  --fb: linear-gradient(180deg, #4aa3ff, #0a68e6);
  color: #fff;
}

.file-badge.violet {
  --fb: linear-gradient(180deg, #a58cff, #6a4ee0);
  color: #fff;
}

.file-badge.green {
  --fb: linear-gradient(180deg, #4dd07a, #1e9a48);
  color: #fff;
}

.file-badge.amber {
  --fb: linear-gradient(180deg, #ffc23d, #e08600);
  color: #fff;
}

.file-badge.slate {
  --fb: linear-gradient(180deg, #a3a9b6, #636a78);
  color: #fff;
}

/* Avatar */
.avatar {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(160deg, var(--amb-2), var(--amb-1));
  color: #2b241d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
}

@media (prefers-color-scheme: dark) {
  .avatar {
    color: #fff;
  }
}

.avatar-lg {
  width: 42px;
  height: 42px;
  font-size: 15px;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.table-wrap:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.table th {
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-soft);
}

.table td .strong,
.table td strong {
  color: var(--ink);
  font-weight: 600;
}

.table th.num,
.table td.num,
.table th.numeric,
.table td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table tbody tr {
  transition: background-color var(--dur-fast) ease;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

@media (hover: hover) and (pointer: fine) {
  .table tbody tr:hover {
    background: var(--surface-tint);
  }
}

/* Notices */
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-4);
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--lens-soft), var(--surface);
  box-shadow: var(--edge-soft), inset 0 0 0 1px var(--line);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.notice svg {
  flex: none;
}

.notice-error {
  background: var(--lens-soft), var(--red-soft), var(--surface);
  box-shadow: var(--edge-soft), inset 0 0 0 1px var(--red-line);
  color: var(--red-ink);
}

.notice-success {
  background: var(--lens-soft), var(--green-soft), var(--surface);
  box-shadow: var(--edge-soft), inset 0 0 0 1px var(--green-line);
  color: var(--green-ink);
}

.notice-info {
  background: var(--lens-soft), var(--brand-soft), var(--surface);
  box-shadow: var(--edge-soft), inset 0 0 0 1px var(--brand-ring);
  color: var(--brand-ink);
}

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: var(--red-ink);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.form-note {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--green-soft);
  color: var(--green-ink);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.inline-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.inline-status .spinner {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
}

.upload-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: var(--text-xs);
}

.upload-progress .spinner {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
}

.preview-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.success-hero {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--lens), var(--green-soft), var(--surface);
  box-shadow: var(--edge), inset 0 0 0 1px var(--green-line);
}

.success-icon {
  display: inline-flex;
  width: 40px;
  height: 40px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(180deg, #4fd67a, #22a64e);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 6px 16px -6px rgba(30, 150, 70, 0.55);
}

.success-hero h3 {
  color: var(--green-ink);
  font-size: var(--text-sm);
}

.success-hero p {
  margin-top: 3px;
  color: var(--green-ink);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.share-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: var(--text-xs);
}

/* Shared primitives */
.icon {
  display: block;
  flex: none;
}

.clipboard-helper {
  position: fixed;
  opacity: 0;
  pointer-events: none;
}

.copy-btn {
  min-width: 96px;
}

.copy-btn.copy-btn-icon {
  min-width: 0;
}

.copy-btn .copy-label {
  display: inline-block;
  min-width: 46px;
  text-align: left;
}

/* Fingerprint light: a SHA-256 drawn as an iris, one ray per byte. */
.iris {
  display: block;
  flex: none;
  overflow: visible;
}

.iris-rays line {
  stroke: currentColor;
  stroke-linecap: round;
}

.iris-glow {
  opacity: 0.95;
}

.iris-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 1.2;
}

.iris-core {
  fill: rgba(255, 255, 255, 0.92);
}

.iris {
  color: #fff;
  filter: drop-shadow(0 6px 14px rgba(16, 24, 40, 0.18));
}

.iris.is-forming .iris-rays {
  animation: iris-rays 900ms var(--ease-out) both;
  transform-box: view-box;
  transform-origin: 50% 50%;
}

.iris.is-forming .iris-glow {
  animation: iris-glow 1100ms var(--ease-out) both;
  transform-box: view-box;
  transform-origin: 50% 50%;
}

@keyframes iris-rays {
  from {
    opacity: 0;
    transform: rotate(-60deg) scale(0.55);
  }
}

@keyframes iris-glow {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  .iris.is-forming .iris-rays,
  .iris.is-forming .iris-glow {
    animation: none;
  }
}

/* Sheets: centred on wide screens, a bottom sheet with a grabber on phones. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: rgba(8, 12, 24, 0.24);
  overscroll-behavior: contain;
  opacity: 1;
  transition: opacity var(--dur-slow) var(--ease-out);
}

@media (prefers-color-scheme: dark) {
  .modal-backdrop {
    background: rgba(0, 0, 0, 0.5);
  }
}

.modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: var(--radius-xl);
  -webkit-backdrop-filter: var(--blur-card);
  backdrop-filter: var(--blur-card);
  background: var(--lens), var(--glass-sheet);
  box-shadow: var(--edge), var(--shadow-lg);
  opacity: 1;
  transform: none;
  transform-origin: center;
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform 380ms var(--ease-drawer);
}

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

.modal-lg {
  max-width: 720px;
}

@starting-style {
  .modal-backdrop {
    opacity: 0;
  }

  .modal {
    opacity: 0;
    transform: scale(0.96);
  }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 22px 22px 12px 24px;
}

.modal-header h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.modal-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.modal-header .icon-btn {
  border-radius: 999px;
  background: var(--surface-tint);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 24px 20px;
  overflow-wrap: anywhere;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 14px 24px 22px;
}

/* Icon buttons */
.icon-btn {
  display: inline-flex;
  width: 34px;
  height: 34px;
  flex: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  transition:
    background-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    transform var(--dur) var(--ease-spring);
}

.icon-btn:active:not(:disabled) {
  transform: scale(0.9);
  transition-duration: 70ms;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.icon-btn:disabled:active {
  transform: none;
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover:not(:disabled) {
    background: var(--surface-tint);
    color: var(--ink);
  }
}

/* Filters and search */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.search-box {
  position: relative;
  flex: 1 1 220px;
  min-width: 0;
  max-width: 340px;
}

.search-box .input {
  padding-left: 38px;
  border-radius: 999px;
}

.search-box svg {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 16px;
  height: 16px;
  color: var(--muted-light);
  pointer-events: none;
  transform: translateY(-50%);
}

.search-box:focus-within svg {
  color: var(--ink);
}

/* Link display */
.link-url {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--space-2);
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  background: var(--surface-tint);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0;
}

.link-url > span,
.link-url > a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tags */
.tag-input {
  display: flex;
  min-height: var(--control-h);
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--glass-control);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: box-shadow var(--dur-fast) ease;
}

.tag-input:focus-within {
  box-shadow: inset 0 0 0 1.5px var(--brand), 0 0 0 4px var(--brand-ring);
}

.tag {
  display: inline-flex;
  height: 30px;
  align-items: center;
  gap: 4px;
  padding: 0 4px 0 11px;
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--edge-soft), inset 0 0 0 1px var(--line);
  font-size: var(--text-xs);
  font-weight: 550;
  line-height: 1;
  max-width: 100%;
}

.tag > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag button {
  display: inline-flex;
  width: 22px;
  height: 22px;
  flex: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface-tint);
  color: currentColor;
  line-height: 1;
  opacity: 0.7;
  transition: opacity var(--dur-fast) ease;
}

.tag button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .tag button:hover {
    opacity: 1;
  }
}

/* Toggle rows: settings style. */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 56px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

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

.toggle-row > div {
  min-width: 0;
}

.toggle-row .title {
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1.35;
}

.toggle-row .desc {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}

/* Switch: platform proportions, spring knob. */
.switch {
  position: relative;
  width: 51px;
  height: 31px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line-strong);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color 200ms ease;
}

.switch::before {
  content: "";
  position: absolute;
  inset: -7px -4px;
  border-radius: 999px;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16), 0 1px 1px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.05);
  transition: transform 280ms var(--ease-spring), width 160ms var(--ease-out);
}

.switch:active:not(:disabled)::after {
  width: 33px;
}

.switch.on:active:not(:disabled)::after {
  transform: translateX(14px);
}

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

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

.switch.on {
  background: var(--switch-on);
  box-shadow: none;
}

.switch.on::after {
  transform: translateX(20px);
}

/* Segmented control */
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-tint);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tab {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease,
    transform var(--dur) var(--ease-spring);
}

.tab:active {
  transform: scale(0.96);
}

.tab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.tab.active {
  background: var(--lens), var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--edge), 0 2px 8px -2px rgba(16, 24, 40, 0.2);
}

@media (hover: hover) and (pointer: fine) {
  .tab:hover:not(.active) {
    color: var(--ink);
  }
}

.filter-chip {
  display: inline-flex;
  height: 34px;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--glass-control);
  color: var(--ink-soft);
  box-shadow: var(--edge-soft), inset 0 0 0 1px var(--line);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    transform var(--dur) var(--ease-spring);
}

.filter-chip:active {
  transform: scale(0.96);
}

.filter-chip:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.filter-chip.active {
  background: var(--ink-button);
  color: var(--on-ink);
  box-shadow: var(--ink-edge);
}

@media (hover: hover) and (pointer: fine) {
  .filter-chip:hover:not(.active) {
    background: var(--glass-control-hover);
    color: var(--ink);
  }
}

/* Activity and event rows */
.activity-list {
  display: flex;
  flex-direction: column;
}

.activity-list.bordered {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--lens-soft), var(--surface);
  box-shadow: var(--edge), var(--shadow-sm);
}

.activity-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

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

.activity-row .text {
  min-width: 0;
  flex: 1;
  font-size: var(--text-sm);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.activity-row .time {
  color: var(--muted-light);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.event-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

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

.event-row-link {
  color: inherit;
  text-decoration: none;
  transition: background-color var(--dur-fast) ease;
}

.event-row-link:active {
  background: var(--surface-tint);
}

@media (hover: hover) and (pointer: fine) {
  .event-row-link:hover {
    background: var(--surface-tint);
  }
}

.event-row-link:focus-visible {
  background: var(--surface-tint);
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.event-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--surface-tint);
  color: var(--ink-soft);
}

.event-body {
  min-width: 0;
  flex: 1;
}

.event-title {
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.event-kind {
  color: var(--muted);
  font-weight: 600;
}

.event-time {
  color: var(--muted-light);
}

.event-dot {
  color: var(--muted-light);
  font-size: var(--text-xs);
  line-height: 1;
}

.event-agent {
  max-width: 120px;
  flex: none;
  margin-left: var(--space-1);
  padding: 3px 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-tint);
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .event-agent {
    display: none;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

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

  .page-actions {
    width: 100%;
  }

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

  .input,
  .textarea,
  .select {
    min-height: 48px;
    font-size: 16px;
  }

  .input {
    height: 48px;
  }

  .file-input {
    font-size: var(--text-xs);
  }

  .btn {
    height: 44px;
  }

  .btn-sm {
    height: 40px;
  }

  .btn-lg {
    height: 54px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .tab {
    height: 38px;
    padding: 0 16px;
  }

  .filter-chip {
    height: 40px;
    padding: 0 16px;
  }

  .search-box {
    max-width: none;
    flex-basis: 100%;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: max(12px, env(safe-area-inset-top)) 0 0;
  }

  .modal {
    max-width: none;
    max-height: calc(100dvh - max(24px, env(safe-area-inset-top)));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .modal::before {
    content: "";
    position: sticky;
    top: 0;
    z-index: 2;
    display: block;
    width: 38px;
    height: 5px;
    margin: 8px auto -13px;
    border-radius: 999px;
    background: var(--line-hover);
  }

  @starting-style {
    .modal {
      opacity: 1;
      transform: translateY(100%);
    }
  }

  .modal-header {
    padding: 22px 18px 10px 20px;
  }

  .modal-body {
    padding: 10px 20px 18px;
  }

  .modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    padding: 12px 20px max(16px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--glass-sheet) 70%, transparent);
  }

  .modal-footer .btn {
    flex: 1;
    height: 52px;
  }

  .toast-stack {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    bottom: auto;
    left: 12px;
    max-width: none;
    align-items: center;
  }

  .toast {
    min-width: 0;
    max-width: 100%;
  }

  @starting-style {
    .toast {
      opacity: 0;
      transform: translateY(-16px) scale(0.96);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal-backdrop,
  .toast {
    transition: opacity var(--dur) ease;
  }

  @starting-style {
    .modal,
    .toast {
      transform: none;
    }
  }

  .btn:active:not(:disabled),
  .icon-btn:active:not(:disabled),
  .tab:active,
  .filter-chip:active {
    transform: none;
  }

  .switch::after {
    transition: none;
  }

  .skeleton {
    animation: none;
    background: var(--surface-tint);
  }

  .spinner {
    animation-duration: 1.6s;
  }
}

/* ---------------------------------------------------------------------------
   System surfaces. Flat grouped backgrounds and opaque cards, the way the
   platform's own apps are built: material only on bars and sheets, colour
   only for state and the one tint.
   ------------------------------------------------------------------------ */

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --surface-soft: #ffffff;
  --surface-tint: rgba(118, 118, 128, 0.12);
  --ink: #000000;
  --ink-soft: #1c1c1e;
  --muted: #6c6c70;
  --muted-light: #6c6c70;
  --placeholder: #8e8e93;
  --line: rgba(60, 60, 67, 0.16);
  --line-strong: rgba(60, 60, 67, 0.24);
  --line-hover: rgba(60, 60, 67, 0.36);

  --brand: #0066d6;
  --brand-dark: #0058b9;
  --brand-soft: rgba(0, 122, 255, 0.12);
  --brand-ink: #0058b9;
  --brand-ring: rgba(0, 122, 255, 0.28);
  --focus: #007aff;

  --glass-bar: rgba(249, 249, 249, 0.82);
  --glass-card: #ffffff;
  --glass-control: rgba(118, 118, 128, 0.12);
  --glass-control-hover: rgba(118, 118, 128, 0.2);
  --glass-sheet: rgba(255, 255, 255, 0.94);
  --blur-bar: blur(20px) saturate(180%);
  --blur-card: none;
  --blur-control: none;
  --lens: none;
  --lens-soft: none;
  --edge: 0 0 0 0 transparent;
  --edge-soft: 0 0 0 0 transparent;

  --shadow-xs: 0 0 0 0 transparent;
  --shadow-sm: 0 0 0 0 transparent;
  --shadow-md: 0 0 0 0 transparent;
  --shadow-lg: 0 10px 40px -12px rgba(0, 0, 0, 0.22);

  --ink-button: #000000;
  --ink-button-hover: #1c1c1e;
  --ink-edge: 0 0 0 0 transparent;

  --reader-bg: #e5e5ea;
}

html,
html[data-mood] {
  --amb-base: #f2f2f7;
  --amb-1: transparent;
  --amb-2: transparent;
  --amb-3: transparent;
  --amb-4: transparent;
}

html[data-mood="dawn"],
html[data-mood="sand"] {
  --amb-base: #ffffff;
}

.ambient i,
.ambient b,
.ambient s,
.ambient::after {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-solid: #1c1c1e;
    --surface-soft: #1c1c1e;
    --surface-tint: rgba(118, 118, 128, 0.24);
    --ink: #ffffff;
    --ink-soft: #ebebf0;
    --muted: #98989f;
    --muted-light: #98989f;
    --placeholder: #6c6c70;
    --line: rgba(84, 84, 88, 0.55);
    --line-strong: rgba(84, 84, 88, 0.75);
    --line-hover: rgba(120, 120, 128, 0.8);

    --brand: #409cff;
    --brand-dark: #6cb2ff;
    --brand-soft: rgba(10, 132, 255, 0.2);
    --brand-ink: #7cbcff;
    --brand-ring: rgba(10, 132, 255, 0.4);
    --focus: #0a84ff;

    --glass-bar: rgba(22, 22, 24, 0.8);
    --glass-card: #1c1c1e;
    --glass-control: rgba(118, 118, 128, 0.24);
    --glass-control-hover: rgba(118, 118, 128, 0.36);
    --glass-sheet: rgba(28, 28, 30, 0.94);
    --lens: none;
    --lens-soft: none;
    --edge: 0 0 0 0 transparent;
    --edge-soft: 0 0 0 0 transparent;

    --shadow-xs: 0 0 0 0 transparent;
    --shadow-sm: 0 0 0 0 transparent;
    --shadow-md: 0 0 0 0 transparent;
    --shadow-lg: 0 10px 40px -12px rgba(0, 0, 0, 0.7);

    --ink-button: #ffffff;
    --ink-button-hover: #e5e5ea;
    --ink-edge: 0 0 0 0 transparent;

    --reader-bg: #000000;
  }

  html,
  html[data-mood] {
    --amb-base: #000000;
    --amb-1: transparent;
    --amb-2: transparent;
    --amb-3: transparent;
    --amb-4: transparent;
  }
}

.mark-stop-a {
  stop-color: #c7c7cc;
}

.mark-stop-b {
  stop-color: #8e8e93;
}

@media (prefers-color-scheme: dark) {
  .mark-stop-a {
    stop-color: #48484a;
  }

  .mark-stop-b {
    stop-color: #3a3a3c;
  }
}
