:root {
  --bg: #f7f7f5; --panel: #ffffff; --ink: #1d2330; --muted: #5d6675; --line: #e3e6ea; --soft: #f1f2f4;
  --accent: #e8590c; --accent-ink: #ffffff; --accent-soft: #fff1e8; --danger: #b3261e; --ok: #1e7a3d;
  --user: #1d2330; --user-ink: #ffffff; --code: #f3f4f6; --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171b; --panel: #1c1f24; --ink: #e8eaee; --muted: #a2a9b4; --line: #2d3138; --soft: #23262c;
    --accent: #ff7a2e; --accent-soft: #3a2518; --user: #2d3138; --user-ink: #e8eaee; --code: #262a31; --danger: #ff6b61; --ok: #5fd394;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* screens and panels use the hidden attribute */
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 12px; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.danger { background: var(--panel); color: var(--danger); border-color: var(--danger); font-weight: 600; }
.ghost { background: transparent; }
.icon { background: transparent; border: none; padding: 6px 8px; font-size: 16px; color: var(--muted); text-decoration: none; }
.big { padding: 12px 20px; font-size: 16px; width: 100%; }
.muted { color: var(--muted); } .small { font-size: 13px; } .error { color: var(--danger); }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 800; font-size: 14px; margin-right: 8px; }
.logo.sm { width: 26px; height: 26px; font-size: 11px; border-radius: 7px; }
.brand { display: flex; align-items: center; font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.screen { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(440px, 100%); }
.code { font: 700 30px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 3px; margin: 10px 0; }
.store-list { display: grid; gap: 8px; margin-top: 12px; }
.store-list button { text-align: left; padding: 12px 14px; font-weight: 600; }

#app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.store-name { display: flex; align-items: center; font-weight: 700; }
.spacer { flex: 1; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.pill.busy { background: var(--accent-soft); color: var(--accent); }
.body { flex: 1; display: flex; min-height: 0; }
#side { width: 250px; border-right: 1px solid var(--line); background: var(--panel); padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
#side.hidden { display: none; }
#chat-list a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
#chat-list a.active, #chat-list a:hover { background: var(--soft); }
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#messages { flex: 1; overflow-y: auto; padding: 20px 16px 8px; }
.msg { max-width: 780px; margin: 0 auto 16px; }
.msg.user .bubble { background: var(--user); color: var(--user-ink); border-radius: var(--radius); padding: 10px 14px; margin-left: auto; width: fit-content; max-width: 85%; white-space: pre-wrap; }
.msg.user img { max-width: 220px; border-radius: 8px; margin-top: 6px; display: block; margin-left: auto; }
.msg.assistant .text { line-height: 1.6; }
.text p { margin: 0 0 10px; } .text ul, .text ol { margin: 0 0 10px; padding-left: 22px; }
.text code { background: var(--code); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.text pre { background: var(--code); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.text pre code { background: none; padding: 0; }
.text table { border-collapse: collapse; margin: 0 0 10px; } .text th, .text td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
.text a { color: var(--accent); }
.steps { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; }
.step { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; }
.step .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; transform: translateY(-1px); }
.step.running .dot { background: var(--accent); animation: ezpulse 1s infinite; }
.step.completed .dot { background: var(--ok); }
.step.error .dot { background: var(--danger); } .step.error { color: var(--danger); }
@keyframes ezpulse { 50% { opacity: .3; } }
details.thinking { font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
details.thinking pre { white-space: pre-wrap; font: inherit; margin: 6px 0 0; }
.typing { color: var(--muted); font-size: 14px; }
.empty { position: absolute; inset: 0 0 120px 0; display: grid; place-content: center; text-align: center; padding: 16px; pointer-events: none; }
.empty h2 { margin: 0 0 6px; }
.examples { display: grid; gap: 8px; margin-top: 16px; pointer-events: auto; }
.example { text-align: left; color: var(--muted); }
#composer { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 16px 8px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; max-width: 820px; margin: 0 auto; }
#input { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; background: var(--bg); color: var(--ink); max-height: 200px; }
#input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.attach { cursor: pointer; }
#attachments { display: flex; gap: 6px; max-width: 820px; margin: 0 auto 6px; flex-wrap: wrap; }
#attachments img { height: 54px; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }
.hint { text-align: center; margin-top: 4px; }
#preview { width: 46%; min-width: 360px; border-left: 1px solid var(--line); display: flex; flex-direction: column; background: var(--panel); }
.preview-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; }
.tab { padding: 4px 10px; font-size: 13px; }
.tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
#preview-frame { flex: 1; border: 0; width: 100%; background: #fff; }
@media (max-width: 900px) {
  #side { position: absolute; z-index: 5; height: calc(100% - 52px); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
  #preview { position: absolute; inset: 52px 0 0 0; width: 100%; min-width: 0; z-index: 6; }
}

.mic.on { background: var(--danger); color: #fff; border-radius: 8px; font-size: 14px; font-weight: 600; padding: 10px 14px; }
.recording { flex: 1; display: flex; align-items: center; gap: 10px; border: 1px solid var(--danger); border-radius: 10px; padding: 10px 12px; background: var(--bg); min-height: 44px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: ezpulse 1s infinite; }
#rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.meter { flex: 1; max-width: 160px; height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .08s; }
.mic.busy { animation: ezpulse 1s infinite; }
