/* Mentaljineer — built on the Youssouf Diallo design system:
   monochrome light, liquid glass and film grain. Dark is the primary theme; Light and Nocturne mirror it. */

/* ---------- Tokens ---------- */
:root {
  --font-sans: "Geist", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px; --space-5: 20px;
  --space-6: 24px; --space-8: 32px; --space-12: 48px; --space-16: 64px;
  --radius-sm: 10px; --radius-md: 18px; --radius-lg: 28px; --radius-xl: 40px; --radius-pill: 999px;
  --blur-glass: 24px; --blur-glass-sm: 12px;

  --glass-sheen: linear-gradient(160deg,#ffffff33,#ffffff31,#ffffff2c,#ffffff24,#ffffff1b,#ffffff13,#ffffff0b,#ffffff06,#ffffff02,#ffffff01,#ffffff03,#ffffff06,#ffffff0b,#ffffff0f,#ffffff13,#ffffff14);
  --grain-white: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.3' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.6 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --grain-black: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.3' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.4 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  /* Dark (primary) */
  color-scheme: dark;
  --void: #050505;
  --graphite-900: #0b0b0c;
  --graphite-800: #141416;
  --graphite-600: #2a2a2d;
  --line: rgba(255, 255, 255, 0.12);
  --glass-fill: rgba(255, 255, 255, 0.06);
  --glass-edge: rgba(255, 255, 255, 0.22);
  --glass-glow: rgba(255, 255, 255, 0.30);
  --silver: #c8c8cc;
  --chrome: #ececee;
  --on-chrome: #0e0e0f;
  --on-horizon: #0e0e0f;
  --ink: #f2f2f3;
  --ink-muted: #9a9a9f;
  --focus: #ffffff;
  --signal-up: #8fe3a1;
  --signal-down: #ff8a7a;
  --shadow-glass: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(255, 255, 255, 0.05), 0 30px 60px rgba(0, 0, 0, 0.55);
  --shadow-glass-sm: inset 0 1px 0 rgba(255, 255, 255, 0.30), 0 8px 20px rgba(0, 0, 0, 0.45);
  --scrim: rgba(0, 0, 0, 0.55);
  --sheet: rgba(20, 20, 22, 0.78);
  --well: rgba(0, 0, 0, 0.28);

  --horizon: linear-gradient(180deg,#0b0b0c,#0b0b0c,#0b0b0c,#0b0b0c,#0b0b0c,#0b0b0c,#0c0c0c,#0c0c0c,#0c0c0c,#0e0e0f,#131418,#191b21,#1f242a,#272e35,#303942,#3d474f,#4f585f,#6d7379,#8b8e93,#a1a3a6,#b4b5b7);
  --spotlight-top: radial-gradient(ellipse 95% 80% at 50% 0%,#393b40,#393b40,#383a3e,#36383c,#33353a,#303237,#2d2f33,#292b2f,#25272a,#212225,#1d1e21,#18191c,#141517,#101113,#0d0d0e,#090a0b,#070707,#050505);
  --glass-core: radial-gradient(ellipse 72% 68% at 46% 48%,#000000eb,#000000e7,#000000de,#000000ce,#000000ba,#000000a3,#0000008a,#00000071,#0000005a,#00000044,#00000030,#00000020,#00000013,#00000008,#00000000);
  --grain-image: var(--grain-white);
  --grain-blend: overlay;
  --grain: 0.12;
}

:root[data-theme="light"] {
  color-scheme: light;
  --void: #f4f4f4;
  --graphite-900: #ececec;
  --graphite-800: #e2e2e2;
  --graphite-600: #c9c9c9;
  --line: rgba(0, 0, 0, 0.12);
  --glass-fill: rgba(255, 255, 255, 0.55);
  --glass-edge: rgba(255, 255, 255, 0.95);
  --glass-glow: rgba(0, 0, 0, 0.10);
  --silver: #5a5a5e;
  --chrome: #1a1a1c;
  --on-chrome: #f2f2f3;
  --on-horizon: #0e0e0f;
  --ink: #0e0e0f;
  --ink-muted: #58585d;
  --focus: #0e0e0f;
  --signal-up: #1d7a35;
  --signal-down: #b3261e;
  --shadow-glass: inset 0 1px 0 rgba(255, 255, 255, 1), inset 0 -1px 0 rgba(0, 0, 0, 0.04), 0 24px 48px rgba(0, 0, 0, 0.12);
  --shadow-glass-sm: inset 0 1px 0 rgba(255, 255, 255, 1), 0 6px 16px rgba(0, 0, 0, 0.10);
  --scrim: rgba(40, 40, 44, 0.28);
  --sheet: rgba(250, 250, 250, 0.82);
  --well: rgba(0, 0, 0, 0.04);

  --horizon: linear-gradient(180deg,#f7f7f7,#f7f7f7,#f7f7f7,#f6f6f6,#f6f6f6,#f6f6f6,#f6f6f6,#f6f6f6,#f5f5f5,#f4f5f5,#f2f3f4,#eff1f2,#eceef0,#e8ebed,#e4e7e9,#dfe2e5,#dadde0,#d4d7db,#cfd2d6,#cacdd1,#c6c9cd);
  --spotlight-top: radial-gradient(ellipse 95% 80% at 50% 0%,#ffffff,#ffffff,#fefefe,#fcfcfc,#fafafa,#f8f8f8,#f5f5f5,#f2f2f2,#efefef,#ededed,#eaeaea,#e8e8e8,#e6e6e6,#e4e4e4,#e3e3e3,#e1e1e1,#e1e1e1,#e0e0e0);
  --glass-core: radial-gradient(ellipse 72% 68% at 46% 48%,#fffffff2,#ffffffef,#ffffffe5,#ffffffd5,#ffffffc0,#ffffffa8,#ffffff8f,#ffffff75,#ffffff5d,#ffffff46,#ffffff32,#ffffff21,#ffffff13,#ffffff08,#ffffff00);
  --grain-image: var(--grain-black);
  --grain-blend: multiply;
  --grain: 0.072;
}

:root[data-theme="nocturne"] {
  color-scheme: dark;
  --void: #070d33;
  --graphite-900: #0a1242;
  --graphite-800: #111c5a;
  --graphite-600: #24348a;
  --line: rgba(180, 200, 255, 0.16);
  --glass-fill: rgba(120, 150, 255, 0.08);
  --glass-edge: rgba(200, 215, 255, 0.30);
  --glass-glow: rgba(140, 170, 255, 0.35);
  --silver: #b9c6ff;
  --chrome: #e9e4f2;
  --on-chrome: #070d33;
  --on-horizon: #070d33;
  --ink: #eef1ff;
  --ink-muted: #aeb8e6;
  --focus: #ffffff;
  --signal-up: #a9e6bf;
  --signal-down: #ffb3c7;
  --shadow-glass: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(255, 255, 255, 0.05), 0 30px 60px rgba(2, 6, 30, 0.55);
  --shadow-glass-sm: inset 0 1px 0 rgba(255, 255, 255, 0.30), 0 8px 20px rgba(2, 6, 30, 0.45);
  --scrim: rgba(2, 5, 24, 0.6);
  --sheet: rgba(14, 24, 84, 0.8);
  --well: rgba(2, 6, 30, 0.35);

  --horizon: linear-gradient(180deg,#060a26,#060a28,#060b29,#060b2a,#060b2b,#060b2c,#070c2e,#070c30,#070d32,#070e36,#091140,#0b154d,#0e1a5a,#11206d,#152783,#1a2f96,#243aa6,#354bb4,#5664bd,#8e8cc4,#cdb9d4);
  --spotlight-top: radial-gradient(ellipse 95% 80% at 50% 0%,#1d2f96,#1d2f95,#1c2e93,#1b2d90,#1a2b8b,#192985,#17277f,#162478,#142170,#121f68,#101c5f,#0e1957,#0c164f,#0b1448,#0a1242,#08103c,#080e37,#070d33);
  --grain-blend: soft-light;
  --grain: 0.18;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--void); }
body {
  margin: 0;
  min-height: 100vh;
  isolation: isolate;
  background: var(--void);
  color: var(--ink);
  font: 400 15px/22px var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--silver); color: var(--void); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: var(--space-4); top: var(--space-4); z-index: 50;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill);
  background: var(--chrome); color: var(--on-chrome); text-decoration: none; font-weight: 500;
  transform: translateY(-200%);
}
.skip:focus-visible { transform: none; }

/* The ground: one faint light from above, fine grain over it. */
.ground { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--spotlight-top), var(--void); }
.ground::after, .grain::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background-image: var(--grain-image); background-size: 200px 200px;
  mix-blend-mode: var(--grain-blend); opacity: var(--grain);
}

.shell { width: 100%; max-width: 1280px; margin-inline: auto; padding-inline: var(--space-4); }
@media (min-width: 720px) { .shell { padding-inline: var(--space-8); } }
@media (min-width: 1280px) { .shell { padding-inline: var(--space-12); } }

/* ---------- Type ---------- */
.display { font-weight: 200; letter-spacing: -0.03em; line-height: 0.95; text-wrap: balance; margin: 0; }
.headline { font-size: 40px; line-height: 44px; font-weight: 300; letter-spacing: -0.02em; text-wrap: balance; margin: 0; }
.title { font-size: 22px; line-height: 28px; font-weight: 400; letter-spacing: -0.01em; text-wrap: balance; margin: 0; }
.caption { font-size: 13px; line-height: 18px; color: var(--ink-muted); margin: 0; }
.label { font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-muted); margin: 0; }
.data { font-family: var(--font-mono); font-size: 12px; line-height: 16px; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-muted); }

/* ---------- Liquid glass ---------- */
.glass {
  position: relative; isolation: isolate;
  border: 1px solid var(--glass-edge); border-radius: var(--radius-lg);
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(140%);
  backdrop-filter: blur(var(--blur-glass)) saturate(140%);
  box-shadow: var(--shadow-glass);
}
.glass::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: var(--glass-sheen); pointer-events: none;
}
.glass--sm { border-radius: var(--radius-md); box-shadow: var(--shadow-glass-sm); }
/* Lit tile: black core, glowing rim, grain inside. One per view. */
.glass--lit { overflow: hidden; }
.glass--lit::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: var(--glass-core); box-shadow: inset 0 0 44px 4px var(--glass-glow);
}
.grain-layer {
  position: absolute; inset: 0; z-index: 0; border-radius: inherit; pointer-events: none;
  background-image: var(--grain-image); background-size: 200px 200px;
  mix-blend-mode: var(--grain-blend); opacity: var(--grain);
}
.glass--lit > :not(.grain-layer) { position: relative; z-index: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 40px; padding: 0 var(--space-5); flex: none;
  border: 1px solid var(--glass-edge); border-radius: var(--radius-pill);
  background-color: var(--glass-fill); background-image: var(--glass-sheen);
  -webkit-backdrop-filter: blur(var(--blur-glass-sm)) saturate(140%);
  backdrop-filter: blur(var(--blur-glass-sm)) saturate(140%);
  box-shadow: var(--shadow-glass-sm);
  color: var(--ink); font: 500 14px/20px var(--font-sans); letter-spacing: -0.005em;
  text-decoration: none; white-space: nowrap;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--solid { background: var(--chrome); color: var(--on-chrome); border-color: transparent; }
.btn--sm { height: 32px; padding: 0 var(--space-3); font-size: 13px; }
.btn--quiet { background: none; border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; color: var(--ink-muted); }
.btn--quiet:hover { color: var(--ink); }
.btn--danger { color: var(--signal-down); }
.btn--icon { width: 40px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Brand lock-up ---------- */
.lockup { display: inline-flex; align-items: center; gap: var(--space-3); text-decoration: none; color: var(--ink); }
.lockup__mark { width: 28px; height: 28px; }
.lockup__rule { width: 1px; height: 28px; background: var(--line); }
.lockup__name { font-size: 20px; line-height: 24px; font-weight: 200; letter-spacing: -0.02em; }
/* The black mark is primary; white only where black would disappear (Dark and Nocturne grounds). */
.mark-on-dark { display: block; }
.mark-on-light { display: none; }
:root[data-theme="light"] .mark-on-dark { display: none; }
:root[data-theme="light"] .mark-on-light { display: block; }

/* ---------- Theme switch ---------- */
.theme-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-pill); }
.theme-switch button {
  display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%; background: none;
}
.theme-switch .swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); transition: transform 0.15s ease; }
.theme-switch button[aria-pressed="true"] .swatch { box-shadow: 0 0 0 2px var(--void), 0 0 0 3px var(--silver); }
.theme-switch button:hover .swatch { transform: scale(1.12); }
.swatch--dark { background: #0b0b0c; }
.swatch--light { background: #f4f4f4; }
.swatch--nocturne { background: #1c33a6; }

/* ---------- Poster (library hero) ---------- */
.poster {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column;
  height: clamp(540px, 66vh, 620px);
  margin-top: var(--space-4);
  padding: var(--space-5) var(--space-5) 0;
  border: 1px solid var(--glass-edge); border-radius: var(--radius-xl);
  background: var(--horizon);
  box-shadow: var(--shadow-glass);
}
.poster.grain::after { z-index: -1; }
.poster__bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.poster__actions { display: flex; align-items: center; gap: var(--space-2); }
.poster__body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: var(--space-4); max-width: 640px; padding-top: var(--space-4); }
.poster__floor { flex: 0 0 34%; }
.poster__headline { font-size: clamp(52px, 8.4vw, 104px); }
.poster__rule { height: 1px; width: min(100%, 520px); background: var(--line); }
.poster__lede { max-width: 46ch; color: var(--ink-muted); margin: 0; text-wrap: pretty; }
.poster__caption {
  position: absolute; left: 0; right: 0; bottom: 1.5%; z-index: 1;
  margin: 0; text-align: center; color: var(--on-horizon);
}
.poster__tile {
  position: absolute; z-index: 1;
  width: 128px; aspect-ratio: 1; left: 50%; bottom: 10%; transform: translateX(-50%);
  display: grid; place-items: center;
  border-radius: var(--radius-lg);
}
.poster__tile img { width: 58%; height: auto; }
.poster__grid { position: absolute; right: var(--space-8); top: 22%; z-index: 0; width: 104px; stroke: var(--ink-muted); stroke-width: 1.25; stroke-linecap: round; opacity: 0.55; display: none; }
@media (min-width: 860px) {
  .poster { padding: var(--space-6) var(--space-8) 0; }
  .poster__floor { flex-basis: 30%; }
  .poster__tile { width: clamp(176px, 17vw, 224px); left: auto; right: 9%; bottom: 13%; transform: none; border-radius: var(--radius-xl); }
  .poster__grid { display: block; }
}

/* ---------- Library toolbar ---------- */
.toolbar-wrap { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--space-3)); z-index: 20; margin-top: var(--space-6); }
.toolbar { display: flex; align-items: center; gap: var(--space-3); padding: 6px 6px 6px var(--space-4); }
.toolbar .icon { color: var(--ink-muted); }
.search {
  flex: 1 1 auto; min-width: 0; height: 40px; padding: 0; border: 0; outline: 0; background: none;
  color: var(--ink); font-size: 15px;
}
.search::placeholder { color: var(--ink-muted); opacity: 1; }
.search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.toolbar:focus-within { border-color: var(--silver); }
.toolbar__count { color: var(--ink-muted); white-space: nowrap; }
.select {
  height: 40px; padding: 0 34px 0 var(--space-4); flex: none;
  border: 1px solid var(--glass-edge); border-radius: var(--radius-pill);
  background: var(--glass-fill) url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%239a9a9f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--ink); font-size: 14px; font-weight: 500;
  -webkit-appearance: none; appearance: none;
}
.select option { background: var(--graphite-800); color: var(--ink); }
:root[data-theme="light"] .select {
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%2358585d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
@media (max-width: 559px) {
  .toolbar__count { display: none; }
  .select { padding-left: var(--space-3); }
}

.chips { display: flex; gap: var(--space-2); margin-top: var(--space-4); overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-2); flex: none;
  height: 32px; padding: 0 var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: none; color: var(--ink-muted); font-size: 13px; font-weight: 500;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { color: var(--ink); border-color: var(--glass-edge); }
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--glass-edge); background: var(--glass-fill); box-shadow: var(--shadow-glass-sm); }
.chip .data { color: var(--ink-muted); }

