/* CardPick — design A "Clean & calm". */
:root {
  --bg: #f4f6f8; --card: #fff; --text: #16191d; --muted: #6b7480; --line: #e3e7eb;
  --accent: #0f9d75; --accent-ink: #fff; --accent-bg: #e3f5ee;
  --tip: #0f7a5c; --tip-bg: #e8f6f0; --warn: #a15c00; --warn-bg: #fff4e0; --bar-warn: #f0a020;
  --danger: #c5221f; --nav: #fff; --shadow: 0 1px 2px rgba(0,0,0,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1114; --card: #181c21; --text: #eef1f4; --muted: #8e98a4; --line: #262c33;
    --accent: #3ccf9e; --accent-ink: #062019; --accent-bg: #133129;
    --tip: #5fd9ad; --tip-bg: #11302a; --warn: #ffc35c; --warn-bg: #33280f; --bar-warn: #e6a23c;
    --danger: #f28b82; --nav: #14181c; --shadow: none;
    color-scheme: dark;
  }
}
@media all {
  :root[data-theme="dark"] {
    --bg: #0e1114; --card: #181c21; --text: #eef1f4; --muted: #8e98a4; --line: #262c33;
    --accent: #3ccf9e; --accent-ink: #062019; --accent-bg: #133129;
    --tip: #5fd9ad; --tip-bg: #11302a; --warn: #ffc35c; --warn-bg: #33280f; --bar-warn: #e6a23c;
    --danger: #f28b82; --nav: #14181c; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", "Leelawadee UI", sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* header */
header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + env(safe-area-inset-top)) 20px 6px; }
.head-in { max-width: 640px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
header h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.2px; }
.head-btns { display: flex; gap: 6px; align-items: center; }
#who { font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-bg); border: 0; border-radius: 16px; padding: 5px 12px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#who[hidden] { display: none; }
#lang { font-size: 13px; font-weight: 600; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 16px; padding: 4px 12px; }
main { max-width: 640px; margin: 0 auto; padding: 0 20px 12px; }
.subtitle { font-size: 14px; color: var(--muted); margin: -4px 0 4px; }

/* labels & chips */
.label { font-size: 12px; color: var(--muted); font-weight: 500; margin: 12px 0 6px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 7px 13px; font-size: 14px; white-space: nowrap; }
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chips.small .chip-btn { padding: 4px 11px; font-size: 13px; }
.chips.small .chip-btn.on { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

/* amount */
.amount { margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 4px 14px 4px 16px;
  display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); }
