/* ===========================================================
   indie.chat — design system
   Swiss/editorial · terracotta accent · mono labels
   =========================================================== */

:root {
  /* canvas + surface */
  --canvas:      #e7e7e8;
  --surface:     #ffffff;
  --surface-2:   #f3f3f4;
  --surface-3:   #eaeaec;

  /* ink */
  --ink:         #18181a;
  --ink-2:       #4d4d51;
  --ink-3:       #88888d;
  --ink-4:       #b0b0b6;

  /* lines */
  --line:        #dbdbde;
  --line-2:      #c8c8cd;
  --line-strong: #18181a;

  /* brand */
  --terra:       #c2562d;
  --terra-ink:   #a8441f;
  --terra-wash:  #efe2db;
  --terra-line:  #ddc0b1;

  --green:       #4f7a5b;
  --green-wash:  #e4eae5;
  --green-line:  #c2d0c4;

  --maroon:      #8c3526;
  --gold:        #7c7c82;

  /* type */
  --sans: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* metrics */
  --rad:   3px;
  --rad-lg: 4px;
  --col:   42rem;   /* message column width */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

button { font-family: inherit; cursor: pointer; }
::selection { background: var(--terra-wash); }

/* mono label utility */
.mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ====================== app shell ====================== */
.app {
  display: grid;
  grid-template-columns: 264px 1fr;
  height: 100%;
  overflow: hidden;
}

.scrim { display: none; }

/* ====================== sidebar ====================== */
.sidebar {
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
}
.logo {
  width: 30px; height: 30px;
  background: var(--terra);
  border-radius: var(--rad);
  display: grid;
  place-items: center;
  flex: none;
  position: relative;
}
.logo::before {
  content: "";
  width: 11px; height: 11px;
  border: 2.5px solid #fff;
  border-radius: 1px;
  transform: rotate(0deg);
}
.logo::after {
  content: "";
  position: absolute;
  width: 4px; height: 4px;
  background: var(--terra);
}
.brand-name {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand-name b { color: var(--terra); font-weight: 800; }
.brand-tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-top: 1px;
}

.new-chat {
  margin: 2px 14px 14px;
  padding: 11px 14px;
  background: var(--terra);
  color: #fff;
  border: none;
  border-radius: var(--rad);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background .14s ease;
}
.new-chat:hover { background: var(--terra-ink); }
.new-chat .plus { font-size: 14px; line-height: 1; }

.conv-head {
  padding: 4px 18px 8px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
}
.conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 8px 12px;
}
.conv-list::-webkit-scrollbar { width: 8px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }

.conv {
  position: relative;
  padding: 9px 11px 9px 12px;
  border-radius: var(--rad);
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.conv:hover { background: var(--surface-3); }
.conv.active {
  background: var(--surface);
  border-color: var(--line);
}
.conv.active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--terra);
}
.conv-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 18px;
}
.conv-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  text-transform: uppercase;
}
.conv-del {
  position: absolute;
  top: 7px; right: 6px;
  width: 22px; height: 22px;
  border: none; background: transparent;
  color: var(--ink-4);
  border-radius: var(--rad);
  display: none;
  align-items: center; justify-content: center;
  font-size: 14px;
}
.conv:hover .conv-del { display: flex; }
.conv-del:hover { background: var(--terra-wash); color: var(--maroon); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  flex: none;
}
.dot.off { background: var(--maroon); }
.foot-txt { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; color: var(--ink-3); text-transform: uppercase; }
.foot-txt b { color: var(--ink); font-weight: 600; }
.admin-link {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-3); text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--rad); padding: 4px 8px;
}
.admin-link:hover { color: var(--ink); border-color: var(--line-2); background: var(--surface); }
.admin-link svg { width: 12px; height: 12px; }

