/* 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: #f2ece4;
  --surface: rgba(255, 253, 250, 0.72);
  --surface-solid: #fffdfa;
  --surface-soft: rgba(255, 253, 250, 0.5);
  --surface-tint: rgba(92, 70, 45, 0.07);
  --ink: #1d1a17;
  --ink-soft: #37322c;
  --muted: #5e574e;
  --muted-light: #6a6359;
  --placeholder: #8c8479;
  --line: rgba(70, 50, 30, 0.1);
  --line-strong: rgba(70, 50, 30, 0.16);
  --line-hover: rgba(70, 50, 30, 0.26);

  --brand: #2a6670;
  --brand-dark: #1f525a;
  --brand-soft: rgba(42, 102, 112, 0.12);
  --brand-ink: #1d4f57;
  --brand-ring: rgba(42, 102, 112, 0.22);
  --focus: #2a6670;
  --on-ink: #fffaf3;

  --green: #2f7a3b;
  --green-soft: rgba(70, 150, 75, 0.15);
  --green-ink: #225c2b;
  --green-line: rgba(70, 150, 75, 0.3);
  --red: #c0412e;
  --red-soft: rgba(210, 85, 60, 0.12);
  --red-ink: #9c3220;
  --red-line: rgba(210, 85, 60, 0.28);
  --amber: #8a5208;
  --amber-soft: rgba(225, 160, 55, 0.18);
  --amber-line: rgba(200, 140, 40, 0.32);
  --violet: #6046a0;
  --violet-soft: rgba(120, 90, 190, 0.13);
  --pink: #a33a68;
  --pink-soft: rgba(200, 80, 130, 0.12);
  --switch-on: #3d9a4c;

  --glass-bar: rgba(255, 252, 247, 0.58);
  --glass-card: rgba(255, 252, 247, 0.46);
  --glass-control: rgba(255, 252, 247, 0.55);
  --glass-control-hover: rgba(255, 252, 247, 0.78);
  --glass-sheet: rgba(255, 252, 247, 0.8);
  --blur-bar: blur(24px) saturate(185%);
  --blur-card: blur(34px) saturate(175%);
  --blur-control: blur(14px) saturate(160%);
  --lens: radial-gradient(120% 70% at 18% -10%, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0) 58%);
  --lens-soft: radial-gradient(140% 90% at 12% -20%, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0) 60%);
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 0 0 1px rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(120, 90, 60, 0.06);
  --edge-soft: inset 0 1px 0 rgba(255, 255, 255, 0.75), inset 0 0 0 1px rgba(255, 255, 255, 0.4);

  --shadow-xs: 0 1px 2px rgba(60, 40, 20, 0.06);
  --shadow-sm: 0 1px 2px rgba(60, 40, 20, 0.05), 0 4px 14px -6px rgba(60, 40, 20, 0.14);
  --shadow-md: 0 1px 2px rgba(60, 40, 20, 0.05), 0 16px 40px -16px rgba(70, 45, 20, 0.26);
  --shadow-lg: 0 2px 6px rgba(60, 40, 20, 0.06), 0 30px 80px -24px rgba(70, 45, 20, 0.38);

  --ink-button: linear-gradient(180deg, #3b352f 0%, #1c1916 100%);
  --ink-button-hover: linear-gradient(180deg, #49423a 0%, #26221e 100%);
  --ink-edge: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 0 0 1px rgba(0, 0, 0, 0.35),
    0 1px 2px rgba(30, 20, 10, 0.2), 0 8px 20px -8px rgba(30, 20, 10, 0.45);

  --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: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-round: ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --amb-base: #efe2d4;
  --amb-1: #f2a679;
  --amb-2: #8ebee6;
  --amb-3: #f5c97f;
  --amb-4: #e79da8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12100e;
    --surface: rgba(40, 36, 32, 0.66);
    --surface-solid: #1f1c19;
    --surface-soft: rgba(255, 245, 230, 0.05);
    --surface-tint: rgba(255, 240, 220, 0.08);
    --ink: #f6f1ea;
    --ink-soft: #e2dacf;
    --muted: #b8afa2;
    --muted-light: #a99f92;
    --placeholder: #857c70;
    --line: rgba(255, 240, 220, 0.1);
    --line-strong: rgba(255, 240, 220, 0.16);
    --line-hover: rgba(255, 240, 220, 0.26);

    --brand: #7dc3c9;
    --brand-dark: #9bd5d9;
    --brand-soft: rgba(125, 195, 201, 0.16);
    --brand-ink: #a9dfe2;
    --brand-ring: rgba(125, 195, 201, 0.3);
    --focus: #9bd5d9;
    --on-ink: #1a1714;

    --green: #82cf89;
    --green-soft: rgba(130, 207, 137, 0.15);
    --green-ink: #a9e5ad;
    --green-line: rgba(130, 207, 137, 0.3);
    --red: #f08b77;
    --red-soft: rgba(240, 139, 119, 0.14);
    --red-ink: #ffb4a4;
    --red-line: rgba(240, 139, 119, 0.3);
    --amber: #f0bb68;
    --amber-soft: rgba(240, 187, 104, 0.14);
    --amber-line: rgba(240, 187, 104, 0.3);
    --violet: #c7b3f2;
    --violet-soft: rgba(199, 179, 242, 0.14);
    --pink: #f2a6c6;
    --pink-soft: rgba(242, 166, 198, 0.14);
    --switch-on: #4fb35e;

    --glass-bar: rgba(34, 31, 28, 0.56);
    --glass-card: rgba(38, 34, 30, 0.42);
    --glass-control: rgba(255, 245, 230, 0.08);
    --glass-control-hover: rgba(255, 245, 230, 0.14);
    --glass-sheet: rgba(30, 27, 24, 0.82);
    --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.16), inset 0 0 0 1px rgba(255, 255, 255, 0.08),
      inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    --edge-soft: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.06);

    --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, #fffaf2 0%, #ebe3d8 100%);
    --ink-button-hover: linear-gradient(180deg, #ffffff 0%, #f3ece2 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);

    --amb-base: #14110f;
    --amb-1: #6b3420;
    --amb-2: #1d3a57;
    --amb-3: #5c4318;
    --amb-4: #50263a;
  }
}

/* Moods: each context has its own light. */
html[data-mood="sky"] {
  --amb-base: #e8ecec;
  --amb-1: #a6cde8;
  --amb-2: #a9d9ca;
  --amb-3: #f0dcbd;
  --amb-4: #cdd0ee;
}

