/* ==========================================================================
   Sense Assist — conversational console
   ========================================================================== */

:root {
  --bg:            #ffffff;
  --bg-2:          #f7f8fa;
  --surface:       #ffffff;
  --surface-2:     #f4f6f8;
  --surface-3:     #eceff2;
  --border:        #e3e7ea;
  --border-strong: #cbd2d9;

  --ink:   #101a24;
  --ink-2: #44515c;
  --ink-3: #79858f;
  --ink-4: #a3adb6;

  --primary:       #0d6e6a;
  --primary-hover: #0a5a57;
  --primary-ink:   #ffffff;
  --primary-soft:  #e4f1f0;
  --primary-line:  #b6dbd8;

  --accent:      #a8631c;
  --accent-soft: #fdf1e3;
  --warn:        #9a5c0d;
  --warn-soft:   #fdf2e0;
  --fail:        #b0322a;
  --fail-soft:   #fceceb;
  --pass:        #17795e;
  --pass-soft:   #e6f4ef;

  --side-bg:   #101b26;
  --side-bg-2: #17242f;
  --side-ink:  #b8c5d0;
  --side-dim:  #6e7f90;

  --shadow-sm: 0 1px 2px rgba(16,26,36,.06);
  --shadow:    0 2px 8px rgba(16,26,36,.08), 0 12px 32px -14px rgba(16,26,36,.18);
  --shadow-lg: 0 16px 48px -10px rgba(16,26,36,.3);

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-ar: "Noto Naskh Arabic", "Geeza Pro", "Al Bayan", "Segoe UI", Tahoma, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --side-w: 264px;
  --read: 768px;
}

:root[data-theme="dark"] {
  --bg:            #101418;
  --bg-2:          #0c1014;
  --surface:       #171d23;
  --surface-2:     #1d242b;
  --surface-3:     #242d35;
  --border:        #283238;
  --border-strong: #3a464f;

  --ink:   #e5ebf0;
  --ink-2: #aab6c0;
  --ink-3: #7e8b95;
  --ink-4: #5c6871;

  --primary:       #29a49d;
  --primary-hover: #33b7b0;
  --primary-ink:   #04211f;
  --primary-soft:  #11312f;
  --primary-line:  #1f5350;

  --accent:      #d2954f;
  --accent-soft: #2d2317;
  --warn:        #d99b3f;
  --warn-soft:   #2c2313;
  --fail:        #e0685e;
  --fail-soft:   #2e1a19;
  --pass:        #3fb489;
  --pass-soft:   #102b23;

  --side-bg:   #090c10;
  --side-bg-2: #0f161d;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow:    0 2px 8px rgba(0,0,0,.5), 0 12px 32px -14px rgba(0,0,0,.7);
  --shadow-lg: 0 16px 48px -10px rgba(0,0,0,.8);
}

* { box-sizing: border-box; }

/* Several component classes set an explicit display, which outranks the UA rule
   behind the hidden attribute. Without this, hidden elements stay on screen. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.6;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -.012em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sprite symbol { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 13px; height: 13px; }
.spacer { flex: 1; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; }

/* ============================== shell ================================== */

.shell { display: grid; grid-template-columns: var(--side-w) 1fr; height: 100vh; overflow: hidden; }
.shell.is-loading .main { opacity: 0; }
.main { min-width: 0; display: flex; flex-direction: column; overflow: hidden; transition: opacity .2s; }

/* ============================== sidebar ================================ */