/* ====================== main ====================== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--canvas);
}

.topbar {
  height: 56px;
  flex: none;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--canvas) 86%, #fff);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}
.topbar-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 50%;
}
.topbar-title span { color: var(--ink-4); font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; margin-right: 8px; }

/* model selector */
.model-sel { position: relative; }
.model-btn {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 7px 11px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink);
  text-transform: uppercase;
  white-space: nowrap;        /* never wrap the label onto multiple lines */
  min-width: 0;
}
.model-btn .sel-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 170px;
}
.model-btn:hover { border-color: var(--line-2); }
.model-btn .sq { width: 8px; height: 8px; background: var(--terra); flex: none; }
.model-btn .chev { color: var(--ink-4); font-size: 9px; margin-left: 2px; }
.model-menu {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.28);
  min-width: 248px;
  padding: 5px;
  z-index: 40;
}
.model-opt {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none; background: transparent;
  border-radius: var(--rad);
  text-align: left;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--ink);
}
.model-opt:hover { background: var(--surface-3); }
.model-opt .sq { width: 8px; height: 8px; background: var(--ink-4); flex: none; }
.model-opt.sel .sq { background: var(--terra); }
.model-opt .desc { display:block; font-family: var(--sans); font-size: 11px; letter-spacing: 0; color: var(--ink-3); text-transform: none; margin-top: 2px; }
.model-opt .label { flex: 1; }
.model-opt .check { color: var(--terra); font-size: 12px; }

/* caption row inside dropdown menus */
.menu-cap {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-4); padding: 4px 10px 6px;
}

/* provider selector — live status dot (green = the chosen provider is the
   one that actually served the last response) */
.prov-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-4); flex: none; }
.prov-dot.on { background: var(--green); }
.prov-sel .model-btn .chev { margin-left: 2px; }

/* ====================== scroll / messages ====================== */
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.scroll::-webkit-scrollbar { width: 10px; }
.scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; }

.thread {
  max-width: var(--col);
  margin: 0 auto;
  padding: 30px 24px 24px;
}

.msg { padding: 14px 0 22px; }
.msg + .msg { border-top: 1px solid var(--line); }
.msg-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 9px;
}
.msg-sq { width: 9px; height: 9px; flex: none; }
.msg.user  .msg-sq { background: var(--ink); }
.msg.bot   .msg-sq { background: var(--terra); }
.msg-role {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-2);
}
.msg.bot .msg-role { color: var(--terra-ink); }
.msg-provider {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-4);
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  white-space: nowrap;
}
.msg-time { font-family: var(--mono); font-size: 10px; color: var(--ink-4); letter-spacing: 0.05em; margin-left: auto; }

.msg-body {
  font-size: 15px;
  line-height: 1.62;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.msg.user .msg-body { white-space: pre-wrap; }

.msg-actions {
  display: flex; gap: 4px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity .14s;
}
.msg:hover .msg-actions { opacity: 1; }
.act-btn {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 4px 9px;
}
.act-btn:hover { border-color: var(--line-2); color: var(--ink); background: var(--surface); }

/* cursor blink */
.caret {
  display: inline-block;
  width: 7px; height: 1.05em;
  background: var(--terra);
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 0%,50%{opacity:1} 50.01%,100%{opacity:0} }

/* ====================== 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,.md h4 { font-weight: 700; line-height: 1.25; margin: 22px 0 10px; letter-spacing: -0.01em; }
.md h1 { font-size: 22px; } .md h2 { font-size: 19px; } .md h3 { font-size: 16px; } .md h4 { font-size: 14px; }
.md ul,.md ol { margin: 0 0 14px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--ink-4); }
.md a { color: var(--terra-ink); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.md strong { font-weight: 700; }
.md blockquote {
  margin: 0 0 14px; padding: 2px 0 2px 16px;
  border-left: 2px solid var(--terra-line);
  color: var(--ink-2);
}
.md hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.md code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
}
.md pre {
  background: #1b1b18;
  border: 1px solid #2c2c27;
  border-radius: var(--rad-lg);
  margin: 0 0 16px;
  overflow: hidden;
}
.md pre .code-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px;
  border-bottom: 1px solid #2c2c27;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: #8d8b83;
}
.md pre .code-copy {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  color: #b4b2a9; background: transparent; border: none; padding: 2px 4px;
}
.md pre .code-copy:hover { color: #fff; }
.md pre code {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: #ecebe6;
  background: transparent;
  border: none;
  padding: 13px 14px;
  overflow-x: auto;
}
.md table { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; }
.md th { background: var(--surface-3); font-weight: 600; }

/* ====================== empty state ====================== */
.empty {
  max-width: var(--col);
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 24px 80px;
}
.empty-mark {
  width: 46px; height: 46px;
  background: var(--terra);
  border-radius: var(--rad);
  display: grid; place-items: center;
  margin-bottom: 22px;
  position: relative;
}
.empty-mark::before { content:""; width: 17px; height: 17px; border: 4px solid #fff; border-radius: 2px; }
.empty h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.025em; margin: 0 0 8px; }
.empty h1 b { color: var(--terra); }
.empty .sub { font-size: 15px; color: var(--ink-2); line-height: 1.55; margin: 0 0 28px; max-width: 30rem; }
.eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-4); margin-bottom: 14px;
}
.prompts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.prompt {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 14px 15px;
  transition: border-color .14s, transform .14s;
}
.prompt:hover { border-color: var(--terra-line); transform: translateY(-1px); }
.prompt .p-k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--terra); display: block; margin-bottom: 6px; }
.prompt .p-t { font-size: 13.5px; color: var(--ink); line-height: 1.4; }

