/* ============================================================
   Sam Tools — design tokens
   Warm paper ground, ink text, navy for intent, vermilion for
   accent. Editorial serif for display, grotesk for interface.
   ============================================================ */

:root {
  /* surfaces */
  --paper:      #FAFAF7;  /* app ground */
  --surface:    #FFFFFF;  /* cards, composer, menus */
  --sunken:     #F5F5F2;  /* rails, user bubbles, code */
  --hover:      #EFEFEA;
  --active:     #E6E6E3;
  --line:       #E6E6E3;
  --line-soft:  #EDEDE8;
  --line-strong:#D6D6D0;

  /* ink */
  --ink:        #151515;
  --ink-soft:   #5C5C57;
  --ink-faint:  #8E8E86;

  /* brand */
  --navy:       #174A8B;
  --vermilion:  #C7372F;
  --accent:     #151515;   /* primary action fill */
  --on-accent:  #FFFFFF;
  --focus:      #174A8B;
  --danger:     #C7372F;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --pill:      999px;

  --rail: 280px;

  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype",
           Palatino, "Book Antiqua", Georgia, serif;
  --sans:  ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
           Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --shadow-sm: 0 1px 2px rgba(21,21,21,.04);
  --shadow:    0 2px 8px rgba(21,21,21,.06);
  --shadow-lg: 0 16px 48px rgba(21,21,21,.14);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #0D0D0D;
    --surface:    #151515;
    --sunken:     #1B1B1B;
    --hover:      #232323;
    --active:     #2C2C2C;
    --line:       #262626;
    --line-soft:  #1F1F1F;
    --line-strong:#3A3A3A;

    --ink:        #F2F2EF;
    --ink-soft:   #A5A59E;
    --ink-faint:  #6E6E68;

    --navy:       #6E9BD8;
    --vermilion:  #E86A60;
    --accent:     #F2F2EF;
    --on-accent:  #151515;
    --focus:      #6E9BD8;
    --danger:     #E86A60;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow:    0 2px 10px rgba(0,0,0,.45);
    --shadow-lg: 0 18px 52px rgba(0,0,0,.6);
  }
}

