:root {
  color-scheme: light;
  --paper: #f5f5f3;
  --surface: #fff;
  --ink: #27292b;
  --muted: #555f63;
  --line: #d7dddb;
  --mark: #28473f;
  --player: #e6eeeb;
  font-family: 'Microsoft YaHei', 'PingFang SC', system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
html, body, body * { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar, body *::-webkit-scrollbar { display:none; width:0; height:0; }
#reading, #bag-list { scrollbar-gutter: auto; }
[hidden] { display: none !important; }
body { margin: 0; height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.masthead { padding: max(12px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 8px max(22px, env(safe-area-inset-left)); }
h1 { margin: 0; font-size: 1.25rem; font-family: 'Songti SC', 'SimSun', serif; line-height: 1.5; font-weight: 700; }
#reading { overflow: auto; }
.history { width: min(100% - 40px, 710px); margin-inline: auto; padding-block: 25px 22px; display: flex; flex-direction: column; gap: 24px; }
.message { min-width: 0; max-width: 100%; }
.message span { display: block; font-size: .81rem; margin: 0 1px 7px; color: var(--muted); }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1rem; line-height: 1.85; }
.message.assistant { align-self: flex-start; }
.message.assistant p { padding: 12px 16px; background: var(--surface); border: 1px solid #e5e5e0; border-radius: 4px 14px 14px 14px; }
.message.user { align-self: flex-end; max-width: min(88%, 52ch); }
.message.user span { text-align: right; }
.message.user p { padding: 8px 13px; background: var(--player); border-radius: 12px 4px 12px 12px; }
.bottom { width: min(100% - 36px, 650px); margin-inline: auto; padding: 5px 0 max(14px, env(safe-area-inset-bottom)); }
.composer { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px 7px; box-shadow: 0 5px 18px #1627220b; }
.composer textarea { display: block; width: 100%; min-height: 56px; max-height: 150px; resize: vertical; padding: 7px; border: 0; background: transparent; }
.composer-bar { display: flex; gap: 4px; align-items: center; }
.composer-bar .primary { margin-left: auto; }
.composer-bar { flex-wrap: wrap; }
.composer-bar > button:not(.model) { flex-shrink: 0; }
.direction-tool[data-active=true] { color: var(--mark); background: var(--player); }
.direction-tool small { font-size: .7rem; margin-inline-start: 4px; }
.status-dot { display: inline-block; background: currentColor; width: 5px; height: 5px; border-radius: 50%; margin: 0 0 3px 4px; }
.aside-panel { border-bottom: 1px solid var(--line); padding: 0 6px 10px; }
.aside-head, .plan-actions { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.aside-head label { color: var(--mark); font-size: .88rem; font-weight: 600; }
.aside-panel small { color: var(--muted); font-size: .8rem; }
.aside-panel textarea, #heaven-text { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; font: inherit; background: var(--paper); line-height: 1.55; }
.composer .aside-panel textarea { min-height: 3em; max-height: 16dvh; margin: 0 0 4px; }
#heaven-text { resize: vertical; min-height: 80px; max-height: 28dvh; }
.scope { border: 0; margin: 14px 0; padding: 0; }
.scope legend { font-size: .92rem; }
.scope label { display: inline-flex; align-items: center; gap: 5px; min-height: 42px; margin-right: 12px; white-space: nowrap; }
.scope input { accent-color: var(--mark); }
.plan-actions { justify-content: flex-end; flex-wrap: wrap; }
.plan-actions > :first-child { margin-right: auto; }
button, textarea, input, select { font: inherit; color: inherit; }
button { min-height: 42px; cursor: pointer; border-radius: 8px; border: 1px solid transparent; padding: 6px 12px; }
button:disabled { opacity: .53; cursor: default; }
.tool { color: var(--muted); background: transparent; }
.tool:not(:disabled):hover, .model:hover { background: var(--player); }
.model { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52%; color: var(--mark); background: var(--paper); }
.primary { border-color: var(--mark); color: #fff; background: var(--mark); }
.primary:not(:disabled):hover { background: #1b362f; }
:focus-visible { outline: 2px solid #46796b; outline-offset: 2px; }
.notice { margin: 2px 0 8px; font-size: .86rem; line-height: 1.5; color: #883d33; overflow-wrap: anywhere; }
dialog { width: min(100% - 28px, 620px); max-height: 85vh; overflow: auto; border: 1px solid var(--line); border-radius: 14px; padding: 15px 19px 17px; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: #20262661; }
.dialog-head, .dialog-buttons { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-head h2 { margin: 0; font-size: 1.1rem; }
.dialog-buttons { margin-block: 8px; }
#connection > label, #model-picker label, .compact { display: grid; gap: 5px; margin: 11px 0; font-size: .92rem; }
input:not([type=checkbox]):not([type=radio]), select { min-width: 0; width: 100%; min-height: 42px; border: 1px solid var(--line); padding: 7px 9px; border-radius: 6px; background: var(--surface); font-size: 1rem; }
details { border-top: 1px solid var(--line); padding: 9px 0; }
summary { cursor: pointer; color: var(--mark); line-height: 1.6; overflow-wrap: anywhere; }
.preset-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); font-size: .9rem; }
.preset-list label { display: flex; min-height: 42px; align-items: center; gap: 5px; }
pre { font: inherit; font-size: .9rem; line-height: 1.65; margin: 7px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.muted { color: var(--muted); font-size: .87rem; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 540px) {
  .masthead { padding-left: 17px; }
  .history { width: calc(100% - 26px); padding-top: 16px; gap: 20px; }
  .bottom { width: calc(100% - 20px); }
  button { min-height: 44px; }
  .composer-bar { gap: 2px; }
  .composer-bar button { padding-inline: 7px; font-size: .9rem; }
  .composer-bar .model { flex: 0 1 auto; max-width: 25%; }
}