/* ---------- Prompt grid ---------- */
.library { padding-block: var(--space-6) var(--space-16); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: var(--space-4); margin-top: var(--space-6); }
.card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-6); min-width: 0; transition: transform 0.2s ease, border-color 0.2s ease; }
.card:hover { transform: translateY(-2px); }
.card:focus-within { border-color: var(--silver); }
.card__top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 16px; }
.card__flag { color: var(--silver); }
.card__title a { text-decoration: none; }
.card__title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card__title a:focus-visible { outline: none; }
.card__summary { color: var(--ink-muted); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.excerpt {
  margin: 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
  background: var(--well); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 12px; line-height: 18px; color: var(--ink-muted);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.excerpt span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card__foot { margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--line); display: flex; align-items: center; gap: var(--space-3); }
.card__meta { flex: 1 1 auto; min-width: 0; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .btn { position: relative; z-index: 1; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tag {
  display: inline-flex; align-items: center; height: 24px; padding: 0 var(--space-2);
  border: 1px solid var(--line); border-radius: 8px; background: none;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); position: relative; z-index: 1;
}
button.tag:hover { color: var(--ink); border-color: var(--glass-edge); }

.status { display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; border: 1px solid currentColor; }
.status--public::before { background: currentColor; }

.skeleton { min-height: 236px; }
.skeleton span { display: block; height: 10px; border-radius: 6px; background: var(--line); }
.skeleton span + span { margin-top: var(--space-3); }

.empty { padding: var(--space-8); display: grid; gap: var(--space-3); justify-items: start; max-width: 560px; margin-top: var(--space-6); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding-block: var(--space-8) calc(var(--space-8) + env(safe-area-inset-bottom, 0px)); }
.footer__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }

/* ---------- Prompt sheet (dialog) ---------- */
.sheet {
  width: min(780px, calc(100vw - 2 * var(--space-4)));
  max-height: min(90vh, 960px);
  margin: auto; padding: 0; overflow: hidden;
  border: 1px solid var(--glass-edge); border-radius: var(--radius-xl);
  background: var(--sheet);
  -webkit-backdrop-filter: blur(32px) saturate(140%);
  backdrop-filter: blur(32px) saturate(140%);
  box-shadow: var(--shadow-glass);
  color: var(--ink);
}
.sheet[open] { display: flex; flex-direction: column; }
.sheet::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--glass-sheen); pointer-events: none; }
.sheet::backdrop { background: rgba(0, 0, 0, 0.55); background: var(--scrim); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet__scroll { position: relative; overflow-y: auto; padding: var(--space-8); display: grid; gap: var(--space-6); overscroll-behavior: contain; }
.sheet__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.sheet__titles { display: grid; gap: var(--space-2); min-width: 0; }
.sheet__summary { color: var(--ink-muted); margin: 0; max-width: 62ch; }
.sheet__meta { color: var(--ink-muted); display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.sheet__section { display: grid; gap: var(--space-3); }
.sheet__foot {
  position: relative; display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-4) var(--space-8) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}
.sheet__foot .caption { margin-right: auto; }
.prompt-text {
  margin: 0; padding: var(--space-5) var(--space-6); border-radius: var(--radius-md);
  background: var(--well); border: 1px solid var(--line);
  font-family: var(--font-sans); font-size: 15px; line-height: 24px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.blank {
  font-family: var(--font-mono); font-size: 13px; padding: 1px 6px; border-radius: 6px;
  border: 1px dashed var(--silver); color: var(--silver); background: none;
}
.blank--filled { border-style: solid; border-color: var(--glass-edge); background: var(--glass-fill); color: var(--ink); font-family: var(--font-sans); font-size: 15px; }
.blanks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: var(--space-3); }
.blanks .textarea { resize: none; overflow-y: auto; }
@media (max-width: 640px) {
  .sheet { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: 0; }
  .sheet__scroll { padding: var(--space-6) var(--space-4); }
  .sheet__foot { padding-inline: var(--space-4); }
  .sheet__foot .caption { flex-basis: 100%; }
}

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
fieldset.field { margin: 0; padding: 0; border: 0; }
fieldset.field legend { padding: 0; margin-bottom: 6px; }
.field__hint { font-size: 12px; line-height: 16px; color: var(--ink-muted); display: flex; justify-content: space-between; gap: var(--space-3); }
.input, .textarea {
  width: 100%; min-width: 0; padding: 9px var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--well); color: var(--ink);
  font-size: 15px; line-height: 22px;
  transition: border-color 0.15s ease;
}
.input:hover, .textarea:hover { border-color: var(--glass-edge); }
.input:focus-visible, .textarea:focus-visible { border-color: var(--silver); }
.input::placeholder, .textarea::placeholder { color: var(--ink-muted); opacity: 0.8; }
.textarea { resize: vertical; min-height: 44px; }
.textarea--prompt { font-family: var(--font-mono); font-size: 13px; line-height: 21px; min-height: 320px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--space-4); }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--well); }
.input-prefix:focus-within { border-color: var(--silver); }
.input-prefix span { padding-left: var(--space-3); color: var(--ink-muted); }
.input-prefix .input { border: 0; background: none; padding-left: 2px; }
.input-prefix .input:focus-visible { outline: none; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--well); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: inline-flex; align-items: center; height: 32px; padding: 0 var(--space-4); border-radius: var(--radius-pill); font-size: 13px; font-weight: 500; color: var(--ink-muted); cursor: pointer; }
.segmented input:checked + span { background: var(--chrome); color: var(--on-chrome); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.check { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--chrome); }

