/* Chomp · Pac-Man arcade theme */
:root {
  --bg: #000000;
  --surface: #050514;
  --surface-2: #0b0b2a;
  --maze: #1b1bd1;
  --maze-glow: rgba(27, 27, 209, .45);
  --maze-dim: #0e0e6e;
  --pellet: #ffb8ae;
  --pac: #ffe600;
  --pac-ink: #000;
  --text: #ffffff;
  --muted: #9b9bd9;
  --blinky: #ff2a2a;
  --pinky: #ffb8ff;
  --inky: #00ffff;
  --clyde: #ffb852;
  --ok: #37ff8b;
  --danger: #ff2a2a;
  --danger-soft: rgba(255, 42, 42, .15);
  --warn: #ffb852;
  --warn-soft: rgba(255, 184, 82, .15);
  --ok-soft: rgba(55, 255, 139, .12);
  --accent: var(--pac);
  --accent-soft: rgba(255, 230, 0, .12);
  --radius: 10px;
  --arcade: "Press Start 2P", "Courier New", monospace;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --tab-h: 66px;
  --top-h: 58px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain; min-height: 100dvh;
  background-image: radial-gradient(circle at 50% 50%, rgba(27,27,209,.08) 0, transparent 60%);
}
a { color: var(--pac); text-decoration: none; }
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; display: block; }
h1, h2, h3 { margin: 0; font-weight: 400; }
h1 { font-family: var(--arcade); font-size: 14px; letter-spacing: .02em; color: var(--pac); text-shadow: 0 0 10px rgba(255,230,0,.5); }
h2 { font-family: var(--arcade); font-size: 9px; color: var(--pellet); text-transform: uppercase; letter-spacing: .08em; margin: 24px 0 10px; display: flex; align-items: center; gap: 10px; }
h2::after { content: ""; flex: 1; height: 0; border-top: 3px dotted var(--pellet); opacity: .55; }
h3 { font-family: var(--arcade); font-size: 11px; color: var(--pac); line-height: 1.6; }
p { margin: 0 0 10px; line-height: 1.5; }
code, pre { font-family: var(--mono); }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 8px; min-height: var(--top-h);
  background: rgba(0,0,0,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 3px solid var(--maze); box-shadow: 0 3px 0 var(--maze-dim), 0 6px 18px var(--maze-glow);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.score { display: flex; flex-direction: column; align-items: flex-end; font-family: var(--arcade); line-height: 1.4; }
.score-label { font-size: 8px; color: var(--blinky); animation: blink 1s steps(2) infinite; }
.score-value { font-size: 11px; color: #fff; }
@keyframes blink { 50% { opacity: 0; } }
.iconbtn { width: 40px; height: 40px; border-radius: 8px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--pac); }
.iconbtn:active { background: var(--surface-2); }
.iconbtn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Main */
.view { padding: 14px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 96px); max-width: 720px; margin: 0 auto; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 6px calc(env(safe-area-inset-bottom) + 6px); background: rgba(0,0,0,.95);
  border-top: 3px solid var(--maze); box-shadow: 0 -3px 0 var(--maze-dim), 0 -6px 18px var(--maze-glow);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 2px; color: var(--muted); font-family: var(--arcade); font-size: 7px; letter-spacing: .04em; }
.tabbar a.active { color: var(--pac); text-shadow: 0 0 8px rgba(255,230,0,.6); }
.tabbar a svg { width: 22px; height: 22px; }