/* ====================== composer ====================== */
.composer-wrap {
  flex: none;
  padding: 0 24px 20px;
  background: linear-gradient(to top, var(--canvas) 62%, transparent);
}
.composer {
  max-width: var(--col);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--rad-lg);
  box-shadow: 0 8px 26px -16px rgba(0,0,0,.3);
  transition: border-color .14s;
}
.composer.focus { border-color: var(--terra-line); }
.composer.drag { border-color: var(--terra); box-shadow: 0 0 0 3px var(--terra-wash); }

/* attachment chips */
.attach-row {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 11px 12px 2px;
}
.chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 5px 7px 5px 8px;
  max-width: 220px;
}
.chip .chip-ic { width: 8px; height: 8px; background: var(--ink-3); flex: none; }
.chip.bin .chip-ic { background: var(--gold); }
.chip.loading .chip-ic { background: var(--terra); animation: chip-pulse 1s ease-in-out infinite; }
.chip.loading .chip-sz { color: var(--terra-ink); }
@keyframes chip-pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
.chip .chip-name { font-family: var(--mono); font-size: 10.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .chip-sz { font-family: var(--mono); font-size: 9.5px; color: var(--ink-4); flex: none; }
.chip .chip-x { border: none; background: transparent; color: var(--ink-4); font-size: 12px; line-height: 1; padding: 0 1px; flex: none; }
.chip .chip-x:hover { color: var(--maroon); }

/* attach + tool buttons in composer */
.attach-btn {
  flex: none;
  width: 34px; height: 40px;
  display: grid; place-items: center;
  background: transparent; border: none;
  color: var(--ink-3); border-radius: var(--rad);
  margin-left: -4px;
}
.attach-btn:hover { color: var(--ink); background: var(--surface-2); }
.attach-btn svg { width: 18px; height: 18px; }

.mic-btn {
  flex: none;
  width: 34px; height: 40px;
  display: grid; place-items: center;
  background: transparent; border: none;
  color: var(--ink-3); border-radius: var(--rad);
}
.mic-btn:hover { color: var(--ink); background: var(--surface-2); }
.mic-btn svg { width: 18px; height: 18px; }
.mic-btn.rec  { color: #fff; background: var(--maroon); animation: mic-pulse 1.1s ease-in-out infinite; }
.mic-btn.busy { color: var(--terra-ink); }
.mic-btn:disabled { cursor: default; }
@keyframes mic-pulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(140,53,38,0.45) } 50%{ box-shadow: 0 0 0 5px rgba(140,53,38,0) } }

.voice-status {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3);
}
.voice-status.rec { color: var(--maroon); }
.voice-status.err { color: var(--maroon); text-transform: none; letter-spacing: 0; }
.voice-status .rec-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--maroon); flex: none; animation: chip-pulse 1s ease-in-out infinite; }
.voice-status .rec-dot.busy { background: var(--terra); }

.tool-toggle {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 100px;
  color: var(--ink-3);
}
.tool-toggle:hover { border-color: var(--line-2); color: var(--ink-2); }
.tool-toggle.on { border-color: var(--terra); background: var(--terra-wash); color: var(--terra-ink); }
.tool-toggle .tt-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); flex: none; }
.tool-toggle.on .tt-dot { background: var(--terra); }
.tool-toggle svg { width: 13px; height: 13px; }

.composer-foot .foot-left { display: flex; align-items: center; gap: 8px; }

/* msg attachments display */
.msg-attach { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.search-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3); border: 1px solid var(--line); border-radius: 100px; padding: 3px 9px;
  margin-bottom: 9px;
}
.search-pill .tt-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--terra); }
/* prominent "what was redacted" note on a user message */
.redaction-note {
  display: flex; align-items: center; gap: 8px;
  background: var(--green-wash);
  border: 1px solid var(--green-line);
  border-left: 3px solid var(--green);
  border-radius: var(--rad);
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 12.5px; line-height: 1.4;
  color: var(--green);
}
.redaction-note .rn-ic { display: inline-flex; flex: none; }
.redaction-note .rn-ic svg { width: 15px; height: 15px; }
.redaction-note b { font-weight: 600; color: var(--ink); }

