/* zedcode design system — "liquid glass on cream"
   Everything visual is driven by the tokens below; tweak the look from here. */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,400;1,9..144,600&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ========================================
   1. DESIGN TOKENS
   ======================================== */
:root {
  /* brand */
  --bone: #FDFAF6;            /* cream page background */
  --paper: #fffdf9;           /* light solid surface */
  --ink: #171310;             /* near-black text */
  --ink-soft: #2b251e;
  --muted: #655b4b;           /* secondary text — AA on glass */
  --faint: #857a68;           /* decorative text only */
  --line: rgba(23, 19, 16, 0.08);
  --line-strong: rgba(23, 19, 16, 0.16);
  --accent: #E8481C;          /* orange-red brand accent */
  --accent-dark: #D93A1E;     /* AA-safe button fill */
  --accent-deep: #a92a13;
  --accent-wash: rgba(232, 72, 28, 0.08);
  --moss: #22301f;
  --ok: #1e7a3c;
  --warn: #9a5b00;

  /* glass surfaces */
  --glass-tint: 255, 255, 255;
  --glass-bg: rgba(255, 255, 255, 0.55);       /* default glass */
  --glass-bg-strong: rgba(255, 255, 255, 0.68);/* panels, modals */
  --glass-bg-soft: rgba(255, 255, 255, 0.42);  /* subtle chips, bars */
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-hairline: rgba(23, 19, 16, 0.06);
  --glass-blur: 20px;
  --glass-sat: 160%;
  --glass-solid: rgba(255, 255, 255, 0.94);    /* fallback when no backdrop-filter */

  /* radii */
  --radius: 10px;
  --radius-card: 20px;
  --radius-lg: 26px;
  --radius-pill: 999px;

  /* layered shadows (tight + wide diffuse) */
  --shadow-tight: 0 1px 2px rgba(23, 19, 16, 0.07);
  --shadow-glass: 0 1px 2px rgba(23, 19, 16, 0.06), 0 12px 32px rgba(23, 19, 16, 0.08);
  --shadow-lift: 0 2px 4px rgba(23, 19, 16, 0.06), 0 24px 56px rgba(23, 19, 16, 0.13);
  --shadow-glow: 0 0 0 4px rgba(232, 72, 28, 0.14), 0 8px 30px rgba(232, 72, 28, 0.16);
  --shadow-accent: 0 6px 22px rgba(232, 72, 28, 0.32);

  /* motion */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-quick: 180ms;
  --dur-smooth: 320ms;
  --dur-slow: 550ms;

  /* fonts (brand, unchanged) */
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

/* ========================================
   2. BASE
   ======================================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bone);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: #fff; }
a { color: inherit; }

:is(button, [role="button"], input, textarea, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-pill);
}

/* ========================================
   3. GLASS PRIMITIVES
   ======================================== */
.glass, .topbar, .prompt-card-hero, .mode-pills, .seg, .promo-banner,
.proj, .fab-popup, .modal, .msg.assistant, .chat-box, .ws-bar, .credits {
  position: relative;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  /* layered shadow: tight contact + wide diffuse + thin inner highlight on the top edge */
  box-shadow: var(--shadow-tight), var(--shadow-glass), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* fallback: browsers without backdrop-filter get a solid, readable surface */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .topbar, .prompt-card-hero, .mode-pills, .seg, .promo-banner,
  .proj, .fab-popup, .modal, .msg.assistant, .chat-box, .ws-bar, .credits {
    background: var(--glass-solid);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* decorative blurred orbs behind the glass — pure gradients, no filter cost */
.glass-orbs {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  pointer-events: none;
}
.glass-orbs i { position: absolute; display: block; border-radius: 50%; }
.glass-orbs .o1 { width: 52vmax; height: 52vmax; top: -18vmax; left: -12vmax;
  background: radial-gradient(closest-side, rgba(232, 72, 28, 0.20), rgba(232, 72, 28, 0) 70%); }
.glass-orbs .o2 { width: 44vmax; height: 44vmax; top: 22vmax; right: -14vmax;
  background: radial-gradient(closest-side, rgba(255, 178, 120, 0.30), rgba(255, 178, 120, 0) 70%); }
.glass-orbs .o3 { width: 34vmax; height: 34vmax; bottom: -12vmax; left: 24vmax;
  background: radial-gradient(closest-side, rgba(232, 72, 28, 0.12), rgba(232, 72, 28, 0) 70%); }

/* staggered entrance for the home hero */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.rise { animation: rise-in var(--dur-slow) var(--ease-out) both; }
.rise:nth-child(1) { animation-delay: 40ms; }
.rise:nth-child(2) { animation-delay: 110ms; }
.rise:nth-child(3) { animation-delay: 180ms; }
.rise:nth-child(4) { animation-delay: 250ms; }
.rise:nth-child(5) { animation-delay: 320ms; }
.rise:nth-child(6) { animation-delay: 390ms; }

/* ========================================
   4. TOPBAR
   ======================================== */
.topbar {
  position: sticky; top: 8px; z-index: 20;
  margin: 8px 12px 0; padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: var(--radius-pill);
}
.wordmark { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.wordmark .mark {
  width: 26px; height: 26px; background: var(--accent); color: #fff;
  display: inline-grid; place-items: center; font-family: var(--font-mono);
  font-size: 14px; font-weight: 700; border-radius: 8px; transform: rotate(-4deg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), var(--shadow-tight);
}
.wordmark .name { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -.02em; }
.topbar .meta { display: flex; align-items: center; gap: 10px; }
.credits {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--radius-pill);
  padding: 5px 12px 5px 9px;
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft);
}
.credits svg { opacity: .65; flex-shrink: 0; }
.free-credit-pill {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  border-radius: var(--radius-pill); padding: 5px 11px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  color: #9b3618; background: rgba(232,72,28,.1); border: 1px solid rgba(232,72,28,.25);
}
.free-credit-pill:empty { display: none; }
.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-pill);
  background: var(--ink); color: var(--bone);
  display: inline-grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  cursor: default;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), var(--shadow-tight);
}