:root[data-theme="dark"] {
  --paper:      #0D0D0D;
  --surface:    #151515;
  --sunken:     #1B1B1B;
  --hover:      #232323;
  --active:     #2C2C2C;
  --line:       #262626;
  --line-soft:  #1F1F1F;
  --line-strong:#3A3A3A;

  --ink:        #F2F2EF;
  --ink-soft:   #A5A59E;
  --ink-faint:  #6E6E68;

  --navy:       #6E9BD8;
  --vermilion:  #E86A60;
  --accent:     #F2F2EF;
  --on-accent:  #151515;
  --focus:      #6E9BD8;
  --danger:     #E86A60;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 2px 10px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 52px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
/* An explicit `display` in author CSS beats the UA rule for [hidden]. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }

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

/* ---------- brand mark ---------- */

.mark { display: inline-flex; gap: 4px; align-items: center; flex: 0 0 auto; }
.mark i { display: block; width: 13px; height: 2.5px; border-radius: 2px; }
.mark i:first-child { background: var(--navy); }
.mark i:last-child  { background: var(--vermilion); }

/* ---------- primitives ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 500; letter-spacing: -.005em;
  cursor: pointer; white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, transform .06s ease;
}
.btn:hover { background: var(--hover); border-color: var(--line-strong); }
.btn:active { transform: translateY(.5px); background: var(--active); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); opacity: .87; }
.btn-primary:active { background: var(--accent); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--hover); border-color: transparent; color: var(--ink); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); border-color: transparent; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }

.input, .textarea, .select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  outline: none; transition: border-color .14s ease, box-shadow .14s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 14%, transparent);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.55; }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px;
}
.field .hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; line-height: 1.5; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 10px; border-radius: var(--pill);
  background: var(--sunken); border: 1px solid var(--line);
  font-size: 12px; color: var(--ink-soft); white-space: nowrap;
}
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty {
  padding: 36px 18px; text-align: center; color: var(--ink-faint);
  font-size: 14px; line-height: 1.6;
}

/* ---------- app shell ---------- */

.app { display: flex; height: 100dvh; overflow: hidden; }

.sidebar {
  width: var(--rail); flex: 0 0 var(--rail);
  display: flex; flex-direction: column;
  background: var(--sunken); border-right: 1px solid var(--line);
}

.sidebar-head {
  display: flex; align-items: center; gap: 9px;
  padding: 18px 16px 14px;
}
.brand {
  font-family: var(--serif);
  font-size: 20px; font-weight: 500; letter-spacing: -.015em;
  margin-right: auto; color: var(--ink);
}

.sidebar-new { padding: 0 12px 12px; }
.sidebar-new .btn {
  width: 100%; height: 40px; justify-content: flex-start;
  border-radius: var(--radius); font-weight: 550;
}

.sidebar-search { padding: 0 12px 10px; }
.sidebar-search .input {
  height: 34px; font-size: 13.5px; padding: 0 11px;
  background: var(--surface); border-radius: var(--radius-sm);
}

.sidebar-tabs { display: flex; gap: 2px; padding: 0 12px 12px; }
.sidebar-tabs button {
  flex: 1; height: 30px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-faint);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.sidebar-tabs button:hover { background: var(--hover); color: var(--ink); }
.sidebar-tabs button[aria-selected="true"] {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.sidebar-body { flex: 1; overflow-y: auto; padding: 0 10px 10px; }

.sidebar-foot {
  border-top: 1px solid var(--line); padding: 10px 12px;
  display: flex; align-items: center; gap: 6px;
}
.sidebar-foot .who { flex: 1; min-width: 0; font-size: 12px; color: var(--ink-faint); }
.sidebar-foot .who strong {
  display: block; color: var(--ink); font-weight: 550; font-size: 13.5px;
}

.list-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px; margin-bottom: 2px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  text-align: left; cursor: pointer; color: var(--ink);
  transition: background .14s ease;
}
.list-item:hover { background: var(--hover); }
.list-item[aria-current="true"] { background: var(--surface); box-shadow: var(--shadow-sm); }
.list-item .label { flex: 1; min-width: 0; font-size: 13.5px; }
.list-item .sub { font-size: 11.5px; color: var(--ink-faint); margin-top: 1px; }
.list-item .row-actions { opacity: 0; display: flex; gap: 2px; }
.list-item:hover .row-actions,
.list-item:focus-within .row-actions { opacity: 1; }
.list-item .leaf { flex: 0 0 16px; color: var(--ink-faint); display: flex; }

.group-label {
  padding: 16px 10px 6px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .09em; color: var(--ink-faint);
}

/* ---------- main column ---------- */

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--paper); }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px; min-height: 60px;
  border-bottom: 1px solid var(--line-soft);
  /* Solid, not frosted: content scrolling under a translucent bar reads as
     clipped text rather than as depth. */
  background: var(--paper);
  position: relative; z-index: 5;
}
.topbar .title {
  font-family: var(--serif);
  font-size: 17px; font-weight: 500; letter-spacing: -.01em; min-width: 0;
}
.topbar .spacer { flex: 1; }
.hamburger { display: none; }

/* model picker */
.model-picker { position: relative; }
.model-button {
  display: flex; align-items: center; gap: 8px; max-width: 260px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--pill);
  background: var(--surface); cursor: pointer;
  font-size: 13.5px; font-weight: 500;
  transition: border-color .14s ease, background .14s ease;
  box-shadow: var(--shadow-sm);
}
.model-button:hover { border-color: var(--line-strong); background: var(--hover); }
.model-button .spark { flex: 0 0 14px; color: var(--navy); display: flex; }
.model-button .name { min-width: 0; }

.model-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  width: min(440px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  max-height: min(480px, 70dvh); overflow: hidden;
}
.model-menu .search { padding: 10px; border-bottom: 1px solid var(--line-soft); }
.model-menu .results { overflow-y: auto; padding: 6px; }
.model-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; text-align: left;
  transition: background .14s ease;
}
.model-row:hover { background: var(--hover); }
.model-row[aria-current="true"] { background: var(--sunken); }
.model-row .meta { flex: 1; min-width: 0; }
.model-row .id { font-size: 11.5px; color: var(--ink-faint); }
.model-row .price {
  font-size: 11.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums;
  text-align: right; flex: 0 0 auto;
}
/* The job a featured model is there to do, read before its name. */
.model-row .job {
  display: inline-block; margin-right: 8px; padding: 1px 6px;
  border-radius: var(--r-sm); background: var(--navy); color: #fff;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  vertical-align: 1px;
}

/* Opens the rest of the catalogue below the recommended set. */
.model-more {
  display: block; width: 100%; margin-top: 4px; padding: 9px 10px;
  border: 0; border-top: 1px solid var(--line-soft); background: transparent;
  color: var(--ink-soft); font: inherit; font-size: 12.5px; text-align: left;
  cursor: pointer; border-radius: 0 0 var(--r-md) var(--r-md);
}
.model-more:hover { background: var(--hover); color: var(--ink); }