.notice { font-size: 13px; line-height: 18px; margin: 0; }
.notice--error { color: var(--signal-down); }
.notice--ok { color: var(--signal-up); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); z-index: 60;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  padding: 10px var(--space-5); border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Studio ---------- */
.studio-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-4); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5); }
.studio-bar__left { display: flex; align-items: center; gap: var(--space-4); }
.studio-bar__right { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.studio { display: grid; gap: var(--space-4); padding-block: var(--space-6) var(--space-16); align-items: start; }
@media (min-width: 1000px) { .studio { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); } }
.panel { padding: var(--space-6); display: grid; gap: var(--space-4); min-width: 0; }
@media (min-width: 1000px) { .panel--list { position: sticky; top: var(--space-4); max-height: calc(100vh - 2 * var(--space-4)); grid-template-rows: auto auto minmax(0, 1fr) auto; } }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.rows { display: grid; gap: 2px; margin: 0 calc(-1 * var(--space-3)); padding: 0; list-style: none; overflow-y: auto; min-height: 0; max-height: 50vh; }
@media (min-width: 1000px) { .rows { max-height: none; } }
.row {
  display: grid; gap: 2px; width: 100%; padding: var(--space-3); text-align: left;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: none;
}
.row:hover { background: var(--glass-fill); }
.row[aria-current="true"] { background: var(--glass-fill); border-color: var(--glass-edge); box-shadow: var(--shadow-glass-sm); }
.row__title { font-size: 14px; line-height: 20px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__meta { color: var(--ink-muted); display: flex; gap: var(--space-2); flex-wrap: wrap; }
.dropzone {
  display: grid; gap: var(--space-2); justify-items: center; text-align: center;
  padding: var(--space-5) var(--space-4); border: 1px dashed var(--glass-edge); border-radius: var(--radius-md);
  color: var(--ink-muted); font-size: 13px; line-height: 18px; cursor: pointer; transition: border-color 0.15s ease, background-color 0.15s ease;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--silver); background: var(--glass-fill); color: var(--ink); }
