:root {
  --ink: #11131a; --slate: #5b6273; --faint: #8a90a0; --line: #e6e8ef; --soft: #f5f6fa; --canvas: #fbfbfd;
  --violet: #7767d8; --violet-soft: #efecff; --green: #2fb36b; --red: #d0452f; --amber: #b7791f;
  --bubble: #f1f2f6; --code: #0f1117; --side: #f7f7fa; --shadow: 0 12px 40px rgba(24, 28, 45, .08);
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #ececf1; --slate: #a3a8b8; --faint: #7d8292; --line: #2a2d36; --soft: #1c1e25; --canvas: #121318;
    --violet-soft: #2a2546; --bubble: #23252e; --side: #17181e; --shadow: 0 12px 40px rgba(0,0,0,.35); }
  .btn { background: #1c1e25 !important; color: var(--ink) !important; } .btn.primary { background: #ececf1 !important; color: #111 !important; }
  .send { background: #ececf1 !important; color: #111 !important; }
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { color: var(--ink); background: var(--canvas); font: 14.5px/1.6 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
.muted { color: var(--slate); } .small { font-size: 12px; } .error { color: var(--red); font-weight: 500; }
.btn { min-height: 38px; padding: 0 15px; border: 1px solid var(--line); border-radius: 11px; background: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.btn:hover { border-color: #c5c9d4; }
.btn.primary { background: #111; color: #fff; border-color: #111; }
.btn.danger { color: var(--red); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; width: 34px; height: 34px; border-radius: 9px; cursor: pointer; display: inline-grid; place-items: center; font-size: 16px; color: var(--slate); }
.icon-btn:hover { background: var(--soft); color: var(--ink); }
.link { border: 0; background: none; color: var(--slate); cursor: pointer; padding: 0; font-size: 12.5px; }
.link:hover { color: var(--ink); }
input, textarea, select { font: inherit; color: inherit; }
.field { display: grid; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--slate); }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: var(--canvas); font-size: 14px; font-weight: 400; color: var(--ink); outline: none; }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(119,103,216,.15); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--slate); font-weight: 500; }

/* gates */
.gate { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center; }
.gate h1 { font-size: 28px; letter-spacing: -.6px; }
.gate-logo { width: 72px; height: 72px; object-fit: contain; }
.gate-lock { font-size: 34px; }
.gate-form { display: grid; gap: 10px; width: min(360px, 90vw); text-align: left; }
.gate-form input[type=password] { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; font-size: 15px; background: var(--canvas); outline: none; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--violet); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* layout */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 12px 10px 10px; gap: 8px; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand img { width: 30px; height: 30px; object-fit: contain; }
.new-chat { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); background: var(--canvas); border-radius: 11px; cursor: pointer; font-weight: 600; }
.new-chat:hover { border-color: #c5c9d4; }
.new-chat span { font-size: 16px; color: var(--violet); }
.search { border: 1px solid transparent; background: var(--soft); border-radius: 10px; padding: 8px 11px; outline: none; font-size: 13px; }
.search:focus { border-color: var(--line); background: var(--canvas); }
.side-nav { display: grid; gap: 1px; }
.nav-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px; font-size: 13.5px; color: var(--slate); }
.nav-row:hover, .item:hover { background: var(--soft); color: var(--ink); }
.nav-row.active, .item.active { background: var(--violet-soft); color: var(--ink); font-weight: 600; }
.ico { width: 18px; text-align: center; color: var(--faint); }
.badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 19px; }
.side-scroll { flex: 1; overflow: auto; min-height: 0; display: grid; align-content: start; gap: 12px; padding-top: 4px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 3px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); }
.mini-add { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 15px; width: 22px; height: 22px; border-radius: 6px; }
.mini-add:hover { background: var(--soft); color: var(--ink); }
.item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 9px; cursor: pointer; font-size: 13.5px; color: var(--ink); }
.item .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 11px; color: var(--faint); flex: none; }
.item .av { width: 20px; height: 20px; border-radius: 6px; background: var(--violet-soft); color: var(--violet); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.empty-side { padding: 2px 10px; font-size: 12px; color: var(--faint); }
.side-foot { border-top: 1px solid var(--line); padding: 10px 6px 0; display: grid; gap: 8px; }
.pc { display: flex; gap: 9px; align-items: center; }
.pc b { font-size: 13px; display: block; } .pc small { color: var(--faint); font-size: 11.5px; }
.grow { flex: 1; min-width: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c7cad3; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(47,179,107,.18); }
.dot.busy { background: var(--violet); box-shadow: 0 0 0 3px rgba(119,103,216,.2); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(119,103,216,.05); } }
.foot-links { display: flex; gap: 14px; font-size: 12.5px; color: var(--slate); }
.foot-links a:hover { color: var(--ink); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar { height: 54px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid transparent; }
.topbar .title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 4px; }
.scroller { flex: 1; overflow: auto; min-height: 0; }
.content { max-width: 800px; margin: 0 auto; padding: 18px 20px 30px; display: grid; gap: 18px; }