.star {
  border: 0; background: transparent; cursor: pointer; padding: 2px;
  color: var(--ink-faint); line-height: 1; font-size: 14px;
  transition: color .14s ease;
}
.star:hover { color: var(--ink-soft); }
.star.on { color: #D9A406; }

.badge {
  display: inline-block; margin-left: 7px; padding: 1px 6px;
  border: 1px solid color-mix(in srgb, var(--navy) 35%, transparent);
  border-radius: var(--pill);
  font-size: 9.5px; font-weight: 650; letter-spacing: .07em;
  text-transform: uppercase; color: var(--navy); vertical-align: 1px;
}

/* ---------- transcript ---------- */

.transcript { flex: 1; overflow-y: auto; padding: 32px 0 8px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 24px; }

/* empty state */
.hero { padding: 8vh 0 0; text-align: center; }
.hero .mark { justify-content: center; margin-bottom: 22px; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(32px, 5vw, 46px); font-weight: 400; letter-spacing: -.025em;
  line-height: 1.12; margin: 0 0 14px; color: var(--ink);
}
.hero p {
  margin: 0 auto; max-width: 460px;
  font-size: 15px; line-height: 1.6; color: var(--ink-soft);
}

.turn { margin-bottom: 26px; }

/* your message: right-aligned, soft */
.turn-user .bubble {
  background: var(--sunken); border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg); padding: 12px 16px;
  margin-left: auto; max-width: 82%; width: fit-content;
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 14.5px;
}

/* reply: attributed, full width */
.turn-head {
  display: flex; align-items: center; gap: 9px; margin-bottom: 8px;
}
.avatar {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  font-size: 11.5px; font-weight: 650; letter-spacing: .02em;
}
.turn-name { font-size: 13.5px; font-weight: 600; letter-spacing: -.005em; }
.turn-time { font-size: 11.5px; color: var(--ink-faint); }
.turn-assistant .bubble { overflow-wrap: anywhere; }

.turn-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; font-size: 11.5px; color: var(--ink-faint);
  opacity: 0; transition: opacity .16s ease;
}
.turn:hover .turn-meta, .turn:focus-within .turn-meta { opacity: 1; }
.turn-user .turn-meta { justify-content: flex-end; }
@media (hover: none) { .turn-meta { opacity: 1; } }

.turn-error {
  border-left: 2px solid var(--danger); padding: 2px 0 2px 12px;
  color: var(--danger); font-size: 13.5px; margin-top: 8px;
}