/* ========================================
   5. HERO + PROMPT (home)
   ======================================== */
.wrap { max-width: 720px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }
.hero-center { display: flex; flex-direction: column; align-items: center; padding: 64px 0 0; text-align: center; }
h1.display {
  font-family: var(--font-display);
  font-size: clamp(38px, 5.2vw, 60px);
  line-height: 1.02; letter-spacing: -.03em;
  margin: 0 0 12px; font-weight: 600;
}
h1.display em { font-style: italic; font-weight: 400; }
.lede-center { color: var(--muted); font-size: 16px; margin: 0 0 32px; max-width: 38ch; }

/* pill tabs — glass container + sliding indicator (see glass-ui.js) */
.mode-pills {
  display: inline-flex; gap: 4px; margin-bottom: 24px;
  padding: 4px; border-radius: var(--radius-pill);
}
.glass-indicator {
  position: absolute; top: 0; left: 0; z-index: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-tight), inset 0 1px 0 rgba(255,255,255,.9), 0 6px 16px rgba(23,19,16,.10);
  transition: transform var(--dur-smooth) var(--ease-spring), width var(--dur-smooth) var(--ease-spring);
  pointer-events: none;
}
.mode-pills button, .seg button { position: relative; z-index: 1; }
.mode-pills:not(.glass-ready) .pill.active,
.seg:not(.glass-ready) button.active { background: var(--accent); color: #fff; } /* JS-off fallback */
.mode-pills.glass-ready .pill.active { color: var(--ink); }
.mode-pills.glass-ready .pill.active svg { stroke: var(--accent); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 22px; border-radius: var(--radius-pill);
  border: 1px solid transparent; background: transparent;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-quick) var(--ease-out), transform var(--dur-quick) var(--ease-spring);
}
.pill:hover { color: var(--ink-soft); }
.pill:active { transform: scale(.97); }

