:root {
  --ink: #18211d;
  --muted: #68736d;
  --line: #dfe6e1;
  --surface: #ffffff;
  --canvas: #f3f6f4;
  --brand: #176b4d;
  --brand-dark: #0e4d37;
  --brand-soft: #e5f3ec;
  --human: #80582b;
  --human-soft: #fbf0df;
  --danger: #9f3b37;
  --danger-soft: #fbeceb;
  --shadow: 0 18px 60px rgba(25, 43, 34, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, textarea { font: inherit; }
button, a, input, textarea { outline-offset: 3px; }
:focus-visible { outline: 3px solid rgba(23, 107, 77, .35); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.eyebrow { margin: 0 0 5px; color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.login-page { display: grid; place-items: center; padding: 30px; background: radial-gradient(circle at 20% 10%, #dcefe5 0, transparent 35%), var(--canvas); }
.login-shell { width: min(100%, 430px); }
.login-card { padding: 44px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.95); box-shadow: var(--shadow); }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 26px; border-radius: 16px; color: white; background: var(--brand); font-size: 25px; font-weight: 800; }
.brand-mark-small { width: 34px; height: 34px; margin: 0; border-radius: 10px; font-size: 17px; }
.login-card h1 { margin: 0; font-size: 34px; letter-spacing: -.03em; }
.login-intro { margin: 10px 0 30px; color: var(--muted); line-height: 1.5; }
.login-card label { display: block; margin: 18px 0 7px; font-size: 13px; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid #cbd5cf; border-radius: 11px; color: var(--ink); background: white; }
input { height: 45px; padding: 0 13px; }
textarea { min-height: 54px; max-height: 140px; padding: 13px; resize: vertical; line-height: 1.4; }
input:disabled, textarea:disabled { color: #8a938e; background: #eef1ef; cursor: not-allowed; }
.form-error { min-height: 20px; margin: 14px 0 8px; color: var(--danger); font-size: 13px; }

.button { min-height: 40px; padding: 9px 16px; border: 0; border-radius: 10px; font-weight: 750; cursor: pointer; transition: transform .12s ease, opacity .12s ease, background .12s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button-primary { color: white; background: var(--brand); }
.button-primary:hover:not(:disabled) { background: var(--brand-dark); }
.button-wide { width: 100%; }
.button-quiet { color: #4d5a53; background: #eef2ef; }
.button-danger-quiet { color: var(--danger); background: var(--danger-soft); }
.button-send { min-width: 86px; color: white; background: var(--brand); }

.topbar { position: relative; z-index: 3; display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
.brand { display: flex; gap: 11px; align-items: center; color: var(--ink); font-size: 18px; font-weight: 800; text-decoration: none; }
.topbar-actions { display: flex; gap: 18px; align-items: center; }
.operator-name { font-size: 13px; font-weight: 700; }
.connection-state { color: var(--muted); font-size: 12px; }
.connection-state::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #35a46f; }
.connection-state.offline::before { background: #cf5a53; }

.workspace { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: calc(100vh - 64px); max-width: 1580px; margin: 0 auto; border-inline: 1px solid var(--line); background: white; }
.conversation-sidebar { min-width: 0; border-right: 1px solid var(--line); background: #fafcfb; overflow: hidden; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; height: 82px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.sidebar-heading h1 { margin: 0; font-size: 21px; }
.conversation-count { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; color: var(--brand); background: var(--brand-soft); font-size: 12px; font-weight: 800; }
.conversation-list { height: calc(100% - 82px); overflow-y: auto; }
.list-status { padding: 32px 20px; color: var(--muted); font-size: 14px; }
.conversation-item { position: relative; display: block; width: 100%; padding: 17px 20px; border: 0; border-bottom: 1px solid #e9eeeb; text-align: left; background: transparent; cursor: pointer; }
.conversation-item:hover { background: #f1f6f3; }
.conversation-item.selected { background: var(--brand-soft); box-shadow: inset 3px 0 var(--brand); }
.conversation-row { display: flex; justify-content: space-between; gap: 10px; }
.conversation-row strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-row time { flex: none; color: var(--muted); font-size: 11px; }
.conversation-preview { display: block; margin-top: 7px; padding-right: 62px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.list-mode { position: absolute; right: 20px; bottom: 15px; padding: 3px 7px; border-radius: 6px; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.list-mode.eva { color: var(--brand); background: var(--brand-soft); }
.list-mode.human { color: var(--human); background: var(--human-soft); }

.chat-panel { position: relative; min-width: 0; background: #f6f8f7; }
.supervision-banner { position: absolute; z-index: 4; top: 10px; left: 50%; transform: translateX(-50%); padding: 7px 13px; border: 1px solid #dfc797; border-radius: 18px; color: #68491f; background: #fff7e6; font-size: 12px; font-weight: 750; box-shadow: 0 4px 12px rgba(80,55,20,.08); }
.empty-state { display: grid; place-content: center; height: 100%; padding: 30px; text-align: center; }
.empty-symbol { margin: 0 auto 14px; color: var(--brand); font-size: 34px; }
.empty-state h2 { margin: 0; font-size: 22px; }
.empty-state p { max-width: 390px; margin: 10px auto; color: var(--muted); }
.chat-content { display: grid; grid-template-rows: 82px auto minmax(0, 1fr) auto; height: 100%; }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--line); background: white; }
.chat-identity { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-identity h2 { margin: 0; overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.chat-identity p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.mobile-back { display: none; border: 0; background: transparent; font-size: 30px; }
.control-summary { display: flex; align-items: center; gap: 12px; }
.mode-badge { padding: 6px 9px; border-radius: 7px; color: var(--brand); background: var(--brand-soft); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.mode-badge.human { color: var(--human); background: var(--human-soft); }
.control-copy { color: var(--muted); font-size: 12px; }
.chat-notice { padding: 10px 24px; color: #284e3d; background: #e3f2e9; font-size: 13px; }
.chat-notice.error { color: #772d29; background: var(--danger-soft); }
.chat-notice.warning { color: #6f4a1e; background: var(--human-soft); }
.messages { display: flex; flex-direction: column; gap: 11px; padding: 24px max(24px, 7vw); overflow-y: auto; scroll-behavior: smooth; }
.message { align-self: flex-start; width: fit-content; max-width: min(72%, 680px); padding: 10px 13px 8px; border: 1px solid var(--line); border-radius: 5px 16px 16px 16px; background: white; box-shadow: 0 3px 12px rgba(35,48,42,.04); }
.message-eva, .message-human { align-self: flex-end; border-radius: 16px 5px 16px 16px; }
.message-eva { border-color: #cde2d6; background: #eaf6ef; }
.message-human { border-color: #ebd8ba; background: #fff7e9; }
.message-unknown { border-color: #d39a51; }
.message-failed { border-color: #d88b86; background: #fff2f1; }
.message-actor { display: block; margin-bottom: 4px; color: var(--brand); font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.message-human .message-actor { color: var(--human); }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.message-meta { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; text-align: right; }
.new-messages { position: absolute; left: 50%; bottom: 146px; z-index: 2; transform: translateX(-50%); padding: 7px 12px; border: 1px solid var(--line); border-radius: 16px; color: var(--brand); background: white; box-shadow: 0 5px 18px rgba(0,0,0,.1); cursor: pointer; }

.action-zone { padding: 12px 20px 14px; border-top: 1px solid var(--line); background: white; }
.takeover-controls, .human-controls { display: flex; gap: 12px; justify-content: flex-end; align-items: end; margin-bottom: 10px; }
.reason-field { flex: 1; max-width: 520px; }
.reason-field span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.reason-field input { height: 40px; }
.composer { display: flex; gap: 10px; align-items: end; }
.composer-help { margin: 7px 2px 0; color: var(--muted); font-size: 11px; }
.confirm-dialog { width: min(92vw, 500px); padding: 0; border: 0; border-radius: 18px; box-shadow: var(--shadow); }
.confirm-dialog::backdrop { background: rgba(13,25,19,.5); }
.confirm-dialog form { padding: 26px; }
.confirm-dialog h2 { margin: 0 0 12px; font-size: 20px; }
.confirm-dialog p { color: var(--muted); line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .chat-panel { display: none; }
  .chat-open .conversation-sidebar { display: none; }
  .chat-open .chat-panel { display: block; }
  .mobile-back { display: inline-block; }
  .topbar { padding: 0 14px; }
  .connection-state { display: none; }
  .operator-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .message { max-width: 86%; }
}

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