/* markdown */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 14px; }
.md h1, .md h2, .md h3 {
  font-family: var(--serif); font-weight: 500;
  line-height: 1.22; margin: 26px 0 12px; letter-spacing: -.02em;
}
.md h1 { font-size: 25px; } .md h2 { font-size: 21px; } .md h3 { font-size: 18px; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 24px; }
.md li { margin: 5px 0; }
.md li::marker { color: var(--ink-faint); }
.md blockquote {
  margin: 0 0 14px; padding: 2px 0 2px 16px;
  border-left: 2px solid var(--line-strong); color: var(--ink-soft);
}
.md code {
  font-family: var(--mono); font-size: .875em;
  background: var(--sunken); border: 1px solid var(--line-soft);
  border-radius: 5px; padding: 1.5px 5px;
}
.md pre {
  margin: 0 0 14px; padding: 14px 16px; overflow-x: auto;
  background: var(--sunken); border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.md pre code { background: none; border: 0; padding: 0; font-size: 13px; line-height: 1.6; }
.md table {
  width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 14px;
  display: block; overflow-x: auto;
}
.md th, .md td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.md th { background: var(--sunken); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.md a { color: var(--navy); text-decoration: underline; text-underline-offset: 2px; }

.caret {
  display: inline-block; width: 7px; height: 1.05em; margin-left: 2px;
  background: var(--ink); vertical-align: text-bottom; border-radius: 1px;
  animation: blink 1.1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

/* ---------- composer ---------- */

.composer { padding: 12px 0 22px; background: var(--paper); }
.composer-box {
  border: 1px solid var(--line-strong); border-radius: var(--radius-xl);
  background: var(--surface); padding: 14px 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.composer-row { display: flex; align-items: center; gap: 8px; }
.composer-row .spacer { flex: 1; }
.composer-box:focus-within {
  border-color: var(--ink-faint);
  box-shadow: 0 2px 14px rgba(21,21,21,.09);
}
.composer-box.drag { border-color: var(--navy); background: var(--sunken); }
.composer-box textarea {
  width: 100%; border: 0; outline: none; background: transparent; resize: none;
  max-height: 240px; padding: 2px 2px 0; line-height: 1.6; font-size: 15.5px;
  min-height: 26px;
}
.composer-box textarea::placeholder { color: var(--ink-faint); }

/* round send button, as in the mockups */
#send {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 50%; font-size: 15px;
}

.composer-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 10px; padding: 0 4px; font-size: 12px; color: var(--ink-faint);
}
.composer-foot .spacer { flex: 1; }
.meter { display: flex; align-items: center; gap: 7px; }
.meter-bar { width: 64px; height: 4px; border-radius: 2px; background: var(--active); overflow: hidden; }
.meter-fill { height: 100%; background: var(--ink-faint); transition: width .25s ease; border-radius: 2px; }
.meter-fill.warn { background: #C9930B; }
.meter-fill.over { background: var(--danger); }

/* web-search toggle reads as a labelled pill when on */
#web-btn {
  border-radius: var(--pill); border: 1px solid transparent;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
#web-btn.on, #web-btn.on:hover {
  background: color-mix(in srgb, var(--navy) 12%, transparent);
  color: var(--navy); border-color: color-mix(in srgb, var(--navy) 32%, transparent);
}
#mic-btn.recording { color: var(--vermilion); }
#mic-btn.recording svg { animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .32; } }

/* ---------- attachments ---------- */

.attach-tray { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.chip {
  display: flex; align-items: center; gap: 8px;
  max-width: 230px; padding: 6px 8px 6px 7px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); font-size: 12.5px; box-shadow: var(--shadow-sm);
}
.chip img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; flex: 0 0 28px; }
.chip .doc {
  width: 28px; height: 28px; border-radius: 6px; flex: 0 0 28px;
  display: grid; place-items: center;
  background: var(--sunken); color: var(--ink-faint);
  font-size: 9.5px; font-weight: 700; letter-spacing: .02em;
}
.chip .chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .chip-sub { color: var(--ink-faint); font-size: 11px; }
.chip .x {
  border: 0; background: transparent; cursor: pointer; padding: 0 2px;
  color: var(--ink-faint); font-size: 16px; line-height: 1;
}
.chip .x:hover { color: var(--ink); }

.turn-attachments {
  display: flex; flex-wrap: wrap; gap: 7px;
  justify-content: flex-end; align-items: flex-end; margin-bottom: 8px;
}
.turn-attachments img {
  max-width: 230px; max-height: 230px; border-radius: var(--radius);
  border: 1px solid var(--line); cursor: zoom-in; display: block;
}
.lightbox {
  position: fixed; inset: 0; z-index: 130; background: rgba(13,13,13,.86);
  display: flex; align-items: center; justify-content: center; padding: 28px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius); }

.notice {
  font-size: 12px; color: var(--ink-soft); line-height: 1.5;
  border-left: 2px solid var(--vermilion); padding-left: 10px;
  display: flex; align-items: center;
}

/* ---------- panels ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(13,13,13,.36); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  width: min(680px, 100%); max-height: 86dvh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 {
  margin: 0; flex: 1; font-family: var(--serif);
  font-size: 19px; font-weight: 500; letter-spacing: -.015em;
}
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body h3 {
  font-size: 12px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-faint);
}
.modal-foot {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--line-soft);
}
.modal-foot .spacer { flex: 1; }

.file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 7px; background: var(--surface);
}
.file-row .name { flex: 1; min-width: 0; font-size: 13.5px; }
.file-row .size {
  font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
.file-row.off { opacity: .5; }

.switch { position: relative; width: 36px; height: 21px; flex: 0 0 36px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: var(--pill);
  background: var(--active); transition: background .16s ease;
}
.switch .thumb {
  position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.28);
  transition: transform .16s ease;
}
.switch input:checked ~ .track { background: var(--navy); }
.switch input:checked ~ .thumb { transform: translateX(15px); }

.dropzone {
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: 24px; text-align: center; color: var(--ink-soft); font-size: 13.5px;
  cursor: pointer; transition: background .14s ease, border-color .14s ease;
}
.dropzone:hover, .dropzone.over { background: var(--sunken); border-color: var(--navy); }

.export-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.export-tile {
  text-align: left; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  transition: background .14s ease, border-color .14s ease, transform .06s ease;
}
.export-tile:hover { background: var(--hover); border-color: var(--line-strong); }
.export-tile:active { transform: translateY(.5px); }
.export-tile:disabled { opacity: .6; cursor: wait; }
.export-name { font-size: 14px; font-weight: 550; }
.export-note { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; line-height: 1.45; }

/* ---------- search results ---------- */

