:root {
  color-scheme: light;
  --ink: #172029;
  --muted: #525d68;
  --paper: #f4efe6;
  --line: #d8d0c2;
  --card: #fffdf8;
  --navy: #1c2c4a;
  --rust: #a53626;
  --teal: #1b6e5c;
  --radius: 16px;
  --sans: system-ui, "PingFang TC", "Hiragino Sans", "Noto Sans Thai", sans-serif;
  --serif: Palatino, "Songti TC", "Yu Mincho", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { overflow-x: clip; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 15% 0%, #e8dcc4, transparent 420px), var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  overflow-wrap: anywhere;
}
h1, h2, h3 { margin: 0; color: var(--navy); font: 650 1.125rem/1.2 var(--serif); }
a { color: var(--navy); }
button, input, select { color: inherit; font: inherit; }
button, input, select, summary, .brand, .cta-btn, .attribution { min-height: 44px; }
input, select { font-size: 16px; }
button, summary, select { cursor: pointer; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.wrap { width: min(1240px, calc(100% - 32px)); margin-inline: auto; }
.num, input[type="number"] { font-variant-numeric: tabular-nums; }
.visually-hidden, .clipboard-buffer {
  position: fixed;
  inset: 0 auto auto 0;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  border: 0;
}
.clipboard-buffer { font-size: 16px; }

.top { background: var(--paper); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block: 5px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.wordmark { font: 650 1.4rem/1 var(--serif); }
.wordmark span { color: var(--rust); }
.tag { display: none; color: var(--muted); font-size: .8rem; }
.lang-select, .field input[type="number"], .field select, .rate input {
  width: 100%;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.lang { min-width: 0; max-width: 50%; }
.lang-select { width: 9rem; max-width: 100%; border-radius: 999px; }
.hero { padding-block: 16px; }
.hero h1 { max-width: 30ch; font-size: clamp(1.5rem, 4vw, 2.6rem); letter-spacing: -.015em; }

.workspace, .grid-2, .assume-grid, .cards, .four, .rate-grid, .presets {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}
.workspace { gap: 12px; align-items: start; padding-bottom: 24px; }
.workspace > *, .grid-2 > *, .assume-grid > *, .cards > *, .four > *, .presets > *, .rate-grid > * { min-width: 0; }
.panel { padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.panel h2 { margin-bottom: 8px; }
.presets { margin-bottom: 10px; }
.presets button, .ghost {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--navy);
  padding: 10px 12px;
  font-size: .875rem;
}
.presets button:hover, .presets button[aria-pressed="true"] { background: var(--navy); color: white; }
.ghost:hover { border-color: var(--navy); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .hint { font-size: .8rem; }
.field label { color: var(--navy); font-weight: 650; }
.hint { color: var(--muted); }
.span-2 { grid-column: 1 / -1; }

.core-result { background: var(--navy); color: #fffdf8; }
.core-result h2 { color: inherit; }
.core-result p { margin: 4px 0 0; }
.core-result .hint { color: #e2dccd; }
.midbox {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  border-block-end: 1px solid #68758d;
  font-size: .85rem;
  padding-bottom: 6px;
  margin-bottom: 6px;
}
.midbox strong { font-size: 1.25rem; }

.controls { display: grid; gap: 8px; }
.assumptions > summary {
  display: list-item;
  list-style-position: inside;
  color: var(--navy);
  font-weight: 650;
  padding: 11px 4px;
}
.assumptions[open] > summary { margin-bottom: 8px; }
.slider-row { display: flex; align-items: center; gap: 8px; }
.slider-row input[type="range"] { flex: 1; min-width: 0; margin: 0; accent-color: var(--navy); }
.slider-row .slider-val { flex: 0 1 8rem; }
.monthly-fields { margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 8px; color: var(--muted); font-size: .85rem; cursor: pointer; }
.check input { flex: 0 0 44px; width: 44px; margin: 0; accent-color: var(--navy); cursor: pointer; }
.rates { border-top: 1px solid var(--line); padding-top: 12px; }
.rates p { margin: 0 0 8px; color: var(--muted); font-size: .85rem; }
.fx-meta span { display: block; }
.rate { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.rate span { flex: 0 0 8ch; }
.rate-actions, .result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rate-actions { margin: 8px 0 12px; }
.rate-actions > *, .result-actions > * { flex: 1 1 9rem; min-width: 0; }
.attribution { display: inline-flex; align-items: center; font-size: .85rem; }

.method { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.method.best { border-color: var(--teal); background: #e4f3ee; }
.method.worst { border-color: #e3c1ba; background: #f8e8e4; }
.method .name { font: 700 .9rem/1.3 var(--sans); }
.method p { margin: 4px 0 0; }
.method .sub, .method .annual { font-size: .8rem; color: var(--muted); }
.method .fee { color: var(--rust); font: 700 1.25rem/1.3 var(--serif); }
.method.best .fee { color: var(--teal); }
.method .total { font-size: .82rem; }
.badge { display: inline-block; margin-bottom: 6px; padding: 2px 7px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge.low { background: #d9efe8; color: #125544; }
.badge.high { background: #f4d6d0; color: #8c2a1c; }
.bars, .result-actions { margin-top: 14px; }
.bars h3 { margin-bottom: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: center; gap: 0 8px; margin-bottom: 8px; font-size: .82rem; }
.bar-row meter { grid-row: 2; grid-column: 1 / -1; width: 100%; min-width: 0; height: 14px; accent-color: var(--rust); }
.bar-row meter.best { accent-color: var(--teal); }
.bar-row meter::-webkit-meter-optimum-value { background: var(--rust); }
.bar-row meter.best::-webkit-meter-optimum-value { background: var(--teal); }
.bar-row meter::-moz-meter-bar { background: var(--rust); }
.bar-row meter.best::-moz-meter-bar { background: var(--teal); }
.bar-amt { text-align: right; }

.cta { padding: 16px; background: var(--navy); color: #f6f1e8; border-radius: var(--radius); }
.cta h2 { color: inherit; }
.cta p { margin: 8px 0 0; font-size: .9rem; }
#cta-coming-soon { color: #ffda8e; font-weight: 650; }
.cta-btn { display: inline-block; background: #f1c56b; border-radius: 8px; padding: 10px 12px; margin-top: 12px; font-weight: 700; text-decoration: none; }
.cta-btn:hover { background: #ffda8e; }
.cta-price { display: block; font-size: .8rem; }
.explainer { padding-bottom: 24px; }
.explainer > h2 { margin-bottom: 10px; }
.four article { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.four p, .foot { font-size: .85rem; color: var(--muted); }
.four p { margin: 6px 0 0; }
.foot { border-top: 1px solid var(--line); padding: 16px 0 24px; }
.foot p { margin: 0 0 8px; max-width: 90ch; }
.toast {
  opacity: 0;
  pointer-events: none;
  position: fixed;
  inset: auto 12px 12px;
  width: fit-content;
  margin-inline: auto;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--navy);
  color: white;
  font-size: .85rem;
  z-index: 2;
}
.toast.show { opacity: 1; }

@media (min-width: 768px) {
  .wrap { width: min(1240px, calc(100% - 48px)); }
  .tag { display: inline; }
  .lang { max-width: none; }
  .hero { padding-block: 26px 18px; }
  .panel { padding: 16px; }
  .grid-2, .assume-grid, .cards, .four, .rate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .presets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) minmax(0, 2fr); gap: 8px; }
  .bar-row meter { grid-row: auto; grid-column: auto; }
}

@media (min-width: 1280px) {
  .workspace {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    grid-template-rows: auto auto auto 1fr;
    gap: 16px;
  }
  .transaction { grid-area: 1 / 1; }
  .controls { grid-area: 2 / 1 / 5; }
  .core-result { grid-area: 1 / 2; }
  #results { grid-area: 2 / 2; }
  .cta { grid-area: 3 / 2; }
  .four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
