:root {
  --deep: #07080d; --page: #0b0d14; --card: #11141c; --raised: #1a1e28;
  --line: rgba(238,240,245,0.08); --line-soft: rgba(238,240,245,0.06);
  --text: #eef0f5; --text2: #a3a9b8; --muted: #7a8296;
  --accent: #6fd3e8; --ok: #4cc38a; --warn: #e0a53c; --bad: #e5484d; --bad-text: #ff8589;
  --ease: cubic-bezier(0.22,1,0.36,1);
  --sans: 'IBM Plex Sans', 'Noto Sans Lao', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--page); color: var(--text); font-family: var(--sans); -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.shell { height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }
.main { flex: 1; overflow-y: auto; padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); } .text2 { color: var(--text2); }
.small { font-size: 12px; } .s13 { font-size: 13px; }
.lao { font-family: 'Noto Sans Lao', var(--sans); }
h1 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 500; }
h2 { margin: 0; font-size: 15px; font-weight: 500; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.pad { padding: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.tnum { font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 4px; flex-shrink: 0; background: currentColor; transition: color 300ms var(--ease); }
.dot.ok { color: var(--ok); } .dot.bad { color: var(--bad); } .dot.warn { color: var(--warn); } .dot.off { color: #3a4150; }
.beat { position: relative; }
.beat.ringA::after, .beat.ringB::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid currentColor; opacity: 0; }
.beat.ringA::after { animation: ringA 900ms var(--ease) 1; }
.beat.ringB::after { animation: ringB 900ms var(--ease) 1; }
@keyframes ringA { from { opacity: .7; transform: scale(.6); } to { opacity: 0; transform: scale(1.6); } }
@keyframes ringB { from { opacity: .7; transform: scale(.6); } to { opacity: 0; transform: scale(1.6); } }
.rise { animation: rise 420ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.open { animation: open 300ms var(--ease) both; }
@keyframes open { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pop { animation: pop 360ms var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.spin { animation: spin 900ms linear infinite; }
.spin-once { animation: spinOnce 700ms var(--ease) 1; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spinOnce { to { transform: rotate(360deg); } }
.draw { stroke-dasharray: 800; animation: draw 1200ms var(--ease) both; }
@keyframes draw { from { stroke-dashoffset: 800; } to { stroke-dashoffset: 0; } }
.slideA { animation: slideA 600ms var(--ease) 1; } .slideB { animation: slideB 600ms var(--ease) 1; }
@keyframes slideA { from { transform: translateX(5px); } to { transform: none; } }
@keyframes slideB { from { transform: translateX(5px); } to { transform: none; } }

.btn { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; cursor: pointer; text-decoration: none;
  transition: background-color 160ms var(--ease), transform 120ms var(--ease), opacity 160ms var(--ease); }
.btn:hover { background: var(--raised); }
.btn:active { transform: scale(0.97); }
.btn.solid { background: var(--text); color: var(--page); border: 0; font-weight: 500; }
.btn.solid:hover { background: #fff; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.big { height: 48px; font-size: 15px; }
.icon-btn { width: 44px; height: 44px; padding: 0; flex-shrink: 0; color: var(--text2); }
.field { height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 0 12px; font-size: 15px; width: 100%; transition: border-color 160ms var(--ease); }
.field:focus { border-color: rgba(111,211,232,0.6); outline: none; }
textarea.field { height: auto; min-height: 48px; max-height: 140px; padding: 12px; resize: none; line-height: 20px; font-size: 14px; }
select.field { height: 36px; font-family: var(--mono); font-size: 12px; padding: 0 8px; }
label.lbl { font-size: 13px; color: var(--text2); }
.err { color: var(--bad-text); font-size: 13px; min-height: 20px; }

.nav { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); border-top: 1px solid var(--line); background: var(--deep); padding-bottom: env(safe-area-inset-bottom); }
.nav a { height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 12px; }
.nav a.on { color: var(--text); font-weight: 500; }
.nav a.on svg { stroke: var(--accent); }

.list { overflow: hidden; }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 40px; border-top: 1px solid var(--line-soft); color: var(--text); text-decoration: none; transition: background-color 160ms var(--ease); }
.list > .item:first-child { border-top: 0; }
.list > .item:hover { background: var(--raised); }
.bar { height: 4px; background: var(--raised); border-radius: 2px; overflow: hidden; }
.bar > div { height: 4px; border-radius: 2px; transition: width 400ms var(--ease); }

.svc { overflow: hidden; transition: border-color 300ms var(--ease); }
.svc.down { border-color: rgba(229,72,77,0.4); }
.svc.done { border-color: rgba(76,195,138,0.4); }
.svc-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 52px; background: none; border: 0; text-align: left; cursor: pointer; }
.chev { transition: transform 200ms var(--ease); }
.svc.expanded .chev { transform: rotate(180deg); }
.progress { height: 2px; }
.progress > div { height: 2px; background: var(--accent); transform-origin: left center; transform: scaleX(0); opacity: 0; transition: transform 900ms var(--ease), opacity 300ms var(--ease); }
dl.facts { margin: 0; display: grid; grid-template-columns: 72px minmax(0,1fr); gap: 8px; font-size: 13px; }
dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; color: var(--text2); word-break: break-all; }
pre.log { margin: 0; background: var(--deep); border: 1px solid var(--line-soft); border-radius: 8px; padding: 12px; font-family: var(--mono); font-size: 11px; line-height: 18px; color: var(--text2); white-space: pre-wrap; word-break: break-all; max-height: 320px; overflow: auto; }
.confirm { background: var(--raised); border-radius: 10px; padding: 12px; }
.btns { display: grid; gap: 8px; }

.thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; font-size: 14px; line-height: 20px; }
.msg { animation: rise 300ms var(--ease) both; }
.bubble { align-self: flex-end; max-width: 85%; background: var(--raised); border: 1px solid var(--line); padding: 8px 12px; border-radius: 12px 12px 4px 12px; white-space: pre-wrap; word-break: break-word; }
.say { white-space: pre-wrap; word-break: break-word; }
.step { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; }
.ask { background: var(--card); border: 1px solid rgba(224,165,60,0.4); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.ask code { font-family: var(--mono); font-size: 12px; background: var(--deep); border-radius: 8px; padding: 8px 12px; white-space: pre-wrap; word-break: break-all; max-height: 240px; overflow: auto; }
.result { display: flex; flex-direction: column; gap: 8px; }
.composer { padding: 8px 12px 12px; display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line-soft); }
.chip-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* coming back to a screen: no entrance animation, it should feel like it never left */
.still .rise, .still .draw, .quiet .msg, .quiet .pop { animation: none; }

@media (prefers-reduced-motion: reduce) { *, *::after { animation: none !important; transition: none !important; } }