/* welcome */
.welcome { min-height: 52vh; display: grid; place-content: center; justify-items: center; text-align: center; gap: 12px; }
.welcome img { width: 60px; height: 60px; object-fit: contain; }
.welcome h1 { font-size: 30px; letter-spacing: -.8px; font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--canvas); border-radius: 99px; padding: 8px 13px; font-size: 13px; cursor: pointer; color: var(--slate); }
.chip:hover { color: var(--ink); border-color: #c5c9d4; }

/* messages */
.msg { display: grid; gap: 8px; }
.msg.user { justify-items: end; }
.bubble { max-width: 85%; padding: 10px 15px; border-radius: 18px; background: var(--bubble); white-space: pre-wrap; word-break: break-word; }
.msg.user .bubble { border-bottom-right-radius: 6px; }
.answer { white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.answer code, .bubble code { font: 12.5px ui-monospace, Consolas, monospace; background: var(--soft); padding: 1px 5px; border-radius: 5px; }
pre { margin: 4px 0; padding: 12px 14px; border-radius: 12px; background: var(--code); color: #e7e9ee; font: 12.5px/1.55 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; }
pre.light { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
.diff .add { color: #7ee2a8; } .diff .del { color: #ff9a8a; } .diff .hunk { color: #a9b4ff; }
.tool { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--slate); }
.tool .st { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--soft); }
.tool .st.done { color: #1f8a50; } .tool .st.error, .tool .st.denied { color: var(--red); } .tool .st.pending { color: #5a49c9; background: var(--violet-soft); }
.status-line { font-size: 13px; color: var(--slate); display: flex; gap: 8px; align-items: center; }
.typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); margin-right: 3px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; max-width: 640px; }
.media-grid.one { grid-template-columns: minmax(0, 520px); }
.media { position: relative; border-radius: 14px; overflow: hidden; background: var(--soft); border: 1px solid var(--line); min-height: 140px; display: grid; place-items: center; }
.media img, .media video { width: 100%; height: auto; display: block; }
.media .ph { font-size: 12px; color: var(--faint); padding: 20px; text-align: center; }
.media a.dl { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11.5px; padding: 3px 9px; border-radius: 8px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.thumbs .media { width: 96px; min-height: 72px; }
.progress { height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; width: min(420px, 100%); }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #9fd3ff, var(--violet)); transition: width .4s; }

/* cards */
.card { border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 10px; background: var(--canvas); }
.card.pending { border-color: #d9d3fb; background: linear-gradient(135deg, var(--canvas), var(--violet-soft)); box-shadow: var(--shadow); }
.card-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.card-head b { font-size: 14px; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--slate); }
.tag.pending { background: var(--violet-soft); color: #5a49c9; } .tag.approved, .tag.done { background: #e5f6ec; color: #1f8a50; }
.tag.denied, .tag.failed { background: #fdecea; color: var(--red); } .tag.expired { color: var(--faint); }
.when { margin-left: auto; font-size: 11.5px; color: var(--faint); }
.warn { color: #8a5a12; background: #fff6e8; border: 1px solid #f3dcb5; padding: 8px 11px; border-radius: 10px; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input.pin { width: 130px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; letter-spacing: 3px; background: var(--canvas); outline: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .wide { grid-column: 1 / -1; }
.list { display: grid; gap: 8px; }
.list-row { display: flex; gap: 10px; align-items: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--canvas); }
.list-row .t { font-weight: 600; } .list-row small { display: block; color: var(--faint); font-size: 12px; }
.page-head { display: flex; align-items: center; gap: 10px; }
.page-head h2 { font-size: 20px; letter-spacing: -.3px; flex: 1; }
.empty { padding: 36px 20px; text-align: center; color: var(--slate); border: 1px dashed var(--line); border-radius: 16px; }

/* composer */
.composer-wrap { flex: none; padding: 6px 20px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.composer-wrap > * { max-width: 800px; margin-left: auto; margin-right: auto; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 22px; background: var(--canvas); box-shadow: var(--shadow); }
.composer:focus-within { border-color: #c9c2f5; }
.composer textarea { flex: 1; border: 0; outline: none; resize: none; background: none; padding: 8px 4px; max-height: 220px; font-size: 15px; line-height: 1.5; }
.send { width: 38px; height: 38px; border-radius: 50%; border: 0; background: #111; color: #fff; font-size: 17px; cursor: pointer; flex: none; }
.send:disabled { opacity: .35; cursor: default; }
.send.stop { background: var(--red); font-size: 13px; }
.hint { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 7px; }
.space-chip { display: flex; margin-bottom: 7px; font-size: 12px; color: var(--slate); gap: 6px; align-items: center; }
.space-chip b { color: var(--ink); }
.attach-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 7px; }
.file-chip { display: inline-flex; gap: 6px; align-items: center; padding: 5px 9px; border-radius: 10px; background: var(--soft); font-size: 12.5px; }
.file-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
.file-chip button { border: 0; background: none; cursor: pointer; color: var(--faint); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(10, 12, 20, .38); display: grid; place-items: center; z-index: 30; padding: 16px; }
.modal.top { z-index: 45; }
.dialog { width: min(520px, 100%); max-height: 90vh; overflow: auto; background: var(--canvas); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px 20px; font-size: 16px; }
.dialog-body { padding: 8px 20px 20px; display: grid; gap: 12px; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 11px; font-weight: 500; box-shadow: 0 12px 30px rgba(0,0,0,.25); z-index: 50; max-width: 90vw; }
.toast.bad { background: var(--red); }

.only-mobile { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 86vw; max-width: 320px; z-index: 20; transform: translateX(-102%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 15; }
  .only-mobile { display: inline-grid; }
  .content { padding: 12px 14px 24px; }
  .composer-wrap { padding: 6px 10px 10px; }
  .bubble { max-width: 92%; }
  .grid2 { grid-template-columns: 1fr; }
}

/* Team room */
.badge.live { background: #d63b3b; }
.team-sys { text-align: center; color: var(--slate); font-size: 12.5px; padding: 2px 10px; white-space: pre-wrap; }
.team-agent .team-name { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; }
.team-agent .team-name .av { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #111; color: #fff; font-size: 11px; }
.team-agent.ask .bubble { border: 1px solid #b9d4ff; background: #f2f7ff; }
.msg .when { font-size: 11px; color: var(--faint); }
.team-plan .tp { display: flex; gap: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.team-plan .tp-t { width: 72px; flex: none; font-weight: 700; font-size: 13.5px; }
.team-plan .tp b { font-size: 13.5px; }
.team-plan .tp small { display: block; color: var(--slate); font-size: 12.5px; white-space: pre-wrap; margin-top: 2px; }
.team-settings { border: 1px solid var(--line); border-radius: 13px; padding: 10px 13px; font-size: 13.5px; }
.team-settings summary { cursor: pointer; color: var(--slate); }
.team-settings > * + * { margin-top: 10px; }
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #d63b3b; margin-right: 8px; animation: livepulse 1.4s infinite; }
@keyframes livepulse { 50% { opacity: .35; } }

.report-msg { display: grid; gap: 6px; }
.report-msg .team-name { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; }
.report-msg .team-name .av { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #111; color: #fff; font-size: 11px; }
.report-msg .bubble { max-width: 100%; }
.team-agent .team-name .tag { margin-left: 4px; font-weight: 600; }
.team-agent.report .bubble { border-left: 3px solid #2e9e6a; }

/* Suggested next steps */
.sugg-box { border: 1px solid var(--line); border-radius: 13px; padding: 10px 12px; margin-top: 10px; background: rgba(255,255,255,.7); }
.sugg-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.sugg { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.sugg-title + .sugg { border-top: 0; }
.sugg-text { flex: 1; min-width: 0; font-size: 13.5px; }
.sugg-text summary { cursor: pointer; color: var(--slate); margin-top: 3px; }
.sugg-text .pre { white-space: pre-wrap; margin-top: 4px; }
.sugg-btns { display: flex; gap: 6px; flex: none; align-items: center; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.sugg.dismissed .sugg-text { opacity: .55; }

/* Work board */
.board-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.board-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 13px; font: inherit; font-size: 13px; cursor: pointer; }
.board-tabs button small { color: var(--slate); margin-left: 4px; }
.board-tabs button.active { background: #111; color: #fff; border-color: #111; }
.board-tabs button.active small { color: #ccc; }
.board-you { border: 1px solid #f0c36d; background: #fff9ec; border-radius: 13px; padding: 10px 13px; font-size: 13.5px; }
.board-team h3 { font-size: 15.5px; margin: 8px 0 8px; }
.board-team h3 small { font-weight: 500; color: var(--slate); font-size: 12.5px; margin-left: 6px; }
.board-agent { border: 1px solid var(--line); border-radius: 13px; padding: 10px 13px; margin-bottom: 8px; background: rgba(255,255,255,.7); }
.ba-name { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.ba-cols { display: grid; grid-template-columns: 1.3fr 1fr 1.2fr; gap: 14px; }
.ba-h { font-size: 11.5px; font-weight: 700; color: var(--slate); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.bi { display: flex; align-items: baseline; gap: 6px; font-size: 13px; padding: 3px 0; }
details.bi { display: block; }
details.bi summary { display: flex; align-items: baseline; gap: 6px; cursor: pointer; list-style: none; }
details.bi summary::-webkit-details-marker { display: none; }
.bi-mark { width: 14px; flex: none; text-align: center; font-weight: 700; }
.bi.done.ok .bi-mark { color: #1f8a57; }
.bi.done.bad .bi-mark { color: #c0392b; }
.bi-time { color: var(--slate); flex: none; font-variant-numeric: tabular-nums; }
.bi-title { flex: 1; min-width: 0; }
.bi-title small { display: block; color: var(--slate); }
.bi-msg { margin: 4px 0 2px 20px; padding: 7px 9px; background: #f2f3f6; border-radius: 9px; white-space: pre-wrap; }
.bi-task { margin: 2px 0 4px 20px; color: var(--slate); white-space: pre-wrap; font-size: 12.5px; }
.bi-tag { font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; color: var(--slate); flex: none; }
.bi-tag.src { border-color: #b9d4ff; color: #2f5fa8; }
.bi.skipped { opacity: .55; }
.bi.none { color: var(--faint); }
.ba-earlier summary { cursor: pointer; color: var(--slate); font-size: 12.5px; margin-top: 4px; }
@media (max-width: 820px) { .ba-cols { grid-template-columns: 1fr; } }
.ba-cols { grid-template-columns: 1fr .65fr 1.45fr; }
.bi-tag { align-self: flex-start; margin-top: 2px; }
