/* AI Master workspace. Same palette as the landing page: paper and ink, with the transit-line colours marking models. */
:root {
  color-scheme: light;
  --paper: #f6f6f3; --surface: #ffffff; --surface-2: #fbfbf9; --sunken: #efeee8;
  --ink: #16181d; --ink-2: #4b505a; --muted: #6c717b; --line: #e4e3dc; --line-2: #d2d1c9;
  --accent: #2a78d6; --btn: #16181d; --btn-ink: #ffffff; --btn-hover: #30343c;
  --pass: #16181d; --pass-ink: #f6f6f3; --pass-muted: #9ca1ab; --pass-line: #343943;
  --good: #138a3e; --warn-bg: #fff2d3; --warn-ink: #7a5200; --bad: #c0362f; --bad-bg: #fdebea;
  --ext-bg: #fff2d3; --ext-ink: #7a5200; --reg-bg: #e1f3e6; --reg-ink: #0f6a2c;
  --l1: #2a78d6; --l2: #eb6834; --l3: #1baf7a; --l4: #eda100; --l5: #e87ba4; --l6: #0f8a3a; --l7: #4a3aa7; --l8: #e34948;
  --logo-tile: #16181d; --logo-1: #3987e5; --logo-2: #eb6834; --logo-3: #1baf7a; --logo-dot: #ffffff;
  --code-bg: #121419; --code-ink: #e7e6e1;
  --shadow: 0 1px 2px rgba(16, 18, 24, .05), 0 8px 24px rgba(16, 18, 24, .07);
  --shadow-lg: 0 24px 60px rgba(16, 18, 24, .22);
  --f-cjk: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "PingFang SC", "Yu Gothic UI", "Microsoft YaHei", Meiryo, "Noto Sans JP", "Noto Sans SC";
  --f-display: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, var(--f-cjk), system-ui, sans-serif;
  --f-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, var(--f-cjk), system-ui, sans-serif;
  --f-mono: "Martian Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --f-code: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --side-w: 268px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0e1013; --surface: #15181d; --surface-2: #191c22; --sunken: #121418;
    --ink: #ecebe6; --ink-2: #b8bbc3; --muted: #8b909a; --line: #252930; --line-2: #353a43;
    --accent: #6ea8f0; --btn: #ecebe6; --btn-ink: #121418; --btn-hover: #ffffff;
    --pass: #1b1f26; --pass-ink: #f2f1ec; --pass-muted: #9ca1ab; --pass-line: #3a404b;
    --good: #4cc771; --warn-bg: #34290f; --warn-ink: #f2c25a; --bad: #f0605f; --bad-bg: #3a1716;
    --ext-bg: #34290f; --ext-ink: #f2c25a; --reg-bg: #0f2c19; --reg-ink: #6fd394;
    --l1: #4e95ea; --l2: #f07b4c; --l3: #2fc28c; --l4: #f0b22a; --l5: #ee93b6; --l6: #37b061; --l7: #8a7cf0; --l8: #f0605f;
    --logo-tile: #262b34; --logo-dot: #f2f1ec; --code-bg: #0b0d10;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0e1013; --surface: #15181d; --surface-2: #191c22; --sunken: #121418;
  --ink: #ecebe6; --ink-2: #b8bbc3; --muted: #8b909a; --line: #252930; --line-2: #353a43;
  --accent: #6ea8f0; --btn: #ecebe6; --btn-ink: #121418; --btn-hover: #ffffff;
  --pass: #1b1f26; --pass-ink: #f2f1ec; --pass-muted: #9ca1ab; --pass-line: #3a404b;
  --good: #4cc771; --warn-bg: #34290f; --warn-ink: #f2c25a; --bad: #f0605f; --bad-bg: #3a1716;
  --ext-bg: #34290f; --ext-ink: #f2c25a; --reg-bg: #0f2c19; --reg-ink: #6fd394;
  --l1: #4e95ea; --l2: #f07b4c; --l3: #2fc28c; --l4: #f0b22a; --l5: #ee93b6; --l6: #37b061; --l7: #8a7cf0; --l8: #f0605f;
  --logo-tile: #262b34; --logo-dot: #f2f1ec; --code-bg: #0b0d10;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
}
html[lang="ja"] { --f-cjk: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP"; }
html[lang="zh-CN"] { --f-cjk: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC"; }

*, *::before, *::after { box-sizing: border-box; }
html, body, #app { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--f-body); -webkit-font-smoothing: antialiased; }
html[lang="ja"] body { line-break: strict; }
[hidden] { display: none !important; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.logo { width: 30px; height: 30px; display: block; flex-shrink: 0; }
.lg-tile { fill: var(--logo-tile); }
.lg-1, .lg-2, .lg-3 { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.lg-1 { stroke: var(--logo-1); } .lg-2 { stroke: var(--logo-2); } .lg-3 { stroke: var(--logo-3); }
.lg-dot { fill: var(--logo-dot); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 11px; border: 1px solid transparent; font-weight: 650; font-size: .94rem; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .15s, border-color .15s, opacity .15s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--btn); color: var(--btn-ink); }
.btn-primary:hover:not(:disabled) { background: var(--btn-hover); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-2); }
.btn-quiet { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn-quiet:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .86rem; border-radius: 9px; }
.btn-block { width: 100%; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-weight: 600; font-size: .88rem; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line-2); background: var(--surface); border-radius: 11px; padding: 11px 13px; min-height: 44px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-2); }
.select { padding-right: 32px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.hint { font-size: .8rem; color: var(--muted); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: .9rem; background: var(--sunken); color: var(--ink-2); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.good { background: var(--reg-bg); color: var(--reg-ink); }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 600 .66rem/1 var(--f-mono); letter-spacing: .04em; padding: 5px 8px; border-radius: 6px; white-space: nowrap; }
.chip-ext { background: var(--ext-bg); color: var(--ext-ink); }
.chip-reg { background: var(--reg-bg); color: var(--reg-ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); flex-shrink: 0; }

/* Auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 32px max(16px, env(safe-area-inset-left, 0px)); }
.auth-card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 28px; display: grid; gap: 18px; }
.auth-brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 750 1.08rem/1 var(--f-display); font-stretch: 106%; }
.auth h1 { margin: 0; font: 780 1.55rem/1.2 var(--f-display); font-stretch: 104%; letter-spacing: -0.015em; text-wrap: balance; }
html[lang="ja"] .auth h1, html[lang="zh-CN"] .auth h1 { letter-spacing: 0; font-weight: 700; }
.auth p { margin: 0; color: var(--ink-2); }
.auth form { display: grid; gap: 14px; }
.auth .switch { font-size: .9rem; color: var(--ink-2); text-align: center; }
.auth .or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; }
.auth .or::before, .auth .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth .legal { font-size: .78rem; color: var(--muted); }
.lang-mini { border: 1px solid var(--line-2); background: var(--surface); border-radius: 9px; padding: 6px 26px 6px 10px; font-size: .82rem; min-height: 34px; }

/* Workspace shell */
.ws { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100%; }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); border-right: 1px solid var(--line); padding: 14px 12px max(14px, env(safe-area-inset-bottom, 0px)); gap: 10px; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 6px; }
.side .new { justify-content: flex-start; }
.side h2 { margin: 10px 6px 2px; font: 600 .66rem/1.2 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.chatlist { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 2px; }
.chatitem { display: flex; align-items: center; gap: 6px; border-radius: 9px; }
.chatitem button.open { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 9px; cursor: pointer; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.chatitem:hover button.open, .chatitem.active button.open { background: var(--sunken); color: var(--ink); }
.chatitem button.del { opacity: 0; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 7px; }
.chatitem:hover button.del, .chatitem.active button.del { opacity: 1; }
.side-foot { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; text-decoration: none; color: var(--ink-2); font-size: .92rem; }
.side-nav a:hover, .side-nav a.active { background: var(--sunken); color: var(--ink); }
.me { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 6px; font-size: .8rem; color: var(--muted); min-width: 0; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100%; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 10px 20px; border-bottom: 1px solid var(--line); background: var(--paper); }
.menu-btn { display: none; }
.modes { display: inline-flex; padding: 3px; background: var(--sunken); border-radius: 11px; gap: 2px; }
.modes button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: .88rem; color: var(--ink-2); cursor: pointer; }
.modes button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.balance { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 8px 6px 12px; }
.balance:hover { border-color: var(--ink-2); }
.balance b { font: 700 .86rem/1 var(--f-mono); }
.balance small { font: 600 .62rem/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.balance .plan-pill { font: 650 .62rem/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; padding: 5px 8px; border-radius: 999px; background: var(--pass); color: var(--pass-ink); }

/* Model bar */
.modelbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px 20px; border-bottom: 1px solid var(--line); background: var(--paper); }
.mchip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 5px 6px 5px 12px; max-width: 100%; min-width: 0; }
.mchip .name { font-weight: 650; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mchip .est { font: 600 .68rem/1 var(--f-mono); color: var(--muted); white-space: nowrap; }
.mchip button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.mchip button:hover { background: var(--sunken); color: var(--ink); }
.addmodel { border-style: dashed; }

/* Thread */
.thread { overflow-y: auto; padding: 22px max(16px, env(safe-area-inset-right, 0px)) 28px 20px; display: grid; align-content: start; gap: 26px; scroll-behavior: smooth; }
.empty { max-width: 640px; margin: 8vh auto 0; text-align: center; display: grid; gap: 12px; justify-items: center; }
.empty h1 { margin: 0; font: 800 clamp(1.6rem, 3vw, 2.2rem)/1.15 var(--f-display); font-stretch: 106%; letter-spacing: -0.02em; text-wrap: balance; }
html[lang="ja"] .empty h1, html[lang="zh-CN"] .empty h1 { letter-spacing: 0; font-weight: 750; }
.empty p { margin: 0; color: var(--ink-2); max-width: 52ch; }
.suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.suggest button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 12px; padding: 9px 13px; cursor: pointer; font-size: .88rem; color: var(--ink-2); text-align: left; max-width: 320px; }
.suggest button:hover { border-color: var(--ink-2); color: var(--ink); }
.turn { display: grid; gap: 12px; }
.umsg { justify-self: end; max-width: min(720px, 92%); background: var(--pass); color: var(--pass-ink); padding: 11px 15px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.replies { display: grid; gap: 12px; grid-template-columns: repeat(var(--n, 1), minmax(0, 1fr)); }
.reply { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; min-width: 0; }
.reply-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 650; font-size: .88rem; }
.reply-head .zone { margin-left: auto; }
.reply-body { padding: 12px 16px; overflow-wrap: anywhere; min-height: 44px; }
.reply-body > :first-child { margin-top: 0; } .reply-body > :last-child { margin-bottom: 0; }
.reply-body pre { background: var(--code-bg); color: var(--code-ink); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font: .82rem/1.6 var(--f-code); }
.reply-body code { font-family: var(--f-code); font-size: .88em; background: var(--sunken); padding: .1em .35em; border-radius: 5px; }
.reply-body pre code { background: none; padding: 0; }
.reply-body h3, .reply-body h4 { font-size: 1rem; margin: 1em 0 .4em; }
.reply-body ul, .reply-body ol { padding-left: 1.3em; }
.reply-body table { border-collapse: collapse; display: block; overflow-x: auto; }
.reply-body td, .reply-body th { border: 1px solid var(--line); padding: 4px 8px; }
.reasoning { margin: 0 16px; border-left: 3px solid var(--line-2); padding: 2px 0 2px 12px; color: var(--muted); font-size: .86rem; }
.reasoning summary { cursor: pointer; font: 600 .7rem/1.6 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; }
.reasoning div { white-space: pre-wrap; max-height: 260px; overflow-y: auto; }
.reply-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 14px; border-top: 1px dashed var(--line-2); margin-top: auto; font-size: .78rem; color: var(--muted); }
.reply-foot .cost { font: 700 .78rem/1 var(--f-mono); color: var(--ink); }
.reply-foot .tok { font-family: var(--f-mono); font-size: .7rem; }
.reply-foot .copy { margin-left: auto; }
.reply.err .reply-body { color: var(--bad); }
.cursor::after { content: ""; display: inline-block; width: .55em; height: 1em; margin-left: 2px; vertical-align: -0.15em; background: var(--ink); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Composer */
.composer { border-top: 1px solid var(--line); background: var(--paper); padding: 12px max(16px, env(safe-area-inset-right, 0px)) max(14px, env(safe-area-inset-bottom, 0px)) 20px; }
.compose-box { max-width: 980px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); padding: 10px 10px 10px 14px; display: grid; gap: 8px; }
.compose-box:focus-within { border-color: var(--ink-2); }
.compose-box textarea { border: 0; outline: none; resize: none; background: transparent; min-height: 26px; max-height: 240px; padding: 6px 2px; line-height: 1.5; }
.compose-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--sunken); padding: 3px; border-radius: 9px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: 7px; padding: 5px 10px; font-size: .78rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.compose-row .est-note { font-size: .74rem; color: var(--muted); flex: 1; min-width: 160px; }
.compose-row .send { margin-left: auto; }
.banner { max-width: 980px; margin: 0 auto 10px; }

