/* Shared layout for the legal pages (terms.html, privacy.html) — earth-tone platform palette:
   light brown surfaces, sage green for buttons/accents. Self-contained (no Tailwind). */
:root {
  --ink: #362B22; --ink-soft: #6B5D4F; --ink-mute: #8C7B69;
  --paper: #F7F2E9; --surface: #FDFBF6; --sand: #EFE5D5; --latte: #EADBC3;
  --tan: #C8A47C; --caramel: #A98260; --caramel-deep: #8A6744;
  --sage: #7C8F6E; --sage-deep: #5E7151; --sage-soft: #DCE3D3; --sage-mist: #EEF2E8;
  --honey-bg: #FBF3E3; --honey-line: #EED6A1; --terra: #AC533B; --terra-bg: #FBEDE7;
  --line: rgba(54,43,34,.1); --line-soft: rgba(54,43,34,.06);
  --shadow: 0 18px 40px -26px rgba(54,43,34,.35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: 'Prompt', sans-serif; color: var(--ink); line-height: 1.7;
  background:
    radial-gradient(60rem 30rem at 100% -10%, rgba(234,219,195,.7), transparent 60%),
    radial-gradient(40rem 26rem at -10% 20%, rgba(220,227,211,.55), transparent 60%),
    var(--paper);
  background-attachment: fixed;
}
a { color: inherit; }
h1, h2, h3 { font-family: 'Kanit', sans-serif; line-height: 1.3; margin: 0; }
p { margin: 0; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 24px; } }

/* ---- Top bar ---- */
.topbar { position: sticky; top: 0; z-index: 40; background: rgba(247,242,233,.88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .wrap { height: 60px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand img { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); }
.brand span { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 16px; }
.topbar .back { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-soft); text-decoration: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(253,251,246,.7); white-space: nowrap; }
.topbar .back:hover { color: var(--caramel-deep); border-color: rgba(169,130,96,.4); }
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; background: linear-gradient(90deg, var(--sage), var(--tan)); transition: width .1s linear; }

