:root {
  color-scheme: light;
  --canvas: #f7f9fd;
  --paper: #fff;
  --ink: #172338;
  --muted: #526179;
  --line: #dce4ef;
  --accent: #244eaa;
  --accent-dark: #183980;
  --accent-pale: #e8effe;
  --danger: #a53125;
  --sidebar: #14213a;
  --sidebar-text: #e3eaf8;
  --sidebar-muted: #aebdd8;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box }
body { margin: 0 }
button, input, textarea { font: inherit }
button { cursor: pointer }
button:disabled { cursor: wait; opacity: .63 }
button, a, input, textarea { -webkit-tap-highlight-color: transparent }
:focus-visible { outline: 2px solid #597ee4; outline-offset: 3px }
[hidden] { display: none !important }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap }

.login-view { display: grid; min-height: 100dvh; place-items: center; padding: 24px; background: radial-gradient(ellipse at 42% 0%, #e5edfc, var(--canvas) 62%) }
.login-card { display: grid; gap: 14px; width: min(100%, 410px); padding: 40px; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 70px #1e396416 }
.login-card h1 { margin: 8px 0 16px; font-size: 1.65rem; letter-spacing: -.025em }
.login-card label, .project-form label { font-size: .9rem; font-weight: 650 }
.brand-mark, .welcome-mark { display: grid; place-items: center; flex: none; font-family: ui-monospace, monospace; font-weight: 750; letter-spacing: -.09em; padding-right: .11em }
.brand-mark { width: 35px; height: 35px; border-radius: 10px; background: #dce7ff; color: #173d89; font-size: 1.06rem }

.workspace { display: grid; grid-template-columns: 262px minmax(0, 1fr); height: 100dvh; overflow: hidden }
.sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--sidebar); color: var(--sidebar-text); padding: 24px 18px 16px }
.brand { display: flex; gap: 11px; align-items: center; margin: 0 5px 27px; font-weight: 750; color: #fff }
.brand-sub { font-weight: 570; color: #c9d6ef }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: #0e192c; border-radius: 10px; padding: 4px; margin-bottom: 16px }
.tabs button { border: 0; background: transparent; padding: 9px 5px; border-radius: 7px; color: var(--sidebar-muted); font-weight: 650; font-size: .9rem }
.tabs button[aria-pressed="true"] { color: #fff; background: #2b3c5a }
.tab-icon { margin-right: 6px; font-weight: 400 }
.new-button { display: flex; align-items: center; gap: 9px; text-align: left; height: 42px; padding: 0 10px; margin-bottom: 23px; border: 1px solid #425471; border-radius: 9px; color: #f2f6ff; background: transparent; font-size: .91rem; font-weight: 650 }
.new-button:hover, .sidebar-footer button:hover { background: #223350 }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden }
.sidebar-label { margin: 0 8px 8px; color: var(--sidebar-muted); font-size: .85rem; font-weight: 600 }
.sidebar-list { display: grid; gap: 3px }
.sidebar-item { width: 100%; padding: 9px; border: 0; border-radius: 7px; background: transparent; color: var(--sidebar-text); text-align: left; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-size: .91rem }
.sidebar-item:hover, .sidebar-item[aria-current="true"] { background: #2b3c5a; color: #fff }
.sidebar-empty { margin: 5px 8px; color: var(--sidebar-muted); font-size: .85rem }
.project-chats { margin-top: 21px; padding-top: 13px; border-top: 1px solid #364866 }
.project-chat-label { display: flex; align-items: center; justify-content: space-between }
.project-chat-label button { border: 0; border-radius: 6px; padding: 3px 6px; color: var(--sidebar-text); background: #2b3c5a }
.sidebar-footer { padding-top: 14px; border-top: 1px solid #364866; margin-top: 14px }
.sidebar-footer button { border: 0; background: transparent; color: var(--sidebar-muted); font-size: .89rem; border-radius: 7px; padding: 7px 8px }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column }
.topbar { min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 27px; border-bottom: 1px solid var(--line); background: var(--paper) }
.breadcrumb { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--muted); font-size: .91rem }
.breadcrumb strong, #section-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.breadcrumb strong { color: var(--ink); font-weight: 650 }
.crumb-separator { color: #74839b }
.mode-label { flex: none; margin-left: auto; padding: 5px 10px; border-radius: 20px; background: var(--accent-pale); color: var(--accent-dark); font-size: .83rem; font-weight: 660 }
.mode-label.elevated { background: #fbe4dd; color: #952f20 }
.menu-button, .scrim { display: none }
.scroll-area { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; display: flex; flex-direction: column }
.welcome { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto; padding: 33px 24px; text-align: center; width: min(100%, 52rem) }
.welcome-mark { width: 64px; height: 64px; background: #dce7ff; color: var(--accent-dark); border: 1px solid #c7d7fa; border-radius: 18px; font-size: 1.8rem; box-shadow: 0 8px 22px #244eaa17 }
.welcome h1 { font-size: clamp(1.65rem, 3.2vw, 2.45rem); letter-spacing: -.045em; margin: 21px 0 10px }
.welcome p { color: var(--muted); margin: 0; overflow-wrap: anywhere; line-height: 1.65 }
.welcome-actions { margin-top: 22px }
.transcript { width: min(100%, 54rem); margin: 0 auto; padding: 32px 28px 20px; display: grid; gap: 26px }
.turn { display: grid; gap: 18px; min-width: 0 }
.message { min-width: 0; line-height: 1.65; overflow-wrap: anywhere }
.message.user { justify-self: end; width: fit-content; max-width: 88%; background: var(--accent-pale); border: 1px solid #d5e0f8; border-radius: 15px 15px 3px 15px; padding: 10px 15px }
.message.user p { margin: 0; white-space: pre-wrap }
.message.assistant { border-left: 2px solid #c7d6ef; padding: 0 0 0 15px }
.message.assistant .message-label { font-weight: 750; color: #27426e; font-size: .88rem; margin-bottom: 5px }
.message p { margin: 0 0 .65em; white-space: pre-wrap }
.message p:last-child { margin-bottom: 0 }
.message h2, .message h3, .message h4 { line-height: 1.38; margin: .75em 0 .35em }
.message ul, .message ol { padding-left: 1.6em; margin: .45em 0 .75em }
.message a { color: var(--accent); text-underline-offset: .15em }
.message code { font-family: ui-monospace, monospace; font-size: .88em }
.message p code, .message li code { background: #e8edf5; border-radius: 4px; padding: 2px 4px }
.message pre { margin: .7rem 0; padding: 14px; overflow: auto; color: #f0f3fb; background: #19273c; border-radius: 9px; white-space: pre }
.message .turn-status, .turn-mode { color: var(--muted); font-size: .85rem }
.message .turn-error, .turn-mode { color: var(--danger) }

.composer { width: min(100%, 54rem); margin: 0 auto; padding: 6px 28px 22px }
.message-form { background: var(--paper); border: 1px solid var(--line); border-radius: 15px; overflow: hidden; box-shadow: 0 5px 24px #2437510b }
.message-form:focus-within { border-color: #9eb4e6 }
.message-form textarea { width: 100%; display: block; min-height: 70px; max-height: 34dvh; resize: vertical; border: 0; border-radius: 0; padding: 13px 15px; color: var(--ink); background: transparent; line-height: 1.48; outline: 0 }
.composer-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 10px 14px }
.composer-context { color: var(--muted); font-size: .84rem; display: grid; gap: 5px }
.full-option { display: flex; align-items: center; gap: 6px; width: fit-content; cursor: pointer; color: var(--ink) }
.full-option input { margin: 0; accent-color: var(--accent); width: 1rem; height: 1rem }
#full-detail { color: var(--danger) }
.primary, .secondary, .stop-button { border: 1px solid transparent; border-radius: 8px; font-weight: 650; min-height: 38px; padding: 7px 14px; font-size: .91rem; white-space: nowrap }
.primary { background: var(--accent); color: #fff }
.primary:hover { background: var(--accent-dark) }
.secondary, .stop-button { background: var(--paper); color: var(--ink); border-color: var(--line) }
.secondary:hover, .stop-button:hover { background: var(--accent-pale) }
.feedback { color: var(--danger); margin: 0; font-size: .9rem; overflow-wrap: anywhere }
.feedback:not(:empty) { margin-bottom: 8px }
.login-card input, .project-form input { width: 100%; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--paper); min-height: 42px; padding: 8px 10px }
dialog { width: min(calc(100% - 32px), 445px); border: 1px solid var(--line); border-radius: 15px; padding: 24px; color: var(--ink); background: var(--paper); box-shadow: 0 25px 65px #18283a30 }
dialog::backdrop { background: #101c34a0 }
.project-form { display: grid; gap: 10px }
.project-form h2 { margin: 0 0 10px; font-size: 1.35rem }
.field-help { color: var(--muted); font-size: .86rem; margin: 0; overflow-wrap: anywhere }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px }

@media (max-width: 700px) {
  .workspace { grid-template-columns: minmax(0, 1fr) }
  .sidebar { display: none; position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); z-index: 3 }
  .sidebar.open { display: flex }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; background: #101c3470; border: 0; z-index: 2 }
  .topbar { padding: 0 12px; min-height: 55px }
  .menu-button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--accent-dark); background: var(--accent-pale); border: 0; border-radius: 7px }
  .composer { padding: 4px 12px max(10px, env(safe-area-inset-bottom)) }
  .transcript { padding: 20px 14px }
  .keyboard-hint { display: none }
  .message.user { max-width: 95% }
  .login-card { padding: 28px }
}