/* Create (image / video) */
.create { overflow-y: auto; padding: 22px max(16px, env(safe-area-inset-right, 0px)) 28px 20px; display: grid; gap: 22px; align-content: start; grid-row: 2 / 5; }
.create-form { max-width: 980px; width: 100%; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; gap: 14px; }
.create-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); align-items: end; }
.gallery { max-width: 980px; width: 100%; margin: 0 auto; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.shot { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: grid; }
.shot img, .shot video { width: 100%; display: block; background: var(--sunken); aspect-ratio: var(--ar, 1); object-fit: cover; max-width: 100%; }
.shot .meta { padding: 9px 12px; display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: .78rem; color: var(--muted); }
.shot .meta p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot .wait { aspect-ratio: var(--ar, 1.777); display: grid; place-items: center; color: var(--muted); font: 600 .74rem/1.4 var(--f-mono); background: repeating-linear-gradient(135deg, var(--sunken) 0 12px, var(--surface-2) 12px 24px); text-align: center; padding: 12px; }

/* Model picker */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 16, .45); display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.dialog { width: min(100%, 640px); max-height: min(86vh, 760px); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; overflow: hidden; border: 1px solid var(--line); }
.dialog header { padding: 18px 20px 10px; display: grid; gap: 6px; }
.dialog header h2 { margin: 0; font: 760 1.2rem/1.2 var(--f-display); }
.dialog header p { margin: 0; color: var(--ink-2); font-size: .88rem; }
.dialog .search { padding: 0 20px 10px; }
.mlist { overflow-y: auto; padding: 4px 12px 12px; display: grid; gap: 4px; align-content: start; }
.mopt { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 10px; border-radius: 12px; border: 1px solid transparent; cursor: pointer; background: none; text-align: left; width: 100%; }
.mopt:hover { background: var(--surface-2); border-color: var(--line); }
.mopt[aria-checked="true"] { background: var(--surface-2); border-color: var(--ink-2); }
.mopt .box { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line-2); display: grid; place-items: center; }
.mopt[aria-checked="true"] .box { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }
.mopt .t { display: grid; gap: 2px; min-width: 0; }
.mopt .t b { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.mopt .t small { color: var(--muted); font: 500 .7rem/1.4 var(--f-mono); }
.mopt .p { text-align: right; font: 700 .76rem/1.2 var(--f-mono); }
.mopt .p small { display: block; font-weight: 500; color: var(--muted); font-size: .64rem; margin-top: 3px; }
.tag { font: 600 .58rem/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; padding: 3px 5px; border-radius: 4px; background: var(--sunken); color: var(--ink-2); }
.dialog footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Account & admin pages */
.page { overflow-y: auto; grid-row: 2 / 5; padding: 26px max(16px, env(safe-area-inset-right, 0px)) 40px 20px; }
.page-inner { max-width: 1000px; margin: 0 auto; display: grid; gap: 22px; }
.page h1 { margin: 0; font: 800 clamp(1.5rem, 2.6vw, 2rem)/1.15 var(--f-display); font-stretch: 106%; letter-spacing: -0.02em; }
html[lang="ja"] .page h1, html[lang="zh-CN"] .page h1 { letter-spacing: 0; font-weight: 750; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: grid; gap: 14px; min-width: 0; }
.card h2 { margin: 0; font: 760 1.1rem/1.2 var(--f-display); }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.meter { height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--c, var(--l1)); border-radius: 4px; }
.kv { display: grid; gap: 4px; }
.kv small { font: 600 .64rem/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kv b { font: 700 1.3rem/1.1 var(--f-mono); }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.plans { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.plancard { border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: grid; gap: 10px; align-content: start; background: var(--surface-2); }
.plancard.featured { background: var(--pass); color: var(--pass-ink); border-color: var(--pass-line); }
.plancard.featured .muted { color: var(--pass-muted); }
.plancard h3 { margin: 0; display: flex; align-items: center; gap: 8px; font: 780 1.15rem/1.2 var(--f-display); }
.plancard .price { font: 820 2.1rem/1 var(--f-display); font-stretch: 110%; letter-spacing: -0.03em; }
.plancard ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: .88rem; }
.plancard li::before { content: "✓"; margin-right: 8px; color: var(--good); font-weight: 700; }
.plancard.featured li::before { color: var(--l3); }
.plancard .btn { margin-top: 6px; }
.plancard.featured .btn-primary { background: var(--pass-ink); color: var(--pass); }
.tops { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tops button { min-height: 64px; border-radius: 13px; border: 1px solid var(--line-2); background: var(--surface-2); box-shadow: inset 0 -3px 0 var(--line); font: 700 1.1rem/1 var(--f-mono); cursor: pointer; }
.tops button:hover:not(:disabled) { border-color: var(--ink-2); }
.tops button:disabled { opacity: .45; cursor: not-allowed; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th { text-align: left; font: 600 .62rem/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .serving td { background: var(--reg-bg); }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.inline-form .field { flex: 1 1 160px; }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; background: var(--pass); color: var(--pass-ink); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .9rem; max-width: calc(100% - 32px); }
.boot { height: 100%; display: grid; place-items: center; color: var(--muted); font: 600 .8rem/1 var(--f-mono); }

/* Mobile */
@media (max-width: 860px) {
  .ws { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 40; transform: translateX(-102%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; padding-top: max(14px, env(safe-area-inset-top, 0px)); }
  .ws.nav-open .side { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform .2s ease; }
  .ws.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(10, 12, 16, .4); z-index: 30; }
  .menu-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; }
  .top { padding-left: max(12px, env(safe-area-inset-left, 0px)); gap: 8px; }
  .modelbar, .thread, .composer, .create, .page { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .replies { grid-template-columns: minmax(0, 1fr); }
  .modelbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .modelbar::-webkit-scrollbar { display: none; }
  .modelbar .mchip { flex-shrink: 0; }
  .balance small { display: none; }
  .modes button { padding: 7px 10px; }
  .tops { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