/* ---- Hero ---- */
.hero { margin: 22px 0 18px; padding: 24px 20px; border-radius: 26px; background: linear-gradient(135deg, #F3E8D6, #EADBC3 55%, #E4E8D9); border: 1px solid rgba(169,130,96,.22); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(253,251,246,.55), transparent 70%); pointer-events: none; }
@media (min-width: 768px) { .hero { padding: 34px 36px; margin-top: 30px; } }
.hero-top { display: flex; align-items: flex-start; gap: 14px; }
.hero-icon { width: 52px; height: 52px; flex-shrink: 0; border-radius: 16px; display: grid; place-items: center; font-size: 1.3rem; color: #FFFDF8; background: linear-gradient(145deg, #D2AE86, #A98260); box-shadow: 0 12px 22px -14px rgba(138,103,68,.9); }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--sage-deep); }
.eyebrow::before { content: ''; width: 18px; height: 2px; border-radius: 2px; background: var(--sage); }
.hero h1 { font-size: 26px; font-weight: 600; margin-top: 4px; }
@media (min-width: 768px) { .hero h1 { font-size: 34px; } }
.hero .intro { margin-top: 10px; font-size: 14.5px; color: var(--ink-soft); max-width: 46rem; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--ink-soft); background: rgba(253,251,246,.75); border: 1px solid rgba(54,43,34,.08); }
.chip i { color: var(--caramel); font-size: 11px; }
.chip.sage { color: var(--sage-deep); background: var(--sage-mist); border-color: rgba(124,143,110,.3); }
.chip.sage i { color: var(--sage); }
.doc-switch { display: inline-flex; gap: 4px; margin-top: 18px; padding: 4px; border-radius: 999px; background: rgba(253,251,246,.7); border: 1px solid rgba(54,43,34,.08); max-width: 100%; }
.doc-switch a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.doc-switch a i { font-size: 12px; color: var(--caramel); }
.doc-switch a.is-active { color: #FFFDF8; background: linear-gradient(135deg, #8DA27E, #667B5B); box-shadow: 0 8px 18px -10px rgba(102,123,91,.9); }
.doc-switch a.is-active i { color: #EEF2E8; }
@media (max-width: 420px) { .doc-switch { display: flex; } .doc-switch a { flex: 1; justify-content: center; padding: 8px 10px; font-size: 12.5px; } }

/* ---- Quick read ---- */
.quick { margin-bottom: 22px; }
.quick-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.quick-head h2 { font-size: 17px; font-weight: 600; }
.quick-head span { font-size: 12px; color: var(--ink-mute); }
.quick-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .quick-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .quick-grid { grid-template-columns: repeat(3, 1fr); } }
.quick-card { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 24px -22px rgba(54,43,34,.5); }
.quick-card b { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.45; }
.quick-card small { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-soft); line-height: 1.55; }
.ic { width: 36px; height: 36px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center; font-size: .85rem; color: var(--caramel-deep); background: linear-gradient(145deg, #F6EBDA, #EADBC3); }
.ic.sage { color: var(--sage-deep); background: linear-gradient(145deg, #EEF2E8, #DCE3D3); }

/* ---- Mobile chapter chips ---- */
.chapter-bar { position: sticky; top: 60px; z-index: 30; margin: 0 -16px 14px; padding: 8px 16px; background: rgba(247,242,233,.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line-soft); overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.chapter-bar::-webkit-scrollbar { display: none; }
.chapter-bar a { display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; padding: 7px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); text-decoration: none; background: var(--surface); border: 1px solid var(--line); }
.chapter-bar a b { font-family: 'Kanit', sans-serif; font-weight: 600; color: var(--caramel); }
.chapter-bar a.is-active { color: #FFFDF8; background: linear-gradient(135deg, #8DA27E, #667B5B); border-color: transparent; }
.chapter-bar a.is-active b { color: #EEF2E8; }
@media (min-width: 1024px) { .chapter-bar { display: none; } }

/* ---- Layout ---- */
.layout { display: grid; gap: 22px; padding-bottom: 60px; }
@media (min-width: 1024px) { .layout { grid-template-columns: 250px minmax(0, 1fr); gap: 30px; } }
.toc { display: none; }
@media (min-width: 1024px) { .toc { display: block; } }
.toc-inner { position: sticky; top: 84px; padding: 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); max-height: calc(100vh - 110px); overflow-y: auto; scrollbar-width: thin; }
.toc-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--ink-mute); margin: 2px 6px 8px; }
.toc-ch { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 12px; font-size: 13px; font-weight: 600; color: var(--ink-soft); text-decoration: none; }
.toc-ch span.n { width: 24px; height: 24px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center; font-family: 'Kanit', sans-serif; font-size: 12px; color: var(--caramel-deep); background: var(--sand); }
.toc-ch:hover { background: rgba(234,219,195,.35); }
.toc-ch.is-active { color: var(--ink); background: var(--sage-mist); }
.toc-ch.is-active span.n { color: #FFFDF8; background: linear-gradient(135deg, #8DA27E, #667B5B); }
.toc-sub { display: none; margin: 2px 0 6px 42px; padding-left: 10px; border-left: 2px solid var(--sand); }
.toc-ch.is-active + .toc-sub { display: block; }
.toc-sub a { display: block; padding: 3px 0; font-size: 12.5px; color: var(--ink-mute); text-decoration: none; line-height: 1.45; }
.toc-sub a:hover { color: var(--caramel-deep); }
.toc-sub a.is-active { color: var(--sage-deep); font-weight: 600; }
.toc-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); display: grid; gap: 4px; }
.toc-foot a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; font-size: 12.5px; color: var(--ink-soft); text-decoration: none; }
.toc-foot a:hover { background: rgba(234,219,195,.35); color: var(--caramel-deep); }
.toc-foot a i { width: 14px; text-align: center; color: var(--caramel); }

/* ---- Chapters & clauses ---- */
.content { display: grid; gap: 18px; min-width: 0; }
.chapter { border-radius: 24px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: 120px; }
@media (min-width: 1024px) { .chapter { scroll-margin-top: 80px; } }
.chapter-head { display: flex; gap: 14px; align-items: center; padding: 16px 18px; background: linear-gradient(135deg, #F8F1E5, #F1E7D6); border-bottom: 1px solid var(--line-soft); }
@media (min-width: 768px) { .chapter-head { padding: 18px 24px; } }
.chapter-head .ch-num { flex-shrink: 0; text-align: center; padding: 6px 10px; border-radius: 14px; background: var(--surface); border: 1px solid rgba(169,130,96,.25); }
.chapter-head .ch-num small { display: block; font-size: 10px; font-weight: 600; color: var(--ink-mute); line-height: 1.2; }
.chapter-head .ch-num b { display: block; font-family: 'Kanit', sans-serif; font-size: 20px; font-weight: 600; color: var(--caramel-deep); line-height: 1.1; }
.chapter-head h2 { font-size: 19px; font-weight: 600; }
.chapter-head p { margin-top: 2px; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.clause { padding: 18px 18px 20px; border-top: 1px solid var(--line-soft); scroll-margin-top: 120px; }
.chapter-head + .clause { border-top: 0; }
@media (min-width: 768px) { .clause { padding: 20px 24px 22px; } }
@media (min-width: 1024px) { .clause { scroll-margin-top: 80px; } }
.clause h3 { display: flex; align-items: baseline; gap: 10px; font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.clause h3 .cn { flex-shrink: 0; font-size: 13px; font-weight: 600; color: var(--sage-deep); background: var(--sage-mist); border: 1px solid rgba(124,143,110,.25); border-radius: 8px; padding: 0 7px; }
.clause p, .clause li { font-size: 14px; color: var(--ink-soft); }
.clause p + p { margin-top: 8px; }
.clause b, .clause strong { color: var(--ink); font-weight: 600; }
.clause a { color: var(--caramel-deep); text-underline-offset: 3px; }
.ticks { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.ticks li { display: flex; gap: 9px; align-items: flex-start; }
.ticks li::before { content: '\f058'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: 12px; color: var(--sage); margin-top: 4px; flex-shrink: 0; }
.ticks.no li::before { content: '\f05e'; color: var(--terra); }

/* Definition / info tiles */
.tiles { display: grid; gap: 8px; margin-top: 10px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile { padding: 10px 12px; border-radius: 14px; background: var(--paper); border: 1px solid var(--line-soft); font-size: 13px; color: var(--ink-soft); line-height: 1.55; }
.tile b { display: block; font-size: 13.5px; color: var(--ink); }
.tile i { color: var(--caramel); margin-right: 6px; }

/* Callouts */
.note { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 11px 13px; border-radius: 14px; font-size: 13px; line-height: 1.6; color: #3D5532; background: var(--sage-mist); border: 1px solid rgba(124,143,110,.28); }
.note i { margin-top: 3px; color: var(--sage); }
.note.warn { color: #6C491C; background: var(--honey-bg); border-color: var(--honey-line); }
.note.warn i { color: #C48D38; }
.note.danger { color: #713627; background: var(--terra-bg); border-color: #EDC2B1; }
.note.danger i { color: var(--terra); }

/* Timeline */
.timeline { list-style: none; margin: 12px 0 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 15px; top: 10px; bottom: 10px; width: 2px; background: linear-gradient(var(--sage-soft), var(--latte), #EDC2B1); }
.timeline li { position: relative; display: flex; gap: 12px; padding: 6px 0; }
.timeline .dot { position: relative; z-index: 1; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; color: #FFFDF8; background: var(--sage); box-shadow: 0 0 0 4px var(--surface); }
.timeline .dot.honey { background: #C48D38; } .timeline .dot.terra { background: var(--terra); } .timeline .dot.caramel { background: var(--caramel); }
.timeline .tl-body { padding-top: 4px; min-width: 0; }
.timeline .tl-body b { display: block; font-size: 13.5px; color: var(--ink); }
.timeline .tl-body span { display: block; font-size: 13px; color: var(--ink-soft); line-height: 1.55; }

/* Data table — rows become stacked cards on phones */
.dtable { margin-top: 12px; border-radius: 16px; border: 1px solid var(--line); overflow: hidden; }
.drow { display: grid; grid-template-columns: 1.25fr 1.25fr .9fr; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--ink-soft); line-height: 1.55; }
.drow:first-child { border-top: 0; }
.drow.head { background: var(--sand); font-size: 12px; font-weight: 700; color: var(--ink-soft); letter-spacing: .02em; }
.drow > div:first-child { color: var(--ink); font-weight: 500; }
.drow > div:first-child i { width: 16px; color: var(--caramel); margin-right: 6px; }
.dtable.two .drow { grid-template-columns: .9fr 1.6fr; }
@media (max-width: 639px) {
  .drow, .dtable.two .drow { grid-template-columns: 1fr; gap: 3px; padding: 12px 14px; }
  .drow.head { display: none; }
  .drow > div[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 700; color: var(--ink-mute); margin-top: 4px; }
}

/* Rights grid */
.rights { display: grid; gap: 8px; margin-top: 10px; grid-template-columns: 1fr 1fr; }
@media (min-width: 768px) { .rights { grid-template-columns: repeat(3, 1fr); } }
.right { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 14px; background: var(--paper); border: 1px solid var(--line-soft); font-size: 13px; color: var(--ink); line-height: 1.4; }
.right i { color: var(--sage); width: 16px; text-align: center; flex-shrink: 0; }

/* Contact */
.contact { display: grid; gap: 14px; padding: 20px 18px; border-radius: 24px; background: linear-gradient(135deg, #EEF2E8, #F3E8D6); border: 1px solid rgba(124,143,110,.25); box-shadow: var(--shadow); scroll-margin-top: 120px; }
@media (min-width: 768px) { .contact { padding: 24px; grid-template-columns: 1fr auto; align-items: center; } }
.contact h2 { font-size: 18px; font-weight: 600; }
.contact p { font-size: 13.5px; color: var(--ink-soft); margin-top: 3px; }
.contact-links { display: grid; gap: 8px; }
@media (min-width: 560px) { .contact-links { grid-template-columns: repeat(2, auto); } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 14px; font-size: 13.5px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn-sage { color: #FFFDF8; background: linear-gradient(135deg, #8DA27E, #667B5B); box-shadow: 0 10px 20px -12px rgba(102,123,91,.9); }
.btn-ghost { color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.btn:hover { transform: translateY(-1px); }

/* Footer + back to top */
.foot { border-top: 1px solid var(--line); padding: 22px 0 90px; text-align: center; font-size: 12.5px; color: var(--ink-mute); }
.foot nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; }
.foot nav a { color: var(--ink-soft); text-decoration: none; }
.foot nav a:hover { color: var(--caramel-deep); }
.to-top { position: fixed; right: 16px; bottom: 18px; z-index: 35; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #FFFDF8; background: linear-gradient(135deg, #8DA27E, #667B5B); box-shadow: 0 12px 24px -12px rgba(102,123,91,.9); opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }

@media print {
  body { background: #fff; }
  .topbar, .chapter-bar, .toc, .to-top, .doc-switch, .quick { display: none !important; }
  .layout { display: block; }
  .chapter, .hero, .contact { box-shadow: none; break-inside: auto; }
}
