/* Mates — redesign concept. Shared tokens + components. */
:root {
  /* type scale */
  --fs-13: 13px; --fs-15: 15px; --fs-17: 17px; --fs-22: 22px; --fs-28: 28px;
  --lh-tight: 1.25; --lh: 1.45;
  /* spacing (4/8pt) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;
  /* radii */
  --r-sm: 8px; --r: 10px; --r-md: 12px; --r-lg: 14px; --r-sheet: 18px;
  /* color */
  --bg: #ffffff;
  --side: #f5f5f7;
  --fill: #f2f2f4;
  --fill-2: #e8e8ed;
  --sel: #e4e4e9;
  --line: #e3e3e8;
  --line-strong: #d2d2d7;
  --text: #111113;
  --text-2: #6b6b72;
  --text-3: #9a9aa1;
  --accent: #0a66ff;
  --accent-hover: #0057e0;
  --accent-soft: #eaf1ff;
  --green: #28b04f;
  --orange: #f29a0c;
  --red: #e5383b;
  --shadow-pop: 0 0 0 1px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.12);
  --shadow-sheet: 0 0 0 1px rgba(0,0,0,.05), 0 20px 50px rgba(0,0,0,.18);
  --ctl-h: 32px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: var(--fs-15); line-height: var(--lh);
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 14px; height: 14px; }
svg.i.lg { width: 22px; height: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font-family: var(--font); font-size: 11px; color: var(--text-3); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; line-height: 16px; background: var(--bg); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--ctl-h); padding: 0 var(--s-4); border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--bg);
  font-size: var(--fs-13); font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--fill); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.dark { background: var(--text); border-color: var(--text); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--fill); }
.btn.danger { color: var(--red); }
.btn.lg { height: 44px; font-size: var(--fs-15); border-radius: var(--r); padding: 0 var(--s-5); }
.btn.block { width: 100%; }
.btn kbd { border-color: rgba(255,255,255,.35); color: rgba(255,255,255,.85); background: transparent; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--fill-2); color: var(--text); }
.icon-btn.on { color: var(--text); }

