:root {
  color-scheme: light;
  --ground: #f4f6f4; --surface: #fff; --raised: #f8faf8; --active: #e8f0eb;
  --ink: #20382d; --text: #24322b; --muted: #59685f; --faint: #667269;
  --accent: #185d4d; --accent-hover: #124a3d; --border: #e1e7e2; --control: #bbc8bf;
  --negative: #a33727; --warning-bg: #f4f0df; --warning-ink: #67551e;
  --radius: 8px; --radius-sheet: 16px; --gap: 24px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--text); font: 14px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button { min-height: 40px; cursor: pointer; border: 1px solid transparent; border-radius: var(--radius); padding: 8px 14px; transition: background-color .15s, border-color .15s; }
button:disabled { color: var(--muted); background: var(--raised); border-color: var(--border); cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--active); color: var(--ink); }
.primary { background: var(--accent); color: var(--surface); font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary { background: var(--surface); border-color: var(--control); color: var(--ink); font-weight: 500; }
.secondary:hover { border-color: var(--accent); background: var(--raised); }
.quiet { color: var(--muted); background: transparent; padding: 8px 10px; }
.quiet:hover:not(:disabled) { color: var(--ink); background: var(--active); }
.danger { color: var(--negative); }
.topbar { max-width: 1232px; margin: auto; padding: 28px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--accent); white-space: nowrap; }
.brand-mark { width: 30px; height: 34px; flex: none; }
.brand-name { font-size: 24px; font-weight: 600; letter-spacing: .04em; color: var(--ink); }
.brand-note { font-size: 14px; font-weight: 400; color: var(--muted); padding-left: 14px; margin-left: 4px; border-left: 1px solid var(--control); }
.account { display: flex; align-items: center; gap: 8px; }
#balance { color: var(--accent); background: var(--active); font-weight: 500; font-variant-numeric: tabular-nums; }
main { max-width: 1184px; margin: 4px auto 0; }
.notice { background: var(--warning-bg); color: var(--warning-ink); font-size: 12px; padding: 10px 16px; border-radius: var(--radius); margin-bottom: 16px; }
/* At 1440: 1184 = 272px history + 1px divider + 911px work area.
   Each work area uses 32px padding; composer and document share both edges. */
