* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: var(--rust); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; }
kbd {
  font: 500 11px/1 var(--mono);
  padding: 3px 5px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  background: var(--bg-2);
}
:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }
::selection { background: rgba(232, 105, 43, .45); }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Icons drawn with strokes */
.icon-btn svg, .btn-new svg, .search svg, .side-link svg, .chip-btn svg, .send svg, .act svg, .seg svg, .x-btn svg {
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) auto;
  height: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 14px 14px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark .logo { width: 30px; height: 30px; }
.brand-name { font: 600 19px/1 var(--display); letter-spacing: -.02em; }
.brand-name span { color: var(--muted); font-weight: 700; }

.btn-new {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border-radius: var(--r);
  background: var(--text);
  color: var(--on-accent);
  font-weight: 600;
  transition: transform .15s var(--ease), background .15s;
}
.btn-new svg { width: 18px; height: 18px; }
.btn-new kbd { margin-left: auto; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.22); color: #e9ded2; }
.btn-new:hover { background: var(--text-hover); }
.btn-new:active { transform: scale(.98); }

.search {
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
}
.search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 9px 0; outline: none; font-size: 14px; }
.search input::placeholder { color: var(--muted); }

.history { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; min-height: 0; }
.history-group { font: 600 11px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 14px 8px 6px; }
.history-item {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 8px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-align: left;
  font-size: 14px;
}
.history-item .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--line-2); }
.history-item[data-kind="noul"] .dot { background: var(--orange); }
.history-item[data-kind="choice"] .dot { background: var(--rust); }
.history-item[data-kind="score"] .dot { background: var(--amber); }
.history-item .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item:hover { background: var(--surface); color: var(--text); }
.history-item.active { background: var(--surface-2); color: var(--text); }
.history-item .del {
  opacity: 0; width: 22px; height: 22px; border-radius: 6px; color: var(--muted);
  display: grid; place-items: center; flex: none;
}
.history-item .del svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.history-item:hover .del, .history-item:focus-within .del { opacity: 1; }
.history-item .del:hover { background: var(--surface-3); color: var(--text); }
.history-empty { color: var(--faint); font-size: 13px; padding: 12px 8px; }

.side-foot { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 14px;
  text-align: left;
}
.side-link svg { width: 17px; height: 17px; color: var(--muted); }
.side-link:hover { background: var(--surface); color: var(--text); }