/* prompt card — the hero glass slab */
.prompt-card-hero {
  width: 100%;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--dur-smooth) var(--ease-spring), box-shadow var(--dur-smooth) var(--ease-out);
}
.prompt-card-hero:focus-within {
  transform: translateY(-3px);
  box-shadow: var(--shadow-tight), var(--shadow-lift), var(--shadow-glow), inset 0 1px 0 rgba(255,255,255,.7);
}
.prompt-card-hero textarea {
  width: 100%; min-height: 110px; border: 0; resize: none;
  background: transparent; padding: 22px 22px 0;
  font: inherit; font-size: 15.5px; color: var(--ink);
  outline: none; line-height: 1.6;
}
.prompt-card-hero textarea::placeholder { color: var(--faint); }
/* typewriter overlay: mirrors the textarea's text metrics exactly. It is
   absolutely positioned so it never changes the box height. */
.type-mirror {
  position: absolute; top: 22px; left: 22px; right: 22px;
  font: inherit; font-size: 15.5px; line-height: 1.6;
  text-align: left; direction: ltr;
  color: var(--ink); white-space: pre-wrap; overflow-wrap: break-word;
  pointer-events: none; z-index: 2;
}
.type-mirror.is-placeholder { color: var(--faint); }
.prompt-card-hero.type-overlay textarea::placeholder { color: transparent; }
.prompt-card-hero.type-overlay textarea { color: transparent; }
.type-caret {
  display: none; width: 2px; height: 1.05em; margin-left: 1px;
  vertical-align: -2px; background: var(--accent); border-radius: 2px;
  animation: type-caret-blink .9s steps(1) infinite;
}
.type-mirror.with-caret .type-caret { display: inline-block; }
@keyframes type-caret-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .type-caret { animation: none; } }
.prompt-bottom { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 12px 14px; }
.plus-circle {
  width: 36px; height: 36px; border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border); background: var(--glass-bg-soft);
  cursor: pointer; display: grid; place-items: center;
  color: var(--muted); transition: all var(--dur-quick) var(--ease-out);
}
.plus-circle:hover { color: var(--ink); background: rgba(255,255,255,.85); }
.prompt-right { display: flex; align-items: center; gap: 10px; }
.mic-icon {
  width: 36px; height: 36px; border-radius: var(--radius-pill);
  border: none; background: transparent;
  cursor: pointer; display: grid; place-items: center;
  color: var(--faint); transition: color var(--dur-quick) var(--ease-out);
}
.mic-icon:hover { color: var(--ink-soft); }
.mic-icon.recording { color: var(--accent); animation: pulse-mic 1s infinite; }
@keyframes pulse-mic { 0%,100% { box-shadow: 0 0 0 0 rgba(232,72,28,.3); } 50% { box-shadow: 0 0 0 7px rgba(232,72,28,0); } }
.submit-circle {
  width: 40px; height: 40px; border-radius: var(--radius-pill);
  border: none; cursor: pointer; position: relative;
  color: #fff; overflow: hidden;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  box-shadow: var(--shadow-accent), inset 0 1px 0 rgba(255,255,255,.45), inset 0 -6px 12px rgba(0,0,0,.12);
  transition: transform var(--dur-quick) var(--ease-spring), box-shadow var(--dur-quick) var(--ease-out);
}
.submit-circle::before { /* glossy highlight */
  content: ''; position: absolute; inset: 2px 2px 55% 2px; border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,0));
  pointer-events: none;
}
.submit-circle:hover { transform: scale(1.05); box-shadow: 0 8px 28px rgba(232,72,28,.42), inset 0 1px 0 rgba(255,255,255,.5); }
.submit-circle:active { transform: scale(.95); }

/* promo banner — slim glass strip */
.promo-banner {
  display: flex; align-items: center; gap: 10px;
  width: 100%; margin-top: 14px;
  padding: 11px 18px; border-radius: var(--radius-card);
  font-size: 13px; color: var(--ink-soft);
}
.promo-banner.hidden { display: none; }
.promo-badge {
  width: 24px; height: 24px; border-radius: 8px;
  background: var(--accent-wash); color: var(--accent);
  display: inline-grid; place-items: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.promo-text { flex: 1; }
.promo-link { color: var(--accent-dark); font-weight: 600; white-space: nowrap; text-decoration: none; transition: opacity var(--dur-quick); }
.promo-link:hover { opacity: .75; }
.promo-close { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--faint); padding: 0 2px; line-height: 1; }
.promo-close:hover { color: var(--ink); }