/* ---------- logo / avatars ---------- */
.logo { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 650; font-size: var(--fs-15); color: var(--text); }
.logo svg { width: 22px; height: 22px; }
.av {
  --sz: 32px; width: var(--sz); height: var(--sz); flex: none;
  display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--fill-2); color: var(--text-2);
  font-size: calc(var(--sz) * .38); font-weight: 600; letter-spacing: .01em; user-select: none;
}
.av.mate { border-radius: 30%; background: var(--text); color: #fff; }
.av.mate svg { width: 56%; height: 56%; }
.av.chan { border-radius: 30%; background: var(--fill-2); color: var(--text-2); }
.av.chan svg { width: 52%; height: 52%; }
.av.s20 { --sz: 20px; } .av.s24 { --sz: 24px; } .av.s28 { --sz: 28px; } .av.s36 { --sz: 36px; } .av.s40 { --sz: 40px; } .av.s56 { --sz: 56px; } .av.s64 { --sz: 64px; }

/* ---------- desktop app shell ---------- */
.app { display: grid; grid-template-columns: 280px 1fr; height: 100vh; min-height: 560px; overflow: hidden; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; position: relative; }
.side-top { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s-2) 0 var(--s-4); flex: none; }
.ws-btn { display: inline-flex; align-items: center; gap: var(--s-2); border: 0; background: transparent; padding: 4px 6px; margin-left: -6px; border-radius: var(--r-sm); font-weight: 600; font-size: var(--fs-15); }
.ws-btn:hover { background: var(--fill-2); }
.ws-btn .faint svg { width: 12px; height: 12px; }
.plus-btn { width: 32px; height: 32px; border-radius: var(--r-sm); color: var(--text); }
.plus-btn[aria-expanded="true"] { background: var(--sel); }
.search {
  display: flex; align-items: center; gap: var(--s-2); height: var(--ctl-h);
  margin: 0 var(--s-3) var(--s-2); padding: 0 var(--s-3); border-radius: var(--r-sm);
  background: var(--fill-2); color: var(--text-3); border: 1px solid transparent;
}
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: var(--fs-13); color: var(--text); }
.search input::placeholder { color: var(--text-3); }
.search:focus-within { background: var(--bg); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.search svg { width: 15px; height: 15px; }
.convs { list-style: none; margin: 0; padding: var(--s-1) var(--s-2) var(--s-3); overflow-y: auto; flex: 1; }
.convs .gap { height: var(--s-2); }
.conv {
  display: grid; grid-template-columns: 32px 1fr; gap: var(--s-3); align-items: center;
  padding: 7px var(--s-2); border-radius: var(--r); color: inherit; text-decoration: none; position: relative;
}
.conv:hover { background: rgba(0,0,0,.035); text-decoration: none; }
.conv[aria-current="page"] { background: var(--sel); }
.conv .l1 { display: flex; align-items: baseline; gap: var(--s-2); min-width: 0; }
.conv .name { font-size: var(--fs-13); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .time { font-size: 12px; color: var(--text-3); flex: none; }
.conv .prev { font-size: var(--fs-13); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 18px; }
.conv .prev.working { color: var(--accent); }
.conv.unread .name::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: 1px; }
.side-foot { flex: none; height: 52px; display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-2) 0 var(--s-4); border-top: 1px solid var(--line); }
.side-foot .me { flex: 1; font-size: var(--fs-13); font-weight: 500; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; background: var(--bg); position: relative; }
.head {
  height: 52px; flex: none; display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-3) 0 var(--s-5); border-bottom: 1px solid var(--line); background: var(--bg);
}
.head-title { display: inline-flex; align-items: center; gap: var(--s-2); border: 0; background: transparent; padding: 4px 8px; margin-left: -8px; border-radius: var(--r-sm); min-width: 0; }
button.head-title:hover { background: var(--fill); }
.head-title .t { font-weight: 600; font-size: var(--fs-15); white-space: nowrap; }
.head-title .sub { font-size: var(--fs-13); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-title .sub.working { color: var(--accent); }
.head .spacer { flex: 1; }
.head .hash { color: var(--text-3); font-weight: 500; }

/* ---------- messages ---------- */
.scroll { flex: 1; overflow-y: auto; }
.thread { max-width: 760px; margin: 0 auto; padding: var(--s-6) var(--s-6) var(--s-4); }
.day { display: flex; align-items: center; justify-content: center; margin: var(--s-2) 0 var(--s-5); font-size: 12px; color: var(--text-3); font-weight: 500; }
.msg { display: grid; grid-template-columns: 32px 1fr; gap: var(--s-3); margin-bottom: var(--s-5); }
.msg .who { display: flex; align-items: baseline; gap: var(--s-2); margin-bottom: 2px; }
.msg .who b { font-size: var(--fs-15); font-weight: 600; }
.msg .who .tag { font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--fill); border-radius: 4px; padding: 0 5px; line-height: 16px; }
.msg .who time { font-size: 12px; color: var(--text-3); }
.msg p { margin: 0 0 var(--s-2); }
.msg p:last-child { margin-bottom: 0; }
.msg .body > * + .run, .msg .body > * + .approval { margin-top: var(--s-3); }
.msg.cont { margin-top: calc(var(--s-5) * -1 + var(--s-1)); }
.mention { color: var(--accent); font-weight: 500; }
.chip-file { display: inline-flex; align-items: center; gap: var(--s-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 10px; font-size: var(--fs-13); margin-top: var(--s-2); }
/* own message as a bubble (DM) */
.mine { display: flex; justify-content: flex-end; margin-bottom: var(--s-5); }
.mine .bubble { background: var(--fill); border-radius: 18px; padding: 9px 14px; max-width: 72%; }
.mine time { display: block; text-align: right; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.system-note { text-align: center; font-size: var(--fs-13); color: var(--text-3); margin: 0 0 var(--s-5); }

/* typing indicator */
.typing { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-13); color: var(--text-2); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .35; } 40% { opacity: 1; } }

