/*
 * CozyKit — the site's whole design system.
 *
 * Two rules it keeps: the palette is the app's own (ui/theme/Color.kt — milk-coffee brown on
 * warm cream, deliberately desaturated), so the site and the product look like one thing; and
 * nothing is fetched from anywhere else. No webfont, no framework, no script — partly because
 * the site's claim is that this software doesn't phone home, and a page that quietly loads
 * fonts from a third party is a poor way to say so.
 */

/* ── Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg: #F8F6F2;          /* app background */
  --surface: #FFFFFF;
  --surface-2: #F2EFE9;
  --surface-3: #ECE8E1;
  --text: #1F1B17;
  --text-2: #4A463F;
  --muted: #6E6A62;
  --accent: #6B5A4C;      /* md_light_primary */
  --accent-hover: #574739;
  --on-accent: #FFFFFF;
  --accent-soft: #F1E4D4; /* md_light_primaryContainer */
  --accent-ink: #4A3B2E;
  --border: #DED8CE;
  --border-strong: #C9C2B6;
  --shadow: 0 1px 2px rgb(31 27 23 / .04), 0 8px 24px -12px rgb(31 27 23 / .18);
  --shadow-lg: 0 2px 4px rgb(31 27 23 / .05), 0 24px 48px -24px rgb(31 27 23 / .30);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;

  --wrap: 1100px;
  --wrap-prose: 720px;
  --gutter: 24px;
  --section: clamp(56px, 9vw, 104px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130F;
    --surface: #1E1B16;
    --surface-2: #221F19;
    --surface-3: #2C2922;
    --text: #E9E2D9;
    --text-2: #CDC6BB;
    --muted: #9E968A;
    --accent: #D8BFA8;    /* md_dark_primary */
    --accent-hover: #E7D3C0;
    --on-accent: #3A2C1E;
    --accent-soft: #3A2E22;
    --accent-ink: #E7D3C0;
    --border: #3A352D;
    --border-strong: #4A463F;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px -12px rgb(0 0 0 / .6);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / .35), 0 24px 48px -24px rgb(0 0 0 / .8);
  }
}

/* ── Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Anchored headings shouldn't hide under the sticky header. */
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* Thai first in the stack: on a Thai phone this picks the system Thai face, and Latin
     characters fall through to the UI font either way. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai UI",
               "Noto Sans Thai", "Sarabun", "Leelawadee UI", Roboto, "Helvetica Neue",
               Arial, sans-serif;
  font-size: 17px;
  /* Thai has tall ascenders and low descenders; anything under ~1.7 collapses the tone marks. */
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Thai runs have no spaces to break at; without this a long one can push past the viewport
     on a narrow phone. */
  overflow-wrap: break-word;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 20;
}
.skip:focus { left: 12px; }

/* ── Layout ─────────────────────────────────────────────────────── */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-prose { width: 100%; max-width: var(--wrap-prose); margin: 0 auto; padding: 0 var(--gutter); }

section { padding: var(--section) 0; }
section + section { padding-top: 0; }

.stack > * + * { margin-top: 16px; }
.mt { margin-top: 28px; }

/* ── Type ───────────────────────────────────────────────────────── */
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.015em; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(32px, 5.2vw, 50px); line-height: 1.18; }
h2 { font-size: clamp(24px, 3.4vw, 33px); }
h3 { font-size: clamp(18px, 2vw, 20px); }

p { margin: 0 0 18px; }
p:last-child { margin-bottom: 0; }

.lede {
  font-size: clamp(18px, 2.2vw, 21px);
  line-height: 1.65;
  color: var(--text-2);
  max-width: 36em;
}
.eyebrow {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.section-head { max-width: 40em; margin-bottom: 40px; }
.section-head h2 + p { margin-top: 14px; color: var(--text-2); }

ul, ol { padding-left: 1.3em; margin: 0 0 18px; }
li { margin-bottom: 8px; }
li::marker { color: var(--muted); }

code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-word;
}

hr { border: none; border-top: 1px solid var(--border); margin: var(--section) 0; }

/* ── Header ─────────────────────────────────────────────────────── */
header.site {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
}
@supports not (backdrop-filter: blur(1px)) {
  header.site { background: var(--bg); }
}
header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand .mark { width: 30px; height: 30px; flex: none; }

nav.site { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
nav.site a {
  color: var(--text-2);
  text-decoration: none;
  font-size: 15px;
  padding: 7px 12px;
  border-radius: 999px;
}
nav.site a:hover { color: var(--text); background: var(--surface-2); }
nav.site a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

/* ── Buttons ────────────────────────────────────────────────────── */
.btns { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 13px 22px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  border: 1px solid transparent;
  transition: background-color .15s ease, transform .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--accent-hover); color: var(--on-accent); transform: translateY(-1px); }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--accent); }