.dropzone:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.editor { display: grid; gap: var(--space-5); }
.editor__actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding-top: var(--space-4); border-top: 1px solid var(--line); }
.editor__actions .notice { margin-right: auto; }
.confirm { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--well); }
.confirm p { margin: 0 auto 0 0; font-size: 13px; }
.chiplist { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; align-items: center; }

.signin { min-height: calc(100vh - 120px); display: grid; place-items: center; padding-block: var(--space-12); }
.signin__tile { width: min(420px, 100%); padding: var(--space-8); display: grid; gap: var(--space-5); border-radius: var(--radius-xl); }
.signin__tile .lockup__mark { width: 40px; height: 40px; }

/* ---------- Tutor page ---------- */
.tutor-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding-top: var(--space-6); }
.tutor-bar__actions { display: flex; align-items: center; gap: var(--space-2); }
@media (max-width: 479px) { .tutor-bar__home { display: none; } }
.tutor { padding-block: var(--space-12) var(--space-16); }
@media (min-width: 720px) { .tutor { padding-top: var(--space-16); } }

.tutor-intro { display: grid; gap: var(--space-4); max-width: 780px; }
.tutor-intro__title { font-size: clamp(44px, 8vw, 88px); }
.tutor-intro__lede { margin: 0; max-width: 58ch; font-size: 17px; line-height: 26px; color: var(--ink-muted); text-wrap: pretty; }
.tutor-flow { display: grid; gap: 10px; margin-top: var(--space-2); }
.tutor-flow__list { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.tutor-flow__list li {
  display: inline-flex; align-items: baseline; gap: var(--space-2); padding: 6px var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  font-size: 13px; line-height: 18px; color: var(--ink-muted);
}
.tutor-flow__list .data { color: var(--ink); }

.tutor-work { display: grid; gap: var(--space-8) var(--space-12); margin-top: var(--space-12); }
@media (min-width: 980px) { .tutor-work { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; } }
.tutor-work__column { display: grid; gap: var(--space-12); min-width: 0; }
.tutor-section { display: grid; gap: var(--space-5); min-width: 0; }
.tutor-section:focus { outline: none; }
.tutor-section__head { display: grid; gap: 6px; }
.tutor-fields { display: grid; gap: 18px; margin: 0; }
.tutor-fields .label { font-size: 12px; letter-spacing: 0.1em; }
.tutor-fields .textarea { resize: none; overflow: hidden; min-height: 66px; }
.tutor-steps { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; counter-reset: step; }
.tutor-steps li { counter-increment: step; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--space-2); align-items: baseline; }
.tutor-steps li::before { content: counter(step); font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); }

.tutor-output { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; padding: var(--space-5); }
@media (min-width: 720px) { .tutor-output { padding: var(--space-6); } }
@media (min-width: 980px) {
  .tutor-output { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--space-6)); max-height: calc(100vh - 2 * var(--space-6)); }
}
.tutor-output__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-4); }
.tutor-output__titles { display: grid; gap: 4px; min-width: 0; }
.tutor-output__actions { display: flex; align-items: center; gap: var(--space-2); }
.tutor-output__text { min-height: 0; max-height: 70vh; overflow: auto; padding: var(--space-4) 18px; font-size: 14px; line-height: 22px; }
@media (min-width: 980px) { .tutor-output__text { flex: 1 1 auto; max-height: none; } }
.tutor-output__text .blank { -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.tutor-output__text .blank--filled { font-size: 14px; }
.tutor-output__status { min-height: 18px; }
.tutor-undo { padding: 0; border: 0; background: none; color: var(--ink); font: inherit; text-decoration: underline; text-underline-offset: 3px; }

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