/* run card (compact, one line) */
.run { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); max-width: 520px; }
.run-line { display: flex; align-items: center; gap: var(--s-2); width: 100%; height: 36px; padding: 0 var(--s-2) 0 var(--s-3); border: 0; background: transparent; text-align: left; border-radius: var(--r); font-size: var(--fs-13); }
.run-line:hover { background: var(--fill); }
.run-line .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-line .el { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 12px; }
.run-line .chev { color: var(--text-3); transition: transform .15s; }
.run[data-open="true"] .chev { transform: rotate(90deg); }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; position: relative; }
.sdot.live::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid var(--accent); opacity: .25; animation: pulse 1.6s infinite; }
.sdot.done { background: var(--green); } .sdot.wait { background: var(--orange); } .sdot.fail { background: var(--red); }
@keyframes pulse { 0% { transform: scale(.7); opacity: .4; } 100% { transform: scale(1.6); opacity: 0; } }
.run-steps { list-style: none; margin: 0; padding: var(--s-1) var(--s-3) var(--s-3) 33px; border-top: 1px solid var(--line); font-size: var(--fs-13); color: var(--text-2); display: none; }
.run[data-open="true"] .run-steps { display: block; }
.run-steps li { display: flex; align-items: center; gap: var(--s-2); padding: 3px 0; }
.run-steps li svg { width: 13px; height: 13px; margin-left: -21px; }
.run-steps li.ok svg { color: var(--green); }
.run-steps li.now { color: var(--text); }

/* approval card */
.approval { border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); max-width: 520px; background: var(--bg); }
.approval .lbl { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--orange); margin-bottom: var(--s-1); }
.approval .what { font-size: var(--fs-15); margin: 0 0 var(--s-3); }
.approval .acts { display: flex; align-items: center; gap: var(--s-2); }
.approval .acts .hint { margin-left: auto; font-size: 12px; color: var(--text-3); }
.approval.done { border-color: var(--line); }
.approval.done .lbl { color: var(--green); }

/* suggestion chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.chip { border: 1px solid var(--line-strong); background: var(--bg); border-radius: 999px; padding: 6px 14px; font-size: var(--fs-13); color: var(--text); }
.chip:hover { background: var(--fill); }

/* ---------- composer ---------- */
.composer-wrap { flex: none; padding: 0 var(--s-6) var(--s-5); }
.composer-wrap .inner { max-width: 760px; margin: 0 auto; }
.composer {
  border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--bg);
  transition: border-color .12s, box-shadow .12s;
}
/* single 2px ring on the OUTER border */
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fmt { display: flex; align-items: center; gap: 2px; padding: 6px var(--s-2) 0; }
.fmt .icon-btn { width: 28px; height: 28px; border-radius: 6px; color: var(--text-3); }
.fmt .icon-btn:hover { color: var(--text); }
.fmt .icon-btn svg { width: 16px; height: 16px; }
.fmt .sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.fmt .b { font-weight: 700; font-size: 14px; } .fmt .it { font-style: italic; font-family: Georgia, serif; font-size: 15px; }
.comp-row { display: flex; align-items: flex-end; gap: var(--s-2); padding: 2px var(--s-2) var(--s-2); }
.comp-row textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent;
  font-size: var(--fs-15); line-height: 22px; padding: 5px var(--s-1); min-height: 32px; max-height: 200px; height: 32px;
}
.comp-row textarea::placeholder { color: var(--text-3); }
.send {
  width: 32px; height: 32px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--fill-2); color: var(--text-3); flex: none;
}
.send.ready { background: var(--accent); color: #fff; }
.send svg { width: 16px; height: 16px; stroke-width: 2.2; }
.comp-hint { font-size: 12px; color: var(--text-3); text-align: center; margin-top: var(--s-2); }

/* ---------- popover ---------- */
.popover {
  position: absolute; z-index: 30; width: 248px; padding: 6px; background: var(--bg);
  border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  transform-origin: top right;
}
.popover[hidden] { display: none; }
.menu-item { display: flex; align-items: center; gap: var(--s-3); width: 100%; height: 36px; padding: 0 var(--s-3); border: 0; background: transparent; border-radius: var(--r-sm); font-size: var(--fs-15); text-align: left; color: var(--text); text-decoration: none; }
.menu-item:hover, .menu-item.hl { background: var(--fill); text-decoration: none; }
.menu-item svg { color: var(--text-2); }
.menu-item kbd { margin-left: auto; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- sheet (desktop dialog) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(17,17,19,.22); z-index: 40; display: grid; place-items: start center; padding-top: 12vh; }
.scrim[hidden] { display: none; }
.sheet {
  width: min(520px, calc(100vw - 32px)); background: var(--bg); border-radius: var(--r-sheet);
  box-shadow: var(--shadow-sheet);
  max-height: 80vh; display: flex; flex-direction: column;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-4) 0 var(--s-6); }