/* ========================================
   6. PROJECTS GRID
   ======================================== */
.projects-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 54px 0 16px; padding-top: 14px;
  border-top: 1px solid var(--line-strong);
}
.projects-head h2 { font-family: var(--font-display); font-size: 28px; margin: 0; letter-spacing: -.02em; }
.projects-head .count { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; padding-bottom: 80px; }
.proj {
  border-radius: var(--radius-card); padding: 16px; cursor: pointer;
  overflow: hidden;
  transition: transform var(--dur-smooth) var(--ease-spring), box-shadow var(--dur-smooth) var(--ease-out);
}
.proj::after { /* sheen sweep */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, rgba(255,255,255,0) 42%, rgba(255,255,255,.55) 50%, rgba(255,255,255,0) 58%);
  transform: translateX(-160%);
  transition: transform .8s var(--ease-out);
}
.proj:hover { transform: translateY(-4px); box-shadow: var(--shadow-tight), var(--shadow-lift), inset 0 1px 0 rgba(255,255,255,.7); }
.proj:hover::after { transform: translateX(160%); }
.proj .thumb {
  height: 86px; border-radius: 14px;
  background: linear-gradient(160deg, var(--moss), #16220f);
  color: var(--bone); display: flex; align-items: flex-end; padding: 10px 12px;
  font-family: var(--font-display); font-style: italic; font-size: 20px;
  margin-bottom: 12px; border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.proj h3 { margin: 0 0 4px; font-size: 15px; }
.proj .sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; }
.proj .del {
  position: absolute; top: 10px; right: 10px; z-index: 1;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,.85);
  border-radius: 8px; font-size: 12px; padding: 2px 7px; cursor: pointer;
  transition: all var(--dur-quick) var(--ease-out);
}
.proj .del:hover { background: var(--accent); color: #fff; border-color: var(--accent-dark); }
.empty {
  border: 1px dashed var(--line-strong); border-radius: var(--radius-card);
  padding: 34px; text-align: center; color: var(--muted); grid-column: 1/-1;
  background: rgba(255,255,255,.4);
}

/* ========================================
   7. SHARED BUTTONS + TOAST
   ======================================== */
.btn {
  font: inherit; font-weight: 600; border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border); padding: 10px 18px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--glass-bg); color: var(--ink);
  transition: transform var(--dur-quick) var(--ease-spring), box-shadow var(--dur-quick) var(--ease-out), background var(--dur-quick) var(--ease-out);
}
.btn:hover { background: rgba(255,255,255,.8); box-shadow: var(--shadow-tight), var(--shadow-glass); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: rgba(0,0,0,.06); color: #fff; position: relative; overflow: hidden;
  box-shadow: var(--shadow-accent), inset 0 1px 0 rgba(255,255,255,.45), inset 0 -6px 12px rgba(0,0,0,.12);
}
.btn-primary::before {
  content: ''; position: absolute; inset: 2px 2px 55% 2px; border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(255,255,255,.4), rgba(255,255,255,0));
  pointer-events: none;
}
.btn-primary:hover { background: linear-gradient(180deg, #EE5327 0%, var(--accent-dark) 100%); box-shadow: 0 8px 28px rgba(232,72,28,.42), inset 0 1px 0 rgba(255,255,255,.5); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-small { padding: 7px 13px; font-size: 13px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: rgba(23, 19, 16, 0.88); color: var(--bone);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  padding: 10px 18px; border-radius: var(--radius-pill); font-size: 13.5px; z-index: 99;
  box-shadow: var(--shadow-tight), var(--shadow-lift), inset 0 1px 0 rgba(255,255,255,.14);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .toast { background: rgba(23, 19, 16, 0.96); }
}

/* ========================================
   8. WORKSPACE
   ======================================== */
.ws { display: grid; grid-template-rows: 64px 1fr; height: 100vh; }
.ws-bar {
  display: flex; align-items: center; gap: 12px;
  margin: 8px 12px 8px; padding: 0 14px;
  border-radius: var(--radius-pill); z-index: 5;
}
.ws-bar .back {
  text-decoration: none; font-family: var(--font-mono); font-size: 12.5px;
  white-space: nowrap;
  border: 1px solid var(--glass-border); border-radius: var(--radius-pill);
  padding: 6px 11px; background: var(--glass-bg-soft);
  transition: background var(--dur-quick) var(--ease-out);
}
.ws-bar .back:hover { background: rgba(255,255,255,.85); }
.ws-title {
  font-family: var(--font-display); font-weight: 600; font-size: 17px;
  border: 1px solid transparent; border-radius: 10px; padding: 3px 8px;
  min-width: 60px; max-width: 340px; background: transparent;
  transition: all var(--dur-quick) var(--ease-out);
}
.ws-title:hover { border-color: var(--line-strong); }
.ws-title:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(232,72,28,.14); }
.seg { display: inline-flex; padding: 3px; border-radius: var(--radius-pill); }
.seg button {
  border: 0; font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 13px; cursor: pointer; color: var(--muted);
  border-radius: var(--radius-pill); background: transparent;
  transition: color var(--dur-quick) var(--ease-out);
}
.seg button.active { color: var(--ink); }
.seg.glass-ready button.active { color: var(--ink); }
.ws-bar .spacer { flex: 1; }
.ws-main { display: grid; grid-template-columns: 400px 1fr; min-height: 0; }
@media (max-width: 900px) { .ws-main { grid-template-columns: 1fr; } }