html[data-mood="sand"] {
  --amb-base: #efe6d8;
  --amb-1: #e9cda3;
  --amb-2: #e7b69b;
  --amb-3: #bcd6e6;
  --amb-4: #f5e6c9;
}

html[data-mood="meadow"] {
  --amb-base: #e5ecda;
  --amb-1: var(--seal-a, #9bd086);
  --amb-2: var(--seal-b, #f2d685);
  --amb-3: #a8d2ea;
  --amb-4: #c4dfab;
}

html[data-mood="dusk"] {
  --amb-base: #ebe6ef;
  --amb-1: #c4b9ea;
  --amb-2: #a7c5e6;
  --amb-3: #efbfc4;
  --amb-4: #f3d1ae;
}

html[data-mood="tide"] {
  --amb-base: #e4ecec;
  --amb-1: #8fcfcd;
  --amb-2: #b2cfee;
  --amb-3: #eedbb9;
  --amb-4: #bfe2cd;
}

@media (prefers-color-scheme: dark) {
  html[data-mood="sky"] {
    --amb-base: #0f1214;
    --amb-1: #1c3d58;
    --amb-2: #164237;
    --amb-3: #4a3a20;
    --amb-4: #2c2d55;
  }

  html[data-mood="sand"] {
    --amb-base: #13110e;
    --amb-1: #5a4320;
    --amb-2: #5d2f20;
    --amb-3: #1c3646;
    --amb-4: #3d3218;
  }

  html[data-mood="meadow"] {
    --amb-base: #0f120d;
    --amb-1: var(--seal-a-dark, #24502a);
    --amb-2: var(--seal-b-dark, #5a4a14);
    --amb-3: #173a52;
    --amb-4: #2c4420;
  }

  html[data-mood="dusk"] {
    --amb-base: #121018;
    --amb-1: #3a2c66;
    --amb-2: #1c3555;
    --amb-3: #55253a;
    --amb-4: #57391e;
  }

  html[data-mood="tide"] {
    --amb-base: #0e1313;
    --amb-1: #134846;
    --amb-2: #1e3556;
    --amb-3: #4a3b1d;
    --amb-4: #1d4430;
  }
}

/* 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 s {
  position: absolute;
  display: none;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95) 0, rgba(255, 255, 255, 0) 22%),
    radial-gradient(circle at 70% 78%, var(--orb-rim, rgba(255, 255, 255, 0.5)) 0, rgba(255, 255, 255, 0) 40%),
    radial-gradient(circle at 45% 40%, var(--orb, var(--amb-1)) 0, color-mix(in srgb, var(--orb, var(--amb-1)) 70%, #5a3a20) 100%);
  box-shadow: 0 30px 60px -20px color-mix(in srgb, var(--orb, var(--amb-1)) 60%, #3a2410);
  will-change: transform;
  animation: orb 26s ease-in-out infinite alternate;
}

.ambient s:nth-of-type(1) {
  top: 50%;
  right: -9vmin;
  width: 40vmin;
  height: 40vmin;
  --orb: var(--amb-1);
}

.ambient s:nth-of-type(2) {
  bottom: 9%;
  left: -6vmin;
  width: 26vmin;
  height: 26vmin;
  --orb: var(--amb-2);
  animation-duration: 32s;
  animation-direction: alternate-reverse;
}

.ambient s:nth-of-type(3) {
  top: 8%;
  right: 16%;
  width: 9vmin;
  height: 9vmin;
  --orb: var(--amb-3);
  animation-duration: 22s;
}

@media (min-width: 960px) {
  .ambient s:nth-of-type(1) {
    top: 26%;
    right: 9%;
    width: 30vmin;
    height: 30vmin;
  }

  .ambient s:nth-of-type(2) {
    bottom: 14%;
    left: auto;
    right: 30%;
    width: 16vmin;
    height: 16vmin;
  }

  .ambient s:nth-of-type(3) {
    top: 12%;
    right: 40%;
  }
}

html[data-mood="dawn"] .ambient s,
html[data-mood="dusk"] .ambient s,
html[data-mood="meadow"] .ambient s {
  display: block;
}

@keyframes orb {
  to {
    transform: translate3d(-3vmin, 4vmin, 0);
  }
}

@media (prefers-color-scheme: dark) {
  .ambient s {
    opacity: 0.75;
  }
}

.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 .4 0 0 0 0 .3 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.16;
}

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

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

@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-idle] .ambient s,
html[data-still] .ambient i,
html[data-still] .ambient b {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .ambient i,
  .ambient b,
  .ambient s {
    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, #d55a43 0%, #b23a26 100%);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(120, 30, 10, 0.25),
    0 8px 20px -8px rgba(160, 40, 20, 0.5);
}

.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(60, 40, 20, 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(60, 40, 20, 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.032em;
  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.035em;
  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: 750;
  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(60, 40, 20, 0.12);
}

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

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

.file-badge.blue {
  --fb: linear-gradient(180deg, #7fb2cf, #3f7d99);
  color: #fff;
}

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

.file-badge.green {
  --fb: linear-gradient(180deg, #8fca86, #4b8f48);
  color: #fff;
}

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

.file-badge.slate {
  --fb: linear-gradient(180deg, #a8a197, #6f685e);
  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, #7cc77f, #3d9a4c);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 6px 16px -6px rgba(40, 120, 50, 0.6);
}

.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(60, 40, 20, 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(30, 22, 14, 0.28);
  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(60, 40, 20, 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;
  }
}
