:root {
  color-scheme: dark;
  --bg: #080c0f;
  --surface: #10171c;
  --surface-2: #151e24;
  --surface-3: #1b262d;
  --line: #26343c;
  --line-soft: #1e2b32;
  --text: #f3f6f4;
  --muted: #94a4ad;
  --green: #66e3a4;
  --green-dark: #143b2b;
  --amber: #f3c86a;
  --red: #ff7b7b;
  --blue: #79b8ff;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% -10%, rgba(51, 136, 105, .18), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button { font: inherit; }

button:focus-visible {
  outline: 3px solid rgba(102, 227, 164, .45);
  outline-offset: 2px;
}

.app-shell {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand, .top-actions, .mode-button, .safe-label, .route-flow, .caller-card,
.call-live, .panel-heading, .consent-actions, .result-actions {
  display: flex;
  align-items: center;
}

.brand { gap: 12px; }

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #07100c;
  background: var(--green);
  border-radius: 13px;
  box-shadow: 0 8px 30px rgba(102, 227, 164, .18);
}

.brand-mark svg, .mode-button svg, .icon-button svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.brand strong { display: block; font-size: 1.1rem; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: .78rem; }

.top-actions { gap: 10px; }
.safe-label { gap: 8px; color: var(--muted); font-size: .85rem; }
.safe-label i, .call-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.mode-button, .icon-button, .result-actions button, .consent {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}

.mode-button {
  gap: 9px;
  padding: 10px 14px;
  border-radius: 12px;
  transition: .2s ease;
}

.mode-button[aria-pressed="true"] {
  color: #1a1201;
  background: var(--amber);
  border-color: var(--amber);
}

.route-strip {
  display: grid;
  grid-template-columns: minmax(180px, .7fr) 2fr;
  align-items: center;
  gap: 30px;
  margin: 14px 0 16px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(16, 23, 28, .86);
}

.route-heading span { display: block; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .09em; }
.route-heading strong { display: block; margin-top: 5px; font-size: .94rem; }
.route-flow { justify-content: space-between; gap: 10px; }
.route-flow > i { color: #40515a; font-style: normal; font-size: 1.5rem; }
.route-node { display: flex; align-items: center; gap: 8px; color: #64757e; }
.route-node span { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid #3a4a53; border-radius: 50%; font-size: .75rem; }
.route-node b { font-size: .82rem; font-weight: 650; white-space: nowrap; }
.route-node.active { color: var(--green); }
.route-node.active span { color: #07100c; background: var(--green); border-color: var(--green); }

.driving-banner {
  display: none;
  margin-bottom: 16px;
  padding: 13px 16px;
  color: #e9d5a4;
  border: 1px solid rgba(243, 200, 106, .35);
  border-radius: 14px;
  background: rgba(84, 60, 14, .28);
  font-size: .9rem;
}
.driving-banner strong { color: var(--amber); }
.driving-banner.visible { display: block; }

.workspace {
  display: grid;
  grid-template-columns: minmax(250px, .72fr) minmax(360px, 1.2fr) minmax(320px, 1fr);
  gap: 16px;
  min-height: 680px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(17, 25, 30, .96), rgba(13, 20, 24, .96));
  box-shadow: 0 20px 70px rgba(0, 0, 0, .15);
}

.panel-heading { justify-content: space-between; gap: 14px; padding: 20px 20px 0; }
.eyebrow { display: block; color: var(--green); font-size: .72rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
h1, h2 { margin: 5px 0 0; font-size: 1.15rem; letter-spacing: -.02em; }
.count, .result-state { padding: 6px 9px; border-radius: 999px; color: var(--muted); background: var(--surface-3); font-size: .75rem; }
.panel-note { margin: 10px 20px 16px; color: var(--muted); font-size: .86rem; line-height: 1.45; }

.scenario-list {
  height: 464px;
  overflow: auto;
  padding: 0 10px 14px;
  scrollbar-width: thin;
  scrollbar-color: #33454e transparent;
}

.future-module { margin: 0 10px 14px; padding: 13px; border: 1px dashed #3a4d56; border-radius: 13px; background: rgba(12, 18, 22, .74); }
.future-module-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.future-module-head span { padding: 4px 7px; color: var(--amber); border-radius: 999px; background: rgba(84, 60, 14, .38); font-size: .68rem; font-weight: 750; text-transform: uppercase; }
.future-module-head strong { font-size: .8rem; }
.future-flow { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin-top: 11px; color: var(--muted); }
.future-flow b { font-size: .7rem; font-weight: 650; }
.future-flow i { color: #53656e; font-style: normal; }
.future-module p { margin: 9px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.4; }

.scenario {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 12px 10px;
  color: var(--text);
  text-align: left;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  cursor: pointer;
}

.scenario:hover { background: var(--surface-2); }
.scenario.active { border-color: rgba(102, 227, 164, .28); background: rgba(31, 82, 61, .28); }
.scenario-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); border-radius: 11px; background: var(--surface-3); font-size: .9rem; font-weight: 750; }
.scenario.active .scenario-icon { color: var(--green); background: var(--green-dark); }
.scenario-copy strong { display: block; font-size: .86rem; font-weight: 650; }
.scenario-copy small { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.scenario-badge { width: 8px; height: 8px; border-radius: 50%; background: #40515a; }
.scenario-badge.warn { background: var(--red); }
.scenario-badge.direct { background: var(--blue); }

.conversation-panel { display: flex; flex-direction: column; }
.conversation-heading { padding-bottom: 16px; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; }
.caller-card { gap: 12px; margin: 0 20px; padding: 13px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--surface-2); }
.avatar { width: 42px; height: 42px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #08100d; background: var(--green); font-size: 1rem; font-weight: 800; }
.caller-card strong { display: block; font-size: .92rem; }
.caller-card span:not(.call-live) { display: block; margin-top: 4px; color: var(--muted); font-size: .78rem; }
.call-live { gap: 6px; margin-left: auto; color: var(--muted); font-size: .75rem; }

.transcript {
  flex: 1;
  overflow: auto;
  min-height: 360px;
  padding: 22px 20px 12px;
  scrollbar-width: thin;
  scrollbar-color: #33454e transparent;
}

.message { max-width: 88%; margin-bottom: 16px; }
.message.caller { margin-left: auto; }
.message .speaker { display: block; margin: 0 0 6px 4px; color: var(--muted); font-size: .72rem; }
.message .bubble { padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px 16px 16px 16px; background: var(--surface-2); font-size: .9rem; line-height: 1.55; }
.message.caller .bubble { border-color: rgba(102, 227, 164, .24); border-radius: 16px 6px 16px 16px; background: rgba(31, 82, 61, .3); }
.message.system { max-width: 100%; }
.message.system .bubble { color: var(--amber); text-align: center; border-color: rgba(243, 200, 106, .22); border-radius: 12px; background: rgba(84, 60, 14, .2); font-size: .82rem; }

.consent-box { margin: 8px 20px 20px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #0b1115; }
.consent-box > span { display: block; margin-bottom: 10px; color: var(--muted); font-size: .75rem; }
.consent-actions { flex-wrap: wrap; gap: 8px; }
.consent { min-height: 39px; padding: 9px 12px; border-radius: 10px; font-size: .82rem; }
.consent.yes { color: var(--green); border-color: rgba(102, 227, 164, .28); background: rgba(31, 82, 61, .32); }
.consent.no { color: #ffc0c0; }
.consent.unclear { color: var(--muted); }
.consent-box[hidden] { display: none; }

.result-panel { display: flex; flex-direction: column; }
.result-state.ready { color: var(--green); background: var(--green-dark); }
.result-state.attention { color: #ffd1d1; background: #4a2428; }
.result-state.direct { color: var(--blue); background: #183550; }
.owner-result { flex: 1; padding: 22px 20px; }
.empty-result { height: 100%; min-height: 430px; display: grid; place-content: center; justify-items: center; padding: 30px; color: var(--muted); text-align: center; }
.empty-ring { width: 74px; height: 74px; display: grid; place-items: center; margin-bottom: 18px; border: 1px dashed #3b4d56; border-radius: 50%; color: #5b6d76; font-size: 1.6rem; }
.empty-result strong { color: var(--text); font-size: .95rem; }
.empty-result p { max-width: 260px; margin: 8px 0 0; font-size: .83rem; line-height: 1.5; }

.result-card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); overflow: hidden; }
.result-card.alert { border-color: rgba(255, 123, 123, .38); }
.result-card-head { padding: 16px; border-bottom: 1px solid var(--line); }
.result-card-head .meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; color: var(--muted); font-size: .75rem; }
.attention-label { color: var(--green); }
.attention-label.alert { color: var(--red); }
.result-card h3 { margin: 0; font-size: 1.05rem; line-height: 1.35; }
.result-card-body { padding: 16px; }
.fact { margin-bottom: 15px; }
.fact:last-child { margin-bottom: 0; }
.fact span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.fact p { margin: 0; font-size: .88rem; line-height: 1.5; }
.translation { padding: 12px; border-left: 3px solid var(--blue); border-radius: 0 10px 10px 0; background: rgba(38, 79, 116, .2); }
.history-row { display: grid; grid-template-columns: auto 1fr; gap: 11px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.history-count { min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--amber); background: rgba(84, 60, 14, .34); font-weight: 800; }
.history-row strong { display: block; font-size: .84rem; }
.history-row small { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; }
.privacy-note { margin-top: 14px; padding: 11px 12px; color: var(--muted); border-radius: 10px; background: #0c1216; font-size: .76rem; line-height: 1.45; }
.action-feedback { margin-top: 12px; padding: 12px; color: var(--green); border: 1px solid rgba(102, 227, 164, .25); border-radius: 10px; background: rgba(31, 82, 61, .2); font-size: .8rem; line-height: 1.45; }
.action-feedback[hidden] { display: none; }
.channel-choice { color: var(--text); background: #0c1418; }
.choice-label { display: block; margin-bottom: 10px; color: var(--text); font-size: .85rem; font-weight: 750; }
.outbound-preview { padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.outbound-preview span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.outbound-preview p { margin: 0; color: var(--text); font-size: .8rem; line-height: 1.45; }
.channel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.channel-button { min-width: 0; padding: 10px; color: var(--text); text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.channel-button:hover { border-color: rgba(102, 227, 164, .45); }
.channel-button strong, .channel-button small { display: block; }
.channel-button strong { font-size: .78rem; }
.channel-button small { margin-top: 4px; color: var(--muted); font-size: .67rem; line-height: 1.35; }
.sms-channel strong { color: var(--blue); }
.call-channel strong { color: var(--green); }
.delivery-warning { display: block; margin-top: 9px; color: var(--muted); font-size: .68rem; }
.delivery-complete strong { display: block; color: var(--green); font-size: .82rem; }
.delivery-complete p { margin: 6px 0; color: var(--text); font-size: .78rem; }
.delivery-complete .outbound-preview { margin: 8px 0; }
.delivery-complete small { display: block; color: var(--muted); font-size: .68rem; }

.result-actions { flex-wrap: wrap; gap: 8px; padding: 0 20px 20px; }
.result-actions[hidden] { display: none; }
.result-actions button { flex: 1 1 calc(50% - 8px); min-height: 40px; padding: 9px 10px; border-radius: 10px; font-size: .82rem; }
.result-actions .primary-action { color: #07100c; background: var(--green); border-color: var(--green); font-weight: 750; }
.result-actions .danger-action { color: #ffc4c4; }
.result-actions button:disabled { color: #07100c; background: #9aaba2; border-color: #9aaba2; cursor: default; }

footer { padding: 16px 4px 0; color: #65757d; text-align: center; font-size: .76rem; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(360px, calc(100vw - 40px)); padding: 12px 15px; color: var(--text); border: 1px solid #345045; border-radius: 12px; background: #15251e; box-shadow: 0 14px 45px rgba(0, 0, 0, .35); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; font-size: .85rem; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 260px 1fr; }
  .result-panel { grid-column: 1 / -1; min-height: 440px; }
  .owner-result { min-height: 300px; }
  .empty-result { min-height: 280px; }
}

@media (max-width: 760px) {
  .app-shell { padding: 12px; }
  .topbar { align-items: flex-start; }
  .top-actions { align-items: flex-end; flex-direction: column-reverse; }
  .safe-label { font-size: .72rem; }
  .mode-button span { display: none; }
  .route-strip { grid-template-columns: 1fr; gap: 13px; }
  .route-flow { overflow-x: auto; padding-bottom: 3px; }
  .route-node b { font-size: .74rem; }
  .workspace { grid-template-columns: 1fr; }
  .scenario-panel, .conversation-panel, .result-panel { grid-column: auto; min-height: auto; }
  .scenario-list { height: auto; max-height: 365px; }
  .future-module { margin-top: 12px; }
  .transcript { min-height: 380px; max-height: 520px; }
  .call-live { display: none; }
  .owner-result { min-height: 360px; }
  .channel-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
