:root {
  color-scheme: light;
  --bg: #f5f7f7;
  --surface: #fff;
  --text: #203438;
  --muted: #617276;
  --line: #dce5e4;
  --teal: #126b61;
  --teal-soft: #e4f0ec;

  --sidebar-bg: #f2f5f3;
  --surface-soft: #f3f7f4;
  --hover: #e8eeeb;
  --selected: #e0eae5;
  --accent-text: #205849;
  --accent-hover: #0e564e;
  --on-accent: #fff;
  --input-border: #b9cbc2;
  --focus: #29867a;
  --success-dot: #4a8a6b;
  --success-bg: #e5f2e9;
  --success-text: #23603c;
  --success-border: #bad7c3;
  --warning: #906028;
  --danger-bg: #fae8e6;
  --danger: #9e3930;
  --danger-border: #dfaaa5;
  --overlay: #18352a66;
  --toast-bg: #264c3e;
  --toast-text: #fff;
  --sans: "Segoe UI", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141d22;
  --surface: #182329;
  --text: #e4eeeb;
  --muted: #a3b7af;
  --line: #34463f;
  --teal: #80d4b9;
  --teal-soft: #253f35;
  --sidebar-bg: #141e23;
  --surface-soft: #1e2e2c;
  --hover: #293b35;
  --selected: #2b4439;
  --accent-text: #a2ddc7;
  --accent-hover: #9ee4cd;
  --on-accent: #10271e;
  --input-border: #4a6558;
  --focus: #80d4b9;
  --success-dot: #80cba6;
  --success-bg: #233c2e;
  --success-text: #a6dfb8;
  --success-border: #4e775c;
  --warning: #e5b778;
  --danger-bg: #482a2b;
  --danger: #ffb1a6;
  --danger-border: #8d5852;
  --overlay: #040b10b3;
  --toast-bg: #345748;
  --toast-text: #f2fff8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--surface); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
button, a, summary, select, input, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
button { transition: background .15s, color .15s; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 20px; z-index: 100; padding: 12px 20px; background: var(--teal); color: var(--on-accent); border-radius: 8px; }
.skip-link:focus { top: 12px; }
.app-shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { min-height: 0; background: var(--sidebar-bg); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 28px 18px 16px; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; margin-bottom: 32px; }
.brand-logo { width: 38px; height: 38px; }
.brand strong { display: block; font-size: 23px; letter-spacing: -.8px; line-height: 1.2; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.new-chat-btn { display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 9px; padding: 12px; font-size: 14px; font-weight: 600; }
.primary, .send-btn, .login-submit { background: var(--teal); color: var(--on-accent); }
.primary:hover, .send-btn:hover, .login-submit:hover { background: var(--accent-hover); }
.new-chat-btn > span { font-size: 21px; line-height: 1; }
.main-nav { margin: 22px 0 28px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 12px; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; font-size: 14px; margin: 3px 0; min-height: 44px; }
.nav-item > span { width: 20px; text-align: center; font-size: 22px; line-height: 1; }
.nav-item:hover, .conv-select:hover { background: var(--hover); }
.nav-item.active { background: var(--selected); color: var(--accent-text); font-weight: 600; }
.history-heading { background: transparent; padding: 0 12px 12px; color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; }
.history-heading:hover { color: var(--teal); }
.conversation-list { overflow: auto; min-height: 45px; flex: 1; }
.sidebar-empty { color: var(--muted); padding: 8px 12px; font-size: 13px; line-height: 1.7; }
.conversation-entry { display: flex; align-items: center; border-radius: 7px; margin: 3px 0; }
.conversation-entry.current { background: var(--selected); color: var(--accent-text); }
.conv-select { background: transparent; color: inherit; flex: 1; min-width: 0; text-align: left; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; font-size: 13px; padding: 11px 12px; border-radius: 7px; }
.conv-delete { flex: none; color: var(--muted); background: transparent; width: 36px; min-height: 40px; border-radius: 6px; font-size: 20px; }
.conv-delete:hover { background: var(--danger-bg); color: var(--danger); }
.sidebar-bottom { padding-top: 20px; min-height: 0; max-height: 55%; overflow: auto; flex-shrink: 0; }
.team-tools { border-top: 1px solid var(--line); padding-top: 15px; font-size: 13px; color: var(--muted); }
.team-tools summary { cursor: pointer; padding: 8px 6px; border-radius: 5px; }
.team-tools summary:hover { color: var(--teal); }
.team-tools nav { margin: 10px 0; }
.assistant-details { padding: 0 12px 16px; font-size: 12px; overflow-wrap: anywhere; }
.assistant-details p { margin: 8px 0 12px; }
.assistant-details strong { display: block; margin-top: 16px; color: var(--muted); font-weight: 600; }
.detail-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.text-link { padding: 2px 0; background: transparent; color: var(--teal); font-size: inherit; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.sidebar-identity { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 16px 10px 0; border-top: 1px solid var(--line); }
.identity-badge { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--selected); color: var(--accent-text); font-weight: 700; }
.sidebar-identity strong { display: block; font-size: 13px; font-weight: 600; }
.sidebar-identity > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.identity-badge { flex: none; }
.logout-btn { margin: 12px 0 0 44px; padding: 8px 10px; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; text-align: left; }
.logout-btn:hover { background: var(--hover); color: var(--text); }
.sidebar-identity small { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.main-area { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 76px; flex: none; border-bottom: 1px solid var(--line); padding: 0 36px; gap: 12px; }
.header-left, .header-right { display: flex; align-items: center; gap: 14px; }
.crumb-current { font-weight: 600; font-size: 15px; }
.crumb-sep { color: var(--muted); }
.crumb { color: var(--muted); font-size: 13px; }
.live-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--accent-text); }
.green-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success-dot); flex: none; }
.live-pill.offline { color: var(--warning); }
.offline .green-dot { background: var(--warning); }
.content { flex: 1; min-height: 0; width: 100%; display: flex; }
.chat-panel { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 28px max(28px, calc((100% - 860px) / 2)); scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.empty-chat { max-width: 800px; min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 0; }
.welcome-mark { width: 60px; height: 60px; background: var(--surface-soft); border-radius: 18px; display: grid; place-items: center; margin-bottom: 20px; }
.welcome-mark img { width: 40px; height: 40px; }
.eyebrow { color: var(--accent-text); font-size: 11px; letter-spacing: 1.5px; font-weight: 600; margin: 0 0 12px; }
.empty-chat h1 { font-size: clamp(26px, 2.7vw, 38px); font-weight: 600; line-height: 1.2; letter-spacing: -1.1px; margin: 0 0 18px; }
.empty-chat > p:not(.eyebrow) { color: var(--muted); max-width: 610px; line-height: 1.8; margin: 0; font-size: 15px; }
.suggestions { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 34px 0 17px; }
.suggestion { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 7px; padding: 20px 17px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; color: var(--text); }
.suggestion:hover { background: var(--surface-soft); border-color: var(--input-border); }
.suggestion-icon { font-size: 24px; line-height: 1; color: var(--teal); margin-bottom: 6px; }
.suggestion strong { font-size: 14px; font-weight: 600; line-height: 1.5; }
.suggestion > span:last-child { color: var(--muted); font-size: 12px; line-height: 1.5; }
.empty-chat > .suggestion-hint { font-size: 12px !important; }
.message { display: flex; gap: 12px; align-items: flex-start; margin: 12px auto 30px; max-width: 820px; }
.message.user { justify-content: flex-end; }
.msg-avatar { flex: none; display: grid; place-items: center; height: 34px; width: 34px; border-radius: 10px; background: var(--surface-soft); font-size: 10px; font-weight: 600; color: var(--accent-text); }
.msg-avatar img { width: 26px; height: 26px; }
.message.user .msg-avatar { order: 2; background: var(--hover); }
.msg-main { max-width: calc(100% - 48px); min-width: 0; }
.message.user .msg-main { max-width: 80%; }
.msg-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.message.user .msg-label { text-align: right; }
.msg-content { font-size: 15px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .msg-content { padding: 13px 18px; background: var(--surface-soft); border-radius: 14px 3px 14px 14px; }
.msg-sources { margin-top: 16px; padding: 9px 12px; border-left: 2px solid var(--teal); background: var(--surface-soft); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.thinking { color: var(--muted); }
.composer-wrap { width: 100%; max-width: 916px; padding: 8px 28px 20px; margin: 0 auto; flex: none; }
.response-options { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.response-options select { min-width: 125px; background: transparent; color: var(--accent-text); border: 1px solid transparent; border-radius: 6px; padding: 6px; font-size: 12px; cursor: pointer; }
.response-options select:hover { background: var(--hover); }
.keyboard-hint { margin-left: auto; font-size: 11px; color: var(--muted); text-align: right; }
.composer { border: 1px solid var(--input-border); border-radius: 14px; padding: 16px 16px 12px; background: var(--surface); box-shadow: 0 4px 20px #243c2e07; }
.composer:focus-within { border-color: var(--teal); box-shadow: 0 0 0 2px #126b6110; }
.composer textarea { display: block; width: 100%; min-height: 54px; max-height: 140px; padding: 0; resize: none; border: 0; outline: none; background: transparent; color: var(--text); font-size: 15px; line-height: 1.6; }
.composer textarea::placeholder { color: var(--muted); }
.composer-bottom, .composer-actions, .voice-actions { display: flex; align-items: center; gap: 8px; }
.composer-bottom { justify-content: space-between; margin-top: 9px; }
.char-counter { font-size: 11px; color: var(--muted); margin-right: 5px; }
.send-btn { display: inline-flex; align-items: center; gap: 12px; min-height: 40px; padding: 9px 15px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.send-btn > span { font-size: 20px; line-height: 1; }
.voice-btn { border: 1px solid transparent; padding: 8px; min-height: 40px; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; }
.voice-btn:hover { background: var(--hover); }
.voice-btn.enabled { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.voice-btn.recording { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.message-listen { background: transparent; color: var(--teal); padding: 3px 7px; font-size: 12px; border-radius: 5px; margin-left: 8px; }
.message-listen:hover { background: var(--teal-soft); }
.voice-help { color: var(--teal); font-size: 12px; margin: 10px 3px 0; }
.composer-disclaimer { font-size: 11px; color: var(--muted); text-align: center; margin: 12px 0 0; line-height: 1.6; }
.icon-btn { background: transparent; color: var(--accent-text); border-radius: 7px; width: 40px; height: 40px; font-size: 23px; flex: none; }
.icon-btn:hover { background: var(--hover); }
.mobile-menu, .mobile-close, .mobile-new-chat, .sidebar-overlay { display: none; }
.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; width: min(620px, 100%); max-height: 85dvh; overflow: auto; box-shadow: 0 20px 80px #18352a26; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; gap: 15px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 21px; line-height: 1.3; margin: 0; font-weight: 600; }
.modal-body { padding: 12px 24px 24px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.modal-body code { background: var(--surface-soft); padding: 3px 6px; border-radius: 4px; color: var(--accent-text); font-size: 12px; overflow-wrap: anywhere; }
.modal-body ul { padding-left: 20px; }
.file-list { list-style: none; padding: 0 !important; }
.file-list li { padding: 10px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.training-refresh { background: var(--teal); color: var(--on-accent); border-radius: 8px; padding: 11px 16px; margin: 12px 0; font-size: 14px; }
.toast { position: fixed; bottom: 25px; left: 50%; z-index: 60; transform: translateX(-50%) translateY(20px); max-width: min(560px, 90vw); padding: 13px 18px; border-radius: 10px; background: var(--toast-bg); color: var(--toast-text); box-shadow: 0 8px 30px #193b3026; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
.login-page { min-height: 100dvh; height: auto; display: grid; place-items: center; padding: 24px 0; background: var(--bg); }
.login-wrap { text-align: center; padding: 38px; border: 1px solid var(--line); border-radius: 18px; width: min(480px, calc(100% - 32px)); background: var(--surface); }
.login-orb img { width: 52px; height: 52px; margin-bottom: 20px; }
.login-wrap h1 { font-size: 29px; font-weight: 600; letter-spacing: -.7px; }
.login-wrap h1 span { color: var(--teal); }
.login-wrap p:not(.eyebrow) { color: var(--muted); font-size: 14px; }
.login-form { text-align: left; display: flex; flex-direction: column; gap: 12px; margin: 28px 0; }
.login-form label { font-size: 13px; font-weight: 600; }
.login-form input { width: 100%; border: 1px solid var(--input-border); border-radius: 8px; padding: 13px; background: var(--surface); color: var(--text); }
.login-submit { padding: 13px; border-radius: 8px; font-weight: 600; }
.zoho-login { display: flex; align-items: center; justify-content: center; gap: 16px; text-decoration: none; }
.login-error { color: var(--danger); font-size: 13px; }
.login-wrap > small { color: var(--muted); font-size: 11px; }
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 240px minmax(0, 1fr); }
  .sidebar { padding-inline: 14px; }
  .topbar { padding-inline: 28px; }
  .suggestion { padding: 16px 13px; }
  .keyboard-hint { display: none; }
}
@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); transform: translateX(-100%); transition: transform .2s; box-shadow: 12px 0 50px #18352a20; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 10; background: var(--overlay); }
  .mobile-menu, .mobile-close, .mobile-new-chat { display: block; }
  .mobile-close { margin-left: auto; }
  .topbar { min-height: 66px; padding-inline: 14px; }
  .header-left, .header-right { gap: 8px; }
  .sidebar:not(.open) { visibility: hidden; }
  .sidebar-bottom { max-height: 50%; }
}
@media (max-width: 540px) {
  body { font-size: 14px; }
  .topbar { min-height: 60px; padding-inline: 8px; }
  .crumb, .crumb-sep { display: none; }
  .live-pill { font-size: 11px; }
  .chat-messages { padding: 14px 18px; }
  .empty-chat { padding: 18px 0; }
  .welcome-mark { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 14px; }
  .welcome-mark img { width: 32px; height: 32px; }
  .eyebrow { font-size: 9px; letter-spacing: 1.1px; margin-bottom: 10px; }
  .empty-chat h1 { font-size: 27px; margin-bottom: 14px; }
  .empty-chat > p:not(.eyebrow) { font-size: 14px; line-height: 1.65; }
  .desktop-break { display: none; }
  .suggestions { grid-template-columns: 1fr; margin: 23px 0 12px; gap: 8px; }
  .suggestion { display: grid; grid-template-columns: 26px 1fr; column-gap: 12px; row-gap: 1px; padding: 12px 14px; align-items: center; }
  .suggestion-icon { grid-row: span 2; margin: 0; }
  .suggestion strong { font-size: 13px; }
  .suggestion > span:last-child { font-size: 11px; }
  .empty-chat > .suggestion-hint { font-size: 11px !important; }
  .composer-wrap { padding: 6px 12px max(12px, env(safe-area-inset-bottom)); }
  .response-options { margin-bottom: 6px; font-size: 11px; }
  .response-options select { font-size: 12px; }
  .composer { padding: 12px 10px 9px; border-radius: 12px; }
  .composer textarea { font-size: 16px; min-height: 50px; }
  .composer-bottom, .composer-actions, .voice-actions { gap: 3px; }
  .voice-btn { padding-inline: 6px; font-size: 11px; }
  .char-counter { display: none; }
  .send-btn { padding: 9px 11px; gap: 7px; font-size: 12px; }
  .composer-disclaimer { font-size: 10px; margin-top: 9px; }
  .message { gap: 8px; margin-bottom: 24px; }
  .msg-content { font-size: 14px; }
  .msg-avatar { width: 28px; height: 28px; }
  .msg-main { max-width: calc(100% - 36px); }
  .message.user .msg-main { max-width: 84%; }
  .modal-backdrop { padding: 12px; }
  .modal-header { padding: 15px 18px; }
  .modal-body { padding: 10px 18px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

.theme-picker { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.theme-picker select { min-height: 38px; min-width: 84px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--text); cursor: pointer; font-size: 12px; }
.theme-picker select:hover { border-color: var(--input-border); }
select option { background: var(--surface); color: var(--text); }
.login-appearance { display: flex; justify-content: flex-end; margin: -12px -12px 24px 0; }
@media (max-width: 540px) {
  .live-pill #status-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .theme-picker select { min-width: 80px; padding-inline: 7px; }
}
