/* ==========================================================================
   Red Penguin: base design system
   Warm paper, warm ink, one vermilion accent. Serif for the big moments,
   a quiet sans for everything you read, mono for addresses and numbers.
   Every colour is a token; the dark theme only re-points the tokens.
   ========================================================================== */

/* --- fonts (self-hosted, SIL Open Font License) --------------------------- */
@font-face {
  font-family: "Geist"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/geist-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/geist-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Geist Mono"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/geist-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist Mono"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/geist-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/instrument-serif-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/instrument-serif-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../fonts/instrument-serif-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../fonts/instrument-serif-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- tokens ---------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* surfaces */
  --paper: #faf8f3;
  --paper-2: #f3f0e8;
  --paper-3: #ebe7dc;
  --card: #ffffff;
  --line: #e7e2d6;
  --line-2: #d8d2c3;

  /* ink */
  --ink: #1a1713;
  --ink-2: #57514a;
  --ink-3: #8b8478;
  --ink-hover: #322d27;
  --on-ink: #faf8f3;

  /* the one accent */
  --accent: #ff4500;
  --accent-hover: #e03d00;
  --accent-ink: #c43600;
  --accent-wash: #fff0e8;
  --accent-rgb: 255, 69, 0;
  --on-accent: #ffffff;

  /* status */
  --ok: #2a7d4f;
  --ok-wash: #e6f3ea;
  --warn: #9a6a12;
  --warn-wash: #faf0d9;
  --bad: #b93a25;
  --bad-wash: #fbe9e5;

  /* lead grades: a warm ramp from sure to unsure */
  --g-a: #25764a;  --g-a-wash: #e3f2e8;
  --g-b: #5c7a1c;  --g-b-wash: #edf3dc;
  --g-c: #9a6a12;  --g-c-wash: #faf0d9;
  --g-d: #b4531b;  --g-d-wash: #fbe9dc;
  --g-e: #7b7468;  --g-e-wash: #eeeae1;

  /* depth */
  --shadow-1: 0 1px 2px rgba(26, 23, 19, .05);
  --shadow-2: 0 1px 2px rgba(26, 23, 19, .04), 0 10px 28px -14px rgba(26, 23, 19, .16);
  --shadow-3: 0 2px 4px rgba(26, 23, 19, .04), 0 28px 60px -26px rgba(26, 23, 19, .28);
  --shadow-pop: 0 0 0 1px rgba(26, 23, 19, .06), 0 18px 44px -18px rgba(26, 23, 19, .3);
  --focus-ring: 0 0 0 4px rgba(var(--accent-rgb), .2);
  --scrim: rgba(26, 23, 19, .38);

  /* shape */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-2xl: 30px;

  /* type */
  --font-ui: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);

  /* grain, used sparingly on large flat areas */
  --grain: 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 .1 0 0 0 0 .09 0 0 0 0 .07 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --paper: #12100d;
  --paper-2: #0c0b09;
  --paper-3: #1d1a16;
  --card: #1a1714;
  --line: #2a2621;
  --line-2: #3b362f;

  --ink: #f4f0e8;
  --ink-2: #b9b1a3;
  --ink-3: #827b6e;
  --ink-hover: #ffffff;
  --on-ink: #14110e;

  --accent: #ff5414;
  --accent-hover: #ff6d36;
  --accent-ink: #ff8a5c;
  --accent-wash: rgba(255, 84, 20, .13);
  --accent-rgb: 255, 84, 20;
  --on-accent: #1a0a04;

  --ok: #6fcf97;
  --ok-wash: rgba(111, 207, 151, .13);
  --warn: #e5b85c;
  --warn-wash: rgba(229, 184, 92, .13);
  --bad: #f08a76;
  --bad-wash: rgba(240, 138, 118, .13);

  --g-a: #74d39c;  --g-a-wash: rgba(116, 211, 156, .14);
  --g-b: #b5d46a;  --g-b-wash: rgba(181, 212, 106, .13);
  --g-c: #e5b85c;  --g-c-wash: rgba(229, 184, 92, .13);
  --g-d: #f0965c;  --g-d-wash: rgba(240, 150, 92, .13);
  --g-e: #a39b8d;  --g-e-wash: rgba(163, 155, 141, .13);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 30px -14px rgba(0, 0, 0, .7);
  --shadow-3: 0 2px 4px rgba(0, 0, 0, .4), 0 30px 64px -26px rgba(0, 0, 0, .85);
  --shadow-pop: 0 0 0 1px rgba(255, 255, 255, .06), 0 20px 48px -18px rgba(0, 0, 0, .85);
  --scrim: rgba(0, 0, 0, .6);

  --grain: 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 1 0 0 0 0 .96 0 0 0 0 .9 0 0 0 .035 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --- reset ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; border-spacing: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(var(--accent-rgb), .22); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* theme change cross-fades instead of snapping */
