:root {
  --bg-outer: #17130d;
  --bg-paper: #f7f1e1;
  --bg-card: rgba(255, 250, 238, 0.88);
  --ink-primary: #2b2116;
  --ink-secondary: #5c4934;
  --accent: #9c6b27;
  --accent-bright: #d49b38;
  --border-guilloche: #876332;
  --calc-bg: #231b12;
  --calc-text: #f9f1df;
  --font-heading: 'Charm', 'Pridi', serif;
  --font-body: 'Sarabun', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

/* 16 Historical Banknote Ink Themes & Era Typography */
body[data-theme="era-1860"] {
  --bg-outer: #18130d; --bg-paper: #f3ead6; --bg-card: rgba(250, 243, 226, 0.9);
  --ink-primary: #2c2013; --ink-secondary: #5e472d; --accent: #8c5a1b; --accent-bright: #cfa04c;
  --border-guilloche: #785221; --calc-bg: #241a0f; --font-heading: 'Charm', serif;
}
body[data-theme="era-1902"] {
  --bg-outer: #101c17; --bg-paper: #f4f3ea; --bg-card: rgba(250, 250, 242, 0.92);
  --ink-primary: #1a2e25; --ink-secondary: #435c50; --accent: #8b261d; --accent-bright: #c94a3e;
  --border-guilloche: #2c4a3c; --calc-bg: #15241d; --font-heading: 'Pridi', serif;
}
body[data-theme="era-1932"] {
  --bg-outer: #1c1410; --bg-paper: #f5ebe1; --bg-card: rgba(252, 245, 238, 0.9);
  --ink-primary: #2e1d14; --ink-secondary: #634433; --accent: #9e4b24; --accent-bright: #d97948;
  --border-guilloche: #7d3f20; --calc-bg: #261811; --font-heading: 'Pridi', serif;
}
body[data-theme="era-1945"] {
  --bg-outer: #1f1912; --bg-paper: #e8dac0; --bg-card: rgba(242, 231, 208, 0.9);
  --ink-primary: #362312; --ink-secondary: #61462b; --accent: #8a2c19; --accent-bright: #c94e34;
  --border-guilloche: #6b4c2b; --calc-bg: #291e12; --font-heading: 'Pridi', serif;
}
body[data-theme="era-1962"] {
  --bg-outer: #111821; --bg-paper: #edf1f5; --bg-card: rgba(247, 250, 252, 0.92);
  --ink-primary: #1c2836; --ink-secondary: #47586b; --accent: #b37d14; --accent-bright: #eab308;
  --border-guilloche: #3b5066; --calc-bg: #172230; --font-heading: 'Pridi', serif;
}
body[data-theme="era-1971"] {
  --bg-outer: #0d1f16; --bg-paper: #e9f5ee; --bg-card: rgba(244, 252, 247, 0.92);
  --ink-primary: #123623; --ink-secondary: #346349; --accent: #1b6b40; --accent-bright: #34d399;
  --border-guilloche: #235c3d; --calc-bg: #10291c; --font-heading: 'Kanit', sans-serif;
}
body[data-theme="era-1980"] {
  --bg-outer: #21130b; --bg-paper: #f7ece2; --bg-card: rgba(253, 246, 240, 0.92);
  --ink-primary: #3b2010; --ink-secondary: #6e4226; --accent: #8a4219; --accent-bright: #e07a3c;
  --border-guilloche: #783b19; --calc-bg: #2b180e; --font-heading: 'Kanit', sans-serif;
}
body[data-theme="era-1983"] {
  --bg-outer: #180f26; --bg-paper: #f2ebf9; --bg-card: rgba(249, 245, 253, 0.92);
  --ink-primary: #291642; --ink-secondary: #593b80; --accent: #6b3fa0; --accent-bright: #c084fc;
  --border-guilloche: #563282; --calc-bg: #221436; --font-heading: 'Kanit', sans-serif;
}
body[data-theme="era-1992"] {
  --bg-outer: #1a1918; --bg-paper: #f0efed; --bg-card: rgba(250, 249, 247, 0.92);
  --ink-primary: #262422; --ink-secondary: #57524c; --accent: #9c7316; --accent-bright: #f59e0b;
  --border-guilloche: #59534c; --calc-bg: #242220; --font-heading: 'Kanit', sans-serif;
}
body[data-theme="era-1997"] {
  --bg-outer: #0b1c26; --bg-paper: #e6f3f8; --bg-card: rgba(242, 250, 253, 0.92);
  --ink-primary: #0d3247; --ink-secondary: #31607a; --accent: #c9341c; --accent-bright: #38bdf8;
  --border-guilloche: #195b80; --calc-bg: #0f2636; --font-heading: 'Kanit', sans-serif;
}
body[data-theme="era-2002"] {
  --bg-outer: #0f2118; --bg-paper: #ebf5ef; --bg-card: rgba(245, 252, 248, 0.92);
  --ink-primary: #143624; --ink-secondary: #38664d; --accent: #0284c7; --accent-bright: #38bdf8;
  --border-guilloche: #245e3f; --calc-bg: #132b1f; --font-heading: 'Kanit', sans-serif;
}
body[data-theme="era-2008"] {
  --bg-outer: #1f1708; --bg-paper: #faf3e1; --bg-card: rgba(254, 250, 238, 0.93);
  --ink-primary: #362607; --ink-secondary: #6b4e16; --accent: #b45309; --accent-bright: #fbbf24;
  --border-guilloche: #92600e; --calc-bg: #291e09; --font-heading: 'Kanit', sans-serif;
}
body[data-theme="era-2013"] {
  --bg-outer: #240e0e; --bg-paper: #faebeb; --bg-card: rgba(254, 245, 245, 0.92);
  --ink-primary: #3b1212; --ink-secondary: #732c2c; --accent: #b91c1c; --accent-bright: #f87171;
  --border-guilloche: #8c2222; --calc-bg: #2e1212; --font-heading: 'Chakra Petch', sans-serif;
}
body[data-theme="era-2017"] {
  --bg-outer: #081829; --bg-paper: #eaf3fc; --bg-card: rgba(244, 249, 254, 0.93);
  --ink-primary: #0c2947; --ink-secondary: #2d557d; --accent: #0284c7; --accent-bright: #00b4d8;
  --border-guilloche: #154c82; --calc-bg: #0c223b; --font-heading: 'Chakra Petch', sans-serif;
}
body[data-theme="era-2020"] {
  --bg-outer: #072129; --bg-paper: #e8f7fa; --bg-card: rgba(242, 252, 254, 0.93);
  --ink-primary: #0a3542; --ink-secondary: #286173; --accent: #0369a1; --accent-bright: #f59e0b;
  --border-guilloche: #135d73; --calc-bg: #0a2d38; --font-heading: 'Chakra Petch', sans-serif;
}
body[data-theme="era-2025"] {
  --bg-outer: #090b16; --bg-paper: #eef2ff; --bg-card: rgba(248, 250, 255, 0.94);
  --ink-primary: #131836; --ink-secondary: #3b4475; --accent: #6d28d9; --accent-bright: #fbbf24;
  --border-guilloche: #4338ca; --calc-bg: #11152b; --font-heading: 'Chakra Petch', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-outer);
  color: var(--ink-primary);
  font-family: var(--font-body);
  transition: background-color 0.45s ease, color 0.45s ease;
}

/* Subtle Guilloche Security Line Pattern */
.guilloche-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image:
    radial-gradient(circle at 20% 50%, transparent 60%, var(--border-guilloche) 61%, transparent 63%),
    radial-gradient(circle at 80% 50%, transparent 60%, var(--border-guilloche) 61%, transparent 63%),
    repeating-linear-gradient(45deg, transparent, transparent 8px, var(--border-guilloche) 8.5px, transparent 9px);
  z-index: 0;
}