.amount:focus-within { border-color: var(--accent); }
.amount .cur { font-size: 22px; color: var(--muted); }
.amount input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 34px; font-weight: 700; letter-spacing: -.5px; padding: 6px 0; }
.amount input::placeholder { font-size: 15px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.amount .clear { border: 0; background: var(--line); color: var(--muted); border-radius: 50%; width: 26px; height: 26px; font-size: 13px; padding: 0; }

/* segmented */
.seg { display: flex; margin-top: 12px; background: var(--line); border-radius: 11px; padding: 3px; font-size: 13px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 9px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.toggle-chip { margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 4px 12px; }
.toggle-chip.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* mini card picture */
.face { --c1: #3b4a5a; --c2: #8a9bb0; display: inline-block; vertical-align: middle; width: 44px; height: 28px; flex: none; border-radius: 5px; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--c1), var(--c2)); background-size: cover; background-position: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.25), inset 0 0 0 1px rgba(255,255,255,.12); }
.face i { position: absolute; left: 6px; bottom: 6px; width: 9px; height: 7px; border-radius: 2px; background: rgba(255,255,255,.65); }
.face b { position: absolute; right: 4px; top: 2px; font-size: 7px; font-weight: 700; color: rgba(255,255,255,.9); letter-spacing: .3px; }
.face.photo i, .face.photo b { display: none; }
.face.md { width: 56px; height: 36px; border-radius: 6px; }
.face.md i { left: 7px; bottom: 7px; width: 11px; height: 8px; }
.face.md b { font-size: 8px; right: 5px; top: 3px; }
.face.lg { width: 150px; height: 95px; border-radius: 10px; }
.face.lg i { left: 14px; bottom: 16px; width: 22px; height: 16px; border-radius: 3px; background: linear-gradient(135deg,#f6d27a,#c99a2e); }
.face.lg b { font-size: 11px; right: 10px; top: 8px; }
.face.lg span { position: absolute; left: 12px; top: 8px; font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.face.photo span { display: none; }

/* results */
.hint-line { font-size: 13px; color: var(--muted); margin: 16px 2px 0; }
.hint-line.alt { color: var(--warn); }
.best { margin-top: 14px; background: var(--card); border: 2px solid var(--accent); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
.best.notowned { border-style: dashed; }
.best-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; }
.badge { background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: 10px; padding: 2px 9px; white-space: nowrap; }
.gain { color: var(--muted); text-align: right; }
.best-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.mid { flex: 1; min-width: 0; }
.name { font-size: 18px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.sub { font-size: 13px; color: var(--muted); margin-top: 1px; overflow-wrap: anywhere; }
.val { font-size: 32px; font-weight: 700; color: var(--accent); line-height: 1; white-space: nowrap; }
.val small { font-size: 15px; margin-left: 3px; }
.val .miles { display: block; font-size: 12px; font-weight: 500; color: var(--muted); text-align: right; margin-top: 4px; }
.pay { margin-top: 12px; width: 100%; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: 12px; padding: 11px; font-size: 15px; }
.list { margin-top: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.item { display: grid; grid-template-columns: 18px 44px 1fr auto; column-gap: 10px; padding: 11px 14px; border-top: 1px solid var(--line); align-items: start; }
.item:first-child { border-top: 0; }
.item .face { margin-top: 2px; }
.item .ext { grid-column: 3 / 5; }
.best-sub { margin-top: 8px; }
.rank { width: 20px; flex: none; color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; margin-top: 5px; }
.name2 { font-size: 15px; font-weight: 600; }
.v2 { font-size: 17px; font-weight: 700; white-space: nowrap; text-align: right; }
.v2.zero { color: var(--muted); font-weight: 500; }
.v2 .miles { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.paysm { display: block; margin: 6px 0 0 auto; border: 1px solid var(--accent); color: var(--accent); background: none; border-radius: 10px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.notowned .name2, .notowned .name { opacity: .8; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--line); color: var(--muted); font-weight: 500; white-space: nowrap; vertical-align: 2px; }
.x { font-size: 12px; margin-top: 5px; overflow-wrap: anywhere; }
.x.tip, .x.warn { border-radius: 8px; padding: 3px 8px; display: table; }
.x.tip { color: var(--tip); background: var(--tip-bg); }
.x.warn { color: var(--warn); background: var(--warn-bg); }
.x.muted { color: var(--muted); }
.x .mini { border: 1px solid currentColor; background: none; color: inherit; border-radius: 10px; padding: 0 8px; font-size: 11.5px; margin-left: 4px; }
.amts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.amts button { border: 1px solid var(--accent); background: var(--accent-bg); color: var(--accent); border-radius: 14px; padding: 2px 11px; font-size: 13px; font-weight: 600; }
.benefit { display: inline-block; font-size: 11.5px; padding: 2px 8px; margin: 4px 4px 0 0; border-radius: 10px; background: var(--accent-bg); color: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }
.regbox { margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--warn); border-radius: 10px; background: var(--warn-bg); }
.regbox .x { margin-top: 0; color: var(--warn); }
.regbtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.regbtn { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 10px; }
.regbtn.plain { font-weight: 500; color: var(--muted); }
.regbtn.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.fxgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; margin-top: 6px; }
dialog label.fxrow { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: 14px; font-weight: 400; }
dialog label.fxrow span { flex: 1; }
dialog label.fxrow input { width: 64px; padding: 5px 7px; font-size: 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); text-align: right; }
dialog label.fxrow i { font-style: normal; color: var(--muted); font-size: 12px; }
.order-btns { display: flex; flex-direction: column; gap: 2px; }
.order-btns button { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 6px; width: 26px; height: 20px; padding: 0; font-size: 11px; line-height: 1; }
.order-btns button:disabled { opacity: .3; }
dialog h3.fsec { font-size: 13px; color: var(--accent); margin: 16px 0 8px; padding-top: 10px; border-top: 1px solid var(--line); }

/* month */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .n { font-size: 23px; font-weight: 700; }
.tile.g .n { color: var(--accent); }
.sec { font-size: 14px; font-weight: 600; margin: 20px 2px 8px; display: flex; justify-content: space-between; align-items: center; }
.cap { padding: 11px 14px; border-top: 1px solid var(--line); }
.cap:first-child { border-top: 0; }
.cap-top { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.cap-top b { font-weight: 600; flex: 1; min-width: 0; }
.cap-top .r { white-space: nowrap; font-size: 13px; }
.bar { height: 7px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar.w i { background: var(--bar-warn); }
.dots { display: flex; gap: 5px; margin-top: 8px; }
.dots i { width: 22px; height: 7px; border-radius: 4px; background: var(--accent); }
.dots i.off { background: var(--line); }
.log { display: flex; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 14px; align-items: center; }
.log:first-child { border-top: 0; }
.log .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-bg); display: grid; place-items: center; font-size: 17px; flex: none; }
.log .mid small { color: var(--muted); }
.log .r { text-align: right; white-space: nowrap; }
.log .r small { display: block; color: var(--accent); font-weight: 600; }
.log .del { border: 0; background: none; color: var(--muted); font-size: 14px; padding: 4px; }
.inline-input { width: 120px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); margin-left: 6px; }

/* cards & settings lists */
.btn { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 3px 11px; font-size: 13px; border-radius: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.actions .grow { flex: 1; }
.mrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.mrow .mid .sub { font-size: 12px; }
.rules { padding: 0 14px 10px; }
.rule { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 13.5px; }
.rule > span:last-child { white-space: nowrap; }
.rule.off { opacity: .5; }
.rule small { color: var(--muted); }
.list > .mblock { border-top: 1px solid var(--line); }
.list > .mblock:first-child { border-top: 0; }
.mblock.notowned .face { opacity: .55; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 12px; transition: .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { left: 21px; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); font-size: 14px; }
.srow:first-child { border-top: 0; }
.srow select, .srow input { max-width: 150px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.small { font-size: 12px; } .muted { color: var(--muted); }

/* bottom nav */
nav#tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: center; background: var(--nav);
  border-top: 1px solid var(--line); padding: 6px 6px calc(8px + env(safe-area-inset-bottom)); }
nav#tabs button { flex: 1; max-width: 160px; border: 0; background: none; color: var(--muted); font-size: 11px; padding: 2px 0; }
nav#tabs svg { display: block; margin: 0 auto 2px; width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav#tabs button.on { color: var(--accent); font-weight: 600; }

/* dialog (bottom sheet) */
dialog { width: min(560px, 100vw); max-width: 100vw; max-height: 92vh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 20px 20px 0 0; background: var(--bg); color: var(--text); }
@media (min-width: 600px) { dialog { margin: auto; border-radius: 20px; } }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 16px 18px 0; }
dialog h2 { margin: 0 0 10px; font-size: 19px; }
dialog label { display: block; margin: 0 0 10px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
dialog label > input:not([type=checkbox]):not([type=color]), dialog label > select, dialog label > textarea {
  display: block; width: 100%; margin-top: 3px; padding: 9px 11px; font-size: 16px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
dialog label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; font-weight: 400; margin: 6px 0; }
dialog label.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
dialog fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 10px; padding: 6px 12px 8px; background: var(--card); }
dialog legend, dialog summary { font-size: 12.5px; color: var(--muted); font-weight: 500; padding: 0 4px; }
dialog details { margin: 0 0 10px; }
dialog small.muted { display: block; font-weight: 400; margin-top: 2px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 10px; }
.look { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 6px 0; }
.look-ctl { flex: 1; min-width: 170px; display: flex; flex-direction: column; gap: 8px; }
.look-ctl select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.look-colors { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.look-colors input { width: 44px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--bg); }
.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.err { color: var(--danger); min-height: 1em; margin: 4px 0; font-size: 13px; }

#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #24292f; color: #fff; padding: 10px 14px; border-radius: 12px; display: flex; gap: 14px; align-items: center;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); z-index: 10; font-size: 14px; }
#toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
#toast button { background: none; border: 0; color: #5fd9ad; font-weight: 700; padding: 0; }