html.theme-fade, html.theme-fade * {
  transition: background-color .35s var(--ease-soft), border-color .35s var(--ease-soft),
    color .35s var(--ease-soft), fill .35s var(--ease-soft), stroke .35s var(--ease-soft) !important;
}

/* thin, quiet scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* --- type ------------------------------------------------------------------ */
.display {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -.012em;
  line-height: 1.04;
}
.display em { font-style: italic; }
.mono { font-family: var(--font-mono); font-feature-settings: "zero", "ss01"; letter-spacing: -.01em; }
.eyebrow {
  font-size: 12px; font-weight: 500; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3);
}
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.accent-text { color: var(--accent-ink); }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; transition: text-decoration-color .15s; }
.link:hover { text-decoration-color: var(--accent); }

/* --- buttons --------------------------------------------------------------- */
.btn {
  --h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 14px; font-weight: 500; line-height: 1; letter-spacing: -.005em;
  white-space: nowrap; user-select: none; cursor: pointer;
  transition: transform .18s var(--ease), background-color .18s var(--ease-soft),
    border-color .18s var(--ease-soft), color .18s var(--ease-soft), box-shadow .22s var(--ease-soft), opacity .18s;
}
.btn:active { transform: scale(.975); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-md); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--ink-hover); box-shadow: var(--shadow-2); }

.btn-accent { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-accent:hover { background: var(--accent-hover); box-shadow: 0 10px 24px -12px rgba(var(--accent-rgb), .7); }

.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--ink-3); background: var(--paper); }

.btn-quiet { color: var(--ink-2); }
.btn-quiet:hover { background: var(--paper-2); color: var(--ink); }

.btn-danger { color: var(--bad); border-color: var(--line-2); background: var(--card); }
.btn-danger:hover { border-color: var(--bad); background: var(--bad-wash); }

.btn-sm { --h: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); gap: 6px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { --h: 52px; padding: 0 22px; font-size: 16px; border-radius: var(--r-lg); gap: 10px; }
.btn-xl { --h: 60px; padding: 0 28px; font-size: 17px; border-radius: 999px; gap: 12px; }
.btn-pill { border-radius: 999px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }

/* the signature call to action: an ink pill carrying a vermilion arrow */
.btn-cta { padding-right: 8px; }
.btn-cta .btn-arrow {
  display: grid; place-items: center;
  width: calc(var(--h) - 16px); height: calc(var(--h) - 16px);
  border-radius: 999px; background: var(--accent); color: var(--on-accent);
  transition: transform .3s var(--spring);
}
.btn-cta .btn-arrow svg { width: 18px; height: 18px; }
.btn-cta:hover .btn-arrow { transform: translateX(3px); }

/* a button that is busy keeps its width and shows a spinner */
.btn.is-busy { pointer-events: none; color: transparent !important; position: relative; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--on-ink); border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn-ghost.is-busy::after, .btn-quiet.is-busy::after { border-color: var(--ink); border-right-color: transparent; }
.btn-accent.is-busy::after { border-color: var(--on-accent); border-right-color: transparent; }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border-radius: var(--r-sm); color: var(--ink-3);
  transition: background-color .15s, color .15s, transform .15s var(--ease);
}
.icon-btn:hover { background: var(--paper-3); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 16px; height: 16px; }

/* --- fields ---------------------------------------------------------------- */
.field { display: grid; gap: 7px; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--ink); }
.field .hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.field .error { font-size: 12.5px; color: var(--bad); line-height: 1.45; }

.input {
  width: 100%; height: 46px; padding: 0 14px;
  border-radius: var(--r-md); border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink);
  font-size: 15px;
  transition: border-color .15s var(--ease-soft), box-shadow .2s var(--ease-soft), background-color .2s;
}
.input::placeholder { color: var(--ink-3); }
.input:hover { border-color: var(--ink-3); }
.input:focus, .input:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.input.mono { font-size: 14px; }
.input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-wash); }
.input.is-good { border-color: var(--ok); box-shadow: 0 0 0 4px var(--ok-wash); }

/* --- small parts ----------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink-2);
  font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: border-color .15s, color .15s, background-color .15s, transform .15s var(--ease);
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip svg { width: 14px; height: 14px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px; border-radius: 999px;
  background: var(--paper-2); color: var(--ink-2);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag-accent { background: var(--accent-wash); color: var(--accent-ink); }
.tag-ok { background: var(--ok-wash); color: var(--ok); }
.tag-warn { background: var(--warn-wash); color: var(--warn); }
.tag-bad { background: var(--bad-wash); color: var(--bad); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-wash); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-wash); }
.dot-bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-wash); }
.dot-live { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); animation: pulse 1.6s var(--ease-soft) infinite; }

.grade {
  display: inline-grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 7px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; line-height: 1;
  background: var(--g-e-wash); color: var(--g-e);
}
.grade[data-g="A"] { background: var(--g-a-wash); color: var(--g-a); }
.grade[data-g="B"] { background: var(--g-b-wash); color: var(--g-b); }
.grade[data-g="C"] { background: var(--g-c-wash); color: var(--g-c); }
.grade[data-g="D"] { background: var(--g-d-wash); color: var(--g-d); }

.kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 6px; border: 1px solid var(--line-2); background: var(--card);
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-2);
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}

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

/* a switch that reads as a physical toggle */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 36px; height: 22px; border-radius: 999px; background: var(--line-2); flex: none;
  position: relative; transition: background-color .2s var(--ease-soft);
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .25s var(--spring);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: var(--focus-ring); }