/* Outer Banknote Shell */
.banknote-shell {
  position: relative;
  z-index: 1;
  width: calc(100vw - 24px);
  height: calc(100vh - 20px);
  margin: 10px auto;
  background: var(--bg-paper);
  border: 3px double var(--border-guilloche);
  border-radius: 12px;
  box-shadow:
    inset 0 0 0 5px var(--bg-paper),
    inset 0 0 0 7px var(--border-guilloche),
    0 18px 45px rgba(0, 0, 0, 0.65);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 12px 18px;
  gap: 10px;
  transition: background-color 0.45s ease, border-color 0.45s ease;
}

/* Decorative Thai Kanok Corners */
.kanok-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-guilloche);
  pointer-events: none;
  z-index: 2;
}
.kanok-corner.tl { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.kanok-corner.tr { top: 8px; right: 8px; border-left: none; border-bottom: none; }
.kanok-corner.bl { bottom: 8px; left: 8px; border-right: none; border-top: none; }
.kanok-corner.br { bottom: 8px; right: 8px; border-left: none; border-top: none; }

/* TOP HEADER */
.treasury-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-guilloche);
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.garuda-emblem {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--border-guilloche);
  color: var(--bg-paper);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.35rem;
  box-shadow: inset 0 0 0 2px var(--accent-bright);
  flex-shrink: 0;
}

