/* Claude Phone: design tokens, layout and components. Light/dark via prefers-color-scheme. */
:root {
  --bg: #FAF9F5; --surface: #FFFFFF; --surface-2: #F1EFE8; --text: #1F1E1D; --muted: #6F6C66; --line: #E4E1D8;
  --accent: #D97757; --accent-strong: #C4623F; --accent-ink: #FFFFFF; --accent-soft: #F6E4DC;
  --user-bg: #EFE9DC; --warn: #C98A1B; --danger: #C0392B; --ok: #3C8D5A; --code-bg: #F3F1EA; --shadow: 0 8px 30px rgba(0, 0, 0, .12);
  --font: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --app-h: 100dvh;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413; --surface: #1F1E1D; --surface-2: #2A2927; --text: #F2F0EA; --muted: #A09D95; --line: #34322F;
    --accent: #E08863; --accent-strong: #EA9B79; --accent-ink: #1A1209; --accent-soft: #3A2A22;
    --user-bg: #2D2B28; --warn: #E0A93B; --danger: #E5675A; --ok: #6CC08B; --code-bg: #1B1A19; --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.45;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%; touch-action: pan-x pan-y; -webkit-user-select: none; user-select: none; }
input, textarea, pre, code, .md, .msg-user, .msg-error, .crumb { -webkit-user-select: text; user-select: text; }
/* No visible scrollbars anywhere (scrolling itself keeps working). */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }
body { position: fixed; inset: 0; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.noscript { padding: 24px; }
.clip-helper { position: fixed; left: -9999px; top: 0; opacity: 0; font-size: 16px; }

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-fill { fill: currentColor; stroke: none; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.app { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); display: flex; flex-direction: column; background: var(--bg); }
.screen { display: flex; flex-direction: column; flex: 1; min-height: 0; animation: screen-in .22s ease; }
.screen.pop { animation: screen-pop .2s ease; }
@keyframes screen-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes screen-pop { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; gap: 4px; min-height: calc(52px + var(--safe-t)); padding: var(--safe-t) calc(8px + var(--safe-r)) 0 calc(8px + var(--safe-l));
  background: var(--bg); border-bottom: 1px solid var(--line); flex: none; }
.topbar h1 { flex: 1; min-width: 0; margin: 0 0 0 6px; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--text); flex: none; }
.iconbtn:active { background: var(--surface-2); }
.iconbtn.on { color: var(--accent-strong); background: var(--accent-soft); }