/* --- the wordmark: Red Penguin over a small Reddit Scraper line ------------- */
.brand-lockup { display: grid; gap: 4px; line-height: 1; }
.brand-sub { font: 600 9.5px/1 var(--font-ui); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); padding-left: 1px; white-space: nowrap; }

/* --- the mascot ------------------------------------------------------------ */
/* Red Penguin, a fluffy baby penguin. Poses are set with data-mood on the svg:
   idle (default), reading (Scout, magnifying glass), mail (in an envelope),
   happy (closed eyes and a hop), asleep. */
.lurk { display: block; overflow: visible; }
.rp .rp-glass, .rp .rp-mail, .rp .rp-happy { display: none; }
.rp .rp-eyes { transform-box: fill-box; transform-origin: 50% 55%; animation: lurk-blink 5.6s infinite; }
.rp .rp-rise { transform-box: fill-box; transform-origin: 50% 100%; }
.rp[data-mood="reading"] .rp-glass { display: inline; transform-box: fill-box; animation: rp-scan 1.9s var(--ease-soft) infinite; }
.rp[data-mood="reading"] .rp-eye-r { opacity: 0; }
.rp[data-mood="mail"] .rp-mail { display: inline; }
.rp[data-mood="mail"] .rp-feet, .rp[data-mood="mail"] .rp-flippers, .rp[data-mood="mail"] .rp-shadow { display: none; }
.rp[data-mood="happy"] .rp-eyes { display: none; }
.rp[data-mood="happy"] .rp-happy { display: inline; }
.rp[data-mood="happy"] .rp-rise, .rp[data-mood="mail"] .rp-rise { animation: lurk-hop .7s var(--spring); }
.rp[data-mood="asleep"] .rp-eyes { animation: none; transform: scaleY(.12); }
.rp.is-peeking .rp-rise { animation: lurk-peek .9s var(--spring) both; }

@keyframes lurk-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes rp-scan { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-7px, 3px); } }
@keyframes lurk-hop { 0% { transform: translateY(0); } 40% { transform: translateY(-12%); } 100% { transform: translateY(0); } }
@keyframes lurk-peek { from { transform: translateY(22%) scale(.86); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .rp .rp-eyes, .rp .rp-glass, .rp .rp-rise { animation: none !important; } }

/* --- overlays -------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: 80; background: var(--scrim);
  opacity: 0; transition: opacity .25s var(--ease-soft);
  display: grid; place-items: center; padding: 20px;
}
.scrim.is-open { opacity: 1; }
.modal {
  width: min(520px, 100%); max-height: min(720px, calc(100vh - 40px)); overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  transform: translateY(12px) scale(.98); opacity: 0;
  transition: transform .35s var(--spring), opacity .25s var(--ease-soft);
}
.scrim.is-open .modal { transform: none; opacity: 1; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.modal-body { padding: 16px 22px 22px; }

.toasts { position: fixed; z-index: 120; left: 50%; bottom: 26px; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast {
  display: inline-flex; align-items: center; gap: 10px; justify-self: center;
  padding: 11px 16px; border-radius: 999px;
  background: var(--ink); color: var(--on-ink); font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-3); pointer-events: auto;
  animation: toast-in .45s var(--spring) both;
}
.toast.is-leaving { animation: toast-out .25s var(--ease-soft) both; }
.toast svg { width: 16px; height: 16px; }
.toast-bad { background: var(--bad); color: #fff; }

.menu {
  position: absolute; z-index: 90; min-width: 190px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  transform-origin: top right; animation: pop-in .18s var(--ease) both;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border-radius: 8px; font-size: 13.5px; color: var(--ink); text-align: left;
  transition: background-color .12s;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--paper-2); outline: none; }
.menu-item svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.menu-item .menu-note { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.menu-item.is-danger { color: var(--bad); }
.menu-item.is-danger svg { color: var(--bad); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-label { padding: 6px 10px 4px; font-size: 11.5px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

/* --- motion ---------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -80% 0; } }

.rise-in { animation: rise-in .5s var(--ease) both; }
.fade-in { animation: fade-in .4s var(--ease-soft) both; }

.skeleton {
  border-radius: 8px;
  background: linear-gradient(100deg, var(--paper-2) 30%, var(--paper-3) 50%, var(--paper-2) 70%);
  background-size: 220% 100%; animation: shimmer 1.4s linear infinite;
}

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--ink);
  animation: spin .7s linear infinite; flex: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
