:root {
  color-scheme: light;
  --bg: #f4f7f3;
  --rail: #eaf1e9;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --surface-muted: #f0f5ef;
  --text: #1d302a;
  --muted: #667b70;
  --line: #dbe7dc;
  --accent: #26785c;
  --accent-strong: #186347;
  --accent-soft: #e0f0e5;
  --bubble-user: #e0f1e7;
  --shadow: 0 18px 45px rgba(31, 64, 47, .08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #25343b;
  --rail: #263d3c;
  --surface: #30434a;
  --surface-soft: #354a50;
  --surface-muted: #385149;
  --text: #f1f7f2;
  --muted: #b6cbc0;
  --line: #47615b;
  --accent: #9bdbc0;
  --accent-strong: #b9ebd1;
  --accent-soft: #36594f;
  --bubble-user: #3c6657;
  --shadow: 0 18px 45px rgba(10, 25, 22, .18);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", Inter, system-ui, sans-serif; }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }

.rail { display: flex; flex-direction: column; background: var(--rail); border-right: 1px solid var(--line); padding: 31px 22px 23px; }
.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 58px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; background: var(--accent-strong); color: white; font-size: 24px; }
:root[data-theme="dark"] .brand-mark { background: #b5e4cc; color: #193b31; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 20px; letter-spacing: -.7px; line-height: 1.1; }
.brand span { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 1.7px; margin-top: 4px; }
.rail-label, .panel-kicker, .eyebrow { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 1.9px; }
.steps { list-style: none; padding: 0; margin: 16px 0 24px; display: grid; gap: 8px; }
.steps li { display: flex; align-items: center; gap: 12px; min-height: 41px; color: var(--muted); padding: 5px 8px; font-size: 13px; border-radius: 11px; }
.steps li.active { color: var(--accent-strong); background: var(--accent-soft); font-weight: 700; }
:root[data-theme="dark"] .steps li.active { color: var(--accent-strong); }
.steps li.done { color: var(--text); }
.step-number { width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; font-size: 12px; font-weight: 700; }
.steps li.active .step-number { border-color: var(--accent); background: var(--accent); color: white; }
:root[data-theme="dark"] .steps li.active .step-number { color: #17392d; }
.steps li.done .step-number { border-color: var(--accent); color: var(--accent); }
.rail-divider { height: 1px; background: var(--line); margin: 2px 0 26px; }
.signal { display: flex; flex-direction: column; gap: 3px; margin-top: 19px; font-size: 12px; }
.signal span { color: var(--muted); }
.signal strong { font-size: 13px; font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.chips:empty { display: none; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--accent-strong); border-radius: 100px; padding: 2px 8px; font-size: 10px; font-weight: 650; text-transform: capitalize; }
.message.typing .bubble { color: var(--muted); font-style: italic; }
.rail-footer { margin-top: auto; padding-top: 34px; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.live-dot, .online { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #48af79; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 108px; flex: 0 0 108px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 34px; }
.topbar h1 { margin: 4px 0 0; font-size: clamp(25px, 2.5vw, 34px); line-height: 1.15; letter-spacing: -1.3px; font-weight: 680; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.theme-toggle, .new-chat { min-height: 37px; border: 1px solid var(--line); border-radius: 10px; padding: 0 13px; background: var(--surface); color: var(--text); box-shadow: 0 3px 10px rgba(31, 64, 47, .03); font-size: 12px; font-weight: 650; white-space: nowrap; }
.theme-toggle:hover, .new-chat:hover { border-color: var(--accent); }
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; padding: 0 24px 24px; min-height: 0; flex: 1; }
.conversation { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; min-width: 0; min-height: 0; height: calc(100dvh - 132px); display: flex; flex-direction: column; box-shadow: var(--shadow); overflow: hidden; }
.conversation-head { min-height: 81px; padding: 17px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.agent-avatar, .small-avatar { display: grid; place-items: center; flex: 0 0 auto; background: var(--accent-soft); color: var(--accent-strong); font-weight: 800; }
.agent-avatar { width: 39px; height: 39px; border-radius: 13px; font-size: 18px; }
.conversation-head strong, .conversation-head span { display: block; }
.conversation-head strong { font-size: 13px; }
.conversation-head span { color: var(--muted); font-size: 11px; margin-top: 2px; }
.conversation-head .online { margin-right: 5px; }
.phase-pill { margin-left: auto; border: 1px solid var(--line); background: var(--surface-soft); color: var(--muted); border-radius: 100px; padding: 6px 11px; text-align: center; font-size: 10px; font-weight: 750; white-space: nowrap; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 27px 28px; display: flex; flex-direction: column; gap: 22px; }
.message { display: flex; align-items: flex-end; gap: 9px; max-width: 90%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.small-avatar { width: 27px; height: 27px; border-radius: 9px; font-size: 12px; }
.message.user .small-avatar { background: var(--surface-muted); color: var(--muted); }
.message-content { min-width: 0; }
.bubble { padding: 13px 16px; border-radius: 14px 14px 14px 4px; background: var(--surface-soft); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: 13px; }
.message.user .bubble { background: var(--bubble-user); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.message-meta { color: var(--muted); font-size: 10px; margin: 6px 3px 0; }
.message.user .message-meta { text-align: right; }
.composer-wrap { padding: 12px 24px 17px; border-top: 1px solid var(--line); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 11px; }
.quick-actions:empty { display: none; }
.quick-actions button { border: 1px solid var(--line); border-radius: 100px; background: var(--surface); color: var(--accent-strong); padding: 6px 11px; font-size: 11px; font-weight: 650; }
.quick-actions button:hover { background: var(--accent-soft); }
.composer { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); padding: 7px 8px 7px 14px; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { width: 100%; min-height: 30px; max-height: 140px; resize: vertical; border: 0; outline: none; background: transparent; color: var(--text); padding: 4px 0; font-size: 13px; }
.composer textarea::placeholder { color: var(--muted); }
.composer button { border: 0; border-radius: 9px; width: 32px; height: 32px; flex: 0 0 auto; background: var(--accent-strong); color: white; }
.composer button:disabled { opacity: .5; cursor: wait; }
.composer-note { color: var(--muted); text-align: center; font-size: 10px; margin-top: 10px; }

.context-panel { min-width: 0; max-height: calc(100dvh - 132px); overflow-y: auto; padding: 15px 2px 0; }
.context-panel h2 { font-size: 22px; letter-spacing: -.6px; margin: 5px 0 4px; }
.panel-intro { color: var(--muted); font-size: 12px; margin: 0 0 23px; line-height: 1.55; }
.case-card, .rule-card, .try-card { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; }
.case-card { min-height: 174px; padding: 21px; box-shadow: 0 8px 22px rgba(31, 64, 47, .035); }
.case-lock { width: 35px; height: 35px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); font-size: 20px; margin-bottom: 15px; }
.case-card strong { font-size: 13px; }
.case-card p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.case-card h2 { margin: 9px 0 0; color: var(--accent-strong); font-size: 23px; }
.case-data { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 8px; border-top: 1px solid var(--line); margin-top: 17px; padding-top: 14px; }
.case-data small, .case-data b { display: block; }
.case-data small { color: var(--muted); font-size: 10px; }
.case-data b { font-size: 12px; font-weight: 650; text-transform: capitalize; }
.case-data b.status { color: var(--accent-strong); }
.rule-card { display: flex; gap: 13px; padding: 18px; margin-top: 13px; background: var(--surface-soft); }
.rule-icon { color: var(--accent-strong); font-size: 19px; line-height: 1; }
.rule-card strong { font-size: 12px; }
.rule-card p { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 4px 0 0; }
.try-card { padding: 17px 18px 5px; margin-top: 22px; }
.try-card .panel-kicker { margin-bottom: 7px; }
.scenario { width: 100%; display: flex; align-items: center; gap: 10px; padding: 13px 0; text-align: left; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--text); font-size: 12px; font-weight: 650; }
.scenario:hover { color: var(--accent-strong); }
.scenario > span:first-child { color: var(--accent); font-size: 10px; font-weight: 800; }
.scenario > span:nth-child(2) { flex: 1; }
.scenario small { display: block; color: var(--muted); font-size: 10px; font-weight: 400; margin-top: 2px; }
.scenario b { color: var(--muted); font-size: 15px; font-weight: 400; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 205px minmax(0, 1fr); }
  .rail { padding-inline: 16px; }
  .main-grid { grid-template-columns: minmax(0, 1fr) 265px; gap: 14px; padding-inline: 16px; }
}
@media (max-width: 900px) {
  .app-shell { display: block; }
  .rail { display: none; }
  .main-grid { grid-template-columns: minmax(0, 1fr); }
  .context-panel { display: none; }
  .conversation { height: calc(100dvh - 126px); }
  .messages { min-height: 0; }
}
@media (max-width: 560px) {
  .topbar { height: 88px; flex-basis: 88px; padding: 14px 16px; }
  .topbar h1 { font-size: 25px; }
  .eyebrow { font-size: 9px; }
  .header-actions { gap: 5px; }
  .theme-toggle, .new-chat { width: 37px; height: 37px; overflow: hidden; padding: 0; font-size: 17px; }
  .new-chat span, .theme-toggle span { display: none; }
  .main-grid { padding: 0 8px 8px; }
  .conversation { height: calc(100dvh - 96px); border-radius: 14px; }
  .conversation-head { padding: 12px 15px; min-height: 68px; }
  .messages { min-height: 0; padding: 18px 13px; }
  .message { max-width: 98%; }
  .composer-wrap { padding: 10px 12px 12px; }
  .phase-pill { font-size: 9px; }
}
#actionChips .chip { display: inline-block; text-transform: none; color: var(--text); }
#actionChips .chip::first-letter { text-transform: uppercase; }