/* Maze cards */
.card {
  position: relative; background: var(--surface); border: 3px solid var(--maze); border-radius: var(--radius); padding: 14px;
  margin-bottom: 12px; box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px var(--maze-dim), 0 0 14px var(--maze-glow);
}
.card.tap { cursor: pointer; transition: transform .08s ease, box-shadow .15s; }
.card.tap:active { transform: scale(.985); box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px var(--maze-dim), 0 0 22px var(--maze-glow); }
.card.pac { border-color: var(--pac); box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px #7a6e00, 0 0 16px rgba(255,230,0,.35); }
.card.ghost-red { border-color: var(--blinky); box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px #6b0e0e, 0 0 16px rgba(255,42,42,.3); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 700; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; line-height: 1.4; }
.desc { font-size: 13.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; font-size: 14px; line-height: 1.5; }
.empty b { color: var(--pac); display: block; margin-bottom: 10px; font-family: var(--arcade); font-size: 10px; line-height: 1.7; }

/* Pellet trail (decorative) */
.pellets { display: flex; gap: 10px; justify-content: center; margin: 8px 0; }
.pellets i { width: 6px; height: 6px; background: var(--pellet); border-radius: 50%; }
.pellets i.power { width: 12px; height: 12px; animation: blink .6s steps(2) infinite; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 6px; font-family: var(--arcade); font-size: 7px; letter-spacing: .04em; text-transform: uppercase; background: var(--surface-2); color: var(--muted); white-space: nowrap; border: 1px solid var(--maze-dim); line-height: 1.2; }
.badge svg { width: 12px; height: 12px; }
.badge.ok { color: var(--ok); border-color: rgba(55,255,139,.4); }
.badge.bad { color: var(--blinky); border-color: rgba(255,42,42,.5); }
.badge.warn { color: var(--clyde); border-color: rgba(255,184,82,.5); }
.badge.accent { color: var(--pac); border-color: rgba(255,230,0,.5); }
.badge.inky { color: var(--inky); border-color: rgba(0,255,255,.5); }
.badge.pinky { color: var(--pinky); border-color: rgba(255,184,255,.5); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--blinky); } .dot.warn { background: var(--clyde); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 14px; border-radius: 8px;
  border: 3px solid var(--maze); background: var(--surface); color: #fff; font-family: var(--arcade); font-size: 9px; line-height: 1.5; letter-spacing: .02em;
  cursor: pointer; transition: transform .08s ease, background .15s; text-align: center; text-transform: uppercase;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--pac); color: var(--pac-ink); border-color: var(--pac); box-shadow: 0 0 14px rgba(255,230,0,.35); }
.btn.teal { background: var(--ok); color: #003; border-color: var(--ok); box-shadow: 0 0 14px rgba(55,255,139,.3); }
.btn.danger { background: transparent; color: var(--blinky); border-color: var(--blinky); }
.btn.ghost { background: transparent; border-color: var(--maze-dim); color: var(--muted); }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 10px; font-size: 8px; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btnrow .btn { flex: 1 1 calc(50% - 4px); }

/* Action grid */
.actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.action {
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 8px; border: 3px solid var(--maze); background: var(--surface);
  text-align: left; cursor: pointer; min-height: 74px; box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px var(--maze-dim);
}
.action:active { transform: scale(.97); }
.action svg { width: 22px; height: 22px; color: var(--pac); }
.action b { font-family: var(--arcade); font-size: 8px; line-height: 1.6; color: #fff; text-transform: uppercase; }
.action .meta { font-size: 12px; line-height: 1.35; }

/* Search */
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 3px solid var(--maze); border-radius: 8px; padding: 0 12px; height: 48px; margin-bottom: 14px; color: var(--pac); }
.search input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 16px; color: #fff; outline: none; min-width: 0; }
.search input::placeholder { color: var(--muted); }

/* FAB */
.fab {
  position: fixed; right: 16px; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); z-index: 25; height: 56px; padding: 0 18px 0 14px; border-radius: 999px;
  border: 3px solid #7a6e00; background: var(--pac); color: #000; font-family: var(--arcade); font-size: 9px; display: inline-flex; align-items: center; gap: 10px;
  box-shadow: 0 0 22px rgba(255,230,0,.5); cursor: pointer; text-transform: uppercase;
}
.fab:active { transform: scale(.96); }
.fab svg { width: 18px; height: 18px; }

/* Sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 40; animation: fade .18s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow: auto; background: var(--surface);
  border: 3px solid var(--maze); border-bottom: 0; border-radius: 16px 16px 0 0; padding: 10px 16px calc(env(safe-area-inset-bottom) + 18px);
  box-shadow: 0 -8px 40px var(--maze-glow); animation: up .22s cubic-bezier(.2,.8,.2,1); max-width: 720px; margin: 0 auto;
}
.sheet .grip { width: 44px; height: 5px; border-radius: 3px; background: var(--maze); margin: 4px auto 14px; }
.sheet h3 { margin-bottom: 6px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }

/* Composer */
.composer { position: relative; margin-top: 10px; }
.composer textarea {
  width: 100%; min-height: 128px; resize: vertical; border-radius: 8px; border: 3px solid var(--maze-dim); background: #000; color: #fff;
  font: inherit; font-size: 16px; padding: 12px 52px 12px 12px; line-height: 1.45; outline: none;
}
.composer textarea:focus { border-color: var(--pac); }
.composer textarea::placeholder { color: var(--muted); }
.mic { position: absolute; right: 8px; top: 8px; width: 40px; height: 40px; border-radius: 8px; border: 2px solid var(--maze); background: var(--surface); color: var(--pac); display: grid; place-items: center; cursor: pointer; }
.mic.on { background: var(--blinky); border-color: var(--blinky); color: #fff; animation: pulse 1.2s infinite; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 10px; border-radius: 999px; border: 2px solid var(--maze); background: var(--surface); font-family: var(--arcade); font-size: 7px; color: #fff; cursor: pointer; white-space: nowrap; text-transform: uppercase; }
.chip.on { background: var(--pac); color: #000; border-color: var(--pac); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.4; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-family: var(--arcade); font-size: 7px; color: var(--pellet); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select { width: 100%; height: 46px; border-radius: 8px; border: 3px solid var(--maze-dim); background: #000; color: #fff; font: inherit; font-size: 16px; padding: 0 12px; outline: none; }
.field input:focus { border-color: var(--pac); }
.field textarea { width: 100%; border-radius: 8px; border: 3px solid var(--maze-dim); background: #000; color: #fff; font: 13px/1.4 ui-monospace, monospace; padding: 8px 10px; outline: none; resize: vertical; word-break: break-all; }

/* Progress with Pac-Man */
.progress { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 8px; background: var(--surface-2); border: 2px solid var(--maze-dim); margin-top: 12px; }
.progress b { font-family: var(--arcade); font-size: 8px; color: var(--pac); line-height: 1.6; display: block; margin-bottom: 4px; text-transform: uppercase; }
.progress.ok { border-color: var(--ok); } .progress.ok b { color: var(--ok); }
.progress.bad { border-color: var(--blinky); } .progress.bad b { color: var(--blinky); }
.progress.warn { border-color: var(--clyde); } .progress.warn b { color: var(--clyde); }
.pacloader { display: flex; align-items: center; gap: 6px; flex: none; }
.pacman { width: 22px; height: 22px; border-radius: 50%; background: var(--pac); position: relative; flex: none;
  background: conic-gradient(from 30deg, transparent 0 60deg, var(--pac) 60deg 360deg); animation: chomp .35s steps(2) infinite; }
@keyframes chomp { 50% { background: conic-gradient(from 5deg, transparent 0 10deg, var(--pac) 10deg 360deg); } }
.pacloader i { width: 5px; height: 5px; border-radius: 50%; background: var(--pellet); animation: eat 1.05s linear infinite; }
.pacloader i:nth-child(3) { animation-delay: .35s; } .pacloader i:nth-child(4) { animation-delay: .7s; }
@keyframes eat { 0% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; transform: translateX(-18px); } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--maze-dim); border-top-color: var(--pac); animation: spin .9s linear infinite; flex: none; }

/* Diff */
.diff { margin-top: 10px; }
.diff details { border: 2px solid var(--maze-dim); border-radius: 8px; margin-bottom: 8px; background: #000; overflow: hidden; }
.diff summary { padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; color: var(--pellet); }
.diff pre { margin: 0; font-size: 11.5px; line-height: 1.5; overflow-x: auto; padding: 8px 0; border-top: 2px solid var(--maze-dim); }
.diff .l { padding: 0 10px; white-space: pre; }
.diff .l.add { background: rgba(55,255,139,.14); color: #d8ffe6; }
.diff .l.del { background: rgba(255,42,42,.16); color: #ffd9d9; }
.diff .l.hunk { color: var(--inky); background: var(--surface-2); }
.diff .l.meta { color: var(--muted); }

/* Checks */
.checks { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.check a { color: var(--muted); }

video { width: 100%; border-radius: 8px; background: #000; margin-top: 8px; border: 2px solid var(--maze-dim); }
.log { background: #000; color: #d6deeb; font-family: var(--mono); font-size: 11.5px; line-height: 1.5; padding: 12px; border-radius: 8px; border: 2px solid var(--maze-dim); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50dvh; overflow: auto; margin-top: 10px; }
.msg { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13.5px; margin-bottom: 6px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 60dvh; overflow-y: auto; padding: 12px; }
.bubble { max-width: 88%; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; border: 2px solid transparent; }
.bubble.user { align-self: flex-end; background: var(--pac); color: #000; border-bottom-right-radius: 4px; }
.bubble.user.queued { opacity: .6; }
.bubble.assistant { align-self: flex-start; background: var(--surface-2); color: #fff; border-color: var(--maze-dim); border-bottom-left-radius: 4px; }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-meta { font-family: var(--arcade); font-size: 6.5px; opacity: .75; margin-top: 8px; text-transform: uppercase; letter-spacing: .05em; }
.toolline { align-self: flex-start; font-size: 12px; color: var(--muted); padding: 2px 10px; font-style: italic; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 3px solid var(--maze); border-radius: 8px; padding: 12px 8px; text-align: center; box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px var(--maze-dim); }
.stat b { display: block; font-family: var(--arcade); font-size: 18px; color: var(--pac); margin-bottom: 8px; }
.stat span { font-family: var(--arcade); font-size: 6.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; line-height: 1.5; }
.stat.red b { color: var(--blinky); } .stat.cyan b { color: var(--inky); }
.ready { font-family: var(--arcade); font-size: 11px; color: var(--pac); text-align: center; margin: 6px 0 14px; letter-spacing: .05em; animation: blink 1.2s steps(2) infinite; }
.ghost-row { display: flex; justify-content: center; gap: 14px; margin: 10px 0; }
.ghost-row svg { width: 26px; height: 26px; }
.listitem { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 2px dotted var(--maze-dim); cursor: pointer; }
.listitem:last-child { border-bottom: 0; }
.listitem .title { font-size: 14px; }
.avatar { width: 38px; height: 38px; border-radius: 8px; background: var(--maze); color: var(--pac); display: grid; place-items: center; font-family: var(--arcade); font-size: 11px; flex: none; box-shadow: inset 0 0 0 2px #000; }

/* Login */
.login { min-height: calc(100dvh - var(--top-h) - 40px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; padding: 20px 8px; }
.login .logo { font-family: var(--arcade); font-size: 22px; color: var(--pac); text-shadow: 0 0 14px rgba(255,230,0,.6); line-height: 1.6; }
.login .tag { font-family: var(--arcade); font-size: 7px; color: var(--pellet); line-height: 1.8; max-width: 320px; }
.chase { display: flex; align-items: center; gap: 12px; height: 40px; overflow: hidden; width: 100%; max-width: 360px; position: relative; }
.chase .track { display: flex; align-items: center; gap: 12px; animation: chase 7s linear infinite; }
.chase .pacman { width: 28px; height: 28px; }
.chase svg { width: 26px; height: 26px; }
.chase i { width: 6px; height: 6px; background: var(--pellet); border-radius: 50%; }
@keyframes chase { from { transform: translateX(380px); } to { transform: translateX(-420px); } }
.press { font-family: var(--arcade); font-size: 9px; color: #fff; animation: blink 1s steps(2) infinite; }

/* Steps */
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.step { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.45; }
.step::before { counter-increment: s; content: counter(s); font-family: var(--arcade); font-size: 9px; color: #000; background: var(--pac); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; }

.sep { height: 0; border-top: 3px dotted var(--maze-dim); margin: 14px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 13.5px; align-items: center; }
.kv b { font-family: var(--arcade); font-size: 7px; color: var(--pellet); text-transform: uppercase; }

/* Toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px); z-index: 60; background: var(--pac); color: #000; padding: 12px 16px; border-radius: 8px; font-family: var(--arcade); font-size: 8px; line-height: 1.6; max-width: calc(100% - 32px); box-shadow: 0 0 20px rgba(255,230,0,.5); animation: up .2s; text-align: center; }
.toast.err { background: var(--blinky); color: #fff; box-shadow: 0 0 20px rgba(255,42,42,.5); }

/* Attachments */
.attachbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.attachbar .btn.sm { flex: none; }
.attchip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 2px solid var(--maze); background: var(--surface-2); font-size: 12px; color: #fff; max-width: 100%; }
.attchip img { width: 22px; height: 22px; object-fit: cover; border-radius: 4px; }
.attchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.attchip button { border: 0; background: transparent; color: var(--blinky); font-weight: 700; cursor: pointer; padding: 0 2px; }

/* Full-height picker sheet: search pinned at the top, list fills what the keyboard leaves */
.sheet.tall { height: 94dvh; max-height: 94dvh; display: flex; flex-direction: column; overflow: hidden; }
.sheet.tall .grip { flex: none; }
.picklist { flex: 1; min-height: 140px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* Rendered markdown inside chat bubbles */
.md p { margin: 0 0 8px; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px 18px; padding: 0; } .md li { margin-bottom: 3px; }
.md code { font-family: var(--mono); font-size: 12.5px; background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; }
.bubble.user .md code { background: rgba(0,0,0,.12); }
.md pre { margin: 6px 0; padding: 10px; background: #000; border: 2px solid var(--maze-dim); border-radius: 8px; overflow-x: auto; font-size: 12px; line-height: 1.45; }
.md pre code { background: transparent; padding: 0; font-size: 12px; }
.md .md-h1, .md .md-h2, .md .md-h3, .md .md-h4 { font-weight: 700; margin: 8px 0 4px; }
.md .md-h1 { font-size: 16px; } .md .md-h2 { font-size: 15px; } .md .md-h3, .md .md-h4 { font-size: 14px; }
.md hr { border: 0; border-top: 2px dotted var(--maze-dim); margin: 8px 0; }
.md a { color: var(--pac); text-decoration: underline; overflow-wrap: anywhere; }
.bubble.user .md a { color: #000; }
.md-media { display: block; max-width: 100%; max-height: 60dvh; border-radius: 8px; border: 2px solid var(--maze-dim); margin: 6px 0; background: #000; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs .thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 2px solid var(--maze); display: block; }
.thumbs video { width: 100%; }
.badge.pinky button, button.badge { cursor: pointer; }

/* Chat mode: Claude Code-style session page */
body.chatmode .view { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 150px); }
.chatbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0 8px; }
.chatbar .meta { margin: 0; font-size: 11.5px; }
.iconbtn.sm { width: 32px; height: 32px; }
.iconbtn.sm svg { width: 18px; height: 18px; }
.chat { display: block; max-height: none; overflow: visible; padding: 4px 0; }
.turn { margin: 12px 0; }
.turn.user { display: flex; justify-content: flex-end; }
.turn.user .bubble { max-width: 90%; }
.turn.assistant { display: flex; gap: 10px; align-items: flex-start; }
.turn.assistant .marker { color: var(--pac); font-size: 14px; line-height: 1.5; flex: none; width: 14px; }
.turn.assistant .md { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.5; color: #fff; }
.turn.working { align-items: center; color: var(--muted); }
details.tool { margin: 6px 0 6px 24px; font-size: 12.5px; color: var(--muted); }
details.tool summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-size: 13.5px; color: var(--text, #e8eaff); overflow-wrap: anywhere; }
details.tool summary .ticon { font-size: 15px; line-height: 1; width: 18px; text-align: center; flex: none; }
details.tool summary .ttext { flex: 0 1 auto; }
details.tool summary em { font-style: normal; font-size: 11.5px; margin-left: 2px; }
details.tool summary .snag { color: #ff6b6b; }
details.tool summary .busy { color: var(--muted); animation: blink 1s steps(2) infinite; }
details.tool.ok summary { opacity: .85; }
details.tool .toolcode-label { margin: 8px 0 0 15px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
details.tool pre.toolcode { color: #8f95c9; }
details.tool summary::-webkit-details-marker { display: none; }
details.tool summary .dot { width: 7px; height: 7px; }
details.tool pre { margin: 6px 0 0 15px; padding: 8px 10px; background: #000; border: 1px solid var(--maze-dim); border-radius: 8px; font-size: 11.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 40dvh; overflow: auto; color: #c7cbe8; }
.thumbs.small .thumb img { width: 72px; height: 72px; }
.bubble.user .thumbs { margin-top: 8px; }
.composerbar { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 24; background: rgba(0,0,0,.96); border-top: 2px solid var(--maze-dim); padding: 8px 10px; max-width: 720px; margin: 0 auto; }
.composerrow { display: flex; align-items: flex-end; gap: 6px; }
.composerrow textarea { flex: 1; min-height: 44px; max-height: 160px; resize: none; border-radius: 12px; border: 2px solid var(--maze-dim); background: #000; color: #fff; font: inherit; font-size: 16px; padding: 11px 12px; line-height: 1.4; outline: none; }
.composerrow textarea:focus { border-color: var(--pac); }
.composerrow .iconbtn { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--maze-dim); background: var(--surface); }
.composerrow .iconbtn.send { background: var(--pac); color: #000; border-color: var(--pac); }
.composerrow .iconbtn:disabled { opacity: .5; }
.attachrow { display: flex; flex-wrap: wrap; gap: 6px; }
.attachrow:empty { display: none; }
.attachrow .attachbar { margin: 0 0 6px; }
.badge.inky, .badge.pinky { padding: 4px 8px; }

/* Chat mode refinements: just the conversation, smaller type, tab bar hidden, menu in a drawer */
body.chatmode .tabbar { display: none; }
body.chatmode .view { padding: 8px 12px calc(env(safe-area-inset-bottom) + 110px); }
body.chatmode .composerbar { bottom: 0; padding-bottom: calc(env(safe-area-inset-bottom) + 8px); }
.chatbar { padding: 2px 0 6px; gap: 6px; }
.chatbar .badge { font-size: 6px; padding: 3px 6px; }
.chatbar .badge svg { width: 10px; height: 10px; }
.turn { margin: 10px 0; }
.turn.assistant .md { font-size: 13.5px; line-height: 1.5; }
.turn.assistant .marker { font-size: 12px; }
.bubble { font-size: 13.5px; padding: 8px 11px; border-radius: 12px; }
.md pre, .md pre code { font-size: 11px; }
details.tool { font-size: 11.5px; margin-left: 20px; }
details.tool summary { font-size: 13px; }
.thinkword { font-family: var(--arcade); font-size: 7.5px; color: var(--pac); letter-spacing: .04em; animation: blink 1.6s steps(2) infinite; }
.composerrow textarea { min-height: 40px; padding: 9px 11px; font-size: 15px; }
.composerrow .iconbtn { width: 40px; height: 40px; border-radius: 10px; }
.composerrow .iconbtn svg { width: 18px; height: 18px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(82vw, 340px); z-index: 45; background: var(--surface); border-left: 3px solid var(--maze); box-shadow: -8px 0 30px var(--maze-glow); transform: translateX(100%); transition: transform .18s ease; padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 12px); overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 3px dotted var(--maze-dim); }
.drawer-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: 10px; border: 2px solid var(--maze-dim); background: var(--surface-2); color: #fff; font-family: var(--arcade); font-size: 7.5px; text-align: left; cursor: pointer; line-height: 1.5; }
.drawer-item svg { width: 18px; height: 18px; color: var(--pac); flex: none; }
.drawer-item:active { background: var(--maze-dim); }

/* Composer: opaque, sits above the keyboard (the viewport meta resizes the page), textarea scrolls past 40% height */
.composerbar { background: #000; }
.composerrow textarea { max-height: 40vh; overflow-y: hidden; }
.sheet.tall { height: 100%; max-height: 100%; }
.turn.user.queued .bubble { opacity: .55; }
.turn.user.sent .bubble { opacity: .85; }

/* HTML / PDF cards and suggested replies in chat */
.doccard { display: flex; align-items: center; gap: 10px; margin: 6px 0; padding: 10px 12px; border: 2px solid var(--maze); border-radius: 10px; background: var(--surface-2); color: #fff; text-decoration: none !important; }
.doccard i { font-style: normal; font-family: var(--arcade); font-size: 7px; color: #000; background: var(--pac); padding: 4px 6px; border-radius: 4px; }
.doccard span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.doccard b { font-family: var(--arcade); font-size: 7px; color: var(--pac); }
.chip.suggestion { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 8px 24px; text-transform: none; font-family: var(--font); font-size: 12.5px; max-width: calc(100% - 24px); white-space: normal; text-align: left; border-color: var(--maze); }
.chip.suggestion svg { width: 14px; height: 14px; color: var(--pac); flex: none; }

/* Chat: keep status, model and cost pinned under the header while the conversation scrolls. */
body.chatmode .chatbar {
  position: sticky; top: var(--topbar-real, var(--top-h)); z-index: 19;
  margin: -8px -12px 6px; padding: 8px 12px 6px;
  background: rgba(0,0,0,.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--maze-dim);
}
/* Completed sessions */
.chip.done { display: inline-flex; align-items: center; margin: 4px 0 8px 24px; text-transform: none; font-family: var(--font); font-size: 12.5px; border-color: var(--ok); color: var(--ok); }
.completed-note { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px 24px; font-size: 12.5px; color: var(--ok); }
.completed-note svg { width: 16px; height: 16px; }
/* Toggle switch */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2); border: 2px solid var(--maze); transition: background .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + span { background: rgba(255,230,0,.18); border-color: var(--pac); }
.switch input:checked + span::before { transform: translateX(20px); background: var(--pac); }
.switch input:disabled + span { opacity: .5; }
.chip.done svg { width: 14px; height: 14px; margin-right: 6px; }
/* Full-screen image viewer */
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.95); display: grid; place-items: center; padding: calc(env(safe-area-inset-top) + 56px) 8px calc(env(safe-area-inset-bottom) + 16px); animation: fade .15s ease; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; touch-action: pinch-zoom; }
.lightbox-bar { position: fixed; top: calc(env(safe-area-inset-top) + 8px); right: 8px; display: flex; gap: 8px; align-items: center; }
.lightbox-close { background: var(--surface); border: 2px solid var(--maze); width: 44px; height: 44px; }
