@font-face { font-family: Thmanyah; src: url(fonts/Thmanyah-Sans-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Thmanyah; src: url(fonts/Thmanyah-Sans-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #f6f5f1; --card: #ffffff; --ink: #161816; --muted: #7a7d78; --line: #e6e4de;
  --accent: #0f7a5c; --accent-soft: #e2f1eb; --key: #ffffff; --op: #e9e7e1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121413; --card: #1c1f1d; --ink: #f1f2ef; --muted: #8d918b; --line: #2a2e2b;
    --accent: #3ccf9a; --accent-soft: #1d3a2f; --key: #1f2320; --op: #2a2f2b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: Thmanyah, system-ui, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }

#app {
  max-width: 460px; margin: 0 auto; min-height: 100%;
  display: flex; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px 0;
}

header { display: flex; align-items: center; gap: 8px; height: 44px; }
h1 { font-size: 22px; margin: 0; flex: 1; }
.icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); font-size: 24px; }
.icon.small { width: 32px; height: 32px; font-size: 22px; }
.pill { background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 6px 12px; font-size: 14px; font-weight: 700; white-space: nowrap; }

#active { background: var(--card); border-radius: 22px; padding: 16px 18px 14px; margin-top: 8px; }
.cur { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); }
.cur .f { font-size: 22px; }
.cur b { color: var(--ink); }
.cur::after { content: '⌄'; margin-top: -6px; }
.amountRow { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
#expr { flex: 1; font-size: 44px; font-weight: 700; text-align: left; min-height: 56px; line-height: 56px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; font-variant-numeric: tabular-nums; }
#expr::-webkit-scrollbar { display: none; }
#expr .op { color: var(--accent); padding: 0 4px; }
#expr:empty::before { content: '0'; color: var(--line); }
#result { min-height: 20px; color: var(--muted); font-size: 16px; text-align: left; }

#list { list-style: none; margin: 10px 0 0; padding: 0; }
#list li { display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
#list li:active { opacity: .6; }
#list .f { font-size: 28px; line-height: 1; }
#list .nm { flex: 1; min-width: 0; }
#list .nm b { display: block; font-size: 16px; }
#list .nm small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#list .v { text-align: left; font-variant-numeric: tabular-nums; }
#list .v b { display: block; font-size: 20px; }
#list .v small { display: block; color: var(--accent); font-size: 13px; }
#list li.home .nm b::after { content: '⌂'; color: var(--muted); font-weight: 400; margin-inline-start: 6px; }

.ghost { color: var(--accent); font-weight: 700; padding: 14px 6px; text-align: start; }
#stamp { color: var(--muted); font-size: 12px; text-align: center; margin: 4px 0 16px; }

#pad {
  position: sticky; bottom: 0; margin: auto -16px 0; padding: 10px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--bg); display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
#pad button { height: 54px; border-radius: 16px; background: var(--key); font-size: 24px; font-variant-numeric: tabular-nums; }
#pad button:active { transform: scale(.96); }
#pad .op { background: var(--op); color: var(--accent); }

.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 460px; max-height: 85vh;
  background: var(--bg); color: var(--ink); border-radius: 22px 22px 0 0;
  display: none; flex-direction: column;
}
.sheet[open] { display: flex; animation: up .22s ease-out; }
.sheet::backdrop { background: rgb(0 0 0 / .35); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheetHead { display: flex; align-items: center; gap: 8px; padding: 14px 16px 8px; }
.sheetHead h2 { flex: 1; margin: 0; font-size: 18px; }
#search { flex: 1; height: 44px; border-radius: 12px; border: 0; background: var(--card); color: var(--ink); padding: 0 14px; font: inherit; font-size: 16px; outline: none; }
#pickList { list-style: none; margin: 0; padding: 0 16px max(16px, env(safe-area-inset-bottom)); overflow-y: auto; }
#pickList li { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
#pickList .f { font-size: 24px; }
#pickList .nm { flex: 1; }
#pickList small { color: var(--muted); margin-inline-start: 6px; }
#pickList li.on::after { content: '✓'; color: var(--accent); font-weight: 700; }

.rows { padding: 0 16px; }
.row { display: flex; align-items: center; justify-content: space-between; width: 100%; background: var(--card); border-radius: 14px; padding: 0 16px; height: 54px; margin-bottom: 8px; font-size: 16px; }
.row b { color: var(--accent); }
.fee { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.fee input { width: 64px; height: 36px; border: 0; border-radius: 10px; background: var(--bg); color: var(--ink); text-align: center; font: inherit; font-size: 16px; }
.hint { color: var(--muted); font-size: 13px; padding: 0 20px max(18px, env(safe-area-inset-bottom)); margin: 4px 0 0; }