.side {
  background: linear-gradient(180deg, var(--side-bg), var(--side-bg-2));
  color: var(--side-ink); display: flex; flex-direction: column; overflow: hidden;
}
.side-top { padding: 14px 12px 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 16px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: linear-gradient(140deg, #14837e, #0b5e5a); color: #fff;
  font-weight: 700; font-size: 12px; letter-spacing: .03em; box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text b { color: #fff; font-size: 14px; font-weight: 600; }
.brand-text em { font-style: normal; font-size: 10.5px; color: var(--side-dim); }

.btn-new {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 9px 12px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: #fff;
  font-size: 13.5px; font-weight: 500; transition: background .12s, border-color .12s;
}
.btn-new:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.24); }

.side-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 1px; }
.side-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); background-clip: content-box; }
.side-group { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-dim); padding: 12px 8px 5px; }
.chat-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 0; background: transparent; color: var(--side-ink); cursor: pointer;
  padding: 8px 9px; border-radius: var(--r-sm); font-size: 13px;
  transition: background .1s, color .1s;
}
.chat-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.chat-item.is-on { background: rgba(255,255,255,.13); color: #fff; font-weight: 500; }
.chat-item .ttl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .ico { color: var(--side-dim); }
.chat-item.is-on .ico { color: var(--primary); }
.chat-item .row-dia {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .04em; flex: none;
  color: var(--side-dim); border: 1px solid rgba(255,255,255,.14);
  border-radius: 4px; padding: 0 4px; line-height: 15px;
}
.chat-item.is-on .row-dia { color: #fff; border-color: rgba(255,255,255,.3); }
.chat-item:hover .row-dia { display: none; }
.chat-item .kill { opacity: 0; border: 0; background: none; padding: 2px; cursor: pointer; color: var(--side-dim); display: flex; border-radius: 4px; }
.chat-item:hover .kill { opacity: 1; }
.chat-item .kill:hover { color: #fff; background: rgba(255,255,255,.12); }
.side-empty { color: var(--side-dim); font-size: 12px; padding: 14px 10px; line-height: 1.55; }

.side-foot { padding: 10px 12px 12px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 8px; }
.side-field { display: flex; flex-direction: column; gap: 4px; }
.side-field label { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--side-dim); }
.side-select {
  width: 100%; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); color: #fff;
  font-size: 12.5px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e7f90' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 13px; padding-right: 26px;
}
.side-select:focus { outline: 0; border-color: var(--primary); }
.side-select:disabled { opacity: .75; cursor: not-allowed; background-image: none; padding-right: 8px; }
.side-select option { background: var(--side-bg-2); color: #fff; }
.side-hint { font-size: 10.5px; line-height: 1.45; color: var(--side-dim); }
.side-row { display: flex; gap: 6px; }
.side-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid rgba(255,255,255,.12); background: transparent; color: var(--side-ink); font-size: 12px;
}
.side-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-health { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--side-dim); padding: 2px 2px 0; }
.side-health .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); flex: none; }
.side-health.is-ok .dot { background: #35c08e; box-shadow: 0 0 0 3px rgba(53,192,142,.18); }
.side-health.is-part .dot { background: #d99b3f; box-shadow: 0 0 0 3px rgba(217,155,63,.18); }
.side-health.is-bad .dot { background: #e0685e; box-shadow: 0 0 0 3px rgba(224,104,94,.18); }

/* ============================== topbar ================================= */

.topbar {
  display: flex; align-items: center; gap: 10px; flex: none;
  height: 52px; padding: 0 16px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 14.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialect-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; padding: 3px 10px; border-radius: 20px;
  background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-line);
  white-space: nowrap;
}
.dialect-pill .pill-k { color: var(--ink-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; }
.dialect-pill b { font-weight: 600; }
.dialect-pill .pill-cur {
  font-family: var(--font-mono); font-size: 10px; padding: 0 5px; border-radius: 4px;
  background: var(--surface); border: 1px solid var(--primary-line);
}
.dialect-pill .ico { width: 12px; height: 12px; opacity: .65; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.only-narrow { display: none; }

/* ============================== thread ================================= */

.thread { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.thread-inner { max-width: var(--read); margin: 0 auto; padding: 26px 22px 12px; display: flex; flex-direction: column; gap: 24px; }

.turn { display: flex; flex-direction: column; gap: 7px; }
.turn-head { display: flex; align-items: center; gap: 8px; }
.who {
  width: 25px; height: 25px; border-radius: 7px; flex: none; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.who-user { background: var(--surface-3); color: var(--ink-2); }
.who-ai { background: linear-gradient(140deg, #14837e, #0b5e5a); color: #fff; }
.who-name { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.turn-head .tiny { font-size: 10.5px; color: var(--ink-4); }

.turn-body { padding-left: 33px; }
.turn-body > * + * { margin-top: 13px; }
.turn-md > * + * { margin-top: 13px; }
.turn-user .turn-body {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 11px 14px; margin-left: 33px;
  white-space: pre-wrap; word-break: break-word;
}
.turn-user .turn-body.is-ar { font-family: var(--font-ar); direction: rtl; text-align: right; font-size: 15.5px; line-height: 1.85; }

/* rendered assistant markdown */
.md { word-break: break-word; }
.md > * + * { margin-top: 11px; }
.md h1, .md h2, .md h3 { font-size: 15px; font-weight: 600; margin-top: 18px; }
.md p { line-height: 1.65; }
.md strong { font-weight: 600; }
.md em { font-style: italic; }
.md ul, .md ol { margin: 0; padding-left: 22px; }
.md li { margin-bottom: 4px; line-height: 1.6; }
.md li::marker { color: var(--ink-4); }
.md code {
  font-family: var(--font-mono); font-size: 12.5px; padding: 1px 5px;
  background: var(--surface-3); border-radius: 4px; color: var(--ink);
}
.md pre {
  margin: 0; padding: 11px 13px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-sm); overflow-x: auto;
}
.md pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.6; }
.md.is-ar { font-family: var(--font-ar); direction: rtl; text-align: right; font-size: 15.5px; line-height: 1.9; }
.md.is-ar ul, .md.is-ar ol { padding-left: 0; padding-right: 22px; }

/* the sendable reply */
.reply-card {
  border: 1px solid var(--primary-line); border-radius: var(--r);
  background: var(--primary-soft); overflow: hidden;
}
.reply-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 11px;
  border-bottom: 1px solid var(--primary-line);
}
.reply-head .lbl {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--primary);
}
.reply-head .dia { font-size: 10.5px; color: var(--ink-3); }
.reply-copy {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--primary-line); background: var(--surface); color: var(--primary);
  border-radius: var(--r-sm); padding: 3px 9px; font-size: 11.5px; font-weight: 500; cursor: pointer;
}
.reply-copy:hover { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.reply-copy.is-done { background: var(--pass-soft); color: var(--pass); border-color: var(--pass); }
.reply-text {
  padding: 13px 15px; font-family: var(--font-ar); direction: rtl; text-align: right;
  font-size: 16px; line-height: 1.95; white-space: pre-wrap; color: var(--ink);
}

.corrected-note {
  display: flex; gap: 8px; align-items: flex-start;
  border: 1px solid var(--warn); border-left-width: 3px; background: var(--warn-soft);
  border-radius: var(--r-sm); padding: 8px 11px; font-size: 12px; line-height: 1.55; color: var(--ink-2);
}
.corrected-note .ico { color: var(--warn); margin-top: 2px; }

.turn-tools { display: flex; gap: 6px; padding-left: 33px; margin-top: -2px; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid transparent;
  background: transparent; color: var(--ink-4); border-radius: var(--r-sm);
  padding: 3px 7px; font-size: 11.5px; cursor: pointer;
}
.tool-btn:hover { background: var(--surface-3); color: var(--ink-2); }

.cursor {
  display: inline-block; width: 7px; height: 15px; margin-left: 1px;
  background: var(--primary); border-radius: 1px; vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.thinking { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 13px; padding-left: 33px; }
.thinking .dots { display: inline-flex; gap: 3px; }
.thinking .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-4); animation: bounce 1.1s infinite; }
.thinking .dots i:nth-child(2) { animation-delay: .16s; }
.thinking .dots i:nth-child(3) { animation-delay: .32s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ============================== welcome ================================ */

.welcome { max-width: var(--read); margin: 0 auto; padding: 52px 22px; text-align: center; }
.welcome-logo {
  width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 18px; display: grid; place-items: center;
  background: linear-gradient(140deg, #14837e, #0b5e5a); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: var(--shadow);
}
.welcome h2 { font-size: 22px; letter-spacing: -.02em; }
.welcome p { margin-top: 9px; color: var(--ink-2); font-size: 14px; line-height: 1.65; max-width: 56ch; margin-left: auto; margin-right: auto; }
.pick-dialect { margin-top: 22px; }
.pick-dialect .lbl {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); display: block; margin-bottom: 8px;
}
.pick-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pick-opt {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--r);
  padding: 9px 15px; cursor: pointer; text-align: center; transition: all .12s;
  display: flex; flex-direction: column; gap: 1px; min-width: 128px;
}
.pick-opt:hover { border-color: var(--primary); }
.pick-opt.is-on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary); }
.pick-opt b { font-size: 13px; font-weight: 600; }
.pick-opt span { font-size: 10.5px; color: var(--ink-3); }
.pick-note { font-size: 11.5px; color: var(--ink-4); margin-top: 9px; }
.suggests { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 26px; text-align: left; }
.suggest {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r);
  padding: 12px 14px; cursor: pointer; transition: all .12s; display: flex; flex-direction: column; gap: 3px;
}
.suggest:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.suggest b { font-size: 13px; font-weight: 600; }
.suggest span { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.suggest .ar { font-family: var(--font-ar); direction: rtl; text-align: right; font-size: 13.5px; color: var(--ink-2); }

/* ============================== composer =============================== */

.composer-wrap { flex: none; padding: 0 22px 12px; background: linear-gradient(180deg, transparent, var(--bg) 40%); }
.composer {
  max-width: var(--read); margin: 0 auto; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow); overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.composer:focus-within { border-color: var(--primary); box-shadow: var(--shadow), 0 0 0 3px var(--primary-soft); }
.composer-input {
  width: 100%; border: 0; background: transparent; resize: none;
  padding: 13px 16px 4px; font-size: 15px; line-height: 1.6; max-height: 220px; overflow-y: auto;
}
.composer-input:focus { outline: 0; }
.composer-input.is-ar { font-family: var(--font-ar); direction: rtl; text-align: right; font-size: 16px; }
.composer-tools { display: flex; align-items: center; gap: 8px; padding: 6px 10px 9px 12px; flex-wrap: wrap; }
.composer-hint { font-size: 11px; color: var(--ink-4); }
.send-btn {
  width: 33px; height: 33px; flex: none; border-radius: 9px; cursor: pointer;
  border: 0; background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; transition: background .12s, opacity .12s;
}
.send-btn:hover:not(:disabled) { background: var(--primary-hover); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn.is-stop { background: var(--fail); }
.composer-foot { max-width: var(--read); margin: 8px auto 0; text-align: center; font-size: 11px; color: var(--ink-4); }

/* ============================== dictation ============================== */

.dictate { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dic-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-2);
  border-radius: 20px; padding: 5px 11px; font-size: 12px; font-weight: 500;
}
.dic-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.dic-btn:disabled { opacity: .45; cursor: not-allowed; }
.dic-btn .ico { color: var(--primary); }
.dic-btn:disabled .ico { color: var(--ink-4); }
.dic-btn.is-ghost { border-color: transparent; }
.dic-btn.is-ghost:hover { border-color: var(--border-strong); }
.dic-stop {
  border-color: var(--fail); color: var(--fail); background: var(--fail-soft); font-weight: 600;
}
.dic-stop:hover { background: var(--fail); color: #fff; }
.dic-stop:hover .rec-dot { background: #fff; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fail); flex: none; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.75); } }
.dic-meter { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.dic-meter i { display: block; width: 3px; border-radius: 2px; background: var(--border-strong); transition: background .1s; }
.dic-meter i:nth-child(1){height:5px} .dic-meter i:nth-child(2){height:8px} .dic-meter i:nth-child(3){height:12px}
.dic-meter i:nth-child(4){height:9px} .dic-meter i:nth-child(5){height:6px}
.dic-meter i.on { background: var(--primary); }
.dic-timer { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.dic-note { font-size: 11px; color: var(--ink-4); }
.dic-spin {
  width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--primary);
  border-top-color: transparent; animation: spin .6s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================== toasts / modal ========================= */

.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 900; }
.toast {
  min-width: 240px; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 10px 13px; font-size: 12.5px;
  animation: slide-in .2s cubic-bezier(.2,.8,.3,1);
}
.toast.is-err { border-left-color: var(--fail); }
.toast.is-ok { border-left-color: var(--pass); }
.toast b { display: block; }
.toast span { color: var(--ink-3); font-size: 11.5px; }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }

.modal-root { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: rgba(12,18,24,.55); }
.modal-root[hidden] { display: none; }
.modal {
  width: 100%; max-width: 620px; max-height: 86vh; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
}
.modal.is-wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 15px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 8px; justify-content: flex-end; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--surface-3); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--fail); }
.btn-danger:hover { background: var(--fail-soft); border-color: var(--fail); }

/* SOP browser */
.sop-list { display: flex; flex-direction: column; gap: 8px; }
.sop-row { border: 1px solid var(--border); border-radius: var(--r); padding: 11px 13px; }
.sop-row b { font-size: 13.5px; }
.sop-row p { font-size: 12px; color: var(--ink-3); line-height: 1.55; margin-top: 3px; }
.sop-row .meta { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.tag { font-size: 10.5px; padding: 1px 7px; border-radius: 20px; background: var(--surface-3); color: var(--ink-2); border: 1px solid var(--border); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 600; transform: translateX(-100%); transition: transform .2s; }
  .side.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .only-narrow { display: inline-flex; }
  .suggests { grid-template-columns: 1fr; }
}

/* ============================== thinking =============================== */

.think {
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); overflow: hidden;
}
.think-head {
  display: flex; align-items: center; gap: 7px; width: 100%; border: 0;
  background: transparent; color: var(--ink-3); cursor: pointer;
  padding: 7px 11px; font-size: 12px; text-align: left; font-family: inherit;
}
.think-head:hover { color: var(--ink-2); background: var(--surface-3); }
.think-head .ico { transition: transform .15s; }
.think.is-open .think-head .ico-chev { transform: rotate(90deg); }
.think-head .lbl { font-weight: 500; }
.think-head .ms { margin-left: auto; font-size: 10.5px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.think-body {
  display: none; padding: 0 12px 11px; font-size: 12.5px; line-height: 1.65;
  color: var(--ink-3); white-space: pre-wrap; word-break: break-word;
  border-top: 1px dashed var(--border); margin-top: -1px; padding-top: 10px;
  max-height: 340px; overflow-y: auto;
}
.think.is-open .think-body { display: block; }
.think.is-live .think-head { color: var(--primary); }
.think.is-live .think-head .lbl::after {
  content: "…"; display: inline-block; animation: ellip 1.2s steps(4,end) infinite;
  width: 0; overflow: hidden; vertical-align: bottom;
}
@keyframes ellip { to { width: 1.1em; } }
