[hidden] { display: none !important; }
:root {
  --bg: #f6f5f1; --card: #ffffff; --ink: #1c1d1a; --muted: #6d6f68; --line: #e3e1da;
  --accent: #14532d; --accent-ink: #ffffff; --soft: #e7f0e9; --neg: #9f1d1d; --pos: #166534; --warn: #a16207;
  --r: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121411; --card: #1c1f1b; --ink: #ecede8; --muted: #9a9d94; --line: #2d312b;
    --accent: #4ade80; --accent-ink: #0b1a10; --soft: #1f2d22; --neg: #f87171; --pos: #4ade80; --warn: #facc15; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 24px); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: -0.01em; }
.status { border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.status.pending { color: var(--warn); border-color: currentColor; }
.status.ok { color: var(--pos); }
.icon-btn { border: 0; background: none; color: var(--ink); font-size: 22px; padding: 4px 6px; }

main { max-width: 520px; margin: 0 auto; padding: 16px; }
form#form { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px;
  display: grid; gap: 14px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 8px; border-radius: 8px; font-size: 15px; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.amount-wrap { display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--line); }
.amount-wrap:focus-within { border-color: var(--accent); }
#amount { flex: 1; border: 0; background: none; color: var(--ink); font-size: 40px; font-weight: 600;
  padding: 4px 0; outline: none; width: 100%; font-variant-numeric: tabular-nums; }
.cur { font-size: 24px; color: var(--muted); }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); }
input, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px;
  padding: 7px 12px; font-size: 14px; }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips button.sugg:not(.on) { border-color: var(--accent); }
.chips.small button { padding: 5px 10px; font-size: 13px; }

details summary { color: var(--muted); font-size: 14px; cursor: pointer; }
details input { margin-top: 8px; }

.primary { border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600;
  border-radius: 12px; padding: 14px; font-size: 17px; }
.primary:active { transform: scale(.99); }
button { font: inherit; cursor: pointer; }
.preview { margin: -4px 0 0; font: 12px/1.4 ui-monospace, Menlo, monospace; color: var(--muted); word-break: break-word; min-height: 1em; }

section h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 22px 4px 8px; }
.recent { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.recent li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.recent li:first-child { border-top: 0; }
.recent .d { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .m { font-size: 12px; color: var(--muted); grid-column: 1; }
.recent .a { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.recent .a.neg { color: var(--neg); } .recent .a.pos { color: var(--pos); }
.recent .q { font-size: 12px; color: var(--warn); text-align: right; }
.recent .empty { color: var(--muted); display: block; }

dialog { border: 0; border-radius: var(--r); padding: 0; width: min(92vw, 460px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.settings { display: grid; gap: 12px; padding: 18px; }
.settings h2 { margin: 0; font-size: 18px; }
.settings button:not(.primary):not(.link) { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; padding: 12px; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.link { border: 0; background: none; color: var(--muted); padding: 6px; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 5; max-width: 90vw; }