.conn {
  margin-top: 8px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  font-size: 13px;
}
.conn:hover { border-color: var(--line-2); }
.conn .pulse { width: 8px; height: 8px; border-radius: 50%; flex: none; position: relative; }
.conn .pulse::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid currentColor; opacity: .25; }
.conn.live .pulse { background: var(--ok); color: var(--ok); }
.conn.off .pulse { background: var(--amber); color: var(--amber); }
.conn b { font-weight: 600; display: block; }
.conn small { color: var(--muted); display: block; font-size: 12px; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 18px;
  border-bottom: 1px solid transparent;
  flex: none;
}
.main.scrolled .topbar { border-bottom-color: var(--line); }
.chat-title { flex: 1; min-width: 0; margin: 0; font: 600 15px/1.2 var(--font); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  color: var(--muted);
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.only-mobile, .only-embed, .embed-brand, .scrim { display: none; }

.thread { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; }
.thread-inner { max-width: 820px; margin: 0 auto; padding: 8px 24px 40px; display: flex; flex-direction: column; gap: 26px; }

/* ---------- Hero ---------- */
.hero { position: relative; min-height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.decor { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.decor * { fill: none; stroke: #ece4d9; }
.decor-rings circle { stroke-width: 9; }
.decor-squiggle { stroke-width: 44; stroke-linecap: round; }
.decor-chev path { stroke-width: 9; stroke-linecap: square; }
.decor-quarters path { fill: #efe8de; stroke: none; }

.hero-inner {
  position: relative;
  max-width: 880px; width: 100%;
  margin: 0 auto;
  padding: 40px 24px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: center;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font: 600 12px/1 var(--font); letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-2);
  margin: 0 0 16px;
}
.eyebrow::before { content: ''; width: 18px; height: 3px; border-radius: 2px; background: var(--grad); }
.hero h1 {
  margin: 0;
  font: 500 clamp(38px, 6vw, 64px)/1.02 var(--display);
  letter-spacing: -.035em;
}
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { color: var(--text-2); font-size: 17px; max-width: 54ch; margin: 18px 0 0; }
.hero-logo .logo { width: clamp(120px, 18vw, 200px); height: auto; }
.hero-logo .petals { transform-origin: 100px 100px; animation: spin 40s linear infinite; }

.steps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.step {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px 7px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.8);
  font-size: 13px; color: var(--text-2);
}
.step b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font: 700 12px/1 var(--display); color: var(--on-accent); }
.step:nth-child(1) b { background: var(--orange); }
.step:nth-child(2) b { background: var(--rust); }
.step:nth-child(3) b { background: var(--amber); }

.tiles {
  position: relative;
  max-width: 880px; width: 100%;
  margin: 18px auto 0;
  padding: 0 24px 28px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  min-height: 168px;
  padding: 14px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  overflow: hidden;
  transition: transform .2s var(--ease), border-color .2s, background .2s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--line-2); background: var(--surface-2); }
.tile-art { width: 46px; height: 46px; margin-bottom: auto; transition: transform .35s var(--ease); }
.tile:hover .tile-art { transform: rotate(-8deg) scale(1.06); }
.tile-art svg { width: 100%; height: 100%; }
.tile-art .hole { fill: var(--surface); }
.tile:hover .tile-art .hole { fill: var(--surface-2); }
.tile-kind { font: 600 11px/1 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 16px; }
.tile-title { font: 700 15px/1.25 var(--display); margin-top: 6px; letter-spacing: -.01em; }
.tile-sub { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.tile.brand-tile { background: var(--orange); border-color: var(--orange); justify-content: center; align-items: center; text-align: center; }
.tile.brand-tile:hover { background: var(--orange-soft); }
.brand-tile .big { font: 600 34px/1 var(--display); letter-spacing: -.04em; color: #fff; }
.brand-tile .tile-sub { color: rgba(255,255,255,.75); }

/* ---------- Messages ---------- */
.msg { display: flex; gap: 12px; }
.msg.fresh { animation: rise .35s var(--ease) both; }
.fresh .ring .val { animation: ring-in .9s var(--ease) both; }
.msg.user { justify-content: flex-end; }
.msg.user .stack { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: min(620px, 88%); }
.bubble {
  padding: 11px 15px;
  border-radius: 18px 18px 4px 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ctx {
  width: 100%;
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  font-size: 13px;
  color: var(--text-2);
}
.ctx summary { cursor: pointer; padding: 8px 12px; list-style: none; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.ctx summary::-webkit-details-marker { display: none; }
.ctx summary::before { content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.ctx[open] summary::before { transform: rotate(45deg); }
.ctx pre { margin: 0; padding: 0 12px 10px; white-space: pre-wrap; font: 13px/1.5 var(--font); overflow-wrap: anywhere; max-height: 240px; overflow: auto; }

.avatar { flex: none; width: 32px; height: 32px; margin-top: 4px; }
.avatar .logo { width: 32px; height: 32px; }
.avatar.busy .petals { transform-origin: 100px 100px; animation: spin 1.4s cubic-bezier(.6,.1,.4,.9) infinite; }
.card { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.thinking { display: flex; align-items: center; gap: 10px; padding-top: 8px; color: var(--text-2); }
.shimmer {
  background: linear-gradient(90deg, var(--muted) 0%, var(--text) 40%, var(--muted) 80%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.6s linear infinite;
  font-weight: 500;
}
.thinking small { color: var(--muted); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-top: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font: 600 11.5px/1.2 var(--font);
  letter-spacing: .02em;
  border: 1px solid var(--line-2);
  color: var(--text-2);
}
.badge.live { border-color: rgba(63,143,95,.35); color: var(--ok); background: rgba(63,143,95,.07); }


.explain { color: var(--text-2); margin: 6px 0 0; }
.explain strong { color: var(--text); }

.card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font: 12px/1.4 var(--mono); color: var(--faint); }
.meta span { white-space: nowrap; }
.meta .hi { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.act {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 13px; font-weight: 500;
  transition: background .15s, border-color .15s, color .15s;
}
.act svg { width: 15px; height: 15px; }
.act:hover { background: var(--surface-2); border-color: var(--line-2); color: var(--text); }
.act.primary { background: var(--text); color: var(--on-accent); border-color: var(--text); }
.act.primary:hover { background: var(--text-hover); }
.act.on { border-color: var(--rust); color: var(--text); background: rgba(232,105,43,.08); }

.link { color: var(--rust); font-size: 13px; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ---------- Translation editor ---------- */
.editor {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.editor-head h4 { margin: 0; font: 700 14px/1.3 var(--display); display: flex; align-items: center; gap: 8px; }
.editor-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.qedit { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.qedit-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.seg button { padding: 6px 11px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.qid { font: 12px/1 var(--mono); color: var(--faint); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field small { color: var(--faint); font-size: 12px; }
.input, .field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--bg);
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--rust); box-shadow: 0 0 0 3px rgba(232,105,43,.15); }

.rows { display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1.4fr) 30px; gap: 6px; align-items: center; }
.row.level { grid-template-columns: 22px minmax(0, 1fr) 30px; }
.row .num { font: 600 11px/1 var(--mono); color: var(--faint); text-align: center; }
.row input { padding: 7px 9px; font-size: 13.5px; }
.x-btn { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--faint); }
.x-btn svg { width: 14px; height: 14px; }
.x-btn:hover { background: var(--surface-3); color: var(--text); }
.row-actions { display: flex; gap: 14px; flex-wrap: wrap; padding-left: 28px; }

.tips { display: flex; flex-direction: column; gap: 6px; }
.tip { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--muted); }
.tip::before { content: '✦'; color: var(--orange); font-size: 11px; }
.editor-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.problems { font-size: 13px; color: var(--amber); }

/* ---------- Composer ---------- */
.composer-wrap { flex: none; padding: 0 24px 14px; max-width: 868px; width: 100%; margin: 0 auto; position: relative; }
.composer-wrap::before { content: ''; position: absolute; left: 0; right: 0; top: -28px; height: 28px; background: linear-gradient(transparent, var(--bg)); pointer-events: none; }
.composer {
  border: 1px solid var(--line-2);
  border-radius: 20px;
  background: var(--surface);
  padding: 10px 10px 8px 14px;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: 0 10px 40px rgba(80,50,20,.08);
}
.composer:focus-within { border-color: var(--orange-soft); box-shadow: 0 10px 40px rgba(80,50,20,.08), 0 0 0 4px rgba(232,105,43,.12); }
.composer #input {
  width: 100%;
  border: 0; outline: none; resize: none;
  background: none;
  padding: 6px 2px;
  font-size: 15.5px; line-height: 1.5;
  max-height: 220px;
}
.composer #input::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--text-2);
  font-size: 13px; font-weight: 500;
}
.chip-btn svg { width: 15px; height: 15px; }
.chip-btn:hover { background: var(--surface-2); color: var(--text); }
.chip-btn.on { border-color: rgba(232,105,43,.5); color: var(--rust); background: rgba(232,105,43,.08); }
.hint { flex: 1; text-align: right; font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--grad);
  color: #fff;
  transition: transform .15s var(--ease), opacity .15s, filter .15s;
  flex: none;
}
.send svg { width: 19px; height: 19px; stroke-width: 2.2; }
.send:hover:not(:disabled) { filter: brightness(1.1); }
.send:active:not(:disabled) { transform: scale(.94); }
.send:disabled { background: var(--surface-3); color: var(--faint); }

.ctx-box { margin: 2px 0 8px -4px; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--bg-2); padding: 8px 10px; }
.ctx-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.ctx-box textarea { width: 100%; border: 0; outline: none; resize: vertical; background: none; padding: 6px 0 2px; font-size: 14px; line-height: 1.5; min-height: 64px; max-height: 260px; }

.preview {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 0 6px 8px;
  font-size: 12.5px; color: var(--muted);
}
.preview .pv {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-2);
}
.preview .pv.warn { color: var(--amber); border-color: rgba(201,138,30,.35); }
.fineprint { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.fineprint a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.modal-note { font-size: 12.5px; color: var(--muted) !important; border-top: 1px solid var(--line); padding-top: 14px; }

/* ---------- Drawer ---------- */
.drawer {
  width: var(--drawer);
  border-left: 1px solid var(--line);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  min-height: 0;
  animation: slide-in .3s var(--ease);
}
.drawer[hidden] { display: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px 20px; }
.drawer-head h3 { margin: 0; flex: 1; font: 700 16px/1.2 var(--display); }
.tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { padding: 10px 10px; font-size: 13px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--rust); }
.tab-note { padding: 12px 20px 0; font-size: 13px; color: var(--muted); }
.code-wrap { position: relative; flex: 1; min-height: 0; margin: 12px 16px 16px; display: flex; }
.code {
  flex: 1; margin: 0; overflow: auto;
  padding: 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--code-bg);
  font: 12.5px/1.65 var(--mono);
  color: var(--code-text);
  white-space: pre;
  tab-size: 2;
}
.code-copy { position: absolute; top: 8px; right: 8px; }
.drawer-foot { padding: 0 20px 16px; font-size: 12.5px; color: var(--muted); }

/* ---------- Modal ---------- */
.modal {
  width: min(760px, calc(100vw - 32px));
  max-height: min(84vh, 900px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 22px;
  background: var(--bg-2);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(80,50,20,.16);
}
.modal[open] { display: flex; flex-direction: column; animation: pop .25s var(--ease); }
.modal::backdrop { background: rgba(43,33,24,.3); backdrop-filter: blur(4px); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 22px 6px 24px; }
.modal-head > div { flex: 1; min-width: 0; }
.modal-head h2 { margin: 0; font: 600 24px/1.15 var(--display); letter-spacing: -.02em; }
.modal-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.modal-body { padding: 14px 24px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.modal h3 { margin: 0 0 8px; font: 700 15px/1.3 var(--display); }
.modal p { margin: 0; color: var(--text-2); }
.modal .tiles { padding: 0; margin: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); }

.types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.type-card { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.type-card .say { font-size: 14px; color: var(--text); }
.type-card .gets { font-size: 13px; color: var(--muted); }
.type-card code { font: 12px/1.5 var(--mono); color: var(--rust); background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: block; white-space: pre-wrap; }
.tips-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.tips-list li { display: grid; grid-template-columns: 26px 1fr; gap: 8px; color: var(--text-2); font-size: 14px; }
.tips-list li b { color: var(--text); font-weight: 600; }
.tips-list li::before { content: counter(tip); counter-increment: tip; width: 22px; height: 22px; border-radius: 7px; background: var(--surface-3); display: grid; place-items: center; font: 700 11px/1 var(--display); color: var(--text-2); }
.tips-list { counter-reset: tip; }
.formats { display: grid; gap: 8px; }
.formats div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; font-size: 13.5px; align-items: baseline; }
.formats span { color: var(--muted); }
.formats code { justify-self: start; }
.formats code, .inline-code { font: 12.5px/1.5 var(--mono); color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
.shortcuts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; font-size: 13.5px; color: var(--text-2); }
.shortcuts div { display: flex; justify-content: space-between; gap: 10px; align-items: center; }

.panel { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.panel .code { flex: none; max-height: 220px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.status-line .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.status-line.ok .pulse { background: var(--ok); }
.key-row { display: flex; gap: 8px; }
.key-row .input { flex: 1; font-family: var(--mono); font-size: 13px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toggle input { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.toggle input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform .2s var(--ease), background .2s; }
.toggle input:checked { background: var(--orange); border-color: var(--orange); }
.toggle input:checked::after { transform: translateX(16px); background: var(--text-hover); }
.toggle b { display: block; font-weight: 600; font-size: 14px; }
.toggle small { color: var(--muted); font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.danger-text { color: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--on-accent);
  font-size: 14px; font-weight: 500;
  box-shadow: 0 12px 30px rgba(80,50,20,.14);
  z-index: 100;
  animation: rise .25s var(--ease);
}

/* ---------- Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes grow { from { width: 0; } }
@keyframes slide-marker { from { left: 0; } }
@keyframes ring-in { from { stroke-dashoffset: 119.38; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .drawer { position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: -20px 0 60px rgba(80,50,20,.14); max-width: 100vw; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(300px, 86vw);
    transform: translateX(-100%); transition: transform .3s var(--ease);
  }
  .app.nav-open .sidebar { transform: none; box-shadow: 20px 0 60px rgba(80,50,20,.14); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(43,33,24,.3); opacity: 0; pointer-events: none; transition: opacity .3s; }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .only-mobile { display: grid; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-inner { grid-template-columns: minmax(0, 1fr); }
  .hero-logo { order: -1; }
  .hero-logo .logo { width: 96px; }
  .types { grid-template-columns: minmax(0, 1fr); }
  .modal .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .thread-inner, .hero-inner, .tiles, .composer-wrap { padding-left: 16px; padding-right: 16px; }
  .hint { display: none; }
  .composer-bar .chip-btn span { display: none; }
  .composer-bar .chip-btn { padding: 6px; }
  #attachBtn::after { content: 'Text'; }
  .composer-bar { justify-content: flex-start; }
  .composer-bar .send { margin-left: auto; }
  .bars li { grid-template-columns: minmax(70px, 38%) minmax(0, 1fr) 40px; gap: 8px; }
  .rows { gap: 12px; }
  .row { grid-template-columns: minmax(0, 1fr) 30px; row-gap: 4px; }
  .row .num { display: none; }
  .row .x-btn { grid-column: 2; grid-row: 1; }
  .row .opt-desc { grid-column: 1 / -1; font-size: 13px; }
  .row-actions { padding-left: 0; }
  .yn { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .formats div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .shortcuts { grid-template-columns: minmax(0, 1fr); }
  .drawer { width: 100vw; }
  .modal-head, .modal-body { padding-left: 18px; padding-right: 18px; }
  .tile { min-height: 150px; }
}

/* ---------- Embedded widget mode ---------- */
body.embed .sidebar, body.embed .scrim { display: none; }
body.embed .app { grid-template-columns: minmax(0, 1fr); }
body.embed .only-embed, body.embed .embed-brand { display: grid; }
body.embed .embed-brand .logo { width: 24px; height: 24px; }
body.embed .only-mobile { display: none; }
body.embed .hero-inner { grid-template-columns: minmax(0, 1fr); padding-top: 16px; }
body.embed .hero-logo, body.embed .steps, body.embed .decor { display: none; }
body.embed .hero h1 { font-size: 30px; }
body.embed .lede { font-size: 14px; }
body.embed .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-left: 16px; padding-right: 16px; }
body.embed .tile { min-height: 130px; }
body.embed .brand-tile { display: none; }
body.embed .thread-inner, body.embed .composer-wrap { padding-left: 14px; padding-right: 14px; }
body.embed .hint { display: none; }
body.embed .fineprint { font-size: 11px; margin-top: 6px; }

/* ---------- Projects ---------- */
.proj-chip {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 8px -4px; padding: 6px 6px 6px 8px;
  border: 1px solid var(--peach); border-radius: var(--r); background: var(--peach-2);
}
.proj-chip svg, .proj-tag svg, .badge svg, .field-note svg, .pv.proj svg, .dropzone > svg, .drop-overlay svg, .proj-summary-panel h3 svg {
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.pc-name { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; text-align: left; font-size: 13px; color: var(--text-2); }
.pc-name svg { width: 16px; height: 16px; color: var(--orange); flex: none; }
.pc-name b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-name span { color: var(--muted); white-space: nowrap; }
.seg.small { padding: 2px; }
.seg.small button { padding: 4px 9px; font-size: 12px; }
.proj-chip .seg { background: var(--surface); }
.proj-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--rust); padding: 3px 9px; border-radius: 999px; background: var(--peach-2); border: 1px solid var(--peach); }
.proj-tag svg, .badge svg { width: 13px; height: 13px; }
.pv.proj { color: var(--rust); border-color: var(--peach); background: var(--peach-2); }
.pv.proj svg { width: 13px; height: 13px; }
.field-note { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--text-2); }
.field-note svg { width: 16px; height: 16px; color: var(--orange); }

.stop-btn { margin-left: auto; padding: 4px 10px; }
.proj-progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.proj-progress i { display: block; height: 100%; background: var(--grad); border-radius: 999px; transition: width .25s var(--ease); }

.proj-summary { margin: 10px 0 12px; font-size: 14px; color: var(--text-2); }
.proj-summary b { color: var(--orange); font-size: 16px; }
.flist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.frow { padding: 9px 10px; border-radius: var(--r-sm); border: 1px solid transparent; }
.frow.hit { background: var(--surface-2); border-color: var(--line); }
.frow-top { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.fpath { flex: 1; min-width: 0; font: 13px/1.4 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.fdir { color: var(--muted); }
.fpath b { font-weight: 500; }
.flines { font-size: 12px; color: var(--muted); white-space: nowrap; }
.fval { font: 600 13px/1 var(--mono); color: var(--text); min-width: 44px; text-align: right; }
.fval small { color: var(--muted); font-weight: 400; }
.frow:not(.hit) .fval { color: var(--muted); font-weight: 500; }
.fbar { height: 5px; margin-top: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.fbar i { display: block; height: 100%; border-radius: 999px; background: var(--line-2); }
.frow.hit .fbar i, .fbar.score i { background: var(--grad); }
.flist.compact .frow { padding: 5px 8px; }
.fsnip { margin-top: 8px; }
.fsnip summary, .fgroup summary { cursor: pointer; font-size: 12.5px; color: var(--rust); font-weight: 500; }
.fsnip pre { margin-top: 8px; max-height: 260px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 12px; }
.fgroup { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.fgroup[open] summary { margin-bottom: 8px; }
.proj-more { display: inline-block; margin-top: 10px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 30px 20px; border: 2px dashed var(--line-2); border-radius: var(--r-lg); background: var(--surface-2);
  transition: border-color .2s, background .2s;
}
.dropzone > svg { width: 34px; height: 34px; color: var(--orange); }
.dropzone b { font-size: 15.5px; color: var(--text); }
.dropzone small { color: var(--muted); max-width: 52ch; }
.dropzone.over { border-color: var(--orange); background: var(--peach-2); }
.dropzone.busy b { color: var(--rust); }
.proj-summary-panel h3 { display: flex; align-items: center; gap: 8px; }
.proj-summary-panel h3 svg { width: 18px; height: 18px; color: var(--orange); }
.proj-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.proj-stats div { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.proj-stats b { display: block; font: 600 20px/1.1 var(--display); }
.proj-stats span { font-size: 12px; color: var(--muted); }
.proj-skipped { font-size: 12.5px; color: var(--muted) !important; }
.proj-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.proj-suggest .chip-btn { background: var(--surface); }

.drop-overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(244, 238, 230, .88); backdrop-filter: blur(4px); pointer-events: none;
}
.drop-overlay div { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 56px; border: 2px dashed var(--orange); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.drop-overlay svg { width: 40px; height: 40px; color: var(--orange); }
.drop-overlay b { font: 600 20px/1.2 var(--display); }
.drop-overlay span { color: var(--muted); font-size: 14px; }

.tile.project-tile { border-color: var(--peach); background: var(--peach-2); }
.tile.project-tile:hover { border-color: var(--orange-soft); }
.tile.project-tile .tile-kind { color: var(--rust); }
.chip-btn.on { border-color: var(--orange-soft); color: var(--rust); background: var(--peach-2); }

@media (max-width: 560px) {
  .proj-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pc-name span { display: none; }
  .proj-chip .seg { order: 3; flex-basis: 100%; display: flex; }
  .proj-chip .seg button { flex: 1; }
  .flines { display: none; }
  #projBtn span { display: none; }
  #projBtn::after { content: 'Project'; }
}

/* Profile pictures (signed in with Google), with initials underneath as a fallback */
.av { position: relative; overflow: hidden; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--amber)); color: #fff; font-weight: 600; letter-spacing: .02em; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface-2); }
.acc-avatar { width: 30px; height: 30px; font-size: 12px; }
.acc-avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.msg-av { width: 32px; height: 32px; margin-top: 4px; font-size: 12px; }
.acc-line { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.acc-line b { display: block; font-weight: 600; }
.acc-line small { display: block; color: var(--muted); font-size: 13px; }

/* Follow-up questions about the same text */
.followups { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.followups > span { width: 100%; font-size: 12px; font-weight: 600; color: var(--muted); }
.fu { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 13px; text-align: left; transition: border-color .15s, background .15s, color .15s; }
.fu:hover { border-color: var(--orange); color: var(--text); background: rgba(232, 105, 43, .06); }
.fu:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.ctx.carried summary { color: var(--rust); }
.pv.carried { border-color: rgba(232, 105, 43, .35); color: var(--rust); }

/* Jump to the latest message */
.to-latest { position: absolute; left: 50%; top: -52px; transform: translateX(-50%); z-index: 5;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.to-latest svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.to-latest:hover { border-color: var(--line-2); }
.to-latest[hidden] { display: none; }

/* Account (signed in with Google) */
.account {
  margin-top: 8px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--r);
  text-align: left;
  min-width: 0;
}
.account:hover { background: var(--surface); }
.acc-text { min-width: 0; font-size: 13px; }
.acc-text b, .acc-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-text b { font-weight: 600; }
.acc-text small { color: var(--muted); font-size: 12px; }

.saved-key {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font-size: 13px;
}
.saved-key .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.saved-key code { margin-left: auto; font-family: var(--mono, ui-monospace, monospace); color: var(--text-2); }

/* Sign-in screen */
body.gated .app { filter: blur(6px); pointer-events: none; user-select: none; }
.gate {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(244, 238, 230, .72);
  backdrop-filter: blur(2px);
}
.gate-card {
  width: min(420px, 100%);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px;
  padding: 36px 28px 26px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(80, 50, 20, .14);
}
.gate-mark { width: 56px; height: 56px; display: block; }
.gate-card h1 { margin: 0; font-family: 'Inter Tight', Inter, sans-serif; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.gate-card p { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.55; }
.gate-error { color: #a33a1d !important; background: rgba(232, 105, 43, .08); border: 1px solid rgba(232, 105, 43, .3); border-radius: 10px; padding: 8px 12px; width: 100%; }
/* Google's sign-in button guidelines: white, gray border, Roboto-like font, the "G" logo. */
.gsi {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; height: 44px; padding: 0 16px;
  border: 1px solid #747775; border-radius: 999px;
  background: #fff; color: #1f1f1f;
  font: 500 15px/1 Roboto, Inter, system-ui, sans-serif;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
}
.gsi:hover { background: #f8f9fa; box-shadow: 0 1px 3px rgba(60, 64, 67, .2); text-decoration: none; }
.gsi:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.gsi[hidden] { display: none !important; }
.gsi svg { width: 20px; height: 20px; flex: none; }
.gsi svg * { stroke: none; }
.gate-fine { font-size: 12px !important; color: var(--muted) !important; }
.gate-back { font-size: 13px; color: var(--muted); }

@media (max-width: 480px) {
  .key-row { flex-wrap: wrap; }
  .key-row .input { flex-basis: 100%; }
}

/* Account menu (opens from the profile picture in the sidebar) */
.side-foot { position: relative; }
.account { width: 100%; }
.acc-chev { margin-left: auto; width: 16px; height: 16px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.account[aria-expanded="true"] { background: var(--surface); }
.acc-menu {
  position: absolute; left: 0; right: 0; z-index: 20;
  padding: 6px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: 0 18px 40px rgba(80, 50, 20, .14);
  animation: rise .16s var(--ease) both;
}
.acc-menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); min-width: 0; }
.acc-menu-head > div { min-width: 0; }
.acc-menu-head b, .acc-menu-head small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-menu-head b { font-weight: 600; font-size: 14px; }
.acc-menu-head small { color: var(--muted); font-size: 12px; }
.acc-menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: var(--r-sm); font-size: 14px; color: var(--text-2); text-align: left; }
.acc-menu-item svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.acc-menu-item:hover, .acc-menu-item:focus-visible { background: var(--surface-2); color: var(--text); outline: none; }

/* "Opening Google…" */
.gsi.loading { pointer-events: none; color: #5f6368; }
.gsi.loading svg { animation: spin 1s linear infinite; }

.toast { pointer-events: auto; }
.toast-act { margin-left: 12px; padding: 2px 4px; color: var(--peach); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.toast-act:hover { color: #fff; }