.sheet-head h2 { margin: 0; font-size: var(--fs-17); font-weight: 600; }
.sheet-body { padding: var(--s-4) var(--s-6) var(--s-2); overflow-y: auto; }
.sheet-foot { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6) var(--s-5); }
.sheet-foot .note { margin-right: auto; font-size: 12px; color: var(--text-3); }
@keyframes up { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- fields ---------- */
.field { margin-bottom: var(--s-4); }
.field > label, .label { display: block; font-size: var(--fs-13); font-weight: 600; margin-bottom: 6px; }
.field .opt { font-weight: 400; color: var(--text-3); }
.input {
  display: flex; align-items: center; gap: var(--s-2); min-height: 40px; padding: 0 var(--s-3);
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--bg);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.input input, .input textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: var(--fs-15); padding: 9px 0; }
.input textarea { resize: none; line-height: 22px; }
.input input::placeholder, .input textarea::placeholder { color: var(--text-3); }
.input .pre { color: var(--text-3); }
.input.big { align-items: flex-start; }
.input.big textarea { min-height: 96px; font-size: var(--fs-17); line-height: 24px; padding: 12px 0; }
.input.lg { min-height: 48px; border-radius: var(--r-md); }
.input.lg input { font-size: var(--fs-17); }
.help { font-size: var(--fs-13); color: var(--text-2); margin: 6px 0 0; }
.tok { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px 0 3px; border-radius: 999px; background: var(--fill); font-size: var(--fs-13); }
.tok .av { --sz: 20px; }
.tok.me { background: var(--accent-soft); color: var(--accent); }

/* switch */
.switch { position: relative; width: 38px; height: 22px; flex: none; display: inline-block; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--fill-2); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* select (32px, chevron centered) */
.select { position: relative; display: inline-flex; align-items: center; height: var(--ctl-h); }
.select select {
  appearance: none; -webkit-appearance: none; height: var(--ctl-h); line-height: 30px;
  padding: 0 30px 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--bg); font-size: var(--fs-13); min-width: 140px;
}
.select select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.select svg { position: absolute; right: 10px; top: 50%; width: 12px; height: 12px; margin-top: -6px; pointer-events: none; color: var(--text-2); }

/* ---------- grouped inset lists (settings / profile) ---------- */
.group-title { font-size: var(--fs-13); font-weight: 600; color: var(--text-2); margin: var(--s-6) 0 var(--s-2) var(--s-1); }
.group-title:first-child { margin-top: 0; }
.group { background: var(--side); border-radius: var(--r); }
.row { display: flex; align-items: center; gap: var(--s-3); min-height: 48px; padding: var(--s-2) var(--s-4); position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: var(--s-4); right: var(--s-4); height: 1px; background: var(--line); }
.row .k { flex: 1; min-width: 0; font-size: var(--fs-13); }
.row .k small { display: block; color: var(--text-2); font-size: 12px; line-height: 16px; }
.row .v { display: flex; align-items: center; gap: var(--s-2); color: var(--text-2); font-size: var(--fs-13); }
.row .inline { border: 1px solid transparent; background: transparent; border-radius: 6px; height: var(--ctl-h); padding: 0 8px; text-align: right; font-size: var(--fs-13); width: 240px; outline: 0; color: var(--text); }
.row .inline:hover { border-color: var(--line-strong); background: var(--bg); }
.row .inline:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--bg); text-align: left; }
.row.link { cursor: pointer; }
.row.link:hover { background: rgba(0,0,0,.025); }
.row.primary-row .k { color: var(--accent); font-weight: 600; font-size: var(--fs-15); display: flex; align-items: center; gap: var(--s-2); }
.row .who { display: flex; align-items: center; gap: var(--s-3); flex: 1; min-width: 0; }
.row .who b { font-size: var(--fs-13); font-weight: 600; display: block; }
.row .who small { display: block; font-size: 12px; color: var(--text-2); }
.row.stack { display: block; padding: var(--s-3) var(--s-4); }
.row.stack .k { display: block; margin-bottom: 6px; }
.row textarea.inline-area { width: 100%; border: 1px solid transparent; border-radius: 6px; background: transparent; resize: none; font-size: var(--fs-13); line-height: 20px; padding: 6px 8px; margin-left: -8px; outline: 0; color: var(--text); }
.row textarea.inline-area:hover { border-color: var(--line-strong); background: var(--bg); }
.row textarea.inline-area:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--bg); }
details.adv > summary { list-style: none; cursor: pointer; }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary .chev { transition: transform .15s; color: var(--text-3); }
details.adv[open] > summary .chev { transform: rotate(90deg); }