.search-hit {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 10px; margin-bottom: 3px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink);
  transition: background .14s ease;
}
.search-hit:hover { background: var(--hover); }
.search-hit .hit-title { font-size: 13.5px; font-weight: 550; }
.search-hit .hit-snippet {
  font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.search-hit mark {
  background: color-mix(in srgb, var(--navy) 16%, transparent);
  color: var(--ink); border-radius: 3px; padding: 0 2px;
}

/* ---------- editing ---------- */

.edit-box { width: 100%; }
.edit-box textarea {
  width: 100%; min-height: 84px; resize: vertical; line-height: 1.55; font-size: 14.5px;
  padding: 12px 14px; border: 1px solid var(--focus); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink); outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 12%, transparent);
}
.edit-actions { display: flex; gap: 7px; justify-content: flex-end; margin-top: 8px; }

.turn.flash .bubble { animation: flash 1.8s ease-out; }
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy) 22%, transparent); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

.trim-note {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 26px; font-size: 11.5px; color: var(--ink-faint);
}
.trim-note::before, .trim-note::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.source-note { color: var(--ink-faint); }

/* ---------- toasts ---------- */

.toast-stack {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: var(--pill); font-size: 13px; font-weight: 500;
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow-lg);
  animation: rise .22s ease-out;
}
.toast.err { background: var(--vermilion); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- auth ---------- */

.auth {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--paper);
}
.auth-card {
  width: min(384px, 100%); padding: 32px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.auth-card .mark { margin-bottom: 20px; }
.auth-card h1 {
  margin: 0 0 6px; font-family: var(--serif);
  font-size: 27px; font-weight: 400; letter-spacing: -.025em;
}
.auth-card .lede { margin: 0 0 26px; color: var(--ink-soft); font-size: 14px; }
.auth-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 12px; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .hamburger { display: inline-flex; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 100;
    transform: translateX(-100%); transition: transform .22s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 0 48px rgba(0,0,0,.24);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim { position: fixed; inset: 0; z-index: 95; background: rgba(13,13,13,.34); }
  .wrap { padding: 0 16px; }
  .turn-user .bubble { max-width: 90%; }
  .model-button { max-width: 168px; }
  .model-menu { right: auto; left: 50%; transform: translateX(-50%); }
  .topbar { padding: 10px 12px; min-height: 56px; }
  .transcript { padding-top: 22px; }
  .hero { padding-top: 6vh; }
}

@media (max-width: 700px) {
  /* The keyboard hint means nothing on a touch keyboard, and it wraps. */
  #composer-hint { display: none; }
}

@media (max-width: 560px) {
  .export-grid { grid-template-columns: 1fr; }
  .model-button { max-width: 128px; }
  .topbar .title { font-size: 15px; }
  .modal { max-height: 92dvh; }
}

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

/* ---------- refinements ---------- */

/* An empty conversation centres in the space it has, rather than
   floating under the top bar with a gulf below it. */
.transcript.is-empty {
  display: flex; flex-direction: column; justify-content: center;
  padding-bottom: 4vh;
}
.transcript.is-empty .hero { padding-top: 0; }

/* Replies sit on a card, which separates them from your own messages
   and keeps long answers from running edge to edge. */
.turn-assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.turn-assistant .turn-meta { padding-left: 4px; }

/* The web toggle carries its label until the composer gets tight. */
#web-btn {
  gap: 7px; padding: 0 13px; width: auto; height: 34px;
  font-size: 13px; border-radius: var(--pill);
  border-color: var(--line); color: var(--ink-soft); background: var(--surface);
}
#web-btn:hover { background: var(--hover); color: var(--ink); }
#web-btn .web-label { white-space: nowrap; }
@media (max-width: 620px) {
  #web-btn { padding: 0; width: 34px; }
  #web-btn .web-label { display: none; }
}

/* first-run setup */
.setup-card { width: min(440px, 100%); }
.setup-card .field { text-align: left; }
.linkish {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--navy); font-size: 12.5px; text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-card .hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; line-height: 1.5; }
.auth-card .hint a { color: var(--navy); }

/* API key status and the missing-key banner */
.key-status { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink-soft); }
.key-status .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.key-status .dot.ok { background: #2E7D4F; }
.key-status .dot.off { background: var(--vermilion); }

.key-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 20px; font-size: 13.5px;
  background: color-mix(in srgb, var(--vermilion) 9%, var(--paper));
  border-bottom: 1px solid color-mix(in srgb, var(--vermilion) 22%, transparent);
  color: var(--ink);
}
.key-banner .btn { margin-left: auto; }