.workbench { display: grid; grid-template-columns: 272px minmax(0, 1fr); grid-template-rows: auto auto; border: 1px solid var(--border); border-radius: var(--radius-sheet); background: var(--surface); overflow: hidden; }
.workspace { display: contents; }
.composer { grid-column: 2; grid-row: 1; padding: 28px 32px 24px; min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
h1, h2, p { margin: 0; }
h1 { font-size: 24px; font-weight: 600; line-height: 1.4; color: var(--ink); }
h2 { font-size: 16px; font-weight: 600; line-height: 1.5; color: var(--ink); }
.composer-intro { font-size: 14px; color: var(--muted); margin-top: 8px; }
.composer > .section-head { flex-wrap: wrap; margin-bottom: 24px; }
.modes { display: flex; gap: 4px; border-radius: var(--radius); background: var(--raised); padding: 4px; flex: none; }
.modes button { color: var(--muted); background: transparent; min-height: 32px; padding: 4px 12px; border-radius: 6px; }
.modes .selected { color: var(--accent); background: var(--active); font-weight: 500; }
.source-label { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 14px; font-weight: 500; margin-bottom: 10px; }
.source-label span { font-size: 12px; color: var(--muted); font-weight: 400; }
textarea { display: block; resize: vertical; width: 100%; min-height: 116px; max-height: 300px; background: var(--raised); border: 1px solid var(--control); border-radius: var(--radius); padding: 16px; color: var(--text); line-height: 1.7; }
textarea::placeholder, input::placeholder { color: var(--faint); opacity: 1; }
textarea:focus { background: var(--surface); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 16px; }
.composer-foot p { font-size: 12px; color: var(--muted); max-width: 380px; }
.composer-foot .primary { min-width: 136px; min-height: 44px; flex: none; }
.composer-foot .primary span { margin-left: 14px; }
.history { grid-column: 1; grid-row: 1 / span 2; border-right: 1px solid var(--border); background: var(--raised); padding: 24px 20px; min-width: 0; }
.history .section-head { margin-bottom: 16px; }
.history .quiet { min-height: 32px; padding: 4px 8px; font-size: 12px; }
.history input { width: 100%; height: 40px; border: 1px solid var(--control); border-radius: var(--radius); padding: 8px 12px; background: var(--surface); color: var(--text); }
.muted { color: var(--muted); font-size: 12px; }
#list-status { margin-top: 20px; line-height: 1.8; }
#list-status:empty { margin: 0; }
.task-list { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; max-height: 640px; overflow: auto; }
.task-list:empty { margin: 0; }
.task-item { width: 100%; display: block; background: transparent; border: 1px solid transparent; padding: 12px; text-align: left; color: var(--text); }
.task-item:hover { border-color: var(--control); }
.task-item.selected { background: var(--active); border-color: transparent; }
.task-item strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; font-weight: 500; line-height: 1.6; overflow-wrap: anywhere; }
.task-item span { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.reader { grid-column: 2; grid-row: 2; min-width: 0; padding: 28px 32px; border-top: 1px solid var(--border); }
#empty-reader { padding: 12px 0; }
.empty-heading { display: flex; align-items: center; gap: 20px; }
.empty-heading svg { width: 32px; height: 38px; color: var(--accent); flex: none; }
.empty-heading h2 { font-size: 18px; font-weight: 500; }
.empty-heading p { color: var(--muted); margin-top: 6px; }
.output-types { display: flex; gap: 24px; padding-left: 52px; margin-top: 24px; color: var(--muted); font-size: 12px; }
.output-types span + span { border-left: 1px solid var(--control); padding-left: 24px; }
.reader .section-head { align-items: flex-start; margin-bottom: 8px; }
.reader .section-head button { flex: none; }
.reader h2 { overflow-wrap: anywhere; }
#reader-title { font-size: 20px; line-height: 1.6; }
#close-result { font-size: 12px; min-height: 32px; padding: 4px 8px; }
#task-meta { font-variant-numeric: tabular-nums; }
#task-status { color: var(--accent); margin-top: 16px; }
#task-status:empty { margin: 0; }
.result-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 8px 0; margin: 20px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.result-actions button { font-size: 12px; }
#timestamps[aria-pressed="true"] { color: var(--accent); background: var(--active); }
.transcript { font-size: 16px; line-height: 2; white-space: pre-wrap; overflow-wrap: anywhere; }
.segment { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 16px; padding: 8px 0; }
.segment time { font: 12px/2 var(--font); color: var(--accent); padding-top: 4px; font-variant-numeric: tabular-nums; }
#task-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
#task-controls:not(:has(button:not([hidden]))) { display: none; }
.error { color: var(--negative); font-size: 14px; margin-top: 12px; }
.file-picker { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 146px; padding: 16px; border: 1px dashed var(--control); border-radius: var(--radius); background: var(--raised); cursor: pointer; }
.file-picker svg { width: 24px; height: 24px; color: var(--accent); margin-bottom: 4px; }
.file-picker strong { font-weight: 500; overflow-wrap: anywhere; }
.file-picker span { font-size: 12px; color: var(--muted); }
.file-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-picker:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
footer { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 4px 28px; color: var(--muted); font-size: 12px; }
footer button { font-size: 12px; }
dialog { width: min(420px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 32px; border: 1px solid var(--border); border-radius: var(--radius-sheet); color: var(--text); background: var(--surface); overflow: auto; box-shadow: 0 16px 64px #13271e26; }
dialog::backdrop { background: #172c2366; }
dialog h2 { font-size: 24px; margin: 0 20px 12px 0; }
dialog p { margin: 12px 0; font-size: 14px; }
dialog .dialog-close { position: absolute; right: 12px; top: 12px; min-width: 40px; font-size: 24px; padding: 0; }
.dialog-brand { display: block; font-size: 14px; font-weight: 600; color: var(--accent); margin-bottom: 20px; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 250px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--raised); margin: 24px 0 12px; }
.qr-wrap img { display: block; width: 210px; height: 210px; object-fit: contain; padding: 8px; }
.qr-wrap p { padding: 0 12px; text-align: center; font-size: 12px; color: var(--muted); }
#login-dialog { text-align: center; }
#login-dialog h2 { margin-right: 0; }
#refresh-code { font-size: 12px; }
.login-benefit { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 20px; font-weight: 500; }
.small { font-size: 12px; }
.wallet-total { font-size: 32px; line-height: 1.4; color: var(--ink); font-variant-numeric: tabular-nums; }
.wallet-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-top: 1px solid var(--border); padding: 12px 0; font-size: 12px; }
.wallet-row span:last-child { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
#ledger { margin-top: 24px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); background: var(--ink); color: var(--surface); padding: 12px 20px; border-radius: var(--radius); z-index: 20; font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
@media (max-width: 1232px) { main { margin-left: 24px; margin-right: 24px; } }
@media (min-width: 721px) and (max-width: 1000px) {
  .workbench { grid-template-columns: 224px minmax(0, 1fr); }
  .composer, .reader { padding: 24px; }
  .history { padding: 20px 16px; }
  .source-label { flex-direction: column; gap: 4px; }
  .composer-foot { flex-direction: column; align-items: stretch; gap: 12px; }
  .composer-foot .primary { align-self: flex-end; }
  .output-types { gap: 12px; padding-left: 0; }
  .output-types span + span { padding-left: 12px; }
}
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; gap: 12px; }
  .brand-note { display: none; }
  .brand-name { font-size: 24px; }
  .account { gap: 4px; }
  .account button { min-height: 44px; padding: 8px 10px; font-size: 12px; }
  main { margin: 0 16px; }
  .notice { padding: 8px 12px; margin-bottom: 12px; }
  .workbench { display: flex; flex-direction: column; }
  .composer { padding: 20px; }
  h1 { font-size: 24px; }
  .composer-intro { display: none; }
  .composer > .section-head { gap: 16px; margin-bottom: 16px; }
  .modes { width: 100%; }
  .modes button { flex: 1; min-height: 40px; }
  .source-label { flex-direction: column; align-items: flex-start; gap: 6px; }
  .source-label span { font-size: 12px; }
  textarea { height: 100px; min-height: 100px; padding: 12px; }
  .composer-foot { flex-wrap: wrap; gap: 16px; }
  .composer-foot p { order: 2; }
  .composer-foot .primary { width: 100%; min-height: 44px; }
  .history { padding: 20px; border-right: none; border-top: 1px solid var(--border); }
  .history .quiet { min-height: 44px; font-size: 14px; }
  .history input { height: 44px; }
  .task-list { max-height: 360px; }
  .reader { padding: 24px 20px; }
  .reader:has(#result[hidden]) { display: none; }
  .workbench:has(#result:not([hidden])) .history { display: none; }
  .reader .section-head { gap: 12px; }
  #reader-title { font-size: 18px; }
  #close-result { min-height: 44px; }
  .result-actions { gap: 0; }
  .result-actions button { min-height: 44px; padding: 8px; }
  .segment { gap: 12px; }
  footer { gap: 8px; padding: 12px 0 20px; }
  footer > span { max-width: 180px; }
  footer button { flex: none; min-height: 44px; }
  dialog { padding: 28px 24px; }
  dialog h2 { font-size: 20px; }
  dialog button { min-height: 44px; }
  .qr-wrap { margin-top: 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }

/* Account-bound MCP connection and consent. */
.mcp-dialog { width: min(640px, calc(100vw - 32px)); }
.mcp-dialog h3 { margin: 24px 0 10px; font-size: 16px; }
.mcp-dialog ol, .mcp-dialog ul { padding-left: 22px; line-height: 1.8; }
.mcp-dialog details { margin: 16px 0; }
.mcp-dialog summary { cursor: pointer; font-weight: 600; }
.mcp-dialog a { color: var(--accent, #28583d); text-underline-offset: 3px; }
.mcp-address { display: flex; gap: 10px; align-items: center; }
.mcp-address input { min-width: 0; flex: 1; font-size: 13px; }
.mcp-consent { border-left: 3px solid #28583d; padding: 0 0 12px 18px; margin: 22px 0; }
.mcp-consent code { display: block; overflow-wrap: anywhere; margin-top: 8px; font-size: 12px; }
.mcp-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.mcp-connection { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid #dfe5df; padding: 10px 0; }
.mcp-connection span { min-width: 0; overflow-wrap: anywhere; }
@media(max-width: 600px) { .topbar .account { gap: 2px; flex-wrap: wrap; justify-content: flex-end; } .topbar .account .quiet { padding: 8px; } }
.mcp-address input { min-height: 44px; padding: 10px 12px; border: 1px solid #b6c6bd; border-radius: 8px; background: #f7faf8; color: #243b31; }
