:root {
  color-scheme: dark;
  --bg: #0a0f18;
  --surface: #101722;
  --surface-2: #151e2b;
  --surface-3: #1b2737;
  --line: #2a3a4f;
  --text: #edf4fb;
  --muted: #91a2b7;
  --accent: #8fb5ff;
  --accent-strong: #5f8ff5;
  --success: #77dbaf;
  --warning: #f3c478;
  --danger: #ff9d9d;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, ui-sans-serif, system-ui, sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.shell { min-height: 100vh; padding: 24px; }
.login-card { width: min(430px, 100%); margin: 10vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 32px; }
.brand-mark { width: 18px; height: 18px; margin-bottom: 22px; border: 2px solid var(--accent); transform: rotate(45deg); }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .14em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 24px; font-size: 26px; letter-spacing: -.01em; }
h2 { margin-bottom: 4px; font-size: 20px; }
.muted { color: var(--muted); }
label { display: block; margin: 16px 0; color: var(--muted); font-size: 12px; }
input { width: 100%; min-height: 44px; margin-top: 7px; border: 1px solid var(--line); border-radius: 8px; background: #0b121c; color: var(--text); padding: 10px 12px; }
.primary, .ghost { min-height: 44px; border-radius: 8px; padding: 9px 14px; font-weight: 700; }
.primary { border: 1px solid var(--accent-strong); background: var(--accent-strong); color: #08101d; }
.primary:hover { background: var(--accent); }
.ghost { border: 1px solid var(--line); background: transparent; color: var(--text); }
.ghost:hover { border-color: var(--accent); background: var(--surface-2); }
.ghost.danger-enabled { border-color: var(--warning); background: #3e301b; color: #ffe0a4; }
.primary.small { min-height: 38px; padding: 7px 12px; font-size: 13px; }
.is-loading { opacity: .6; cursor: progress; }
.error { min-height: 22px; margin: 12px 0 0; color: var(--danger); }
.console { max-width: 1700px; margin: 0 auto; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 4px 0 22px; }
.topbar h1 { margin: 0; }
.top-actions, .chat-actions { display: flex; align-items: center; gap: 10px; }
.badge, .pill { display: inline-flex; align-items: center; min-height: 28px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; color: var(--muted); font-size: 11px; }
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr) 310px; min-height: calc(100vh - 120px); overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.sidebar, .incident-panel { min-width: 0; padding: 16px; background: #0e151f; }
.sidebar { border-right: 1px solid var(--line); }
.incident-panel { border-left: 1px solid var(--line); }
.sidebar-head, .panel-title, .chat-head, .message-meta, .incident-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sidebar-head { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.icon-btn { display: inline-grid; min-width: 44px; min-height: 44px; place-items: center; border: 0; background: transparent; color: var(--muted); font-size: 19px; }
.icon-btn:hover { color: var(--text); }
.conversation-list { display: grid; gap: 6px; padding-top: 12px; }
.conversation { width: 100%; min-height: 58px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); padding: 10px; text-align: left; }
.conversation:hover, .conversation.selected { border-color: var(--line); background: var(--surface-2); }
.conv-title, .conv-meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-title { font-weight: 600; }
.conv-meta { margin-top: 4px; color: var(--muted); font-size: 11px; }
.chat-panel { min-width: 0; padding: 20px; }
.empty-state { display: grid; min-height: 50vh; place-content: center; color: var(--muted); text-align: center; }
.empty-icon { width: 34px; height: 34px; margin: 0 auto 18px; border: 1px solid var(--accent); border-radius: 50%; position: relative; }
.empty-icon::after { content: ''; position: absolute; width: 12px; height: 1px; left: 10px; top: 16px; background: var(--accent); }
.chat-head { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.message-list { display: grid; gap: 12px; padding: 18px 0; }
.message { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.message-meta { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.message-meta-right { display: inline-flex; align-items: center; gap: 8px; }
.match-badge { border: 1px solid var(--warning); border-radius: 999px; background: #5a431f; color: #ffe0a4; padding: 3px 7px; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.message-bubble { padding: 12px; }
.message-bubble .pill { margin-right: 5px; }
.chat-copy { display: grid; gap: 10px; margin-top: 12px; }
.turn { display: grid; gap: 5px; }
.chat-copy pre { overflow: auto; max-height: 52vh; margin: 0; border: 1px solid var(--line); border-left-width: 3px; border-radius: 7px; background: #0f1722; color: var(--text); padding: 13px 14px; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; font: 14px/1.65 Inter, ui-sans-serif, system-ui, sans-serif; }
.turn-user pre { border-left-color: var(--success); background: #101c21; }
.turn-assistant pre { border-color: #38527b; border-left-color: var(--accent); background: #101927; }
.turn-system pre { border-left-color: var(--muted); background: #121820; color: #c5d0dc; font-size: 13px; }
.turn-tool pre { border-left-color: var(--warning); background: #211c14; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.reveal { overflow: auto; max-height: 52vh; margin: 12px 0 0; border: 1px solid var(--line); border-radius: 8px; background: #0b121c; color: var(--text); padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
.chat-role { color: var(--success); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.turn-assistant .chat-role { color: var(--accent); }
.turn-tool .chat-role { color: var(--warning); }
.detector-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.risk { border: 1px solid transparent; border-radius: 999px; padding: 4px 7px; font-size: 10px; }
.risk-critical { border-color: #884f5a; background: #40212a; color: #ffb4bd; }
.risk-high { border-color: #806237; background: #3a2b18; color: #ffd797; }
.risk-medium { border-color: #3f5d8e; background: #1c2e49; color: #bcd5ff; }
.risk-low { border-color: #34715a; background: #173c31; color: #a9f0cf; }
.detected-fragment { display: inline; border: 1px solid transparent; border-radius: 4px; padding: 2px 4px; font-weight: 800; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.detected-critical { border-color: #d26b78; background: #5a2732; color: #ffe3e8; }
.detected-high { border-color: #d4a24e; background: #5a431f; color: #ffe0a4; }
.detected-medium { border-color: #6f9ddd; background: #243b60; color: #d9e7ff; }
.detected-low { border-color: #4ba67e; background: #1d4b3c; color: #d2ffe9; }
.incident { display: block; width: 100%; margin: 10px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); padding: 11px; text-align: left; }
.incident:hover, .incident.active { border-color: var(--accent-strong); background: var(--surface-3); }
.incident:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.incident:disabled { cursor: not-allowed; opacity: .55; }
.incident strong { display: block; margin: 8px 0 4px; }
.incident small, .incident time, .incident-value, .incident-hint { display: block; margin: 0; color: var(--muted); overflow-wrap: anywhere; font-size: 12px; }
.incident-hint { margin-top: 8px; color: var(--accent); font-size: 11px; opacity: .8; }
.incident-status { min-height: 22px; margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.message.incident-target { scroll-margin-block: 72px; border-color: var(--warning); outline: 4px solid var(--warning); outline-offset: 5px; background: #2a2b35; box-shadow: inset 6px 0 0 var(--warning), 0 0 28px #f3c47855; }
.message:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.panel-title { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.load-more { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-3); color: var(--text); }
.load-more:hover { border-color: var(--accent); }
.skeleton-list, .message-skeleton { display: grid; gap: 8px; }
.skeleton-list i { display: block; height: 58px; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.message-skeleton i { display: block; height: 160px; border-radius: 10px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
dialog { width: min(400px, calc(100vw - 28px)); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); padding: 22px; }
dialog::backdrop { background: #02050aaa; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions .primary { width: auto; }
@keyframes shimmer { 0% { background-position: 0 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; } }
@media (max-width: 1120px) { .layout { grid-template-columns: 260px minmax(0, 1fr); } .incident-panel { display: none; } }
@media (max-width: 720px) { .shell { padding: 12px; } .topbar { align-items: flex-start; flex-direction: column; } .top-actions { width: 100%; justify-content: space-between; } .layout { grid-template-columns: 1fr; min-height: 0; } .sidebar { border-right: 0; border-bottom: 1px solid var(--line); } .chat-panel { min-height: 70vh; padding: 14px; } .chat-head { align-items: flex-start; flex-direction: column; } .chat-actions { width: 100%; } .chat-actions button { flex: 1; } }
