:root {
  --bg: #f5efe4;
  --paper: #fffdf8;
  --paper-soft: #faf5ea;
  --ink: #181614;
  --muted: #58514a;
  --rule: #ddd4c3;
  --gold: #f2b830;
  --gold-deep: #d99c18;
  --primary: #137a6e;
  --teal: #137a6e;
  --teal-soft: #e3f2ef;
  --red: #d63e36;
  --red-soft: #fceae8;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --shadow-hard: 4px 4px 0 #181614;
  --shadow-soft: 0 18px 44px rgba(24, 22, 20, 0.08);
  --radius: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.62;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(24, 22, 20, 0.055) 1px, transparent 1px);
  background-size: 20px 20px;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.tb-home-head {
  text-align: center; max-width: 780px; margin: 4px auto 26px;
}
.tb-home-h1 {
  font: 700 clamp(38px, 5.4vw, 62px)/1.03 var(--serif);
  letter-spacing: -0.03em; margin: 0 0 12px; color: var(--ink);
}
.tb-home-h1 em {
  font-style: italic; color: var(--red);
  text-decoration: underline; text-decoration-color: var(--gold);
  text-decoration-thickness: 5px; text-underline-offset: 6px;
}
.tb-home-lede {
  margin: 0 auto; max-width: 62ch; color: var(--muted); font-size: 16.5px; line-height: 1.6;
}
.tb-tool-host { margin: 0 auto; }

.tb-wrap { max-width: 1140px; margin: 0 auto; padding: 0 20px; }

/* Header */
.tb-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(245, 239, 228, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--ink);
}
.tb-nav-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 66px;
}
.tb-brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); font: 700 20px/1 var(--serif); letter-spacing: -0.02em;
  text-decoration: none;
}
.tb-brand:hover { text-decoration: none; }
.tb-brand img, .tb-brand svg { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.tb-nav { display: flex; align-items: center; gap: 22px; }
.tb-nav a {
  color: var(--ink); font: 600 14px/1.2 var(--sans); opacity: 0.84;
  transition: opacity 150ms ease, color 150ms ease;
}
.tb-nav a:hover { opacity: 1; color: var(--teal); text-decoration: none; }
.tb-nav-cta {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: 999px;
  background: var(--gold); color: var(--ink); border: 2px solid var(--ink);
  font: 700 13.5px/1 var(--sans); box-shadow: 2px 2px 0 var(--ink);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.tb-nav-cta:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); text-decoration: none; }

/* Main & Editorial Sections */
.tb-main { padding: 28px 0 72px; }
.tb-section { margin: 56px 0 0; }
.tb-section-head { max-width: 720px; margin: 0 0 24px; }
.tb-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--paper); border: 1.5px solid var(--ink);
  font: 700 11.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--teal); margin: 0 0 12px;
}
.tb-h2 {
  font: 700 clamp(28px, 3.6vw, 40px)/1.12 var(--serif);
  letter-spacing: -0.02em; margin: 0 0 10px; color: var(--ink);
}
.tb-sub { margin: 0; color: var(--muted); font-size: 16px; }

/* Era Exhibition Strip */
.tb-era-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px;
}
.tb-era-card {
  background: var(--paper); border: 2px solid var(--ink); border-radius: 14px;
  padding: 12px 12px 16px; box-shadow: var(--shadow-hard);
  transition: transform 180ms cubic-bezier(.22,1,.36,1), box-shadow 180ms ease;
}
.tb-era-card:hover { transform: translateY(-4px) rotate(-0.5deg); box-shadow: 6px 8px 0 var(--ink); }
.tb-era-pic {
  border-radius: 8px; overflow: hidden; border: 1.5px solid var(--rule);
  background: var(--paper-soft); aspect-ratio: 4/3; margin-bottom: 12px;
}
.tb-era-pic img { width: 100%; height: 100%; object-fit: cover; }
.tb-era-tag {
  display: inline-block; font: 700 11px/1 var(--mono); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--teal); background: var(--teal-soft);
  padding: 4px 8px; border-radius: 6px; margin-bottom: 7px;
}
.tb-era-card h3 { font: 700 17px/1.2 var(--serif); margin: 0 0 5px; }
.tb-era-card p { font-size: 13.5px; color: var(--muted); margin: 0; line-height: 1.48; }