.ministry-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-secondary);
}

.site-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--ink-primary);
  line-height: 1.15;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.serial-plate {
  background: rgba(0, 0, 0, 0.06);
  border: 1px dashed var(--border-guilloche);
  padding: 3px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.serial-label {
  font-size: 0.7rem;
  color: var(--ink-secondary);
}

.serial-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: #b91c1c;
  letter-spacing: 0.04em;
}

.era-theme-badge {
  background: var(--border-guilloche);
  color: #fff;
  padding: 4px 11px;
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl-btn, .hub-link {
  background: var(--bg-card);
  color: var(--ink-primary);
  border: 1.5px solid var(--border-guilloche);
  padding: 5px 10px;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.ctrl-btn:hover, .hub-link:hover {
  background: var(--border-guilloche);
  color: #fff;
}

.ctrl-btn.playing {
  background: #b91c1c;
  color: #fff;
  border-color: #7f1d1d;
}

.hub-link {
  background: var(--calc-bg);
  color: var(--accent-bright);
}

/* MAIN WORKSPACE (2 ZONES) */
.banknote-stage {
  display: grid;
  grid-template-columns: 1.58fr 1fr;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.banknote-stage.switching {
  opacity: 0.45;
  transform: translateY(3px);
}

/* LEFT/CENTER: LEDGER PANEL */
.ledger-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
  min-height: 0;
}

.showcase-top {
  display: grid;
  grid-template-columns: auto 1fr 270px;
  gap: 12px;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid var(--border-guilloche);
  border-radius: 10px;
  padding: 10px 14px;
}

.era-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.year-rosette {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--bg-paper) 58%, rgba(0,0,0,0.08) 100%);
  border: 3px double var(--border-guilloche);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.ad-year {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-primary);
}

.be-year {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 2px;
}

.denom-pill {
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--border-guilloche);
  color: #fff;
  padding: 2px 8px;
  border-radius: 99px;
  text-align: center;
  white-space: nowrap;
}

.era-headline {
  min-width: 0;
}

.era-title {
  font-family: var(--font-heading);
  font-size: 1.38rem;
  line-height: 1.25;
  color: var(--ink-primary);
  margin-bottom: 5px;
}

.era-subtitle {
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink-secondary);
}

.artwork-frame {
  width: 270px;
  height: 135px;
  background: rgba(255, 255, 255, 0.55);
  border: 1.5px dashed var(--border-guilloche);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 4px;
}

.banknote-svg {
  width: 100%;
  height: 100%;
  color: var(--ink-primary);
}

/* 4 ECONOMIC SPECS GRID */
.specs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.spec-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-guilloche);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.spec-icon {
  font-size: 1.45rem;
  flex-shrink: 0;
}

