:root {
  --paper: oklch(98.5% 0.004 80);
  --paper-2: oklch(96.5% 0.006 80);
  --ink: oklch(22% 0.012 60);
  --ink-soft: oklch(40% 0.010 60);
  --ink-mute: oklch(55% 0.008 60);
  --rule: oklch(90% 0.008 70);
  --rule-soft: oklch(94% 0.006 70);
  --accent: oklch(48% 0.14 265);
  --accent-soft: oklch(94% 0.03 265);

  --fs-narrative: 20px;
  --fs-narrative-lh: 1.55;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; font-feature-settings: "zero"; }

/* ---------- App layout ---------- */
.app {
  display: grid;
  grid-template-rows: 1fr auto;
  height: 100vh;
  padding-top: 28px;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 32px 32px;
  overflow-y: auto;
}

.stage__section {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.stage__section-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}

/* ---------- Card ---------- */
.card {
  width: 100%;
  max-width: 880px;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(20, 20, 20, 0.02), 0 12px 40px -12px rgba(30, 30, 30, 0.08);
  padding: 40px 44px 36px;
}

.card__head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.badge {
  align-self: flex-start;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge--expense    { background: oklch(96% 0.02 265); color: oklch(38% 0.12 265); border-color: oklch(88% 0.04 265); }
.badge--settlement { background: oklch(96% 0.03 155); color: oklch(35% 0.10 155); border-color: oklch(88% 0.05 155); }
.badge--setup      { background: var(--paper-2); color: var(--ink-soft); border-color: var(--rule); }

.card__title {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.card__narrative {
  margin-bottom: 24px;
}
.card__narrative p {
  margin: 0 0 10px;
  font-size: var(--fs-narrative);
  line-height: var(--fs-narrative-lh);
  color: var(--ink-soft);
  text-wrap: pretty;
}
.card__narrative p:last-child { margin-bottom: 0; }

/* ---------- Field rows ---------- */
.card__fields {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 4px 0;
  margin-bottom: 20px;
}
.field-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 20px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule-soft);
  align-items: baseline;
}
.field-row:last-child { border-bottom: none; }
.field-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
}
.field-value {
  font-size: 17px;
  color: var(--ink);
  line-height: 1.4;
}
.field-value.mono { font-size: 16px; letter-spacing: -0.005em; }

.strategy {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--rule);
}
.strategy--equal    { background: oklch(96% 0.02 265); color: oklch(35% 0.12 265); border-color: oklch(88% 0.04 265); }
.strategy--exact    { background: oklch(96% 0.03 150); color: oklch(32% 0.10 150); border-color: oklch(87% 0.05 150); }
.strategy--finetune { background: oklch(96% 0.03 60);  color: oklch(36% 0.10 60);  border-color: oklch(88% 0.05 60); }
.strategy--personal { background: var(--paper-2);      color: var(--ink-soft);     border-color: var(--rule); }

/* ---------- Breakdown table ---------- */
.card__breakdown {
  margin-bottom: 20px;
}
.card__breakdown-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
  margin-bottom: 8px;
}
.breakdown {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper-2);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.breakdown th, .breakdown td {
  padding: 9px 14px;
  text-align: left;
  font-size: 15px;
  border-bottom: 1px solid var(--rule-soft);
}
.breakdown th {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
  background: rgba(0,0,0,0.015);
}
.breakdown tr:last-child td { border-bottom: none; }
.breakdown .num { text-align: right; }

.card__note {
  font-size: 14px;
  color: var(--ink-mute);
  font-style: italic;
  margin-top: 10px;
  line-height: 1.5;
}

/* ---------- Callout ---------- */
.callout {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid;
  border-radius: 10px;
  margin-top: 20px;
}
.callout__icon {
  font-size: 18px;
  line-height: 1;
  padding-top: 2px;
  font-weight: 700;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}
.callout__body { flex: 1; }
.callout__label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 3px;
  opacity: 0.9;
}
.callout__text {
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- Name mapping ---------- */
.name-mapping {
  margin-top: 24px;
  padding: 20px;
  background: var(--paper-2);
  border: 1px dashed var(--rule);
  border-radius: 10px;
}
.name-mapping__title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-bottom: 4px;
}
.name-mapping__sub {
  font-size: 13px;
  color: var(--ink-mute);
  line-height: 1.45;
  margin-bottom: 14px;
}
.name-mapping__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.name-field { display: flex; flex-direction: column; gap: 6px; }
.name-field__label {
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-weight: 500;
}
.name-field__role {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: -0.01em;
}
.name-field input {
  background: white;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.name-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Navigation bar ---------- */
.navbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 16px 32px;
  background: white;
  border-top: 1px solid var(--rule);
}

.nav-btn {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 14px;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.12s;
  font-weight: 500;
}
.nav-btn--next {
  justify-self: end;
  padding: 10px 14px 10px 18px;
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.nav-btn:hover:not(:disabled) { border-color: var(--ink-soft); }
.nav-btn--next:hover:not(:disabled) { background: oklch(32% 0.012 60); }
.nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.nav-btn__arrow { font-size: 16px; line-height: 1; }

.nav-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 180px;
}
.counter {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 14px;
  color: var(--ink-mute);
}
.counter__num   { color: var(--ink); font-weight: 600; font-size: 15px; }
.counter__sep   { opacity: 0.5; margin: 0 2px; }
.progress {
  width: 200px;
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

/* ---------- Brand tag ---------- */
.brand {
  position: fixed;
  top: 18px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.brand__text { pointer-events: none; }

/* ---------- Trip switcher ---------- */
.trip-switcher {
  display: flex;
  gap: 6px;
  margin-left: 8px;
  pointer-events: all;
}
.trip-tab {
  padding: 4px 10px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-mute);
  background: white;
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.trip-tab:hover { border-color: var(--ink-soft); color: var(--ink); }
.trip-tab--active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.brand__mark {
  width: 26px; height: 26px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 12px;
}
.brand__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.brand__sub {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
}

/* Hint text bottom-right */
.app::after {
  content: "← / → to navigate";
  position: fixed;
  top: 22px;
  right: 28px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
}