/* Editorial Prose & Tables */
.tb-article-card {
  background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: clamp(22px, 3.5vw, 40px); box-shadow: var(--shadow-soft);
}
.tb-article-card h2 {
  font: 700 clamp(24px, 3vw, 32px)/1.18 var(--serif); margin: 30px 0 12px; letter-spacing: -0.02em;
}
.tb-article-card h2:first-child { margin-top: 0; }
.tb-article-card h3 { font: 700 19px/1.25 var(--serif); margin: 22px 0 8px; }
.tb-article-card p, .tb-article-card li { color: #2b2723; font-size: 15.5px; }
.tb-article-card ul, .tb-article-card ol { padding-left: 22px; }
.tb-article-card li { margin: 6px 0; }
.tb-article-card table {
  width: 100%; border-collapse: collapse; margin: 18px 0 24px;
  font-size: 14.5px; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden;
}
.tb-article-card th, .tb-article-card td {
  padding: 12px 14px; border-bottom: 1.5px solid var(--rule); text-align: left; vertical-align: top;
}
.tb-article-card th { background: var(--paper-soft); font-weight: 700; color: var(--ink); }

/* FAQ */
.tb-faq { display: grid; gap: 12px; }
.tb-faq details {
  background: var(--paper); border: 2px solid var(--ink); border-radius: 12px;
  padding: 15px 18px; box-shadow: 3px 3px 0 var(--ink);
}
.tb-faq summary {
  cursor: pointer; font: 700 16px/1.35 var(--sans); list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.tb-faq summary::-webkit-details-marker { display: none; }
.tb-faq summary::after { content: "+"; font: 700 20px/1 var(--mono); color: var(--teal); }
.tb-faq details[open] summary::after { content: "−"; color: var(--red); }
.tb-faq details p { margin: 10px 0 0; color: var(--muted); font-size: 15px; }

/* Subpage Hero */
.tb-page-hero {
  background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: clamp(22px, 3.6vw, 38px); box-shadow: var(--shadow-hard); margin-bottom: 28px;
  display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 24px; align-items: center;
}
.tb-page-hero.is-text-only { grid-template-columns: 1fr; }
.tb-page-hero h1 { font: 700 clamp(32px, 4.4vw, 50px)/1.08 var(--serif); margin: 0 0 12px; letter-spacing: -0.025em; }
.tb-page-hero p { margin: 0; font-size: 16.5px; color: var(--muted); max-width: 60ch; }
.tb-page-thumb {
  border-radius: 12px; overflow: hidden; border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--gold); background: var(--paper-soft);
}
.tb-breadcrumb { font: 600 13px/1.2 var(--mono); color: var(--muted); margin: 0 0 14px; }
.tb-breadcrumb a { color: var(--teal); }

/* Related Strip */
.tb-related {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 26px;
}
.tb-rel-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 12px;
  box-shadow: 3px 3px 0 var(--ink); color: var(--ink);
  transition: transform 150ms ease;
}
.tb-rel-card:hover { transform: translateY(-2px); text-decoration: none; }
.tb-rel-card strong { font: 700 15.5px/1.25 var(--serif); color: var(--ink); }
.tb-rel-card span { font-size: 13px; color: var(--muted); }

/* Footer */
.tb-footer {
  border-top: 2px solid var(--ink); background: var(--paper); padding: 44px 0 28px; margin-top: 40px;
}
.tb-footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px; }
.tb-footer-brand p { font-size: 14px; color: var(--muted); max-width: 38ch; margin: 12px 0 0; }
.tb-footer-col { display: flex; flex-direction: column; gap: 8px; }
.tb-footer-col h3 { font: 700 12.5px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 6px; color: var(--ink); }
.tb-footer-col a { font-size: 14px; color: var(--muted); }
.tb-footer-col a:hover { color: var(--teal); }
.tb-footer-bottom {
  margin-top: 28px; padding-top: 18px; border-top: 1.5px solid var(--rule);
  font-size: 13px; color: var(--muted);
}

@media (max-width: 960px) {
  .tb-nav { display: none; }
  .tb-era-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb-page-hero { grid-template-columns: 1fr; }
  .tb-related { grid-template-columns: 1fr; }
  .tb-footer-grid { grid-template-columns: 1fr; }
}

