:root {
  color-scheme: light dark;
  --paper: light-dark(#fbfcfa, #192220);
  --panel: light-dark(#edf2ee, #202e2a);
  --surface: light-dark(#fff, #23312d);
  --ink: light-dark(#182b25, #edf6f0);
  --soft: light-dark(#52695e, #afc6ba);
  --line: light-dark(#d8e3dc, #405247);
  --accent: light-dark(#174e3e, #9cd9bf);
  --on-accent: light-dark(#fff, #142a20);
  --wash: light-dark(#e0ede5, #2c443a);
  --clay: light-dark(#f2e6da, #533d2d);
  --clay-ink: light-dark(#76482c, #f2c3a2);
  --danger: light-dark(#a22a2a,#ffaaaa);
  font: 16px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
:where(h1,h2,p,ul) { margin: 0; }
:where(button,input,textarea) { font: inherit; color: inherit; }
button, a { cursor: pointer; }
button:disabled { cursor: default; opacity: .56; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1 { font-size: 1.2rem; letter-spacing: -.03em; line-height: 1.23; overflow-wrap: anywhere; }
h2 { font-size: 1.11rem; letter-spacing: -.022em; overflow-wrap: anywhere; }
input, textarea { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
input { padding: 9px 11px; width: 100%; }
.plain, .primary, .new { min-height: 42px; padding: 8px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 8px; font-size: .875rem; font-weight: 620; text-decoration: none; }
.plain { border: 0; background: transparent; color: var(--soft); }
.plain:hover { background: var(--wash); color: var(--ink); }
.primary { border: 1px solid transparent; background: var(--accent); color: var(--on-accent); }
.primary:not(:disabled):hover { filter: brightness(1.15); }
.muted { color: var(--soft); font-size: .8rem; }
.error, .danger { color: var(--danger); }
.error { font-size: .875rem; }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: var(--panel); }
.login-card { width: min(100%, 390px); display: grid; gap: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; padding: 28px; box-shadow: 0 18px 68px #0d35291c; }
.login-card h1 { font-size: 1.6rem; margin-bottom: 4px; }
.login-card label { display: grid; gap: 6px; font-size: .875rem; font-weight: 600; }
.login-card .brand { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: center; white-space: nowrap; letter-spacing: -.035em; font-weight: 750; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); border-radius: 9px; }
.brand-mark span { border: 1.5px solid currentColor; border-radius: 3px; width: 17px; height: 14px; position: relative; }
.brand-mark span::before, .brand-mark span::after { position: absolute; content: ""; background: currentColor; }
.brand-mark span::before { width: 100%; height: 1px; top: 3px; }
.brand-mark span::after { height: 8px; width: 1px; top: 3px; left: 4px; }
.app { display: grid; grid-template-columns: 238px minmax(0,1fr); min-height: 100dvh; }
.sidebar { display: flex; flex-direction: column; min-width: 0; padding: 18px 13px 12px; background: var(--panel); border-inline-end: 1px solid var(--line); max-height: 100dvh; position: sticky; top: 0; }
.sidebar .brand { margin: 2px 5px 22px; }
.new { background: var(--surface); color: var(--accent); border: 1px solid var(--line); }
.new:hover { border-color: var(--accent); }
.new span { font-size: 1.15rem; line-height: 1; }
.sidebar-link { justify-content: flex-start; margin-top: 7px; }
.section-label { font-weight: 730; text-transform: uppercase; letter-spacing: .095em; color: var(--soft); font-size: .72rem; }
.sidebar .section-label { margin: 18px 9px 8px; }
.history { display: grid; gap: 3px; align-content: start; overflow: auto; margin-bottom: 12px; }
.history-item { background: transparent; border: 0; border-radius: 8px; color: var(--ink); padding: 9px; text-align: start; display: grid; gap: 1px; overflow-wrap: anywhere; }
.history-item strong { font-size: .875rem; font-weight: 650; }
.history-item:hover, .history-item[aria-current="true"] { background: var(--wash); }
.account { margin-top: auto; border-top: 1px solid var(--line); padding: 10px 5px 0; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px; font-size: .875rem; font-weight: 650; }
.account .plain { padding-inline: 8px; }
.main { display: flex; flex-direction: column; min-width: 0; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 14px 24px; background: var(--paper); position: sticky; top: 0; z-index: 2; }
.heading,.toolbar-actions { display: flex; gap: 8px; align-items: center; min-width: 0; }
.toolbar-actions { flex: 0 0 auto; }
.toolbar-actions .plain { padding-inline: 9px; }
.mobile { display: none; }
.main-body { display: flex; flex: 1; min-width: 0; }
.primary-view { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.new-view { width: min(100%, 720px); margin: auto; padding: 24px; }
.new-view h2 { font-size: clamp(1.7rem, 4vw, 2.5rem); letter-spacing: -.055em; }
.new-view > .muted { margin: 3px 0 20px; font-size: .95rem; }
.model-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.model { display: grid; gap: 4px; text-align: start; padding: 16px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; }
.model:not(:disabled):hover { border-color: var(--accent); background: var(--wash); }
.model strong { font-size: 1rem; }
.model .initial { margin-bottom: 8px; }
.initial { width: 34px; height: 34px; border-radius: 9px; background: var(--wash); color: var(--accent); display: grid; place-items: center; font-size: .8rem; font-weight: 750; }
.initial.claude { background: var(--clay); color: var(--clay-ink); }
.banner { padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px; margin: 13px 20px 0; }
.chat-view { flex: 1; width: min(100%, 920px); margin: 0 auto; padding: 25px 23px 17px; display: flex; flex-direction: column; }
.messages { display: flex; flex-direction: column; gap: 23px; flex: 1; }
.message { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 10px; max-width: 100%; overflow-wrap: anywhere; }
.message.mine { grid-template-columns: minmax(0,1fr); align-self: end; max-width: min(88%,700px); background: var(--wash); border-radius: 13px 13px 3px 13px; padding: 11px 14px; }
.author { font-size: .875rem; line-height: 1.4; font-weight: 730; margin-bottom: 5px; }
.message-text { white-space: pre-wrap; }
.message-text h2, .message-text h3 { margin: 12px 0 5px; white-space: normal; }
.message-text pre, #file-content pre { border: 1px solid var(--line); background: var(--surface); padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .875rem; border-radius: 8px; }
.message-text code { font-family: ui-monospace, monospace; font-size: .875em; }
.message-text ul { padding-inline-start: 21px; }
.message-text li { white-space: normal; }
.message-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.file { display: flex; gap: 9px; max-width: 100%; text-align: start; align-items: center; color: var(--ink); background: var(--surface); padding: 7px 9px; min-height: 42px; border: 1px solid var(--line); border-radius: 8px; }
.file:hover { border-color: var(--accent); }
.file strong { display: block; font-size: .84rem; font-weight: 650; overflow-wrap: anywhere; }
.file-ext { flex: none; font-size: .69rem; line-height: 1.2; font-weight: 750; color: var(--accent); border: 1px solid var(--line); border-radius: 5px; padding: 6px 4px; }
.compose { display: grid; gap: 5px; padding: 9px; margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; position: sticky; bottom: 12px; box-shadow: 0 4px 20px #15372a12; }
.compose textarea { width: 100%; min-height: 53px; max-height: 220px; background: transparent; resize: vertical; border: 0; padding: 7px; }
.compose-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.draft-files { display: flex; flex-wrap: wrap; gap: 6px; }
.draft-files button { background: var(--wash); border: 0; border-radius: 6px; padding: 6px 9px; overflow-wrap: anywhere; text-align: start; font-size: .84rem; }
.run, .turn-error { display: flex; align-items: center; gap: 8px; padding: 13px 0 0; color: var(--soft); font-size: .875rem; }
.turn-error { color: var(--danger); flex-wrap: wrap; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.files { width: min(290px,32%); padding: 22px 13px; border-inline-start: 1px solid var(--line); background: var(--panel); overflow-wrap: anywhere; }
.files h2 { margin-bottom: 14px; }
.file-list { display: grid; gap: 7px; padding: 7px 0 16px; }
.usage-view { padding: 24px; width: min(100%,1060px); margin-inline: auto; }
.usage-view h2 { margin: 21px 0 8px; }
.totals { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(210px,100%),1fr)); gap: 10px; }
.total { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 14px; }
.total h2 { margin: 0 0 5px; }
.stats { width: 100%; border-collapse: collapse; font-size: .84rem; }
.stats th,.stats td { text-align: start; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-wrap { overflow: auto; }
dialog { color: var(--ink); width: min(570px,calc(100% - 22px)); max-height: 89dvh; padding: 19px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
dialog::backdrop { background: #10271e85; }
dialog p { margin: 5px 0 12px; }
.dialog-heading, .dialog-controls { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.dialog-controls { justify-content: flex-end; }
.destructive { background: var(--danger); color: var(--paper); }
#file-content { margin-bottom: 12px; max-height: 58dvh; overflow: auto; }
#file-content img { max-width: 100%; height: auto; }
@media (max-width: 760px) {
  .app { grid-template-columns: 185px minmax(0,1fr); }
  .main-body { flex-direction: column; }
  .files { width: 100%; border-inline-start: 0; border-top: 1px solid var(--line); }
  .toolbar,.chat-view,.usage-view { padding-inline: 14px; }
}
@media (max-width: 560px) {
  .app { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: static; max-height: none; border: 0; border-bottom: 1px solid var(--line); }
  .sidebar:not(.expanded) { display: none; }
  .history { max-height: 35dvh; }
  .mobile { display: inline-flex; padding-inline: 6px; }
  .toolbar { padding-inline: 7px; }
  .toolbar-actions { gap: 0; }
  .toolbar-actions .plain { padding-inline: 6px; }
  .new-view { padding-inline: 14px; }
}
@media (max-width: 350px) {
  .model-grid { grid-template-columns: 1fr; }
}
