:root {
  color-scheme: light;
  font: 15px/1.55 Inter, "Segoe UI", system-ui, sans-serif;
  color: #1e2230;
  background: #f9f9fc;
  --page: #f9f9fc;
  --surface: #fff;
  --ink: #1e2230;
  --muted: #62687b;
  --line: #e3e5ef;
  --accent: #4938ad;
  --accent-quiet: #eeebff;
  --good: #1c705a;
  --good-quiet: #e7f6ef;
  --danger: #9b412e;
  --nav: #202131;
  --nav-text: #fbfaff;
  --nav-muted: #b6b7ce;
  --nav-line: #45465c;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
:focus-visible { outline: 2px solid #7863f0; outline-offset: 3px; }
[hidden] { display: none !important; }

.cabinet { display: grid; grid-template-columns: 298px minmax(0, 1fr); height: 100dvh; }
.sidebar { display: flex; flex-direction: column; min-height: 0; padding: 23px 16px 16px; background: var(--nav); color: var(--nav-text); }
.brand { display: flex; gap: 12px; align-items: center; padding: 1px 5px 0; font-weight: 750; font-size: 17px; letter-spacing: -.025em; }
.brand small { display: block; font-size: 12px; color: var(--nav-muted); font-weight: 500; letter-spacing: 0; }
.brand-mark { width: 37px; height: 37px; border-radius: 11px; background: #a597ff; display: flex; align-items: center; justify-content: center; gap: 3px; transform: rotate(-7deg); }
.brand-mark i { width: 3px; border-radius: 3px; height: 10px; background: #21213d; transform: rotate(21deg); }
.brand-mark i:nth-child(2) { height: 17px; }
.brand-mark i:nth-child(3) { height: 22px; }
.new { display: flex; align-items: center; gap: 10px; text-align: left; margin: 30px 3px 27px; padding: 8px 13px; background: #dcd3ff; color: #261d50; border: 0; border-radius: 9px; font-size: 14px; font-weight: 750; }
.new span { font-size: 21px; line-height: 1; font-weight: 500; }
.new:hover { background: #ece5ff; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 8px; color: var(--nav-muted); }
.sidebar-heading h2 { margin: 0; font-size: 12px; font-weight: 650; }
.count { font-size: 11px; font-variant-numeric: tabular-nums; }
.chats { flex: 1; overflow: auto; min-height: 50px; }
.chat { display: grid; grid-template-columns: 8px minmax(0, 1fr); column-gap: 10px; width: 100%; margin-bottom: 3px; text-align: left; border: 1px solid transparent; border-radius: 9px; padding: 9px 10px; background: transparent; color: var(--nav-text); }
.chat:hover { background: #303146; }
.chat[aria-current] { background: #39384e; border-color: #504e6b; box-shadow: inset 2px 0 #b4a2ff; }
.chat-label { font-size: 13px; font-weight: 630; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat .status { grid-column: 2; color: var(--nav-muted); font-size: 11px; }
.chat .status.done { color: #a1dfc6; }
.chat .status.running, .chat .status.uncertain { color: #d3c8ff; }
.chat .status.failed { color: #f9a892; }
.chat-dot { width: 6px; height: 6px; border-radius: 50%; background: #8f8fa7; align-self: center; }
.chat-dot.done { background: #83d7b6; }
.chat-dot.running, .chat-dot.uncertain { background: #b5a4ff; }
.chat-dot.failed { background: #f9a892; }
.muted { font-size: 13px; color: var(--nav-muted); margin: 10px 10px; }
.account { margin: 13px 3px 0; padding-top: 12px; border-top: 1px solid var(--nav-line); display: grid; gap: 7px; }
.account:empty { display: none; }
.account label { font-size: 11px; color: var(--nav-muted); }
.account select { background: #2d2d43; color: var(--nav-text); border: 1px solid #484960; border-radius: 8px; padding: 6px 8px; font-size: 12px; width: 100%; }

.conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.thread-header { display: flex; align-items: center; gap: 16px; min-width: 0; padding: 18px 30px; border-bottom: 1px solid var(--line); background: var(--surface); }
.thread-identity { flex: 1; min-width: 0; }
.eyebrow { font-size: 11px; font-weight: 650; color: var(--muted); padding-bottom: 3px; }
h1 { margin: 0; font-size: clamp(18px, 1.65vw, 25px); letter-spacing: -.035em; line-height: 1.25; overflow-wrap: anywhere; }
.back { display: none; white-space: nowrap; border: 0; background: none; color: var(--accent); font-weight: 700; padding: 2px; }
.status { color: var(--muted); font-size: 11px; font-weight: 700; }
.thread-status { flex: none; border-radius: 999px; background: var(--accent-quiet); color: var(--accent); padding: 5px 10px; }
.status.running, .status.uncertain { color: var(--accent); }
.status.done { color: var(--good); }
.thread-status.done { background: var(--good-quiet); }
.status.failed { color: var(--danger); }
.log { padding: 32px max(24px, calc((100% - 752px)/2)) 22px; overflow: auto; }
.empty { margin: clamp(14px, 10vh, 96px) auto 0; width: 100%; max-width: 640px; }
.empty h2 { font-size: clamp(27px, 4vw, 45px); font-weight: 650; letter-spacing: -.055em; line-height: 1.12; margin: 0; }
.empty p { color: var(--muted); max-width: 405px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.example { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--accent); font-weight: 600; padding: 6px 12px; font-size: 12px; }
.example:hover { background: var(--accent-quiet); }
.message { border-radius: 14px; margin: 0 0 14px; padding: 14px 18px; overflow-wrap: anywhere; }
.request { background: var(--accent-quiet); margin-left: auto; width: fit-content; max-width: 90%; }
.result { background: var(--surface); border: 1px solid var(--line); padding: 16px 19px; margin-right: min(7%, 55px); }
.message-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; font-weight: 750; }
.origin { color: var(--muted); font-size: 11px; font-weight: 550; }
.body { margin-top: 5px; white-space: pre-wrap; font-size: 14px; }
.composer-area { padding: 4px max(24px, calc((100% - 752px)/2)) max(17px, env(safe-area-inset-bottom)); }
.composer { position: relative; border: 1px solid var(--line); border-radius: 15px; padding: 11px 13px 9px; background: var(--surface); box-shadow: 0 6px 22px #2122470d; }
.composer:focus-within { border-color: #a99add; }
.composer-context { color: var(--accent); font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
textarea { width: 100%; max-height: 150px; resize: vertical; border: 0; padding: 7px 0 0; color: var(--ink); background: transparent; outline: none; font-size: 14px; }
textarea:focus-visible { outline: none; }
textarea::placeholder { color: var(--muted); }
.composer-actions { display: flex; justify-content: flex-end; }
.composer button { border: 0; border-radius: 8px; background: var(--accent); color: white; padding: 6px 10px; font-size: 12px; font-weight: 750; }
.composer button span { margin-left: 5px; }
.error { padding: 6px 0 0; margin: 0; color: var(--danger); font-size: 13px; }
.schedule-open { border: 1px solid var(--nav-line); border-radius: 10px; background: transparent; color: var(--nav-text); padding: 8px 12px; text-align: left; }
.thread-header .schedule-open { display: none; }
.schedule-dialog { width: min(94vw, 620px); max-height: 88dvh; padding: clamp(14px, 3vw, 24px); border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--ink); }
.schedule-dialog::backdrop { background: #13112577; }
.schedule-heading, .schedule-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.schedule-heading h2 { margin: 0; font-size: 20px; }
.schedule-dialog button { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--accent); background: var(--surface); }
.schedule-dialog .schedule-close { min-width: 44px; min-height: 44px; font-size: 20px; line-height: 1; }
.schedule-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.schedule-row small { display: block; margin-top: 3px; color: var(--muted); }
.schedule-controls { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.schedule-card { display: block; margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; overflow-wrap: anywhere; }
.schedule-next { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin: 12px 0; font-size: 13px; }
.schedule-next time { font-weight: 650; }
.schedule-runs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.schedule-run { min-width: 0; padding: 10px; border-radius: 8px; background: var(--page); font-size: 13px; }
.schedule-run-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 4px; }
.schedule-run-status { padding: 1px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.schedule-run-status.running, .schedule-run-status.queued { color: var(--accent); background: var(--accent-quiet); }
.schedule-run-status.done { color: var(--good); background: var(--good-quiet); }
.schedule-run-status.failed { color: var(--danger); }
.schedule-run p { margin: 6px 0; }
.schedule-run a { display: flex; align-items: center; min-height: 44px; color: var(--accent); }
.schedule-run time, .schedule-expired { display: block; color: var(--muted); }
.schedule-retry { margin-top: 8px; }
.schedule-form { margin-top: 14px; }
.schedule-form label { display: block; margin-bottom: 8px; font-size: 13px; }
.schedule-form label[hidden] { display: none; }
.schedule-form input, .schedule-form textarea, .schedule-form select { display: block; width: 100%; margin-top: 4px; border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; color: var(--ink); background: var(--surface); font: inherit; }
.schedule-form [type=submit] { background: var(--accent); color: white; border-color: var(--accent); }
.schedule-error { color: var(--danger); margin-bottom: 0; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }


@media (max-width: 680px) {
  .cabinet { display: block; }
  .sidebar { height: 100%; padding-top: max(20px, env(safe-area-inset-top)); }
  .conversation { display: none; height: 100%; }
  .show-chat .sidebar { display: none; }
  .show-chat .conversation { display: grid; }
  .back { display: inline-block; font-size: 12px; }
  .thread-header { gap: 10px; padding: 11px 13px; }
  .thread-status { padding: 3px 6px; font-size: 9px; }
  .thread-header .schedule-open { display: block; flex: none; border-color: var(--line); color: var(--accent); padding: 5px 7px; font-size: 12px; }
  .log { padding: 16px 13px 12px; }
  .composer-area { padding-left: 12px; padding-right: 12px; }
  .message { padding: 11px 13px; }
}
@media (max-width: 480px) {
  .schedule-runs { grid-template-columns: 1fr; }
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    color: #edeef7;
    background: #1a1b26;
    --page: #1a1b26;
    --surface: #252635;
    --ink: #edeef7;
    --muted: #b8bdd1;
    --line: #3e4054;
    --accent: #c7baff;
    --accent-quiet: #34304d;
    --good: #91d8b9;
    --good-quiet: #203b36;
    --danger: #ffad9b;
    --nav: #151621;
  }
  .composer button { color: #251b4c; }
}