.chat {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--glass-hairline);
  background: var(--glass-bg-soft);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
}
.chat-log { flex: 1; overflow-y: auto; padding: 18px 16px 12px; display: flex; flex-direction: column; gap: 14px; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.msg { max-width: 100%; animation: msg-in var(--dur-smooth) var(--ease-out) both; }
.msg.user {
  align-self: flex-end; background: var(--ink); color: var(--bone);
  border-radius: 16px 16px 4px 16px; padding: 10px 13px; font-size: 14px;
  max-width: 92%; white-space: pre-wrap;
  box-shadow: var(--shadow-tight), inset 0 1px 0 rgba(255,255,255,.12);
}
.msg.assistant {
  align-self: flex-start; border-radius: 16px 16px 16px 4px;
  padding: 11px 13px; font-size: 14px; max-width: 94%; white-space: pre-wrap;
  box-shadow: var(--shadow-tight), var(--shadow-glass), inset 0 1px 0 rgba(255,255,255,.7);
}
.msg.assistant.error { border-color: rgba(232,72,28,.5); background: rgba(255, 236, 229, 0.75); }
.msg .who { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; color: var(--muted); display: block; margin-bottom: 5px; }
.applied { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 6px; }
.applied .pill {
  font-family: var(--font-mono); font-size: 11px;
  background: rgba(34, 48, 31, 0.10); border: 1px solid rgba(34, 48, 31, 0.22);
  color: #2c4527; border-radius: var(--radius-pill); padding: 3px 9px;
}
.applied .sum { font-size: 12.5px; color: var(--muted); font-style: italic; width: 100%; }
.typing { display: inline-flex; gap: 5px; padding: 6px 0 2px; }
.typing i { width: 7px; height: 7px; border-radius: var(--radius-pill); background: var(--line-strong); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,100% { opacity: .3; } 50% { opacity: 1; } }
.chat-box {
  border-top: 1px solid var(--glass-hairline); padding: 12px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.chat-box textarea {
  width: 100%; min-height: 64px; max-height: 160px; resize: vertical;
  border: 1px solid var(--line-strong); border-radius: 14px;
  padding: 10px 12px; font: inherit; font-size: 14px;
  background: rgba(255,255,255,.85); outline: none;
  transition: border-color var(--dur-quick) var(--ease-out), box-shadow var(--dur-quick) var(--ease-out);
}
.chat-box textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,72,28,.15); }
.chat-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.chat-row .hint { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }

