:root {
  color-scheme: light;
  --ink: #191a30;
  --muted: #5a5d72;
  --line: #e1e4ee;
  --surface: #fff;
  --paper: #f5f6fa;
  --accent: #5036d7;
  --accent-hover: #3d29a8;
  --selected: #eeebff;
  --danger: #9f233b;
  --note: #fff7df;
  font-family: "Golos Text", Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid #2176ff; outline-offset: 2px; }
button, select, input, textarea { border-radius: 8px; }
input, textarea, select { border: 1px solid #c8ccdb; color: var(--ink); background: var(--surface); }
input, select { min-height: 42px; padding: 9px 11px; }
textarea { padding: 10px 12px; width: 100%; resize: vertical; min-height: 65px; max-height: 166px; line-height: 1.45; }
p { margin: 0; }
h1, h2 { margin: 0; letter-spacing: -.04em; }
h1 { font-size: 32px; line-height: 1.1; }
h2 { font-size: clamp(22px, 3vw, 28px); line-height: 1.1; }
.topbar { height: 62px; padding: 0 clamp(14px, 3vw, 44px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 720; letter-spacing: -.045em; }
.brand-mark { background: var(--accent); color: #fff; display: grid; place-items: center; width: 35px; height: 35px; border-radius: 9px; font-size: 15px; font-weight: 820; }
.primary, .plain { min-height: 40px; padding: 8px 13px; font-weight: 650; }
.primary { background: var(--accent); border: 1px solid var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.plain { background: var(--surface); border: 1px solid #c8ccdb; color: var(--ink); }
.plain:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.auth { display: grid; place-items: start center; padding: clamp(36px, 13vh, 120px) 18px 30px; }
.auth-card { width: min(100%, 400px); padding: clamp(22px, 6vw, 34px); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.auth-card p { margin-top: 11px; color: var(--muted); line-height: 1.4; }
.auth-card form { display: grid; gap: 15px; margin-top: 23px; }
.auth-card label { display: grid; gap: 5px; font-size: 14px; font-weight: 600; }
.auth-card .error { margin: 0; color: var(--danger); }
.auth-card > button { margin-top: 15px; }
.workspace { display: grid; grid-template-columns: minmax(300px, 365px) minmax(0, 1fr); height: calc(100dvh - 62px); min-height: 400px; max-width: 1550px; margin: auto; background: var(--surface); border-inline: 1px solid var(--line); }
.inbox, .thread { min-height: 0; min-width: 0; }
.inbox { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.inbox-header { padding: 21px 17px 15px; border-bottom: 1px solid var(--line); }
.inbox-header input { width: 100%; margin-top: 17px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.filters button, .compose-modes button { border: 1px solid transparent; padding: 7px 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 650; min-height: 34px; }
.filters button:hover, .compose-modes button:hover { color: var(--accent); background: var(--paper); }
.filters button[aria-pressed="true"], .compose-modes button[aria-pressed="true"] { background: var(--selected); color: var(--accent-hover); border-color: #dad3ff; }
.inbox-body { flex: 1; min-height: 0; overflow: auto; }
.list-state:not(:empty) { padding: 16px; color: var(--muted); font-size: 14px; }
.conversations { margin: 0; padding: 0; list-style: none; }
.conversation { position: relative; width: 100%; display: grid; gap: 5px; padding: 14px 15px 13px 17px; text-align: left; color: var(--ink); background: var(--surface); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.conversation:hover { background: var(--paper); }
.conversation[aria-current="true"] { background: var(--selected); box-shadow: inset 3px 0 var(--accent); }
.conversation:focus-visible { outline-offset: -3px; }
.row-heading, .row-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-heading strong { font-size: 14px; }
.row-heading time, .row-meta { font-size: 12px; color: var(--muted); }
.preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.unread { background: var(--accent); color: #fff; border-radius: 16px; padding: 1px 6px; min-width: 19px; text-align: center; }
.more, .retry { display: block; margin: 14px auto; }
.thread-empty { height: 100%; display: grid; place-content: center; color: var(--muted); font-size: 16px; background: var(--paper); }
.thread-panel { height: 100%; display: flex; flex-direction: column; }
.thread-header { background: var(--surface); padding: 15px clamp(15px, 3vw, 31px); border-bottom: 1px solid var(--line); }
.thread-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; column-gap: 15px; row-gap: 10px; }
.thread-mode, .notice, .thread-error, .compose-actions p { color: var(--muted); font-size: 13px; line-height: 1.35; }
.thread-mode { margin-top: 5px; }
.thread-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.thread-controls select { font-weight: 650; font-size: 14px; }
.thread-controls .plain { font-size: 14px; }
.notice:not(:empty) { margin-top: 9px; color: var(--accent-hover); }
.thread-error { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-top: 11px; color: var(--danger); }
.thread-error button { min-height: 32px; font-size: 13px; }
.mobile-back { display: none; }
.history { flex: 1; overflow: auto; min-height: 60px; padding: 16px clamp(14px, 3vw, 31px); background: var(--paper); }
.older { display: block; margin: 0 auto 11px; }
.messages { list-style: none; margin: 0 auto; padding: 0; display: flex; flex-direction: column; gap: 12px; max-width: 850px; }
.message { width: fit-content; min-width: 125px; max-width: min(82%, 620px); padding: 10px 13px; border-radius: 11px 11px 11px 2px; background: var(--surface); border: 1px solid var(--line); }
.message[data-author="ai"], .message[data-author="human"] { align-self: end; background: var(--selected); border-color: #dad3ff; border-radius: 11px 11px 2px 11px; }
.message[data-author="note"] { align-self: end; background: var(--note); border-color: #ead8a7; border-radius: 11px; }
.message-meta { display: flex; align-items: baseline; gap: 12px; justify-content: space-between; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.message-meta strong { color: var(--ink); }
.message time { white-space: nowrap; }
.message p { line-height: 1.44; white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { padding: 10px clamp(14px, 3vw, 31px) 13px; background: var(--surface); border-top: 1px solid var(--line); }
.compose-modes { display: flex; gap: 6px; margin-bottom: 6px; }
.compose-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 5px; }
.compose-actions .primary { flex-shrink: 0; }
.error { margin-top: 5px; color: var(--danger); font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 680px) {
  .workspace { display: block; border: 0; min-height: 0; }
  .inbox, .thread { height: 100%; }
  .inbox { border: 0; }
  .workspace:not(.thread-open) .thread, .workspace.thread-open .inbox { display: none; }
  .mobile-back { display: inline-block; margin-bottom: 8px; min-height: 34px; padding: 4px 8px; font-size: 13px; }
  .thread-header, .composer { padding-top: 9px; padding-bottom: 9px; }
  .message { max-width: 94%; }
}
@media (max-width: 360px) {
  .compose-actions { flex-wrap: wrap; }
  .compose-actions .primary { margin-left: auto; }
}