/* ── Hero ───────────────────────────────────────────────────────── */
.hero { padding-top: clamp(40px, 7vw, 80px); }
.hero-grid {
  display: grid;
  gap: clamp(32px, 5vw, 64px);
  align-items: center;
  grid-template-columns: 1fr;
}
@media (min-width: 880px) {
  .hero-grid { grid-template-columns: 1.05fr 0.95fr; }
}
.hero h1 { margin-bottom: 20px; }
.hero .lede { margin-bottom: 28px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}

/* ── Phone mockup ───────────────────────────────────────────────── */
.phone {
  --w: 272px;
  width: var(--w);
  border-radius: 34px;
  padding: 9px;
  background: linear-gradient(160deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  margin: 0 auto;
}
.phone img {
  border-radius: 26px;
  width: 100%;
  background: var(--surface-2);
}
.phone.sm { --w: 228px; }

.phone-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(-40px, -2vw, 0px);
}
.phone-fan {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}
.phone-fan .phone { --w: 100%; }
@media (max-width: 700px) {
  .phone-fan { grid-template-columns: 1fr; max-width: 300px; margin: 0 auto; gap: 24px; }
}

figure { margin: 0; }
figcaption {
  margin-top: 14px;
  font-size: 14.5px;
  color: var(--muted);
  text-align: center;
}

/* ── Cards & grids ──────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
/* Six cards want three across, not four-and-two-orphans. */
.grid.three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}
.card h3 { margin-bottom: 10px; }
.card p { color: var(--text-2); font-size: 15.5px; line-height: 1.65; }
.card .ico {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 21px;
  margin-bottom: 16px;
}

a.app-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 4vw, 36px);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
a.app-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  color: inherit;
}
a.app-card .row { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
a.app-card .tile {
  width: 52px; height: 52px; flex: none;
  border-radius: 15px;
  background: var(--accent-soft);
  display: grid; place-items: center;
  font-size: 26px;
}
a.app-card h3 { margin: 0; font-size: 21px; }
a.app-card .sub { color: var(--muted); font-size: 15px; }
a.app-card p { color: var(--text-2); }
a.app-card .more { color: var(--accent-ink); font-weight: 600; font-size: 15px; margin-top: 14px; display: inline-block; }

/* ── Feature rows (text beside a screenshot) ────────────────────── */
.feature {
  display: grid;
  gap: clamp(28px, 5vw, 56px);
  align-items: center;
  grid-template-columns: 1fr;
  padding: clamp(32px, 5vw, 56px) 0;
}
@media (min-width: 880px) {
  .feature { grid-template-columns: 1fr 1fr; }
  .feature.flip .feature-media { order: -1; }
}
.feature h3 { font-size: clamp(21px, 2.6vw, 26px); margin-bottom: 14px; }
.feature p { color: var(--text-2); }
.feature ul { color: var(--text-2); font-size: 15.5px; }

/* ── Callout ────────────────────────────────────────────────────── */
.note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 22px 26px;
  color: var(--text-2);
  font-size: 15.5px;
}
.note strong { color: var(--text); }

/* ── Facts strip ────────────────────────────────────────────────── */
.facts {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.facts div { background: var(--surface); padding: 22px; }
.facts dt { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.facts dd { margin: 0; font-size: 17px; font-weight: 600; }

/* ── Docs (privacy, label page) ─────────────────────────────────── */
.doc { padding: clamp(24px, 5vw, 56px) 0 var(--section); }
.doc h1 { margin-bottom: 18px; }
.doc h2 { margin: 48px 0 14px; }
.doc h3 { margin: 32px 0 10px; }
.doc .meta { color: var(--muted); font-size: 15px; margin-bottom: 8px; }
.doc p, .doc li { color: var(--text-2); }

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin: 32px 0 44px;
}
.toc p { font-weight: 600; margin: 0 0 10px; font-size: 15px; color: var(--text); }
.toc ol { margin: 0; font-size: 15px; }
.toc li { margin-bottom: 5px; }

.lang { display: flex; gap: 8px; margin-bottom: 28px; flex-wrap: wrap; }
.lang a {
  font-size: 14px;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-2);
}
.lang a:hover { border-color: var(--accent); color: var(--text); }

/* ── Footer ─────────────────────────────────────────────────────── */
footer.site {
  border-top: 1px solid var(--border);
  padding: 44px 0 56px;
  color: var(--muted);
  font-size: 14.5px;
}
footer.site .wrap {
  display: flex;
  justify-content: space-between;
  gap: 20px 32px;
  flex-wrap: wrap;
}
footer.site nav { display: flex; gap: 6px 20px; flex-wrap: wrap; }
footer.site a { color: var(--muted); text-decoration: none; }
footer.site a:hover { color: var(--text); }

/* ── Print (the privacy policy gets printed and filed) ──────────── */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --text-2: #222; --border: #ccc; }
  header.site, footer.site, .lang, .toc, .skip { display: none; }
  body { font-size: 11pt; line-height: 1.6; }
  .doc { padding: 0; }
  h1, h2, h3 { break-after: avoid; }
  a { color: #000; text-decoration: underline; }
}