.stage {
  display: flex; flex-direction: column; min-height: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(253, 246, 236, .85));
}
.stage-meta { display: flex; align-items: center; gap: 10px; padding: 10px 18px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.preview-wrap { flex: 1; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 20px; min-height: 0; }
.frame {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden;
  box-shadow: var(--shadow-tight), var(--shadow-lift);
  transition: width var(--dur-smooth) var(--ease-out);
  width: 100%; max-width: 100%; display: flex; flex-direction: column;
}
.frame.desktop { max-width: 1100px; }
.frame.tablet { width: 768px; }
.frame.mobile { width: 375px; }
.frame-bar { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--paper); }
.frame-bar i { width: 10px; height: 10px; border-radius: var(--radius-pill); background: var(--line-strong); display: block; }
.frame-bar i:first-child { background: var(--accent); }
.frame-url { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-left: 8px; background: var(--bone); border: 1px solid var(--line); padding: 2px 10px; border-radius: var(--radius-pill); }
iframe.preview { width: 100%; height: calc(100vh - 220px); min-height: 420px; border: 0; background: #fff; }
.loading-veil { padding: 60px 20px; text-align: center; color: var(--muted); font-family: var(--font-mono); font-size: 13px; }

/* code view — solid, readable (intentionally not glass) */
.codeview { flex: 1; min-height: 0; display: grid; grid-template-columns: 230px 1fr; background: var(--paper); border-top: 1px solid var(--line); }
.filetree { border-right: 1px solid var(--line); overflow-y: auto; padding: 10px; font-family: var(--font-mono); font-size: 12.5px; }
.filetree .f { padding: 6px 9px; border-radius: 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filetree .f:hover { background: var(--bone); }
.filetree .f.active { background: var(--ink); color: var(--bone); }
.codepane { overflow: auto; padding: 0; background: #14110d; color: #ece5d3; }
.codepane pre { margin: 0; padding: 18px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; white-space: pre; }

/* deploy modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(23,19,16,.4); display: grid; place-items: center; z-index: 1000; }
.modal {
  border-radius: var(--radius-lg); padding: 28px; width: 90%; max-width: 460px;
  box-shadow: var(--shadow-tight), 0 30px 80px rgba(23,19,16,.35), inset 0 1px 0 rgba(255,255,255,.7);
  animation: rise-in var(--dur-smooth) var(--ease-out) both;
}
.modal h3 { margin: 0 0 4px; font-size: 17px; }

/* ---------- footer ---------- */
.site-footer { text-align: center; padding: 30px 16px 44px; color: var(--muted); font-size: 12.5px; position: relative; z-index: 1; }

/* ========================================
   9. MOTION SAFETY + SMALL SCREENS
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .glass-indicator { transition: none; }
}
@media (max-width: 640px) {
  .topbar { margin: 6px 8px 0; padding: 8px 12px; }
  .hero-center { padding: 40px 0 0; }
  .wrap { padding: 0 16px; }
  .ws-bar { margin: 6px 8px; gap: 8px; padding: 0 10px; }
  .ws-title { max-width: 130px; }
}

/* ========================================
   10. SIDEBAR · MODEL DROPDOWN · SETTINGS MODAL · KEY BADGE
   ======================================== */

/* --- sidebar (home page only, collapsed by default) --- */
.sidebar {
  position: fixed; top: 12px; bottom: 12px; left: 12px; width: 292px; z-index: 40;
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px;
  border-radius: var(--radius-lg);
  transform: translateX(calc(-100% - 24px));
  transition: transform var(--dur-smooth) var(--ease-spring), box-shadow var(--dur-smooth) var(--ease-out);
  visibility: hidden;
}
.sidebar.open { transform: none; visibility: visible; box-shadow: var(--shadow-tight), var(--shadow-lift), inset 0 1px 0 rgba(255,255,255,.7); }
.sb-head { display: flex; align-items: center; justify-content: space-between; }
.sb-close {
  width: 30px; height: 30px; border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border); background: rgba(255,255,255,.6);
  font-size: 17px; line-height: 1; cursor: pointer; color: var(--muted);
  transition: color var(--dur-quick) var(--ease-out), background var(--dur-quick) var(--ease-out);
}
.sb-close:hover { color: var(--ink); background: rgba(255,255,255,.9); }
.sb-new { width: 100%; justify-content: center; }
.sb-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; min-height: 0; padding-right: 2px; }
.sb-label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); margin: 10px 0 6px;
}
.sb-projects { display: flex; flex-direction: column; gap: 2px; }
.sb-proj {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 12px; cursor: pointer;
  transition: background var(--dur-quick) var(--ease-out);
}
.sb-proj:hover { background: rgba(255,255,255,.75); }
.sb-proj-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-proj-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.sb-proj-del {
  border: none; background: transparent; color: var(--faint);
  font-size: 15px; line-height: 1; cursor: pointer; padding: 2px 5px; border-radius: 8px;
  transition: color var(--dur-quick) var(--ease-out), background var(--dur-quick) var(--ease-out);
}
.sb-proj-del:hover { color: #fff; background: var(--accent); }
.sb-empty { color: var(--muted); font-size: 12.5px; padding: 8px 10px; font-style: italic; }
.sb-item {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; background: transparent; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--ink-soft); padding: 9px 10px; border-radius: 12px; cursor: pointer;
  transition: background var(--dur-quick) var(--ease-out);
}
.sb-item:hover { background: rgba(255,255,255,.75); }
.sb-new-badge { font-size: 9px; font-weight: 800; letter-spacing: .06em; color: #fff; background: var(--accent); border-radius: 6px; padding: 2px 5px; }
.sb-foot {
  display: flex; align-items: center; gap: 10px;
  border-top: 1px solid var(--glass-hairline); padding-top: 12px;
}
.sb-user { flex: 1; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-logout { color: var(--muted); font-size: 13px; padding: 6px 10px; }
.sb-logout:hover { color: var(--accent-dark); background: rgba(232,72,28,.08); }
.sb-backdrop {
  position: fixed; inset: 0; z-index: 39;
  background: rgba(23, 19, 16, 0.35);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-smooth) var(--ease-out);
}
.sb-backdrop.visible { opacity: 1; pointer-events: auto; }
.sb-toggle { display: inline-grid; cursor: pointer; }

/* --- model dropdown (prompt box + chat row) --- */
.model-select { position: relative; }
.model-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--glass-border); background: var(--glass-bg-soft);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border-radius: var(--radius-pill); padding: 7px 12px;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  cursor: pointer; max-width: 200px; white-space: nowrap;
  transition: background var(--dur-quick) var(--ease-out), box-shadow var(--dur-quick) var(--ease-out), transform var(--dur-quick) var(--ease-spring);
}
.model-btn:hover { background: rgba(255,255,255,.85); }
.model-btn .chev { opacity: .6; transition: transform var(--dur-quick) var(--ease-out); }
.model-select.open .model-btn { background: rgba(255,255,255,.92); box-shadow: var(--shadow-tight), var(--shadow-glass); }
.model-select.open .model-btn .chev { transform: rotate(180deg); }
.model-btn #modelLabel { overflow: hidden; text-overflow: ellipsis; }
.model-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; min-width: 230px; z-index: 60;
  display: none; padding: 6px;
  border-radius: 16px;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-tight), var(--shadow-lift), inset 0 1px 0 rgba(255,255,255,.7);
}
.model-select.open .model-menu { display: block; animation: rise-in var(--dur-quick) var(--ease-out) both; }
.model-opt {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: none; background: transparent; font: inherit; font-size: 13.5px;
  color: var(--ink); text-align: left; padding: 8px 12px; border-radius: 10px; cursor: pointer;
  transition: background var(--dur-quick) var(--ease-out);
}
.model-opt:hover { background: rgba(255,255,255,.8); }
.model-opt .check { color: var(--accent); font-weight: 700; visibility: hidden; }
.model-opt.selected .check { visibility: visible; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .model-menu, .sidebar { background: var(--glass-solid); }
}

