:root { color-scheme: dark; --bg:#111418; --card:#1c2128; --line:#313843; --text:#f2f4f7; --dim:#9aa4b2; --accent:#34d399; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, system-ui, sans-serif;
  display: flex; flex-direction: column; position: fixed; inset: 0; }
header { padding: calc(env(safe-area-inset-top) + 6px) 12px 6px; text-align: center; }
#rate { background: none; border: 0; color: var(--dim); font-size: 13px; padding: 4px 8px; }
#rate.stale { color: #fbbf24; }
main { flex: 1; min-height: 0; position: relative; }
section { position: absolute; inset: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 24px; width: 100%; max-width: 560px; margin: 0 auto; }
button { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #05281b; font-weight: 600; }
input { font: inherit; font-size: 22px; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; width: 100%; min-width: 0; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* camera */
#stage { flex: 1; min-height: 0; position: relative; overflow: hidden; background: #000; }
#video { width: 100%; height: 100%; object-fit: cover; }
#guide { position: absolute; left: 6%; right: 6%; top: 22%; height: 46%; border: 2px solid rgba(255,255,255,.7); border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); pointer-events: none; }
#marks { position: absolute; inset: 0; pointer-events: none; }
.mark { position: absolute; border: 2px solid var(--accent); border-radius: 6px; }
.mark b { position: absolute; left: -2px; bottom: 100%; background: var(--accent); color: #05281b; font-size: 17px; padding: 1px 7px; border-radius: 6px 6px 6px 0; white-space: nowrap; }
.mark.guess { border-style: dashed; }
#status { position: absolute; left: 12px; right: 12px; top: 12px; text-align: center; font-size: 14px; text-shadow: 0 1px 4px #000; pointer-events: none; }
#retry { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); }
#readout { padding: 12px 16px; text-align: center; background: var(--bg); }
#big { font-size: 46px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.15; }
#small { color: var(--dim); font-size: 14px; min-height: 20px; }

/* calculator */
.cols { display: grid; grid-template-columns: 1fr auto 1fr 36px; align-items: center; gap: 8px; color: var(--dim); font-size: 14px; text-align: center; margin-bottom: 10px; }
#swap { padding: 4px 12px; font-size: 20px; }
.row { display: grid; grid-template-columns: 1fr 1fr 36px; gap: 8px; margin-bottom: 10px; }
.row .del { padding: 0; background: none; border: 0; color: var(--dim); font-size: 20px; }
.row .del:disabled { visibility: hidden; }
#add { width: 100%; border-style: dashed; }
#total { text-align: center; padding: 22px 0 16px; }
.label { color: var(--dim); font-size: 14px; }
#total-main { font-size: 42px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
#total-sub { font-size: 20px; color: var(--dim); font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 10px; }
.actions button { flex: 1; }

/* log */
details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
summary { list-style: none; display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary .name { font-weight: 600; overflow-wrap: anywhere; }
summary .sub { color: var(--dim); font-size: 13px; }
summary .amt { text-align: right; white-space: nowrap; }
summary .aud { color: var(--accent); font-weight: 700; font-size: 19px; }
.detail { padding: 0 14px 12px; border-top: 1px solid var(--line); font-size: 14px; }
.line { display: flex; justify-content: space-between; padding-top: 8px; }
.detail button { margin-top: 12px; padding: 8px 14px; color: #f87171; }
#export { width: 100%; margin-top: 6px; }
.note { color: var(--dim); font-size: 13px; text-align: center; margin-top: 12px; }
.empty { color: var(--dim); text-align: center; padding: 40px 0; }

/* bottom bar */
nav { display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid var(--line); background: var(--card); padding-bottom: env(safe-area-inset-bottom); }
nav button { background: none; border: 0; border-radius: 0; color: var(--dim); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; font-size: 12px; }
nav button.on { color: var(--accent); }
nav svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

dialog { margin: 18vh auto auto; width: min(340px, 90vw); background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog p { margin-bottom: 12px; }
dialog input { margin-bottom: 14px; font-size: 17px; }