/* PWA install banner */
.pwa-banner {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: flex; align-items: center; gap: 11px;
  max-width: min(440px, calc(100vw - 24px));
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--rad-lg, 12px);
  box-shadow: 0 16px 40px -14px rgba(0,0,0,.42);
}
.pwa-banner .pwa-ic { width: 34px; height: 34px; border-radius: 8px; flex: none; }
.pwa-banner .pwa-txt { font-size: 13px; line-height: 1.4; color: var(--ink-2); flex: 1; min-width: 0; }
.pwa-banner .pwa-txt b { color: var(--ink); font-weight: 600; }
.pwa-banner .pwa-install {
  flex: none;
  background: var(--terra); color: #fff; border: none;
  border-radius: var(--rad); padding: 8px 14px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer;
}
.pwa-banner .pwa-install:hover { background: var(--terra-ink); }
.pwa-banner .pwa-x {
  flex: none; border: none; background: transparent; color: var(--ink-4);
  font-size: 14px; line-height: 1; padding: 2px 4px; cursor: pointer;
}
.pwa-banner .pwa-x:hover { color: var(--ink); }

.model-warn {
  display: block;
  font-size: 12px; line-height: 1.5;
  color: var(--maroon);
  background: var(--terra-wash);
  border: 1px solid var(--terra-line);
  border-radius: 7px;
  padding: 7px 11px;
  margin-bottom: 11px;
}
.model-warn b { font-weight: 600; }
.model-warn .warn-ic { margin-right: 6px; }

/* composer */
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 10px 10px 16px;
}
.composer textarea {
  flex: 1;
  border: none; outline: none; resize: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  max-height: 220px;
  padding: 6px 0;
}
.composer textarea::placeholder { color: var(--ink-4); }
.send {
  flex: none;
  width: 40px; height: 40px;
  background: var(--terra);
  border: none;
  border-radius: var(--rad);
  color: #fff;
  display: grid; place-items: center;
  transition: background .14s, opacity .14s;
}
.send:hover:not(:disabled) { background: var(--terra-ink); }
.send:disabled { background: var(--line-2); cursor: not-allowed; }
.send svg { width: 18px; height: 18px; }
.stop {
  flex: none;
  width: 40px; height: 40px;
  background: var(--ink);
  border: none; border-radius: var(--rad);
  display: grid; place-items: center;
}
.stop .sq { width: 12px; height: 12px; background: #fff; border-radius: 1px; }
.stop:hover { background: #000; }

.composer-foot {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 8px 14px;
}
.composer-foot .hint {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em;
  color: var(--ink-4); text-transform: uppercase;
}
.composer-foot .hint b { color: var(--ink-3); }
.composer-foot .count { font-family: var(--mono); font-size: 10px; color: var(--ink-4); }

/* error banner */
.banner {
  max-width: var(--col);
  margin: 0 auto 10px;
  background: var(--terra-wash);
  border: 1px solid var(--terra-line);
  border-radius: var(--rad);
  padding: 9px 13px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em;
  color: var(--maroon);
  display: flex; align-items: center; gap: 8px;
}
.banner .x { margin-left: auto; cursor: pointer; border: none; background: transparent; color: var(--maroon); font-size: 14px; }

/* mobile */
.menu-btn { display: none; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 0 0 40px -10px rgba(0,0,0,.4);
  }
  .app.nav-open .sidebar { transform: none; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 55; }
  .app.nav-open .scrim { display: block; }
  .menu-btn {
    display: grid; place-items: center;
    width: 36px; height: 36px; border: 1px solid var(--line); background: var(--surface);
    border-radius: var(--rad); margin-right: 12px;
  }
  .prompts { grid-template-columns: 1fr; }
  :root { --col: 100%; }
}

/* phones — keep the topbar and composer from getting cramped */
@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { display: none; }          /* sidebar already shows the chat */
  .menu-btn { flex: none; margin-right: 4px; }
  .tools { gap: 6px; min-width: 0; }         /* allow the tool row to shrink */
  .model-sel { min-width: 0; }
  .model-btn { padding: 7px 8px; gap: 6px; font-size: 10px; letter-spacing: 0.03em; min-width: 0; }
  .model-btn .sel-label { max-width: 88px; }
  .model-btn .chev { font-size: 8px; }
  .icon-btn { width: 34px; height: 34px; flex: none; }
  .icon-btn svg { width: 16px; height: 16px; }

  /* dropdown menus must never overflow the viewport */
  .model-menu { min-width: 0; width: max-content; max-width: calc(100vw - 24px); }

  /* the keyboard hint is desktop-only; reclaim the row on phones */
  .composer-foot .hint { display: none; }
  .composer-wrap { padding-left: 12px; padding-right: 12px; }
  .thread { padding-left: 16px; padding-right: 16px; }
}