.spec-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.spec-label {
  font-size: 0.7rem;
  color: var(--ink-secondary);
}

.spec-value {
  font-size: 0.84rem;
  color: var(--ink-primary);
  font-weight: 700;
  line-height: 1.25;
}

/* STORY & HIGHLIGHTS ROW */
.story-highlights-row {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 10px;
  min-height: 0;
}

.story-box, .highlights-box {
  background: var(--bg-card);
  border: 1.5px solid var(--border-guilloche);
  border-radius: 10px;
  padding: 10px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.box-header {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px dashed var(--border-guilloche);
  padding-bottom: 4px;
}

.story-text {
  font-size: 0.86rem;
  line-height: 1.62;
  color: var(--ink-primary);
  text-align: justify;
}

.highlights-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.highlights-list li {
  position: relative;
  padding-left: 18px;
  font-size: 0.82rem;
  line-height: 1.48;
  color: var(--ink-primary);
}

.highlights-list li::before {
  content: "❖";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-weight: bold;
}

/* RIGHT ZONE: PURCHASING POWER CALCULATOR */
.calculator-panel {
  background: var(--calc-bg);
  color: var(--calc-text);
  border: 2px solid var(--accent-bright);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.35);
  overflow-y: auto;
}

.calc-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calc-icon {
  font-size: 1.5rem;
}

.calc-title {
  font-family: var(--font-heading);
  font-size: 1.08rem;
  color: var(--accent-bright);
}

.calc-subtitle {
  font-size: 0.76rem;
  color: #d6caba;
}

.calc-input-group {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 8px 10px;
}

.input-label {
  display: block;
  font-size: 0.74rem;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1.5px solid var(--accent-bright);
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 7px;
}

.currency-prefix {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-bright);
  margin-right: 6px;
}

#bahtInput {
  width: 100%;
  background: transparent;
  border: none;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  outline: none;
}

.currency-suffix {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-left: 6px;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  padding: 4px 2px;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover, .preset-btn.active {
  background: var(--accent-bright);
  color: #111827;
  border-color: var(--accent-bright);
  font-weight: 700;
}

.calc-results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.result-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.result-card.highlight-result {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.2), rgba(255, 255, 255, 0.05));
  border-color: var(--accent-bright);
}

.res-head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
}

.res-emoji {
  font-size: 0.95rem;
}

.res-title {
  font-size: 0.72rem;
  color: #cbd5e1;
}

.res-main-val {
  font-family: var(--font-heading);
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--accent-bright);
}

.res-val {
  font-family: var(--font-mono);
  font-size: 0.96rem;
  font-weight: 700;
  color: #ffffff;
}

.res-sub {
  font-size: 0.67rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* BOTTOM TIMELINE SCRUBBER */
.timeline-footer {
  border-top: 2px solid var(--border-guilloche);
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.timeline-track-wrap {
  position: relative;
}

.timeline-progress-bar {
  height: 3px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 99px;
  margin-bottom: 5px;
  overflow: hidden;
}

.timeline-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.timeline-nodes {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 4px;
}

.era-node-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-guilloche);
  border-radius: 6px;
  padding: 4px 2px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.2s ease;
}

.era-node-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.era-node-btn.active {
  background: var(--border-guilloche);
  color: #ffffff;
  border-color: var(--ink-primary);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
}

.node-ad {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.node-be {
  font-size: 0.6rem;
  opacity: 0.82;
}

.footer-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--ink-secondary);
}

.era-counter {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink-primary);
}

/* Responsive fallback for smaller screens */
@media (max-width: 1120px) {
  html, body { height: auto; overflow-y: auto; }
  .banknote-shell { height: auto; min-height: 98vh; }
  .banknote-stage { grid-template-columns: 1fr; }
  .showcase-top { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .specs-grid { grid-template-columns: repeat(2, 1fr); }
  .story-highlights-row { grid-template-columns: 1fr; }
  .timeline-nodes { grid-template-columns: repeat(8, 1fr); }
}