/* ---------- settings window ---------- */
.settings { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.settings .side { padding-top: 0; }
.set-nav { list-style: none; margin: 0; padding: var(--s-1) var(--s-2); }
.set-nav a { display: flex; align-items: center; gap: var(--s-3); height: 34px; padding: 0 var(--s-2); border-radius: var(--r-sm); color: var(--text); font-size: var(--fs-13); font-weight: 500; text-decoration: none; }
.set-nav a:hover { background: rgba(0,0,0,.035); }
.set-nav a[aria-current="page"] { background: var(--sel); }
.set-ico { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: var(--bg); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.set-ico svg { width: 14px; height: 14px; }
.set-main { overflow-y: auto; }
.set-main .head { position: sticky; top: 0; z-index: 2; }
.set-body { max-width: 680px; margin: 0 auto; padding: var(--s-6) var(--s-8) var(--s-12); }
.set-toolbar { display: flex; gap: var(--s-2); margin-bottom: var(--s-4); }
.set-toolbar .search { margin: 0; flex: 1; background: var(--side); }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: var(--fs-13); font-weight: 500; text-decoration: none; height: 32px; padding: 0 6px; margin-left: -6px; border-radius: var(--r-sm); }
.back-link:hover { background: var(--fill-2); text-decoration: none; color: var(--text); }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; background: var(--fill-2); font-size: 11px; font-weight: 600; color: var(--text-2); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- auth / onboarding ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s-8) var(--s-5); background: var(--bg); }
.auth-card { width: 100%; max-width: 360px; }
.auth-card .logo { margin-bottom: var(--s-10); }
.auth-card h1 { font-size: var(--fs-28); line-height: var(--lh-tight); letter-spacing: -.01em; margin: 0 0 var(--s-2); font-weight: 700; }
.auth-card .lead { color: var(--text-2); margin: 0 0 var(--s-8); }
.auth-card .btn.lg { width: 100%; }
.or { display: flex; align-items: center; gap: var(--s-3); color: var(--text-3); font-size: var(--fs-13); margin: var(--s-5) 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.stack-2 > * + * { margin-top: var(--s-2); }
.legal { font-size: 12px; color: var(--text-3); margin-top: var(--s-8); text-align: center; }
.step { font-size: var(--fs-13); color: var(--text-3); margin-bottom: var(--s-3); font-weight: 500; }
.enter-hint { display: flex; align-items: center; gap: 6px; font-size: var(--fs-13); color: var(--text-3); margin-top: var(--s-3); }

/* ---------- empty / first chat ---------- */
.hello { max-width: 760px; margin: 0 auto; padding: var(--s-6); }

/* ---------- 1024 degrade ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 248px 1fr; }
  .settings { grid-template-columns: 210px 1fr; }
  .thread, .hello { padding-left: var(--s-5); padding-right: var(--s-5); }
  .composer-wrap { padding-left: var(--s-5); padding-right: var(--s-5); }
  .set-body { padding-left: var(--s-6); padding-right: var(--s-6); }
}

/* ======================================================= */
/* ---------- mobile (iOS-like) ---------- */
.m { --safe-top: max(env(safe-area-inset-top), 12px); --safe-bot: max(env(safe-area-inset-bottom), 20px); height: 100vh; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; position: relative; }
.m .tap { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--accent); padding: 0; border-radius: 12px; }
.m-nav { flex: none; padding: var(--safe-top) var(--s-2) 0; display: flex; align-items: center; justify-content: space-between; height: calc(var(--safe-top) + 44px); background: var(--bg); }
.m-large { font-size: var(--fs-28); font-weight: 700; letter-spacing: -.01em; margin: 0; padding: var(--s-1) var(--s-4) var(--s-2); }
.m .search { margin: 0 var(--s-4) var(--s-2); height: 36px; border-radius: var(--r); font-size: var(--fs-15); }
.m .search input { font-size: var(--fs-17); }
.m-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.m-row { display: grid; grid-template-columns: 44px 1fr; gap: var(--s-3); align-items: center; padding: 0 var(--s-4); min-height: 72px; color: inherit; text-decoration: none; position: relative; }
.m-row:active { background: var(--fill); }
.m-row .txt { align-self: stretch; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid var(--line); min-width: 0; padding: var(--s-2) 0; }
.m-row .l1 { display: flex; align-items: baseline; gap: var(--s-2); }
.m-row .name { flex: 1; font-weight: 600; font-size: var(--fs-17); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.m-row .time { font-size: var(--fs-15); color: var(--text-3); }
.m-row .prev { font-size: var(--fs-15); color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.m-row .prev.working { color: var(--accent); }
.m-row.unread::before { content: ""; position: absolute; left: 5px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--accent); }
.m-chat-nav { flex: none; padding: var(--safe-top) var(--s-1) 0; height: calc(var(--safe-top) + 52px); display: grid; grid-template-columns: 88px 1fr 88px; align-items: center; border-bottom: 1px solid var(--line); background: var(--bg); }
.m-chat-nav .back { display: inline-flex; align-items: center; color: var(--accent); font-size: var(--fs-17); border: 0; background: transparent; min-height: 44px; padding: 0 4px; text-decoration: none; }
.m-chat-nav .back svg { width: 24px; height: 24px; stroke-width: 2.2; }
.m-chat-nav .center { display: flex; flex-direction: column; align-items: center; border: 0; background: transparent; padding: 0; min-height: 44px; justify-content: center; }
.m-chat-nav .center b { font-size: var(--fs-17); font-weight: 600; line-height: 20px; }
.m-chat-nav .center small { font-size: 12px; color: var(--accent); line-height: 16px; }
.m .thread { padding: var(--s-4); }
.m .msg { grid-template-columns: 28px 1fr; gap: var(--s-2); }
.m .msg .who b { font-size: var(--fs-15); }
.m .mine .bubble { max-width: 82%; font-size: var(--fs-17); line-height: 22px; }
.m .msg p { font-size: var(--fs-17); line-height: 23px; }
.m .run, .m .approval { max-width: none; }
.m .run-line { height: 44px; font-size: var(--fs-15); }
.m .approval .btn { height: 44px; flex: 1; font-size: var(--fs-15); }
.m-composer { flex: none; padding: var(--s-2) var(--s-3) var(--safe-bot); border-top: 1px solid var(--line); background: var(--bg); }
.m-composer .composer { border-radius: 20px; }
.m-composer .fmt { padding: 4px var(--s-2) 0; justify-content: space-between; }
.m-composer .fmt .icon-btn { width: 44px; height: 36px; }
.m-composer .comp-row { padding: 0 6px 6px; align-items: center; }
.m-composer .comp-row textarea { font-size: var(--fs-17); }
.m-composer .icon-btn.att { width: 36px; height: 36px; border-radius: 50%; }
.m-composer .send { width: 36px; height: 36px; }
.m-sheet-scrim { position: absolute; inset: 0; background: rgba(17,17,19,.28); z-index: 40; display: flex; align-items: flex-end; }
.m-sheet { width: 100%; background: var(--bg); border-radius: 20px 20px 0 0; padding: 6px var(--s-4) var(--safe-bot); }
@keyframes slide { from { transform: translateY(24px); } to { transform: none; } }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto var(--s-1); }
.m-sheet-head { display: grid; grid-template-columns: 88px 1fr 88px; align-items: center; margin: 0 calc(var(--s-2) * -1) var(--s-3); }
.m-sheet-head h2 { margin: 0; font-size: var(--fs-17); text-align: center; font-weight: 600; }
.m-sheet-head .tap { font-size: var(--fs-17); justify-self: start; padding: 0 8px; }
.m-sheet .input.big textarea { min-height: 120px; }
.m-sheet .btn.lg { height: 50px; border-radius: var(--r-md); font-size: var(--fs-17); font-weight: 600; width: 100%; margin-top: var(--s-4); }
.m .auth { min-height: 0; flex: 1; place-items: start center; padding: calc(var(--safe-top) + var(--s-16)) var(--s-5) var(--safe-bot); }
.m .auth-card .btn.lg { height: 50px; font-size: var(--fs-17); border-radius: var(--r-md); }
.m .auth-card .input.lg { min-height: 50px; }