/* very narrow phones (≤380px) — truncate the labels harder so the
   provider+model pickers never collide with the menu/gear buttons */
@media (max-width: 380px) {
  .topbar { padding: 0 8px; gap: 6px; }
  .tools { gap: 4px; }
  .model-btn { padding: 6px 7px; gap: 5px; }
  .model-btn .sel-label { max-width: 56px; }
}

/* ====================== topbar tools + modal ====================== */
.tools { display: flex; align-items: center; gap: 9px; }
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  color: var(--ink-2);
}
.icon-btn:hover { border-color: var(--line-2); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

.modal-scrim {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20,18,15,.34);
  display: grid; place-items: center;
  padding: 20px;
}
.modal {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--rad-lg);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.45);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.modal-head .eb { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--terra); display: block; margin-bottom: 3px; }
.modal-x { width: 28px; height: 28px; border: none; background: transparent; color: var(--ink-3); border-radius: var(--rad); font-size: 16px; }
.modal-x:hover { background: var(--surface-3); color: var(--ink); }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }

.preset-row { display: flex; gap: 6px; }
.preset {
  flex: 1;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 8px 6px; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--rad); color: var(--ink-2);
}
.preset.on { border-color: var(--terra); background: var(--terra-wash); color: var(--terra-ink); }
.preset:hover { border-color: var(--line-2); }

.field label {
  display: block;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 6px;
}
.field input {
  width: 100%;
  font-family: var(--mono); font-size: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface-2); color: var(--ink);
  outline: none;
}
.field input:focus { border-color: var(--terra-line); background: var(--surface); }
.adm-select {
  width: 100%; font-family: var(--mono); font-size: 12px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface-2); color: var(--ink); outline: none;
}
.adm-select:focus { border-color: var(--terra-line); background: var(--surface); }
.field .help { font-family: var(--sans); font-size: 11px; color: var(--ink-3); margin-top: 5px; line-height: 1.45; }
.field .help code { font-family: var(--mono); font-size: 10.5px; background: var(--surface-3); padding: 1px 4px; border-radius: 2px; }

.modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.test-status { flex: 1; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.03em; }
.test-status.ok { color: var(--green); }
.test-status.bad { color: var(--maroon); }
.test-status.run { color: var(--ink-3); }
.btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600;
  padding: 9px 15px; border-radius: var(--rad); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--terra); border-color: var(--terra); color: #fff; }
.btn.primary:hover { background: var(--terra-ink); border-color: var(--terra-ink); }

.note {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-left: 2px solid var(--terra);
  border-radius: var(--rad);
  padding: 10px 12px;
  font-size: 12px; line-height: 1.5; color: var(--ink-2);
}
.note b { color: var(--ink); }

/* ====================== admin console ====================== */
.admin { min-height: 100%; display: flex; flex-direction: column; }
.admin-top {
  height: 60px; flex: none;
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.admin-top .logo { width: 28px; height: 28px; }
.admin-brand { display: flex; align-items: baseline; gap: 10px; }
.admin-brand .nm { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; margin-right: 2px; }
.admin-brand .nm b { color: var(--terra); }
.admin-brand .tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-4); }
.admin-top .back {
  margin-left: auto;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-2); text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--rad); padding: 8px 13px;
}
.admin-top .back:hover { border-color: var(--line-2); color: var(--ink); }

.admin-wrap { flex: 1; overflow-y: auto; }
.admin-inner { max-width: 920px; margin: 0 auto; padding: 34px 28px 60px; }

.admin-eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-4); }
.admin-h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; margin: 6px 0 22px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.tab {
  position: relative;
  background: transparent; border: none;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); padding: 11px 14px;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); font-weight: 600; }