.content { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px calc(16px + var(--safe-r)) calc(24px + var(--safe-b)) calc(16px + var(--safe-l)); }
.section-title { margin: 18px 4px 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.row:active { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.row .meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.row .icon { color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.running { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.empty { padding: 36px 12px; text-align: center; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 14px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); }
.btn:active { background: var(--accent-strong); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; }
.field { width: 100%; min-height: 48px; padding: 0 14px; font-size: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.field:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search { margin-bottom: 10px; }
.error-text { color: var(--danger); font-size: 14px; margin: 4px 2px 0; min-height: 20px; }

.login { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b)); max-width: 420px; width: 100%; margin: 0 auto; }
.login h1 { margin: 8px 0 0; font-size: 26px; }
.login p { margin: 0; color: var(--muted); }
.logo { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.logo .icon { width: 34px; height: 34px; }

.banner { flex: none; padding: 8px 16px; font-size: 14px; text-align: center; background: var(--accent-soft); color: var(--text); }
.banner.error { background: var(--danger); color: #fff; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; z-index: 60;
  max-width: 86vw; padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%); }

.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .4); display: flex; align-items: flex-end; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-height: 82dvh; display: flex; flex-direction: column; background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding-bottom: var(--safe-b); animation: rise .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; padding: 8px 8px 4px 20px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 18px; }
.sheet-body .section-title { margin: 10px 4px 2px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; width: 100%; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.opt .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt .meta { display: block; font-size: 13px; color: var(--muted); }
.crumb { font-family: var(--mono); font-size: 13px; color: var(--muted); padding: 2px 4px 6px; word-break: break-all; }
.hint { font-size: 14px; color: var(--muted); padding: 10px 14px; background: var(--surface-2); border-radius: 12px; }

.actionbar { flex: none; display: flex; gap: 8px; padding: 8px calc(12px + var(--safe-r)) calc(8px + var(--safe-b)) calc(12px + var(--safe-l)); border-top: 1px solid var(--line); background: var(--bg); }
.actionbar .btn { flex: 1; min-width: 0; padding: 0 12px; }
.content.has-bar { padding-bottom: 16px; }
.sheet-foot { position: sticky; bottom: 0; display: flex; flex-direction: column; gap: 8px; margin: 4px -16px -16px; padding: 10px 16px 12px; background: var(--bg); border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: 8px; }
.inline-form .field { flex: 1; min-width: 0; }
.usage-strip { display: flex; align-items: center; justify-content: center; gap: 20px; flex: none; width: 100%; min-height: 46px; padding: 4px 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 13px; color: var(--muted); }
.usage-strip:active { background: var(--surface-2); }
.u-item { display: inline-flex; align-items: center; gap: 7px; }
.u-pct { min-width: 3.2ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.meter { position: relative; display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: var(--accent); }
.meter.warn .fill { background: var(--warn); }
.meter.crit .fill { background: var(--danger); }
.usage-row { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.usage-head { display: flex; justify-content: space-between; font-weight: 600; }
.usage-row .meter { display: block; width: 100%; height: 8px; border-radius: 4px; background: var(--surface-2); }
.usage-row .meta { font-size: 13px; color: var(--muted); }
.hint.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.controls { display: flex; align-items: center; gap: 6px; padding: 8px calc(10px + var(--safe-r)) 8px calc(10px + var(--safe-l)); border-bottom: 1px solid var(--line); flex: none; }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: 1 1 0; min-width: 0; min-height: 40px; padding: 0 10px; border-radius: 20px; background: var(--surface-2); font-size: 14px; font-weight: 550; overflow: hidden; }
.chip .txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.mode { flex: 0 0 auto; }
.chip .icon { width: 16px; height: 16px; }
.chip.mode { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.chat-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px calc(16px + var(--safe-r)) 10px calc(16px + var(--safe-l)); display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.jump { position: absolute; right: 16px; bottom: 12px; width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); z-index: 5; }
.msg-user { align-self: flex-end; max-width: 86%; padding: 10px 14px; border-radius: 18px 18px 6px 18px; background: var(--user-bg); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-assistant { align-self: stretch; min-width: 0; display: flex; flex-direction: column; gap: 10px; font-size: 16.5px; }
.msg-error { align-self: stretch; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); overflow-wrap: anywhere; white-space: pre-wrap; font-size: 14px; }
.turn-foot { align-self: flex-start; font-size: 12px; color: var(--muted); }
.copy-msg { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 8px; font-size: 13px; color: var(--muted); border-radius: 8px; }
.copy-msg .icon { width: 15px; height: 15px; }
.status-line { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.status-line .icon { width: 16px; height: 16px; }

.md { overflow-wrap: anywhere; min-width: 0; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md .code, .md .table-wrap { margin: 0 0 .8em; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.1em 0 .4em; line-height: 1.25; }
.md h1 { font-size: 1.3em; } .md h2 { font-size: 1.18em; } .md h3, .md h4 { font-size: 1.05em; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: .2em 0; }
.md blockquote { padding: 2px 0 2px 12px; border-left: 3px solid var(--line); color: var(--muted); margin-left: 0; }
.md a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md code { font-family: var(--mono); font-size: .88em; padding: .1em .35em; border-radius: 6px; background: var(--code-bg); }
.md .code { border: 1px solid var(--line); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.md .code-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 2px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.md .code-copy { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 8px; color: var(--muted); font-size: 12px; }
.md .code-copy .icon { width: 14px; height: 14px; }
.md pre { margin: 0; padding: 10px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.md pre code { padding: 0; background: none; font-size: inherit; }
.md .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md table { border-collapse: collapse; font-size: 14px; }
.md th, .md td { padding: 6px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.caret { display: inline-block; width: 8px; height: 1.05em; margin-left: 2px; vertical-align: text-bottom; background: var(--accent); border-radius: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.tool, .thinking { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.tool > summary, .thinking > summary { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; cursor: pointer; list-style: none; font-size: 14px; }
.tool > summary::-webkit-details-marker, .thinking > summary::-webkit-details-marker { display: none; }
.tool .tname { font-weight: 650; flex: none; }
.tool .tsum { flex: 1; min-width: 0; color: var(--muted); font-family: var(--mono); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool .tstate { flex: none; display: grid; place-items: center; color: var(--muted); }
.tool .tstate .icon { width: 16px; height: 16px; }
.tool.err .tstate { color: var(--danger); }
.tool.ok .tstate { color: var(--ok); }
.tool .tbody, .thinking .tbody { border-top: 1px solid var(--line); padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.tool .tlabel { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tool pre, .thinking pre { margin: 0; max-height: 280px; overflow: auto; padding: 8px 10px; border-radius: 8px; background: var(--code-bg); font-family: var(--mono); font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.thinking > summary { color: var(--muted); }
/* No inner scroll area: the chat list scrolls (and follows the newest thought), a nested scroller trapped the swipe. */
.thinking pre { max-height: none; overflow: visible; font-family: var(--font); font-size: 14px; color: var(--muted); }

.composer { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 8px calc(12px + var(--safe-r)) calc(8px + var(--safe-b)) calc(12px + var(--safe-l)); border-top: 1px solid var(--line); background: var(--bg); }
.inputbox { flex: 1; min-width: 0; display: flex; align-items: flex-end; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); }
.inputbox:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.composer textarea { flex: 1; min-width: 0; min-height: 42px; max-height: 140px; padding: 10px 14px 10px 0; resize: none; border: 0; border-radius: 0 22px 22px 0; background: none; outline: none; font-size: 16px; line-height: 1.35; }
.attach { width: 42px; height: 42px; flex: none; display: grid; place-items: center; color: var(--muted); border-radius: 21px; }
.attach[disabled] { opacity: .35; }
.attach-bar { flex: none; display: flex; gap: 8px; padding: 8px calc(12px + var(--safe-r)) 8px calc(12px + var(--safe-l)); overflow-x: auto; -webkit-overflow-scrolling: touch; border-top: 1px solid var(--line); background: var(--bg); }
.attach-bar:not([hidden]) + .composer { border-top: 0; padding-top: 0; }
.attach-chip { position: relative; width: 64px; height: 64px; flex: none; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.attach-chip img { display: block; width: 100%; height: 100%; object-fit: cover; }
.attach-chip.busy img { opacity: .45; }
.attach-chip .spinner { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text); }
.attach-chip .x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 11px; background: rgba(0, 0, 0, .62); color: #fff; }
.attach-chip .x::after { content: ''; position: absolute; inset: -10px; }
.attach-chip .x .icon { width: 13px; height: 13px; }
.pics { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.pic { width: 128px; height: 128px; object-fit: cover; border-radius: 12px; background: var(--surface-2); display: block; }
.pic.missing { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: var(--muted); text-align: center; }
.lightbox { display: block; width: 100%; max-height: 68dvh; object-fit: contain; border-radius: 12px; background: var(--surface-2); }
@media (max-width: 400px) { .composer textarea::placeholder { font-size: 14px; } }
.usage-btn { --pct: 0; --ring: var(--accent); position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: conic-gradient(var(--ring) calc(var(--pct) * 1%), var(--line) 0); }
.usage-btn::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--surface-2); }
.usage-btn > * { position: relative; }
.usage-btn .icon { width: 20px; height: 20px; color: var(--muted); }
.usage-btn.warn { --ring: var(--warn); }
.usage-btn.crit { --ring: var(--danger); }
.mic { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; background: var(--surface-2); color: var(--text); flex: none; }
.mic.rec { background: var(--danger); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
.mic.cancel { background: transparent; color: var(--muted); }
.mic[disabled] { opacity: .6; }
.send { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }
.send[disabled] { opacity: .35; }
.send.stop { background: var(--text); color: var(--bg); }

.offline-bar { background: var(--text); color: var(--bg); text-align: center; font-size: 13px; padding: calc(4px + var(--safe-t)) 8px 4px; flex: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; } .caret { animation: none; } }
@media (min-width: 700px) { .content, .messages { padding-left: max(16px, calc((100vw - 760px) / 2)); padding-right: max(16px, calc((100vw - 760px) / 2)); } }
