/* Hallmark: workbench, warm paper, signal yellow. */
/* Critique: keep the primary surface focused on asking and sending. */
:root {
  color-scheme: light;
  --paper: #f9f8f4;
  --rail: #f0eee6;
  --white: #fffefa;
  --ink: #25251e;
  --muted: #625f52;
  --muted-strong: #514e40;
  --line: #e1ded3;
  --hover: #eeebe1;
  --accent: #f5ce49;
  --accent-soft: #fff0b8;
  --focus: #654e00;
  --alert: #873622;
  --scrim: #22221960;
  --font: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
button, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 3px;
}
button { transition: background-color 150ms ease, transform 150ms ease; }
button:active:not(:disabled) { transform: scale(.98); }
[hidden] { display: none !important; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.skip:focus { position: fixed; z-index: 10; top: 12px; left: 12px; background: var(--white); color: var(--ink); padding: 8px; }
.app { display: grid; grid-template-columns: 242px minmax(0,1fr); min-height: 100dvh; max-width: 1700px; margin: auto; }
.rail { background: var(--rail); border-right: 1px solid var(--line); padding: 24px 20px 20px; display: flex; flex-direction: column; max-height: 100dvh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 4px; white-space: nowrap; font-size: 18px; letter-spacing: -.03em; }
.brand .icon { margin-left: auto; }
.mark { display: grid; place-items: center; border-radius: 10px; width: 34px; height: 34px; background: var(--ink); color: var(--accent); font-size: 21px; font-weight: 800; }
.new, .thread { display: flex; width: 100%; align-items: center; gap: 8px; text-align: left; min-height: 44px; border-radius: 10px; font-size: 14px; }
.new { justify-content: center; margin-top: 28px; border: 1px solid var(--line); background: var(--white); font-weight: 700; }
.new:hover, .thread:hover, .thread.selected { background: var(--hover); }
.recent { margin-top: 24px; overflow-y: auto; }
.recent h2 { color: var(--muted); font-size: 13px; font-weight: 650; margin: 0 0 8px 8px; }
.thread { border: 0; background: transparent; color: var(--muted-strong); padding: 0 12px; overflow-wrap: anywhere; }
.thread.selected { color: var(--ink); font-weight: 650; }
.rail-bottom { margin-top: auto; padding: 12px 4px 4px; }
.budget-label { display: flex; justify-content: space-between; gap: 4px; font-size: 12px; }
progress { display: block; width: 100%; height: 5px; border: 0; margin: 8px 0; accent-color: var(--accent); }
progress::-webkit-progress-bar { background: var(--line); border-radius: 10px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 10px; }
.fine { color: var(--muted); font-size: 12px; }
.workspace { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr) auto; height: 100dvh; min-width: 0; }
.top { min-height: 69px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 24px; }
.top-left, .top-right { min-width: 0; display: flex; align-items: center; gap: 8px; }
.model { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; }
.model > [data-icon] { pointer-events: none; position: absolute; left: 10px; color: var(--muted); }
.model > [data-icon]:last-child { right: 9px; left: auto; }
.model select { appearance: none; min-width: 0; width: 173px; min-height: 44px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-weight: 650; padding: 0 28px 0 36px; cursor: pointer; }
.status { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; padding: 0 8px; border-radius: 10px; border: 0; background: transparent; font-size: 12px; white-space: nowrap; }
.status[aria-pressed="true"] { background: var(--accent-soft); }
.status[aria-pressed="false"]:hover { background: var(--hover); }
.locked { color: var(--muted-strong); }
main { overflow: auto; min-width: 0; }
.view { max-width: 810px; margin: 0 auto; padding-inline: 24px; }
.chat-view { display: flex; flex-direction: column; height: 100%; }
.chat-body { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow: auto; }
.welcome { align-self: center; margin-block: auto; text-align: center; padding: 28px 4px; }
.welcome:not([hidden]) .chat-symbol { animation: symbol-in 280ms ease-out both; }
.chat-symbol { display: block; object-fit: contain; margin: 0 auto 8px; }
h1 { text-wrap: balance; margin: 0; min-width: 0; overflow-wrap: break-word; font-size: clamp(28px, 4.8vw, 53px); letter-spacing: -.065em; line-height: 1.22; }
.welcome h1 { font-size: 24px; }
.chat-footer { padding-block: 8px; }
.compose { border: 1px solid var(--line); border-radius: 18px; background: var(--white); padding: 8px; }
.compose:focus-within { border-color: var(--muted); }
.compose textarea { display: block; field-sizing: content; resize: none; width: 100%; min-height: 40px; max-height: 124px; padding: 8px; border: 0; background: transparent; font-size: 16px; }
.compose textarea::placeholder { color: var(--muted); }
.compose textarea:focus-visible { outline: none; }
.compose-actions, .compose-tools { display: flex; align-items: center; gap: 4px; }
.compose-actions { justify-content: space-between; }
.icon, .search { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 8px; background: transparent; border: 0; border-radius: 10px; }
.icon:hover, .search:hover { background: var(--hover); }
.search { font-size: 13px; font-weight: 650; }
.search[aria-pressed="true"] { background: var(--accent-soft); }
.send { background: var(--accent); color: var(--ink); border-radius: 50%; }
.send:hover:not(:disabled) { background: var(--accent-soft); }
.send:disabled { color: var(--muted); background: var(--rail); }
.attachment { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--rail); border-radius: 8px; padding-left: 8px; font-size: 13px; overflow-wrap: anywhere; }
.tabs { --tab-width: 99px; --tab-height: 56px; --tab-index: 0; position: relative; display: flex; justify-content: center; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { position: relative; width: var(--tab-width); min-height: var(--tab-height); display: grid; grid-template-rows: 28px 16px; justify-items: center; align-content: center; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 11px; transition: color 160ms ease-out; }
.tabs button:hover { background: var(--hover); }
.tabs button[aria-current] { color: var(--ink); font-weight: 750; }
.tab-indicator { position: absolute; pointer-events: none; top: calc((var(--tab-height) - 44px) / 2); left: calc(50% - var(--tab-width) * 1.5); width: var(--tab-width); height: 28px; display: grid; justify-items: center; transform: translateX(calc(var(--tab-index) * 100%)); transition: transform 200ms cubic-bezier(.2,.75,.25,1); }
.tab-indicator::before { content: ""; width: 44px; height: 28px; border-radius: 8px; background: var(--accent-soft); }
[data-icon] { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; }
svg { width: 17px; height: 17px; }
.send svg, .tabs svg { width: 19px; height: 19px; }
.mobile { display: none; }
.messages { min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 20px 4px 8px; }
.bubble { white-space: pre-wrap; overflow-wrap: anywhere; max-width: min(90%, 58ch); margin: 0; padding: 12px 16px; border-radius: 14px; background: var(--white); border: 1px solid var(--line); }
.bubble.user { align-self: flex-end; background: var(--accent-soft); }
.bubble.arriving { animation: message-in 170ms ease-out both; }
.other-view:not([hidden]) { animation: message-in 150ms ease-out both; }
.other-view { padding-block: 32px; }
.other-view h1 { margin-bottom: 20px; font-size: clamp(27px, 4vw, 40px); }
.panel { padding: 16px; border-radius: 14px; background: var(--white); border: 1px solid var(--line); margin-bottom: 12px; }
.panel h2 { margin: 0 0 8px; font-size: 18px; }
.panel p, .row { font-size: 14px; margin: 8px 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row strong { text-align: right; }
.row select { max-width: 60%; min-height: 44px; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions button, .basic { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--white); }
.actions .primary { background: var(--accent); }
.basic { align-self: flex-start; }
.basic:hover, .actions button:hover { background: var(--accent-soft); }
.startup, .login { width: min(100% - 32px, 390px); margin-inline: auto; }
.startup { padding-block: 32px; color: var(--muted); }
.login { display: grid; align-items: center; min-height: 100dvh; padding-block: 24px; }
.login-card { padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--white); }
.login h1 { margin-block: 20px 16px; font-size: 30px; }
.login img { display: block; margin: 12px auto; max-width: 100%; height: auto; }
.login details code { display: block; overflow-wrap: anywhere; margin-top: 8px; user-select: all; }
.field-form { display: grid; gap: 12px; }
.field-form label { display: grid; gap: 4px; font-size: 14px; }
.field-form input, .field-form textarea, .field-form select, .sheet select {
  min-width: 0; width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper); font-size: 16px;
}
.control { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--ink); text-decoration: none; font-size: 14px; }
.control:hover { background: var(--hover); }
.control.primary { background: var(--accent-soft); font-weight: 700; }
.control.primary:hover { background: var(--accent); }
.control.compact { min-height: 36px; font-size: 13px; }
.control.inline { border: 0; overflow-wrap: anywhere; min-width: 0; background: transparent; text-align: left; }
.control:disabled, .icon:disabled { opacity: .55; }
.feedback { color: var(--alert); font-size: 13px; margin: 4px 0; overflow-wrap: anywhere; }
.feedback:empty { display: none; }
.room-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block: 8px; font-size: 14px; }
.room-toolbar > span { overflow-wrap: anywhere; min-width: 0; }
.room-toolbar button { flex-shrink: 0; }
.room-trash { margin-top: 8px; padding: 0 8px; font-size: 13px; }
.room-trash summary, .panel summary, .sheet summary { cursor: pointer; min-height: 44px; align-content: center; }
.stack { display: grid; gap: 8px; }
.stack:empty { display: none; }
.entry { display: grid; gap: 4px; padding-block: 8px; border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.entry:last-child { border-bottom: 0; }
.entry > p { margin: 0; }
.entry .actions { flex-wrap: wrap; margin-top: 0; }
.entry .actions button { font-size: 13px; }
.panel > .stack + form { margin-top: 12px; }
.check-field { display: flex !important; align-items: center; gap: 8px; }
.check-field input { margin: 0; width: 18px; min-height: inherit; min-width: 18px; accent-color: var(--focus); }
.sheet { width: min(600px, 100% - 24px); max-height: min(85dvh, 720px); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--white); padding: 16px; }
.sheet h2 { margin-block: 0 12px; font-size: 20px; overflow-wrap: anywhere; }
.sheet h3 { font-size: 14px; }
.sheet::backdrop { background: var(--scrim); }
.file-text { white-space: pre-wrap; overflow-wrap: anywhere; overflow: auto; max-height: 230px; min-height: 40px; padding: 8px; border-radius: 8px; background: var(--rail); }
.search-panel { padding: 12px; margin-block: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.search-panel h2 { margin: 0; font-size: 16px; }
.search-panel ol { padding-inline-start: 24px; font-size: 14px; overflow-wrap: anywhere; }
.search-panel li + li { margin-top: 8px; }
.search-panel li p { margin: 0; }
.search-panel a { color: var(--focus); }
@keyframes message-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes symbol-in {
  from { opacity: 0; transform: translateY(5px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes drawer-in {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@media (max-width: 820px) {
  .app { display: block; }
  .mobile { display: inline-flex; }
  .rail { display: none; position: fixed; inset: 0 auto 0 0; z-index: 3; width: min(290px, 87%); }
  .rail.open { display: flex; animation: drawer-in 200ms ease-out both; }
  .brand .icon { margin-left: auto; }
  .scrim { position: fixed; inset: 0; z-index: 2; border: 0; background: var(--scrim); }
  .top { padding: 4px 8px; min-height: 52px; }
  .top-left, .top-right { gap: 4px; }
  .view { padding-inline: 10px; }
  .other-view { padding-block: 16px; }
  .other-view h1 { margin-bottom: 12px; font-size: 23px; }
  .panel { padding: 12px; }
  .panel h2 { font-size: 16px; }
}

@media (max-width: 520px) {
  .welcome { padding-block: 12px; }
  .welcome h1 { font-size: 19px; }
  .compose { padding: 4px; border-radius: 14px; }
  .chat-footer { padding-block: 4px; }
  .model select { width: 128px; font-size: 12px; padding-left: 8px; padding-right: 24px; }
  .model > [data-icon]:first-child { display: none; }
  .status { padding-inline: 4px; font-size: 11px; }
  .status svg { width: 14px; height: 14px; }
  .search > span:last-child { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .tabs { --tab-width: calc(100% / 3); --tab-height: 48px; }
}

@media (max-width: 350px) {
  .top { padding-inline: 4px; gap: 4px; }
  .top-left .icon { min-width: 44px; }
  .model select { width: 124px; }
  .status > [data-icon] { display: none; }
}

@media (min-width: 821px) {
  .app.rail-collapsed { grid-template-columns: minmax(0,1fr); }
  .app.rail-collapsed .rail { display: none; }
  .app:not(.rail-collapsed) #open-rail { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