/* --- "using your key" badge --- */
.key-badge {
  display: none; align-items: center; gap: 5px;
  position: absolute; top: 10px; right: 14px; z-index: 2;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  color: #1e7a3c; background: rgba(62, 207, 110, 0.12);
  border: 1px solid rgba(62, 207, 110, 0.32);
  border-radius: var(--radius-pill); padding: 3px 10px;
}
.key-badge-chat { position: static; align-self: flex-start; margin-bottom: 8px; }

/* --- add-key card in chat --- */
.ooc-msg .btn { align-self: flex-start; }

/* --- settings modal + workspace API-key pill --- */
.ws-credits { cursor: pointer; font-family: var(--font-mono); font-size: 11px; color: var(--muted); background: var(--glass-bg-soft); border: 1px solid var(--glass-border); border-radius: var(--radius-pill); padding: 6px 12px; transition: background var(--dur-quick) var(--ease-out); }
.ws-credits:hover { background: rgba(255,255,255,.85); }
/* one-time promo ad */
.promo-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center; padding: 20px;
  background: rgba(24, 14, 9, .62);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
}
.promo-dialog { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; max-height: 92vh; }
.promo-dialog video {
  height: min(76vh, 760px); max-width: 100%; width: auto;
  border-radius: 22px; background: #000; object-fit: contain;
  box-shadow: 0 30px 90px rgba(30, 12, 4, .45), inset 0 1px 0 rgba(255,255,255,.2);
}
.promo-skip, .promo-sound, .promo-play {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border-radius: var(--radius-pill); padding: 8px 15px;
  border: 1px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.9); color: #3a2318;
  transition: transform var(--dur-quick) var(--ease-out), background var(--dur-quick) var(--ease-out);
}
.promo-skip:hover, .promo-sound:hover, .promo-play:hover { background: #fff; transform: translateY(-1px); }
.promo-skip { position: absolute; top: -13px; right: -4px; }
.promo-sound, .promo-play { align-self: center; }
.promo-caption { color: rgba(255,255,255,.86); font-size: 12.5px; letter-spacing: .02em; }
.promo-caption a { color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 640px) {
  .promo-overlay { padding: 12px; }
  .promo-dialog video { height: 72vh; border-radius: 18px; }
}

.settings-modal { position: relative; max-height: 86vh; overflow-y: auto; }
.settings-close { position: absolute; top: 12px; right: 14px; font-size: 20px; }
.set-section { margin-top: 18px; }
.set-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.set-row { display: flex; gap: 8px; }
.set-row input { flex: 1; min-width: 0; }
.set-row input, .set-input {
  padding: 9px 12px; font: inherit; font-size: 13.5px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: rgba(255,255,255,.85); color: var(--ink); outline: none;
  transition: border-color var(--dur-quick) var(--ease-out), box-shadow var(--dur-quick) var(--ease-out);
}
.set-row input:focus, .set-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,72,28,.15); }
.set-select {
  width: 100%; padding: 9px 12px; font: inherit; font-size: 13.5px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: rgba(255,255,255,.85); color: var(--ink); outline: none; cursor: pointer;
  transition: border-color var(--dur-quick) var(--ease-out), box-shadow var(--dur-quick) var(--ease-out);
}
.set-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,72,28,.15); }
.set-input { width: 100%; margin-top: 8px; }
.set-help { font-size: 12.5px; color: var(--muted); margin: 4px 0 10px; line-height: 1.5; }
.set-help a { color: var(--accent-dark); font-weight: 600; }
.set-help code { font-family: var(--font-mono); font-size: 11.5px; background: rgba(232,72,28,.08); padding: 1px 5px; border-radius: 6px; }
.set-steps { margin: 0 0 10px; padding-left: 20px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.set-steps a { color: var(--accent-dark); font-weight: 600; }
.set-steps code { font-family: var(--font-mono); font-size: 11.5px; background: rgba(232,72,28,.08); padding: 1px 5px; border-radius: 6px; }
.key-state { font-family: var(--font-mono); font-size: 12px; color: var(--ok); margin-top: 6px; min-height: 1.2em; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.key-msg { display: none; font-size: 12.5px; margin-top: 8px; }
.key-msg.visible { display: block; }
.key-msg.ok { color: var(--ok); }
.key-msg.bad { color: #b23012; }
.remember-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-top: 12px; cursor: pointer; }
.remember-row input { accent-color: var(--accent); }