.tab.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--terra); }
.tab .n { color: var(--ink-4); margin-left: 6px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.section-head .sub { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-4); margin-top: 3px; }

.table { border: 1px solid var(--line); border-radius: var(--rad-lg); overflow: hidden; background: var(--surface); }
.trow {
  display: grid; align-items: center;
  padding: 13px 16px;
  border-top: 1px solid var(--line);
}
.trow:first-child { border-top: none; }
.trow.head {
  background: var(--surface-2);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
}
.trow .cell-main { font-weight: 600; font-size: 14px; }
.trow .cell-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 2px; word-break: break-all; }
.trow .mono-cell { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }

.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: var(--rad); border: 1px solid var(--line);
}
.tag-chip .sq { width: 7px; height: 7px; }
.tag-chip.green { color: var(--green); border-color: var(--green-line); background: var(--green-wash); }
.tag-chip.green .sq { background: var(--green); }
.tag-chip.gray { color: var(--ink-3); }
.tag-chip.gray .sq { background: var(--ink-4); }
.tag-chip.terra { color: var(--terra-ink); border-color: var(--terra-line); background: var(--terra-wash); }
.tag-chip.terra .sq { background: var(--terra); }

.row-acts { display: flex; gap: 6px; justify-content: flex-end; }
.mini {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: var(--rad); padding: 5px 9px;
}
.mini:hover { border-color: var(--line-2); color: var(--ink); }
.mini.danger:hover { border-color: var(--terra-line); color: var(--maroon); background: var(--terra-wash); }
.mini.approve { color: var(--green); border-color: var(--green-line); }
.mini.approve:hover { color: var(--green); border-color: var(--green); background: var(--green-wash); }

/* toggle switch */
.switch {
  width: 38px; height: 22px; border-radius: 100px;
  border: 1px solid var(--line-2); background: var(--surface-2);
  position: relative; flex: none; transition: background .14s, border-color .14s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .16s;
}
.switch.on { background: var(--terra); border-color: var(--terra); }
.switch.on::after { transform: translateX(16px); }

.tool-card {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px;
  border: 1px solid var(--line); border-radius: var(--rad-lg);
  background: var(--surface); margin-bottom: 10px;
}
.tool-card .tc-body { flex: 1; }
.tool-card .tc-name { font-weight: 700; font-size: 14.5px; }
.tool-card .tc-desc { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; line-height: 1.45; }
.tool-card .tc-key { margin-top: 12px; }
.tool-card .tc-key input {
  width: 100%; font-family: var(--mono); font-size: 11.5px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--rad);
  background: var(--surface-2); color: var(--ink); outline: none;
}
.tool-card .tc-key input:focus { border-color: var(--terra-line); background: var(--surface); }
.tool-card .tc-key label { display: block; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 5px; }

.empty-cell { padding: 22px 16px; text-align: center; font-family: var(--mono); font-size: 11px; color: var(--ink-4); }

/* ====================== auth screen ====================== */
.auth-screen {
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--canvas);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--rad-lg);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.28);
  padding: 30px 30px 24px;
}
.auth-brand {
  display: flex;
  align-items: center;
  margin-bottom: 26px;
}
.auth-tabs {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--rad);
  overflow: hidden;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: pointer;
}
.auth-tab.on { background: var(--terra); color: #fff; }
.auth-tab:hover:not(.on) { background: var(--surface-2); }
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-error {
  background: var(--terra-wash);
  border: 1px solid var(--terra-line);
  border-radius: var(--rad);
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--maroon);
  line-height: 1.4;
}
.auth-notice {
  background: var(--green-wash, #e6efe8);
  border: 1px solid var(--green-line);
  border-radius: var(--rad);
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--green);
  line-height: 1.4;
}
.auth-note-sm {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--ink-4);
  line-height: 1.5;
}
.auth-submit {
  width: 100%;
  padding: 11px;
  font-size: 12px;
  margin-top: 4px;
}
.auth-hint {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ====================== user foot in sidebar ====================== */
.user-foot {
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
}
.user-avatar {
  width: 28px; height: 28px;
  background: var(--terra);
  color: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex: none;
}
.user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 4px 8px;
  font-size: 13px;
  color: var(--ink-3);
  flex: none;
  cursor: pointer;
  line-height: 1;
}
.logout-btn:hover { color: var(--maroon); border-color: var(--terra-line); background: var(--terra-wash); }