/* Result Page Alignment & Larger Memory Passport */
.tb-tool-host .tbg-res-grid {
  grid-template-columns: 1.06fr 0.94fr;
  gap: 24px;
  align-items: stretch;
}
.tb-tool-host .tbg-res-grid > div:first-child {
  display: flex;
  flex-direction: column;
}
.tb-tool-host .tbg-calib {
  margin-top: auto;
}
.tb-tool-host .tbg-passport-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 22px 20px;
  height: 100%;
}
.tb-tool-host .tbg-passport-col canvas {
  width: 100%;
  max-width: 356px;
  max-height: 632px;
  height: auto;
  margin: 0 auto 18px;
  border-radius: 12px;
}
.tb-tool-host .tbg-thumb-strip {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

/* Mobile First-Screen Polish (Visual-First Above the Fold) */
@media (max-width: 760px) {
  .tb-wrap { padding: 0 14px; }
  .tb-nav-inner { min-height: 54px; }
  .tb-brand { font-size: 18px; gap: 8px; }
  .tb-brand img, .tb-brand svg { width: 28px; height: 28px; }
  .tb-nav-cta { padding: 7px 13px; font-size: 12.5px; }
  .tb-main { padding: 12px 0 56px; }
  .tb-home-head { margin: 0 auto 12px; }
  .tb-home-head .tb-kicker {
    font-size: 12px;
    letter-spacing: 0.04em;
    padding: 4px 10px;
    margin-bottom: 7px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tb-home-h1 {
    font-size: clamp(28px, 8.4vw, 36px);
    line-height: 1.04;
    margin: 0 0 6px;
  }
  .tb-home-lede {
    font-size: 13.5px;
    line-height: 1.44;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .tb-tool-host .tbg-shell {
    border-radius: 16px;
    box-shadow: 4px 4px 0 var(--ink);
  }
  .tb-tool-host .tbg-topbar {
    flex-wrap: nowrap;
    padding: 9px 12px;
    gap: 8px;
  }
  .tb-tool-host .tbg-mode-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
    min-width: 0;
    gap: 6px;
    padding-bottom: 2px;
  }
  .tb-tool-host .tbg-mode-pills::-webkit-scrollbar { display: none; }
  .tb-tool-host .tbg-mpill {
    flex: none;
    white-space: nowrap;
    padding: 7px 11px;
    font-size: 12px;
  }
  .tb-tool-host .tbg-top-tools { flex: none; gap: 5px; }
  .tb-tool-host .tbg-icon-btn { padding: 6px 8px; font-size: 12px; }
  .tb-tool-host .tbg-start {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 12px 14px 15px;
  }
  .tb-tool-host .tbg-start-left,
  .tb-tool-host .tbg-start-right { min-width: 0; max-width: 100%; }
  .tb-tool-host .tbg-start-right { order: -1; }
  .tb-tool-host .tbg-polaroid {
    transform: none;
    padding: 7px 7px 9px;
    border-radius: 12px;
    box-shadow: 3px 4px 0 rgba(24, 22, 20, 0.14);
  }
  .tb-tool-host .tbg-polaroid-img { aspect-ratio: 16 / 9; }
  .tb-tool-host .tbg-polaroid-cap { margin-top: 7px; font-size: 12px; }
  .tb-tool-host .tbg-thumb-strip {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    margin-top: 8px;
    padding-bottom: 2px;
  }
  .tb-tool-host .tbg-thumb-strip::-webkit-scrollbar { display: none; }
  .tb-tool-host .tbg-thumb { flex: 0 0 64px; }
  .tb-tool-host .tbg-start-left h2 {
    font-size: 20px;
    line-height: 1.15;
    margin: 0 0 10px;
    text-align: center;
  }
  .tb-tool-host .tbg-start-left p,
  .tb-tool-host .tbg-mode-brief { display: none; }
  .tb-tool-host .tbg-start-btn {
    padding: 13px 18px;
    font-size: 16px;
    border-radius: 12px;
    box-shadow: 3px 3px 0 var(--ink);
  }
  .tb-tool-host .tbg-meta-row {
    margin-top: 10px;
    gap: 8px 12px;
    font-size: 12px;
    justify-content: center;
  }
  .tb-tool-host .tbg-res-grid { grid-template-columns: 1fr; gap: 18px; }
  .tb-tool-host .tbg-passport-col { height: auto; padding: 16px; }
  .tb-tool-host .tbg-passport-col canvas { max-width: 310px; max-height: 550px; }
  .tb-tool-host .tbg-clues { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tb-tool-host .tbg-clue-item { padding: 6px; }
  .tb-tool-host .tbg-clue-item strong { font-size: 12px; line-height: 1.25; }
}
@media (max-width: 560px) {
  .tb-era-grid { grid-template-columns: 1fr; }
  .tb-tool-host .tbg-clues { grid-template-columns: 1fr; }
}