/* ---------- gallery / principles ---------- */
.doc { max-width: 1040px; margin: 0 auto; padding: var(--s-12) var(--s-8) var(--s-16); }
.doc h1 { font-size: var(--fs-28); letter-spacing: -.01em; margin: var(--s-6) 0 var(--s-2); }
.doc h2 { font-size: var(--fs-22); margin: var(--s-12) 0 var(--s-4); letter-spacing: -.005em; }
.doc h3 { font-size: var(--fs-15); margin: 0 0 var(--s-1); }
.doc .lead { color: var(--text-2); font-size: var(--fs-17); max-width: 640px; margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-3); }
.card { display: block; border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4); color: inherit; text-decoration: none; background: var(--bg); }
.card:hover { border-color: var(--line-strong); background: var(--side); text-decoration: none; }
.card .n { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; font-weight: 600; }
.card p { margin: 2px 0 0; font-size: var(--fs-13); color: var(--text-2); }
.ba { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.ba th { text-align: left; font-weight: 600; color: var(--text-2); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.ba td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ba td:first-child { color: var(--text-2); text-decoration: line-through; text-decoration-color: var(--text-3); width: 48%; }
.rules { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
.rule { background: var(--side); border-radius: var(--r); padding: var(--s-4); font-size: var(--fs-13); }
.rule b { display: block; font-size: var(--fs-15); margin-bottom: 2px; }
.swatch-row { display: flex; align-items: baseline; gap: var(--s-6); padding: var(--s-2) 0; border-bottom: 1px solid var(--line); }
.swatch-row code { font-family: var(--mono); font-size: 12px; color: var(--text-3); width: 120px; flex: none; }
.space-row { display: flex; align-items: center; gap: var(--s-4); padding: 6px 0; }
.space-row code { font-family: var(--mono); font-size: 12px; color: var(--text-3); width: 120px; }
.space-row span { height: 12px; background: var(--accent); border-radius: 2px; }
.color-chip { display: inline-flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); margin-right: var(--s-4); }
.color-chip i { width: 64px; height: 40px; border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-8); }
@media (max-width: 760px) { .two, .rules { grid-template-columns: 1fr; } .doc { padding: var(--s-8) var(--s-5); } }

/* fixes */
.ws-btn > svg { width: 20px; height: 20px; flex: none; }
.conv > span:last-child { display: block; min-width: 0; }
.conv .prev { display: block; }
.av.mate svg { width: 66%; height: 66%; }
.run-line .chev, .run-line .el { display: inline-flex; align-items: center; }
a.head-title, a.head-title:hover { color: inherit; text-decoration: none; }
a.head-title:hover { background: var(--fill); }
.mine > div { max-width: 72%; display: flex; flex-direction: column; align-items: flex-end; }
.mine .bubble, .m .mine .bubble { max-width: none; }
.m .mine > div { max-width: 84%; }
a.btn { color: var(--text); text-decoration: none; }
a.btn.primary, a.btn.dark { color: #fff; }
.row.stack .k { margin-bottom: 0; }
.row textarea.inline-area { display: block; margin: 0 -8px; width: calc(100% + 16px); padding: 4px 8px; }
.set-body .select select { width: 200px; }
.set-body .row .inline { margin-right: -8px; }
.m-composer { border-top: 0; }

/* motion only when opened by interaction — static/first frame is the final state */
.popover.anim { animation: pop .14s ease-out; }
.scrim.anim .sheet { animation: up .2s cubic-bezier(.2,.8,.2,1); }
.m-sheet-scrim.anim .m-sheet { animation: slide .2s cubic-bezier(.2,.8,.2,1); }
.m-sheet-scrim[hidden] { display: none; }
.pill { vertical-align: 1px; margin-left: 4px; }
