/* Public pages and the chat: front page, about, sign-in and sign-up, chat app.
   A jewellery house's look: pearl and midnight grounds, sapphire ink, champagne gold;
   serif display headings over IBM Plex text; hallmark stamps mark every source. */

@font-face { font-family: "Plex"; src: url("fonts/plex-sans-latin-400.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-024F, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Plex"; src: url("fonts/plex-sans-latin-500.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0000-024F, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Plex"; src: url("fonts/plex-sans-latin-600.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0000-024F, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Plex"; src: url("fonts/plex-sans-thai-400.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Plex"; src: url("fonts/plex-sans-thai-500.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Plex"; src: url("fonts/plex-sans-thai-600.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Plex Mono"; src: url("fonts/plex-mono-latin-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/plex-mono-latin-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
/* Display: Cormorant Garamond for Latin, Noto Serif Thai for Thai (both variable). */
@font-face { font-family: "Gem Display"; src: url("fonts/cormorant-garamond-latin.woff2") format("woff2"); font-weight: 300 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Gem Display"; src: url("fonts/noto-serif-thai.woff2") format("woff2"); font-weight: 300 700; font-display: swap; unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }

:root {
  --paper: #f7f5f0;        /* pearl */
  --paper-2: #efebe2;
  --card: #fffefb;
  --ink: #121a2b;          /* midnight sapphire text */
  --ink-soft: #5b6273;
  --line: #e4ded2;
  --sapphire: #1c4876;
  --sapphire-ink: #ffffff;
  --sapphire-tint: #e8eef6;
  --primary: #1c4876;      /* main buttons */
  --on-primary: #ffffff;
  --gold: #8a6406;         /* assay gold, for text and stamps */
  --gold-line: #c6a052;
  --gold-tint: #f6eedb;
  --champagne-1: #e6c886;  /* gold buttons */
  --champagne-2: #c99c48;
  --on-gold: #1d1606;
  --glow: rgba(28, 72, 118, 0.10);
  --shadow: rgba(18, 26, 43, 0.45);
  --danger: #a3261f;
  --ready: #1f8a5b;        /* a model ready to use */
  --focus: #8a6406;
  --radius: 14px;
  --sans: "Plex", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  --mono: "Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --display: "Gem Display", "Cormorant Garamond", "Noto Serif Thai", Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b0f1a;      /* midnight velvet */
    --paper-2: #10162a;
    --card: #131a2b;
    --ink: #efeae0;        /* pearl text */
    --ink-soft: #a6abb8;
    --line: #252d42;
    --sapphire: #9fc2ea;
    --sapphire-ink: #0b0f1a;
    --sapphire-tint: #1b2740;
    --primary: #ece6d8;    /* pearl buttons on midnight */
    --on-primary: #0b0f1a;
    --gold: #e3bd62;
    --gold-line: #a8843a;
    --gold-tint: #2a2414;
    --champagne-1: #edd394;
    --champagne-2: #c9a04e;
    --on-gold: #1a1305;
    --glow: rgba(90, 140, 210, 0.16);
    --shadow: rgba(0, 0, 0, 0.7);
    --danger: #ff8f87;
    --ready: #5fd49a;
    --focus: #e3bd62;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --paper: #0b0f1a;      /* midnight velvet */
    --paper-2: #10162a;
    --card: #131a2b;
    --ink: #efeae0;        /* pearl text */
    --ink-soft: #a6abb8;
    --line: #252d42;
    --sapphire: #9fc2ea;
    --sapphire-ink: #0b0f1a;
    --sapphire-tint: #1b2740;
    --primary: #ece6d8;    /* pearl buttons on midnight */
    --on-primary: #0b0f1a;
    --gold: #e3bd62;
    --gold-line: #a8843a;
    --gold-tint: #2a2414;
    --champagne-1: #edd394;
    --champagne-2: #c9a04e;
    --on-gold: #1a1305;
    --glow: rgba(90, 140, 210, 0.16);
    --shadow: rgba(0, 0, 0, 0.7);
    --danger: #ff8f87;
    --ready: #5fd49a;
    --focus: #e3bd62;
    color-scheme: dark;
  }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
}
a { color: var(--sapphire); text-underline-offset: 0.18em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline { display: inline; }
h1, h2, h3 { text-wrap: balance; }
:lang(th) { line-height: 1.75; }

/* Serif display headings; Thai needs more room for its tone marks. */
.display { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; line-height: 1.05; }
:lang(th) .display, .display:lang(th) { font-weight: 500; letter-spacing: 0; line-height: 1.4; }

/* --- shared pieces -------------------------------------------------------------------- */

.mark { width: 28px; height: 28px; flex: none; }
/* The mark: a brilliant-cut diamond in gold, each facet its own shade, with a glint. */
.gem-table { fill: #fff3cf; }
.gem-crown { fill: #f0d48a; }
.gem-crown-dark { fill: #d9ad55; }
.gem-pavilion { fill: #c4943c; }
.gem-pavilion-dark { fill: #8f6418; }
.gem-edge { fill: none; stroke: #6b4a10; stroke-width: 0.8; stroke-linejoin: round; }
.gem-glint { fill: var(--gold); }
/* Khaisom (ไข่ส้ม), the mark since 19 Nov 2026: an orange egg cut like a gem, with a face, a navy
   scarf and a sapphire brooch; the flat form of the mascot in static/khaisom/. */
.kh-body { fill: #f28c28; }
.kh-facet-lit { fill: #ffc77a; }
.kh-facet-hi { fill: #fbab4f; }
.kh-facet-dim { fill: #e0701c; }
.kh-edge { fill: none; stroke: #fff2dc; stroke-opacity: 0.7; stroke-width: 0.45; stroke-linejoin: round; }
.kh-scarf { fill: #1c4876; }
.kh-scarf-edge { fill: none; stroke: #c6a052; stroke-width: 0.6; }
.kh-eye { fill: #2a1a10; }
.kh-shine { fill: #fff; }
.kh-smile { fill: none; stroke: #2a1a10; stroke-width: 0.95; stroke-linecap: round; }
.kh-brooch { fill: #6fa6e8; stroke: #c6a052; stroke-width: 0.4; }

.wordmark {
  display: inline-flex; align-items: center; gap: 0.6rem; min-width: 0;
  color: var(--ink); text-decoration: none; font-weight: 600; letter-spacing: -0.01em;
}
.wordmark span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.6rem; padding: 0 1.15rem; border: 1px solid var(--primary);
  border-radius: 999px; background: var(--primary); color: var(--on-primary);
  font: 500 0.95rem/1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button:hover { filter: brightness(1.08); }
.button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.button-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.button-quiet:hover { border-color: var(--gold-line); filter: none; }
.button-gold {
  border-color: transparent; color: var(--on-gold);
  background: linear-gradient(160deg, var(--champagne-1), var(--champagne-2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 20px -12px var(--champagne-2);
}
.button-link {
  padding: 0; border: 0; background: none; color: var(--sapphire);
  font: inherit; font-size: 0.85rem; cursor: pointer; text-decoration: underline;
  text-underline-offset: 0.18em;
}
.button-link.danger { color: var(--danger); }
.icon-button {
  display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  color: var(--ink); font-size: 1.3rem; cursor: pointer;
}
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.aside, .note { color: var(--ink-soft); font-size: 0.875rem; }
.error { color: var(--danger); }
.notice {
  margin: 0 0 1rem; padding: 0.7rem 1rem; border-radius: 10px;
  background: var(--sapphire-tint); color: var(--ink);
}

/* English / ไทย */
.lang-switch {
  display: inline-flex; flex: none; padding: 2px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--card);
}
.lang-switch a {
  padding: 0.22rem 0.6rem; border-radius: 999px; color: var(--ink-soft);
  font: 500 0.78rem/1.3 var(--sans); text-decoration: none;
}
.lang-switch a:hover { color: var(--ink); }
.lang-switch a[aria-current] { background: var(--ink); color: var(--paper); }

/* The hallmark: a struck assay stamp, used for every source. */
.hallmark {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.45em; height: 1.45em; margin: 0 0.1em 0 0.2em; padding: 0 0.3em;
  border: 1.5px solid var(--gold-line); background: var(--gold-tint); color: var(--gold);
  font: 500 0.78em/1 var(--mono); letter-spacing: 0.02em; vertical-align: 0.12em;
  clip-path: polygon(0.32em 0, calc(100% - 0.32em) 0, 100% 0.32em, 100% calc(100% - 0.32em),
                     calc(100% - 0.32em) 100%, 0.32em 100%, 0 calc(100% - 0.32em), 0 0.32em);
  text-decoration: none;
}
a.cite { text-decoration: none; }
a.cite .hallmark, a.cite.hallmark { cursor: pointer; }
a.cite:hover .hallmark, a.cite.hallmark:hover { background: var(--gold-line); color: var(--card); }

/* --- top bar of the public pages -------------------------------------------------------- */

.site-top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  width: min(72rem, 100% - 2rem); margin: 0 auto; padding: 0.9rem 0;
}
.site-nav { display: flex; align-items: center; gap: 0.6rem; }
.nav-link { padding: 0.3rem 0.4rem; color: var(--ink-soft); font-size: 0.92rem; text-decoration: none; white-space: nowrap; }
.nav-link:hover { color: var(--ink); }

/* --- about page --------------------------------------------------------------------------- */

.landing {
  min-height: 100vh; display: flex; flex-direction: column;
  background:
    radial-gradient(60rem 32rem at 85% -10%, var(--glow), transparent 70%),
    var(--paper);
}
.landing-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  width: min(72rem, 100% - 2rem); margin: auto auto 0; padding: 1.25rem 0;
  border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 0.875rem;
}
.landing-main { width: min(72rem, 100% - 2rem); margin: 0 auto; }

.hero {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center; padding: clamp(2rem, 7vw, 5rem) 0 clamp(2.5rem, 6vw, 4.5rem);
}
.eyebrow {
  margin: 0 0 1rem; color: var(--gold); font: 500 0.76rem/1.4 var(--mono);
  letter-spacing: 0.14em; text-transform: uppercase;
}
:lang(th) .eyebrow { font-family: var(--sans); font-size: 0.85rem; letter-spacing: 0.02em; }
.hero h1 { margin: 0 0 1.25rem; font-size: clamp(2.6rem, 5.6vw, 4.4rem); }
:lang(th) .hero h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); }
.lede { margin: 0 0 2rem; max-width: 36rem; color: var(--ink-soft); font-size: 1.08rem; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; }
.hero-aside { margin: 0.9rem 0 0; }

.specimen {
  margin: 0; padding: 1.25rem; border: 1px solid var(--line); border-radius: 20px;
  background: var(--card); box-shadow: 0 40px 70px -50px var(--shadow);
  position: relative;
}
.specimen::before {
  content: ""; position: absolute; inset: -1px -1px auto; height: 3px; border-radius: 20px 20px 0 0;
  background: linear-gradient(90deg, transparent, var(--champagne-2), transparent);
}
.specimen-q {
  margin-left: auto; max-width: 85%; padding: 0.75rem 1rem; border-radius: 16px 16px 4px 16px;
  background: var(--sapphire-tint); font-weight: 500;
}
.specimen-a { padding: 1rem 0.25rem 0.25rem; }
.specimen-a p { margin: 0 0 1rem; }
.specimen figcaption { padding-top: 0.75rem; border-top: 1px dashed var(--line); color: var(--ink-soft); font-size: 0.8rem; }
.hallmarks { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.75rem; padding: 0; list-style: none; }
.hallmarks li {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.65rem 0.3rem 0.35rem;
  border: 1px solid var(--line); border-radius: 999px; font-size: 0.82rem; color: var(--ink-soft);
}
.hallmarks .hallmark { margin: 0; vertical-align: 0; }

.facets {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0 0 5rem;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line);
}
.facet { padding: 1.6rem; background: var(--card); }
.facet-mark {
  display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; margin: 0 0 1rem;
  border: 1.5px solid var(--gold-line); border-radius: 50%; color: var(--gold);
  font: 600 1.05rem/1 var(--display);
}
.facet-mark.hallmark { border-radius: 0; font: 500 0.9rem/1 var(--mono); }
.facet h2 { margin: 0 0 0.5rem; font-size: 1.05rem; font-weight: 600; }
.facet p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

.section-head { max-width: 40rem; margin: 0 0 2rem; }
.section-head h2, .library h2 { margin: 0 0 0.75rem; font-size: clamp(2rem, 4vw, 2.8rem); }
.section-head > p:last-child { margin: 0; color: var(--ink-soft); }

.models-intro { margin: 0 0 3rem; }
.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.kind {
  padding: 1.4rem 1.5rem; border: 1px solid var(--line); border-top: 3px solid var(--gold-line);
  border-radius: 6px 6px var(--radius) var(--radius); background: var(--card);
}
.kind h3 { margin: 0 0 0.4rem; font: 600 1.6rem/1.15 var(--display); }
:lang(th) .kind h3 { font-weight: 500; font-size: 1.35rem; line-height: 1.5; }
.kind p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

.ways {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0 0 5rem;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line);
}
.way { padding: 1.5rem 1.6rem; background: var(--paper-2); }
.way h3 { margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 600; }
.way p { margin: 0 0 0.75rem; color: var(--ink-soft); font-size: 0.95rem; }
.way a { font-weight: 500; text-decoration: none; }

.library { margin: 0 0 5rem; }
.library > p { margin: 0 0 1.25rem; color: var(--ink-soft); }
.publishers { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.publishers li {
  padding: 0.45rem 0.85rem; border: 1px solid var(--gold-line); border-radius: 6px;
  background: var(--card); font: 500 0.82rem/1.3 var(--mono); color: var(--ink);
}

/* --- sign-in and sign-up -------------------------------------------------------------------- */

.entry { position: relative; background: radial-gradient(50rem 30rem at 50% -10%, var(--glow), transparent 70%), var(--paper); }
.entry-top { position: absolute; top: 1rem; right: 1rem; }
.entry-main {
  display: flex; flex-direction: column; align-items: center; gap: 1.5rem;
  min-height: 100vh; padding: 11vh 1rem 3rem;
}
.entry-card {
  width: min(25rem, 100%); padding: 2rem; border: 1px solid var(--line);
  border-radius: 20px; background: var(--card); box-shadow: 0 30px 60px -45px var(--shadow);
}
.entry-card h1 { margin: 0 0 0.5rem; font: 600 2rem/1.1 var(--display); }
:lang(th) .entry-card h1 { font-weight: 500; font-size: 1.6rem; line-height: 1.45; }
.entry-lede { margin: 0 0 1.25rem; color: var(--ink-soft); font-size: 0.92rem; }
.entry-card form { margin-top: 1.25rem; }
.entry-card label { display: block; margin-bottom: 1rem; font-size: 0.9rem; color: var(--ink-soft); }
.entry-card input, .entry-card textarea {
  display: block; width: 100%; margin-top: 0.35rem; padding: 0.65rem 0.8rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
  color: var(--ink); font: inherit;
}
.entry-card textarea { resize: vertical; min-height: 6rem; line-height: 1.5; }
.entry-card input:focus, .entry-card textarea:focus { border-color: var(--sapphire); outline: none; }
.hint { display: block; margin-top: 0.3rem; font-size: 0.78rem; }
.entry-card .button { width: 100%; margin-top: 0.5rem; }
.entry-card .aside { margin: 1.25rem 0 0; }
.entry-back { color: var(--ink-soft); font-size: 0.875rem; }
.account-section { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.account-section .button { width: auto; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-size: 0.9rem; }
.button-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.cf-turnstile { margin: 0.25rem 0 1rem; min-height: 65px; }

/* --- chat app ------------------------------------------------------------------------------ */

.app { height: 100vh; overflow: hidden; }
.shell { display: grid; grid-template-columns: 17.5rem 1fr; height: 100vh; height: 100dvh; }

.rail {
  display: flex; flex-direction: column; gap: 1rem; min-height: 0; padding: 1rem;
  border-right: 1px solid var(--line); background: var(--paper-2);
}
.rail-head { display: flex; align-items: center; justify-content: space-between; }
.rail-close, .rail-open, .scrim { display: none; }
.new-chat { width: 100%; background: var(--card); color: var(--ink); border-color: var(--line); }
.new-chat:hover { border-color: var(--gold-line); filter: none; }
.new-chat svg { stroke: var(--gold); }
.history { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -0.5rem; }
.history-list { margin: 0; padding: 0; list-style: none; }
.history-list a {
  display: block; padding: 0.45rem 0.6rem; border-radius: 8px; color: var(--ink);
  font-size: 0.9rem; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-list a:hover { background: var(--card); }
.history-list a[aria-current="page"] { background: var(--card); box-shadow: inset 2px 0 0 var(--gold-line); font-weight: 500; }
.history-empty { padding: 0 0.6rem; color: var(--ink-soft); font-size: 0.875rem; }

/* The account button at the foot of the chat list, and the menu that opens above it. */
.rail-foot { margin: 0 -0.5rem; padding-top: 0.6rem; border-top: 1px solid var(--line); }
.user-menu > summary.user-button {
  display: flex; width: 100%; gap: 0.65rem; padding: 0.45rem 0.5rem; border-radius: 10px; color: var(--ink);
}
.user-button:hover, .user-menu[open] > .user-button { background: var(--card); }
.avatar {
  display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%;
  background: linear-gradient(145deg, #f0d48a, #c4943c); color: #3b2a08; font-weight: 600; font-size: 0.9rem;
}
.user-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 0.92rem; }
.user-menu > summary svg.chevron { width: 16px; height: 16px; color: var(--ink-soft); transition: transform 0.15s; }
.user-menu:not([open]) svg.chevron { transform: rotate(180deg); }
.top-panel.user-panel {
  position: absolute; top: auto; bottom: calc(100% + 0.5rem); left: 0; right: 0; width: auto; padding: 0.35rem;
  max-height: calc(100dvh - 6rem); overflow-y: auto;
}
.user-panel .menu-group { display: grid; gap: 0.1rem; margin: 0; padding: 0.3rem 0; }
.user-panel .menu-group + .menu-group { border-top: 1px solid var(--line); }
.user-panel form { margin: 0; }
.user-panel .menu-item { display: flex; align-items: center; gap: 0.65rem; }
.user-panel .menu-item svg {
  width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; opacity: 0.8;
}
.menu-label {
  margin: 0.2rem 0.75rem 0.3rem; color: var(--ink-soft); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.admin-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0.1rem; }
.admin-links a {
  padding: 0.4rem 0.75rem; border-radius: 8px; color: var(--ink); font-size: 0.86rem; text-decoration: none;
}
.admin-links a:hover { background: var(--paper); }
.switch-row { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.35rem 0.75rem 0.5rem; }
.switch-text { flex: 1; display: grid; gap: 0.2rem; font-size: 0.9rem; }
.switch-text small { color: var(--ink-soft); font-size: 0.76rem; line-height: 1.45; }
.switch {
  position: relative; flex: none; width: 2.4rem; height: 1.4rem; margin-top: 0.05rem; padding: 0;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.4rem - 6px); height: calc(1.4rem - 6px);
  border-radius: 50%; background: var(--ink-soft); transition: transform 0.15s, background 0.15s;
}
.switch[aria-checked="true"] { background: var(--gold); border-color: var(--gold); }
.switch[aria-checked="true"]::after { transform: translateX(1rem); background: #fff; }
.switch:focus-visible { outline: 2px solid var(--gold-line); outline-offset: 2px; }

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-top {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 1.5rem;
  border-bottom: 1px solid var(--line);
}
.stage-title {
  flex: 1; margin: 0; font-size: 0.95rem; font-weight: 500; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 1.5rem 1.5rem 2rem; scroll-behavior: smooth; }
.thread > * { max-width: 46rem; margin-left: auto; margin-right: auto; }

/* An empty chat sits in the middle of the screen, as in other chat apps; the first
   question moves the box to the bottom. */
.stage:has(#welcome) .thread { flex: 0 1 auto; margin-top: auto; padding-bottom: 1rem; }
.stage:has(#welcome) .composer { margin-bottom: auto; padding-bottom: 2rem; }

.welcome { padding: 2rem 0 1rem; text-align: center; }
.welcome .mark { width: 46px; height: 46px; }
.welcome h1 { margin: 1rem 0 0.5rem; font: 600 clamp(2rem, 4.5vw, 3rem)/1.1 var(--display); letter-spacing: -0.01em; }
.welcome h1:lang(th), :lang(th) .welcome h1 { font-weight: 500; font-size: clamp(1.7rem, 3.6vw, 2.4rem); line-height: 1.45; }
.welcome > p { margin: 0 auto 1.4rem; max-width: 40rem; color: var(--ink-soft); }
.suggestions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; text-align: left; }
.suggestion {
  padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink); font: inherit; font-size: 0.92rem; line-height: 1.5;
  text-align: left; cursor: pointer; transition: border-color 0.15s ease, transform 0.15s ease;
}
.suggestion:hover { border-color: var(--gold-line); transform: translateY(-1px); }

.exchange { margin: 0 auto 2rem; }
.turn-user { display: flex; justify-content: flex-end; margin-bottom: 1rem; }
.question {
  margin: 0; max-width: 80%; padding: 0.7rem 1rem; border-radius: 16px 16px 4px 16px;
  background: var(--sapphire-tint); white-space: pre-wrap; overflow-wrap: anywhere;
}
.turn-assistant { display: grid; grid-template-columns: 2rem 1fr; gap: 0.75rem; }
.avatar .mark { width: 26px; height: 26px; margin-top: 0.15rem; }
.reply { min-width: 0; }
.answer { overflow-wrap: anywhere; }
.answer ul { margin: 0.4rem 0 0.6rem; padding-left: 1.25rem; }
.answer li { margin: 0.2rem 0; }
.answer.refused { color: var(--ink-soft); font-style: italic; }
/* A reply being written is formatted as it will be when finished (formatReply in site.js). */
.suggest-next { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.9rem; }
.suggestion-chip {
  padding: 0.4rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--ink); font: 400 0.84rem/1.35 var(--sans); text-align: left; cursor: pointer;
}
.suggestion-chip::before { content: "\2197"; margin-right: 0.35rem; color: var(--gold); }
.suggestion-chip:hover { border-color: var(--gold-line); }
.answer.streaming:empty::after, .answer.streaming > p:last-child::after, .answer.streaming > ul:last-child > li:last-child::after, .answer.streaming > ol:last-child > li:last-child::after { content: "\258D"; margin-left: 1px; color: var(--gold); animation: blink 1s steps(2, start) infinite; }
.answer a.cite { display: inline-flex; }
.answer a.cite::before { content: none; }

.guidance {
  margin: 0.9rem 0 0; padding: 0.8rem 1rem; border: 1px dashed var(--line);
  border-radius: 12px; background: var(--card);
}
.guidance p { margin: 0.2rem 0; white-space: pre-line; }
.guidance-label { font: 500 0.72rem/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }

.sources { display: grid; gap: 0.45rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.sources details { border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.sources summary {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.5rem;
  padding: 0.5rem 0.75rem; cursor: pointer; list-style: none; font-size: 0.86rem;
}
.sources summary::-webkit-details-marker { display: none; }
.sources .hallmark { margin: 0; vertical-align: 0; }
.source-title { font-weight: 500; }
.where { color: var(--ink-soft); font: 0.78rem/1.4 var(--mono); }
.excerpt {
  margin: 0; padding: 0.6rem 0.9rem 0.8rem; border-top: 1px solid var(--line);
  color: var(--ink-soft); font-size: 0.88rem; white-space: pre-line;
}

.reply-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; margin-top: 0.75rem; }
.reply-meta .note { font-size: 0.8rem; }
.feedback { display: inline-flex; align-items: center; gap: 0.6rem; }
.concept { margin: 0; }
.concept img { display: block; max-width: min(100%, 30rem); height: auto; border-radius: 12px; border: 1px solid var(--line); }
.chart .plot { min-height: 18rem; }

/* Ready-made diagrams below a reply (templates/diagrams/). Colours follow the theme;
   colour-grade swatches keep their own fill, as they show the stones' colour. */
.diagram { margin: 0.75rem 0; padding: 0.75rem; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.diagram .dg { display: block; width: 100%; max-width: 36rem; height: auto; margin: 0 auto; font-family: var(--sans); }
.diagram figcaption { margin-top: 0.4rem; }
.dg text { font-size: 15px; }
.dg-label { fill: var(--ink); }
.dg-strong, .dg-grade, .dg-number { font-weight: 600; }
.dg-small { fill: var(--ink-soft); font-size: 13px !important; }
.dg-tiny { fill: var(--ink-soft); font-size: 11.5px !important; }
.dg-greek { fill: var(--gold); font-size: 16px !important; font-weight: 600; }
.dg-grade { fill: var(--ink); font-size: 12.5px !important; }
.dg-number { fill: var(--ink); }
.dg-step { fill: var(--gold); font-weight: 600; }
.dg-stone { fill: var(--sapphire-tint); stroke: var(--sapphire); stroke-width: 1.6; stroke-linejoin: round; }
.dg-facet { fill: none; stroke: var(--sapphire); stroke-width: 0.9; opacity: 0.55; }
.dg-metal { fill: var(--gold-tint); stroke: var(--gold-line); stroke-width: 1.6; stroke-linejoin: round; }
.dg-prong { fill: none; stroke: var(--gold-line); stroke-width: 5; stroke-linecap: round; }
.dg-bead { fill: var(--gold-line); }
.dg-lead { fill: none; stroke: var(--ink-soft); stroke-width: 1; }
.dg-measure { fill: none; stroke: var(--gold); stroke-width: 1.2; }
.dg-rule { stroke: var(--line); stroke-width: 1; }
.dg-ray { fill: none; stroke: var(--gold); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.dg-leak { fill: none; stroke: var(--danger); stroke-width: 2.2; stroke-dasharray: 6 4; stroke-linejoin: round; stroke-linecap: round; }
.dg-inclusion { fill: var(--ink); opacity: 0.7; }
.dg-band { fill: var(--paper-2); }
.dg-band-strong { fill: var(--gold-tint); stroke: var(--gold-line); }
.dg-box { fill: var(--paper); stroke: var(--line); }
.dg-box-gold { fill: var(--gold-tint); stroke: var(--gold-line); }
.dg-swatch { stroke: rgba(18, 26, 43, 0.25); }
.dg-swatch-text { fill: #121a2b; font-size: 13px !important; font-weight: 600; }
.file-note { margin-left: 0.5rem; }
.file-chip { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0.2rem 0.4rem 0.4rem 0; padding: 0.3rem 0.4rem 0.3rem 0.6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font-size: 0.85rem; max-width: 100%; }
.file-chip[hidden] { display: none; }
.file-chip svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.file-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .photo-remove { position: static; flex: none; }

.pending .reply { color: var(--ink-soft); }
.pending .dots::after { content: "…"; animation: blink 1.2s steps(4, end) infinite; }
@keyframes blink { 0% { opacity: 0.2; } 50% { opacity: 1; } 100% { opacity: 0.2; } }

.thread .error { padding: 0.7rem 1rem; border: 1px solid var(--danger); border-radius: 10px; }
.failed .reply { display: grid; justify-items: start; gap: 0.75rem; }
.failed .error { margin: 0; }

.composer { padding: 0 1.5rem 1rem; }
.composer-box, .composer-note { max-width: 46rem; margin: 0 auto; }
.composer-box {
  padding: 0.6rem 0.6rem 0.5rem 1rem; border: 1px solid var(--line); border-radius: 22px;
  background: var(--card); box-shadow: 0 16px 36px -28px var(--shadow);
}
.composer-box:focus-within { border-color: var(--gold-line); }
.composer textarea {
  display: block; width: 100%; max-height: 12rem; padding: 0.35rem 0; border: 0; resize: none;
  background: transparent; color: var(--ink); font: inherit; line-height: 1.5; outline: none;
}
.composer-row { position: relative; display: flex; align-items: center; gap: 0.75rem; }
.send {
  display: grid; place-items: center; width: 2.35rem; height: 2.35rem; flex: none; margin-left: auto;
  border: 0; border-radius: 50%; color: var(--on-gold); cursor: pointer;
  background: linear-gradient(160deg, var(--champagne-1), var(--champagne-2));
}
.send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.send:disabled, .send.htmx-request { opacity: 0.45; cursor: wait; }
.composer-note { margin-top: 0.5rem; color: var(--ink-soft); font-size: 0.75rem; text-align: center; }
.guest-note { font-size: 0.8rem; }
.guest-note + .ai-note { margin-top: 0.2rem; }
.send.stop { background: var(--ink); color: var(--paper); }
.send.stop svg { fill: currentColor; stroke: none; }
.stopped-note { margin: 0.5rem 0 0; color: var(--ink-soft); font-size: 0.8rem; font-style: italic; }

/* About page: work stories and questions. */
.stories { margin: 0 0 4.5rem; }
.story-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.story {
  display: grid; align-content: start; gap: 0.5rem; padding: 1.4rem 1.5rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
}
.story-mark {
  display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 12px;
  background: var(--gold-tint); color: var(--gold);
}
.story-mark svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.story h3 { margin: 0.3rem 0 0; font: 600 1.35rem/1.25 var(--display); }
:lang(th) .story h3 { font-weight: 500; font-size: 1.2rem; line-height: 1.5; }
.story p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }
.story a { justify-self: start; margin-top: 0.3rem; font-weight: 500; }
.faq { margin: 0 0 4.5rem; }
.faq-list { display: grid; gap: 0.6rem; max-width: 48rem; }
.faq-item { border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.faq-item summary {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.95rem 1.2rem; font-weight: 600; cursor: pointer; list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--gold); font: 400 1.3rem/1 var(--sans); transition: transform 0.15s ease; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { margin: 0; padding: 0 1.2rem 1.1rem; color: var(--ink-soft); }
@media (max-width: 860px) { .story-grid { grid-template-columns: 1fr; } }

/* Retry and Edit: only on the latest exchange. */
.redo-only { display: none; }
#answers > .exchange:not(.pending):last-of-type .redo-only { display: inline-flex; }
.embed .redo-only { display: none !important; }
.turn-user { align-items: flex-start; gap: 0.4rem; }
.question-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; max-width: 80%; min-width: 0; }
.question-wrap .question { max-width: 100%; }
.edit-question {
  align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; margin-top: 0.3rem;
  border: 0; border-radius: 50%; background: none; color: var(--ink-soft); cursor: pointer; opacity: 0;
  transition: opacity 0.15s ease;
}
.turn-user:hover .edit-question, .edit-question:focus-visible { opacity: 1; }
@media (hover: none) { .edit-question { opacity: 0.7; } }
.edit-question:hover { color: var(--ink); background: var(--card); }
.edit-question svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.editing-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 46rem; margin: 0 auto 0.4rem; padding: 0.35rem 0.9rem;
  border-radius: 10px; background: var(--gold-tint); color: var(--ink); font-size: 0.82rem;
}

/* Photos: the button, the photo waiting to go, and a sent photo. */
.attach {
  display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; flex: none;
  border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--ink-soft); cursor: pointer;
}
.attach[hidden] { display: none; }
.attach:hover, .attach:focus-within { border-color: var(--gold-line); color: var(--ink); }
.attach svg, .photo-note svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.photo-chip { position: relative; display: inline-block; margin: 0.2rem 0 0.4rem; }
.photo-chip[hidden] { display: none; }
.photo-chip img { display: block; max-width: 7rem; max-height: 5rem; border: 1px solid var(--line); border-radius: 10px; object-fit: cover; }
.photo-remove {
  position: absolute; top: -0.45rem; right: -0.45rem; width: 1.4rem; height: 1.4rem; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--ink);
  font: 600 0.85rem/1 var(--sans); cursor: pointer;
}
.sent-photo { display: block; max-width: min(16rem, 100%); max-height: 14rem; border: 1px solid var(--line); border-radius: 14px; object-fit: cover; }
.photo-note { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--ink-soft); font-size: 0.78rem; }

/* Ideas under the empty chat's box. */
.starters {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem;
  max-width: 46rem; margin: 0.9rem auto 0.4rem;
}
.starter {
  display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.45rem 0.9rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--ink); font: 500 0.85rem/1.3 var(--sans); cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.starter:hover { border-color: var(--gold-line); transform: translateY(-1px); }
.starter svg { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.guest-note strong { color: var(--gold); font-weight: 600; }

/* --- choosing a model --------------------------------------------------------------------- */

.model-chip {
  display: inline-flex; align-items: center; gap: 0.4rem; max-width: 17rem;
  padding: 0.35rem 0.75rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink); font: 500 0.82rem/1.2 var(--sans);
  text-decoration: none; cursor: pointer; list-style: none; user-select: none;
}
.model-chip::-webkit-details-marker { display: none; }
.model-chip:hover { border-color: var(--gold-line); }
.model-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-chip svg { width: 14px; height: 14px; flex: none; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.model-chip .chev { stroke: var(--ink-soft); transition: transform 0.15s ease; }
.model-menu[open] .chev { transform: rotate(180deg); }

.model-panel {
  position: absolute; bottom: calc(100% + 0.9rem); left: -0.5rem; z-index: 30;
  width: min(27rem, calc(100vw - 2rem)); max-height: min(30rem, 62vh); overflow-y: auto;
  padding: 1.1rem; border: 1px solid var(--line); border-radius: 18px;
  background: var(--card); box-shadow: 0 30px 70px -30px var(--shadow);
}
.model-panel-title { margin: 0 0 0.8rem; font: 600 1.5rem/1.1 var(--display); }
:lang(th) .model-panel-title { font-weight: 500; font-size: 1.25rem; line-height: 1.5; }
.model-tabs { display: flex; gap: 0.25rem; margin: 0 0 0.9rem; padding: 0.25rem; border-radius: 999px; background: var(--paper); }
.model-tab {
  flex: 1; padding: 0.4rem 0.7rem; border: 0; border-radius: 999px; background: none;
  color: var(--ink-soft); font: 500 0.85rem/1.3 var(--sans); cursor: pointer;
}
.model-tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px -1px var(--shadow); }
.model-group { display: grid; gap: 0.5rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.model-group + .model-group { margin-top: 1rem; }
.model-group legend { margin-bottom: 0.3rem; padding: 0; font-weight: 600; font-size: 0.9rem; }
.model-panel:has(.model-tabs:not([hidden])) legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.model-panel:has(.model-tabs:not([hidden])) .model-group + .model-group { margin-top: 0; }
.model-group-note { margin: 0 0 0.25rem; color: var(--ink-soft); font-size: 0.82rem; }
.model-card {
  position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.model-card:hover { border-color: var(--gold-line); }
.model-card.waiting { opacity: 0.55; cursor: not-allowed; }
.model-card.waiting:hover { border-color: var(--line); }
.model-card input { position: absolute; opacity: 0; pointer-events: none; }
.model-card:has(input:checked) { border-color: var(--gold); background: var(--gold-tint); }
.model-card:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.model-card-body { display: grid; gap: 0.1rem; min-width: 0; }
.model-name { font-weight: 600; font-size: 0.95rem; }
.model-provider { color: var(--gold); font: 500 0.7rem/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
:lang(th) .model-provider { font-family: var(--sans); letter-spacing: 0; text-transform: none; }
.model-desc { color: var(--ink-soft); font-size: 0.82rem; }
.model-tick { width: 1.15rem; height: 1.15rem; border: 1.5px solid var(--line); border-radius: 50%; }
.model-card:has(input:checked) .model-tick {
  border-color: var(--champagne-2); background: var(--champagne-2);
  box-shadow: inset 0 0 0 3px var(--gold-tint);
}
.model-panel-foot { margin: 0.9rem 0 0; color: var(--ink-soft); font-size: 0.78rem; }
.composer-row { flex-wrap: wrap; }
.options-menu .model-chip svg:first-child { stroke: var(--gold); }
.options-panel { width: min(25rem, calc(100vw - 2rem)); }
.option-group { margin: 0 0 1rem; padding: 0; border: 0; min-width: 0; }
.option-group legend { margin-bottom: 0.45rem; padding: 0; font-weight: 600; font-size: 0.9rem; }
.segmented { display: flex; gap: 0.25rem; padding: 0.25rem; border-radius: 12px; background: var(--paper); }
.segmented.wrap { flex-wrap: wrap; }
.segmented label { position: relative; flex: 1 1 auto; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; padding: 0.4rem 0.6rem; border-radius: 9px; text-align: center; white-space: nowrap;
  color: var(--ink-soft); font: 500 0.82rem/1.3 var(--sans); cursor: pointer;
}
.segmented span:hover { color: var(--ink); }
.segmented input:checked + span { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px -1px var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.htmx-indicator { visibility: hidden; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { visibility: visible; }

/* --- the front page for visitors ---------------------------------------------------------- */

.guest .guest-shell {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  background: radial-gradient(56rem 30rem at 50% 0%, var(--glow), transparent 70%), var(--paper);
}
.guest .stage { flex: 1; }

/* --- narrow screens ----------------------------------------------------------------------- */

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .facets, .kinds { grid-template-columns: 1fr; }
  .ways { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: min(19rem, 86vw);
    transform: translateX(-102%); transition: transform 0.2s ease;
  }
  .rail-open-state .rail { transform: none; }
  .rail-close, .rail-open { display: inline-grid; }
  .rail-open-state .scrim { display: block; position: fixed; inset: 0; z-index: 10; background: rgba(12, 19, 34, 0.45); }
  .stage-top, .thread { padding-left: 1rem; padding-right: 1rem; }
  .composer { padding: 0 0.75rem 0.75rem; }
  .suggestions { grid-template-columns: 1fr; }
  .suggestion:nth-child(n+3) { display: none; }
  .question-wrap { max-width: 90%; }
  .composer-note { display: none; }
  .guest-note, .ai-note { display: block; }
  .wide-only { display: none; }
  .site-nav { gap: 0.4rem; }
  .site-nav .button { min-height: 2.25rem; padding: 0 0.8rem; font-size: 0.85rem; }
}

@media (max-width: 520px) {
  .site-top .wordmark { flex: none; }
  .site-top .wordmark span { display: none; }
  .nav-link { padding: 0.3rem 0.2rem; font-size: 0.85rem; }
  .site-nav { gap: 0.3rem; }
  .site-nav .button { padding: 0 0.7rem; }
  .lang-switch a { padding: 0.42rem 0.5rem; }
  .model-chip { white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .rail, .suggestion, .model-chip .chev { transition: none; }
  .pending .dots::after { animation: none; }
}

/* --- Reports ---------------------------------------------------------------------------- */

.report-page { width: min(46rem, 100% - 2rem); margin: 0 auto; padding: 1.5rem 0 3rem; }
.report-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 2rem; }
.report-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.report-head { padding-bottom: 1.25rem; margin-bottom: 1.5rem; border-bottom: 2px solid var(--gold-line); }
.report-head .eyebrow { margin: 1.25rem 0 0.25rem; }
.report-head h1 { margin: 0 0 0.4rem; font: 600 2rem/1.15 var(--display); }
:lang(th) .report-head h1 { font-weight: 500; font-size: 1.6rem; line-height: 1.45; }
.report-item { padding: 0 0 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--line); break-inside: avoid; }
.report-q { margin: 0 0 0.6rem; font-size: 1.05rem; font-weight: 600; }
.report-sources { margin: 0.8rem 0 0; padding: 0; list-style: none; display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--ink-soft); }
.report-sources li { display: flex; gap: 0.5rem; align-items: baseline; }
.report-foot { margin-top: 2rem; }
@media print {
  .report-actions { display: none; }
  .report { background: #fff; color: #111; }
  .report-page { width: 100%; padding: 0; }
  a { color: inherit; text-decoration: none; }
}

/* --- Browse models ------------------------------------------------------------------------ */

.provider-mark {
  --tone: #8a6406;
  display: inline-grid; place-items: center; flex: none; width: 2.6rem; height: 2.6rem;
  border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent); border-radius: 12px;
  background: color-mix(in srgb, var(--tone) 18%, var(--card)); color: var(--tone);
  font: 600 0.9rem/1 var(--sans); letter-spacing: 0.02em;
}
.provider-mark.small { width: 1.35rem; height: 1.35rem; border-radius: 6px; font-size: 0.6rem; }
.tone-0 { --tone: #8a6406; } .tone-1 { --tone: #0f766e; } .tone-2 { --tone: #b4532a; }
.tone-3 { --tone: #1d5fd8; } .tone-4 { --tone: #4f46e5; } .tone-5 { --tone: #7c3aed; }
.tone-6 { --tone: #c2410c; } .tone-7 { --tone: #475569; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .provider-mark { color: color-mix(in srgb, var(--tone) 70%, #ffffff); background: color-mix(in srgb, var(--tone) 30%, var(--card)); }
}
:root[data-theme="dark"] .provider-mark { color: color-mix(in srgb, var(--tone) 70%, #ffffff); background: color-mix(in srgb, var(--tone) 30%, var(--card)); }

.model-browser {
  width: min(58rem, calc(100vw - 2rem)); max-height: min(44rem, calc(100dvh - 2rem));
  padding: 0; border: 1px solid var(--line); border-radius: 20px;
  background: var(--card); color: var(--ink); box-shadow: 0 40px 90px -40px var(--shadow);
}
.model-browser[open] { display: flex; flex-direction: column; }
.model-browser::backdrop { background: rgba(8, 12, 22, 0.55); backdrop-filter: blur(2px); }
.browser-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.4rem 0.6rem; }
.browser-head .eyebrow { margin: 0 0 0.2rem; }
.browser-head h2 { margin: 0; font: 600 1.7rem/1.1 var(--display); }
:lang(th) .browser-head h2 { font-weight: 500; font-size: 1.4rem; line-height: 1.45; }
.browser-search {
  display: flex; align-items: center; gap: 0.5rem; margin: 0.4rem 1.4rem 0;
  padding: 0.55rem 0.9rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
}
.browser-search:focus-within { border-color: var(--gold-line); }
.browser-search svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--ink-soft); stroke-width: 2; stroke-linecap: round; }
.browser-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; outline: none; }
.browser-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.8rem 1.4rem 0.2rem; }
.filter-chip {
  padding: 0.3rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--ink-soft); font: 500 0.82rem/1.3 var(--sans); cursor: pointer;
}
.filter-chip span { margin-left: 0.2rem; opacity: 0.7; font-variant-numeric: tabular-nums; }
.filter-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.browser-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0.8rem 1.4rem 1rem; }
.browser-empty { margin: 1rem 0; color: var(--ink-soft); text-align: center; }
.browser-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem;
  padding: 0.8rem 1.4rem 1rem; border-top: 1px solid var(--line);
}
.browser-foot .note { margin: 0; font-size: 0.8rem; }

.tile-section + .tile-section { margin-top: 1.1rem; }
.tile-section-title {
  margin: 0 0 0.5rem; color: var(--ink-soft); font: 500 0.68rem/1.4 var(--mono);
  letter-spacing: 0.12em; text-transform: uppercase;
}
:lang(th) .tile-section-title { font-family: var(--sans); letter-spacing: 0; text-transform: none; font-size: 0.8rem; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: 0.5rem; }
.model-tile {
  position: relative; display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.7rem 2.1rem 0.7rem 0.75rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); text-align: left; transition: border-color 0.15s ease, background 0.15s ease;
}
label.model-tile { cursor: pointer; }
label.model-tile:hover { border-color: var(--gold-line); }
.model-tile input { position: absolute; opacity: 0; pointer-events: none; }
.model-tile .provider-mark { width: 2rem; height: 2rem; border-radius: 9px; font-size: 0.7rem; margin-top: 0.05rem; }
.tile-body { display: grid; gap: 0.08rem; min-width: 0; flex: 1; }
.tile-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.4rem; }
.tile-name { font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.tile-provider { color: var(--ink-soft); font: 500 0.6rem/1.5 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
:lang(th) .tile-provider { font-family: var(--sans); letter-spacing: 0; text-transform: none; font-size: 0.72rem; }
.tile-desc {
  margin-top: 0.15rem; color: var(--ink-soft); font-size: 0.76rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.badge { padding: 0 0.4rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); font: 500 0.62rem/1.6 var(--sans); white-space: nowrap; }
.badge-gold { border-color: var(--gold-line); color: var(--gold); background: var(--gold-tint); }
.tile-check {
  position: absolute; top: 0.75rem; right: 0.75rem; width: 1rem; height: 1rem;
  border: 1.5px solid var(--line); border-radius: 50%;
}
.model-tile:has(input:checked) { border-color: var(--gold); background: var(--gold-tint); }
.model-tile:has(input:checked) .tile-check { border-color: var(--champagne-2); background: var(--champagne-2); box-shadow: inset 0 0 0 2.5px var(--gold-tint); }
.model-tile:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.model-tile.waiting { padding-right: 0.75rem; background: transparent; border-style: dashed; }
.model-tile.waiting .tile-name { color: var(--ink-soft); }
.model-tile.waiting .provider-mark { filter: saturate(0.4); opacity: 0.75; }
label.model-tile.waiting { cursor: not-allowed; }
label.model-tile.waiting:hover { border-color: var(--line); }
.models-on-offer { margin: 2rem 0 1rem; font: 600 1.3rem/1.2 var(--display); }
.models-intro .model-tile { background: var(--card); }
.models-intro .model-tile.waiting { background: transparent; }

@media (max-width: 760px) {
  .model-browser {
    width: 100vw; max-width: 100vw; max-height: 88dvh; margin: auto 0 0;
    border-radius: 20px 20px 0 0; border-bottom: 0;
  }
  .model-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .model-tile { transition: none; } }

/* --- The AI Assist icon's chat, inside a client's page ------------------------------------ */

.embed .embed-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--paper); }
.embed .stage { flex: 1; }
.embed-top {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line); background: var(--card);
}
.embed-top .wordmark { font-size: 0.92rem; }
.embed-top .mark { width: 22px; height: 22px; }
.embed .thread { padding: 0.9rem 0.9rem 1rem; }
.embed .composer { padding: 0 0.6rem 0.6rem; }
.embed .composer-note.embed-note { display: block; margin-top: 0.4rem; font-size: 0.7rem; }
.embed-welcome { padding: 0.5rem 0 0.5rem; text-align: left; }
.embed-greeting {
  margin: 0 0 0.9rem; padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: 14px 14px 14px 4px;
  background: var(--card); max-width: 92%;
}
.embed .suggestions { grid-template-columns: 1fr; gap: 0.5rem; }
.embed .suggestion { padding: 0.6rem 0.8rem; font-size: 0.86rem; }
.embed .suggestion:nth-child(n+3) { display: block; }
.embed .question { max-width: 88%; }
.embed .turn-assistant { grid-template-columns: 1.6rem 1fr; gap: 0.5rem; }
.embed .avatar .mark { width: 20px; height: 20px; }
.embed .stage:has(#welcome) .thread { flex: 1 1 auto; margin-top: 0; }
.embed .stage:has(#welcome) .composer { margin-bottom: 0; padding-bottom: 0.6rem; }

/* --- About page: live figures and audiences ----------------------------------------- */

.figures {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 0 0 4rem;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line);
}
.figure { display: grid; gap: 0.2rem; padding: 1.2rem 1.3rem; background: var(--card); color: inherit; text-decoration: none; }
a.figure:hover strong { text-decoration: underline; text-underline-offset: 4px; }
.figure strong { font: 600 2.1rem/1 var(--display); color: var(--gold); font-variant-numeric: tabular-nums; }
.figure span { color: var(--ink-soft); font-size: 0.85rem; }

.audiences { margin: 0 0 4.5rem; }
.audience-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.audience { padding: 1.4rem 1.5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.audience h3 { margin: 0 0 0.35rem; font: 600 1.45rem/1.2 var(--display); }
:lang(th) .audience h3 { font-weight: 500; font-size: 1.25rem; line-height: 1.5; }
.audience > p { margin: 0 0 0.9rem; color: var(--ink-soft); font-size: 0.95rem; }
.try-list { display: grid; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.try-list a {
  display: block; padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink); font-size: 0.88rem; text-decoration: none;
}
.try-list a::before { content: "\2197"; margin-right: 0.45rem; color: var(--gold); }
.try-list a:hover { border-color: var(--gold-line); }

.ways.three { grid-template-columns: repeat(3, 1fr); }
.foot-links { display: flex; gap: 1.2rem; }

/* The library page: the kinds of sources, as cards. */
.sources-page { padding: 2.5rem 0 4rem; }
.sources-page .section-head h1 { margin: 0 0 0.75rem; font-size: clamp(2.2rem, 4.5vw, 3.2rem); }
.source-kinds { grid-template-columns: repeat(3, 1fr); margin: 0 0 1.75rem; }
.source-kinds .audience > p { margin: 0; }
.sources-more { color: var(--ink-soft); }
@media (max-width: 960px) { .source-kinds { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .source-kinds { grid-template-columns: 1fr; } }

/* --- Motion --------------------------------------------------------------------------------- */

.to-reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; }
.to-reveal.revealed { opacity: 1; transform: none; }

.specimen .writing::after { content: "\258D"; margin-left: 2px; color: var(--gold); animation: blink 1s steps(2, start) infinite; }
.specimen .waiting-sources { opacity: 0; transform: translateY(6px); }
.specimen .hallmarks { transition: opacity 0.5s ease, transform 0.5s ease; }
.specimen figcaption { display: flex; justify-content: space-between; gap: 1rem; }
.specimen-replay { font-size: 0.8rem; }

/* A hallmark is struck: it lands slightly large and settles. */
@keyframes stamp { 0% { transform: scale(1.7); opacity: 0; } 60% { transform: scale(0.92); opacity: 1; } 100% { transform: scale(1); } }
.stamp-in, .answer .hallmark { animation: stamp 0.38s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }

/* The gem catches the light now and then. */
@keyframes glint { 0%, 82%, 100% { filter: none; } 88% { filter: drop-shadow(0 0 6px rgba(230, 200, 134, 0.85)) brightness(1.25); } }
.welcome .mark, .site-top .mark, .rail-head .mark { animation: glint 6s ease-in-out infinite; }

/* Khaisom blinks now and then: only the logo in the header, the chat rail and the big logo,
   never the small marks beside each answer. Off when the visitor asks for less motion. */
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
.kh-eyes { transform-box: fill-box; transform-origin: center; }
.site-top .mark .kh-eyes, .rail-head .mark .kh-eyes, .welcome .mark .kh-eyes, .logo-big .kh-eyes { animation: blink 6.5s ease-in-out infinite; }
.logo-big .kh-eyes { animation-delay: 1.8s; }

/* The name with the Thai name under it (_name.html). */
.wordmark .name { display: inline-flex; flex-direction: column; line-height: 1.05; }
.name-th { font: 500 0.74em/1.25 var(--display); color: var(--gold); letter-spacing: 0; }

/* The big logo (_logo_big.html): sign-in, sign-up and the front-page footer. */
.logo-big { display: inline-flex; align-items: center; gap: 1rem; color: var(--ink); text-decoration: none; }
.logo-big-mark { width: 84px; height: 84px; flex: none; filter: drop-shadow(0 6px 10px rgba(18, 26, 43, 0.15)); }
.logo-big-text { display: flex; flex-direction: column; }
.logo-big-name { font: 600 2.7rem/0.95 var(--display); letter-spacing: 0.005em; }
.logo-big-th { font: 500 1.2rem/1.35 var(--display); color: var(--gold); margin-top: 0.2rem; }
.logo-big-tag { margin-top: 0.4rem; font: 500 0.68rem/1.2 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.entry-main .logo-big { margin-bottom: 1.5rem; }
.landing-foot .logo-big { flex-basis: 100%; padding: 0.75rem 0 0.25rem; }

@media (max-width: 860px) {
  .figures { grid-template-columns: repeat(2, 1fr); }
  .figure:last-child { grid-column: span 2; }
  .audience-grid, .ways.three { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .to-reveal { opacity: 1; transform: none; transition: none; }
  .stamp-in, .answer .hallmark, .welcome .mark, .site-top .mark, .rail-head .mark { animation: none; }
  .kh-eyes, .logo-big .kh-eyes { animation: none; }
  .specimen .writing::after { animation: none; }
}

/* Speaking a message. */
.mic.listening { border-color: var(--danger); color: var(--danger); animation: listening 1.4s ease-in-out infinite; }
@keyframes listening { 50% { box-shadow: 0 0 0 5px rgba(200, 60, 60, 0.15); } }
@media (prefers-reduced-motion: reduce) { .mic.listening { animation: none; } }

/* Searching your chats. */
.chat-search {
  display: flex; align-items: center; gap: 0.45rem; margin: 0.25rem 0 0.4rem; padding: 0.4rem 0.7rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
}
.chat-search:focus-within { border-color: var(--gold-line); }
.chat-search svg { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--ink-soft); stroke-width: 2; stroke-linecap: round; }
.chat-search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 0.875rem; outline: none; }

/* The chat's Share and More menus, and renaming it. */
.top-menu { position: relative; }
.top-menu > summary { display: inline-flex; align-items: center; gap: 0.35rem; list-style: none; cursor: pointer; }
.top-menu > summary::-webkit-details-marker { display: none; }
.top-menu > summary svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.more-menu > summary svg { fill: currentColor; stroke: none; }
.top-panel {
  position: absolute; top: calc(100% + 0.5rem); right: 0; z-index: 30; width: min(22rem, calc(100vw - 2rem));
  padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  box-shadow: 0 24px 60px -28px var(--shadow);
}
.menu-list { display: grid; width: 12rem; padding: 0.35rem; }
.menu-list form { margin: 0; }
.menu-item {
  display: block; width: 100%; padding: 0.55rem 0.75rem; border: 0; border-radius: 8px; background: none;
  color: var(--ink); font: inherit; font-size: 0.9rem; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--paper); }
.menu-item.danger { color: var(--danger); }
.share-panel { display: grid; gap: 0.75rem; }
.share-panel p { margin: 0; color: var(--ink-soft); font-size: 0.88rem; }
.share-panel form { margin: 0; }
.share-link { display: flex; gap: 0.5rem; }
.share-link input {
  flex: 1; min-width: 0; padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink); font: 0.8rem/1.4 var(--mono);
}
.rename-form { flex: 1; display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.rename-form[hidden] { display: none; }
.rename-form input[type=text] {
  flex: 1; min-width: 0; padding: 0.35rem 0.6rem; border: 1px solid var(--gold-line); border-radius: 8px;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 0.95rem;
}
@media (max-width: 520px) { .share-menu > summary span { display: none; } }
.share-menu > summary { text-decoration: none; }
@media (max-width: 760px) {
  .top-panel { position: fixed; top: 3.7rem; left: 0.75rem; right: 0.75rem; width: auto; }
  .more-menu .top-panel { left: auto; width: 13rem; }
}

/* About page: the product itself. */
.product-shot { margin: 0 0 4.5rem; }
.shot-frame {
  margin: 0; padding: 0.5rem; border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px);
  background: linear-gradient(160deg, var(--gold-tint), transparent 60%), var(--card);
  box-shadow: 0 40px 90px -50px var(--shadow);
}
.shot-frame img { display: block; width: 100%; height: auto; border-radius: var(--radius); }

/* Models ready to use stand out; those waiting for their provider's key are dimmed. */
.model-tile:not(.waiting) { background: var(--card); border-color: var(--gold-line); box-shadow: 0 10px 24px -20px var(--shadow); }
.model-tile.waiting { opacity: 0.5; }
.ready-dot {
  display: inline-flex; align-items: center; gap: 0.3rem; color: var(--ready);
  font: 600 0.62rem/1.6 var(--sans); white-space: nowrap;
}
.ready-dot::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--ready); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ready) 22%, transparent); }
.tile-section[data-section="ready"] .tile-section-title { color: var(--ready); }

/* Answers: real paragraphs, headings and tables. */
.answer p { margin: 0 0 0.8rem; }
.answer p:last-child, .answer > :last-child { margin-bottom: 0; }
.answer blockquote { margin: 0 0 0.8rem; padding: 0.5rem 0.9rem; border-left: 3px solid var(--gold-line); background: var(--gold-tint); border-radius: 0 8px 8px 0; }
.answer blockquote p { margin: 0; }
.answer .answer-heading { margin: 1.1rem 0 0.35rem; font-size: 1.02rem; }
.answer > .answer-heading:first-child { margin-top: 0; }
.answer ol { margin: 0.4rem 0 0.8rem; padding-left: 1.4rem; }
.answer-table { max-width: 100%; margin: 0.4rem 0 0.9rem; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.answer-table table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.answer-table th, .answer-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.answer-table th { background: var(--paper-2); font-weight: 600; }
.answer-table tr:last-child td { border-bottom: 0; }

/* Answer actions: small icon buttons, as in other chat apps. */
.reply-actions { display: inline-flex; align-items: center; gap: 0.15rem; }
.reply-actions .feedback { gap: 0.15rem; }
.act {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; padding: 0;
  border: 0; border-radius: 8px; background: none; color: var(--ink-soft); cursor: pointer;
}
.act:hover { background: var(--card); color: var(--ink); }
.act svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.act.done { color: var(--ready); }
.redo-only.act { display: none; }
#answers > .exchange:not(.pending):last-of-type .redo-only.act { display: inline-grid; }
.reply-meta { gap: 0.3rem 0.75rem; }

/* The chat's More button: a quiet icon, like Share beside it. */
.more-menu > summary.icon-button { width: 2.1rem; height: 2.1rem; border-color: transparent; background: none; color: var(--ink-soft); }
.more-menu > summary.icon-button:hover { background: var(--card); color: var(--ink); }

/* Phones: the message box on one row; the model and style chips keep only their icons. */
@media (max-width: 520px) {
  .composer-row { flex-wrap: nowrap; gap: 0.4rem; }
  /* Icons only on a phone; the model's name stays for screen readers. */
  .app:not(.guest) .composer-row #model-current, .composer-row #options-current { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .composer-row .model-chip { min-height: 2.25rem; padding: 0.35rem 0.55rem; }
  .composer-row .attach { width: 2.25rem; height: 2.25rem; }
}

/* The chat list's day headings. */
.history-day { margin: 0.9rem 0.6rem 0.25rem; color: var(--ink-soft); font: 600 0.7rem/1.4 var(--sans); letter-spacing: 0.04em; text-transform: uppercase; }
.history-day:first-child { margin-top: 0.2rem; }
:lang(th) .history-day { text-transform: none; letter-spacing: 0; font-size: 0.78rem; }
.answer-table th, .answer-table td { overflow-wrap: normal; word-break: normal; hyphens: manual; }
.answer-table th:first-child, .answer-table td:first-child { min-width: 7.5rem; }
.answer-table td { min-width: 9rem; }
.failed .try-again { justify-self: start; min-height: 2.2rem; }

/* --- CCI: who made the assistant ----------------------------------------------------------- */
:root { --cci: #f7821b; --cci-ink: #1d1203; --cci-soft: #fff3e6; }
.cci-band {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 0; margin: 0 0 4rem;
  border-radius: calc(var(--radius) + 4px); overflow: hidden; background: var(--cci); color: var(--cci-ink);
}
.cci-photo { min-height: 18rem; }
.cci-photo .site-photo, .cci-photo .photo-placeholder { width: 100%; height: 100%; min-height: 18rem; border-radius: 0; }
.cci-text { display: grid; align-content: center; gap: 0.5rem; padding: 2rem 2.2rem; }
.cci-logos { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem; }
.cci-logos img { height: 3.2rem; width: auto; background: #fff; border-radius: 10px; padding: 0.35rem 0.5rem; }
.cci-kicker { margin: 0; font: 600 0.72rem/1.4 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; }
:lang(th) .cci-kicker { letter-spacing: 0; text-transform: none; font-size: 0.85rem; }
.cci-band h2 { margin: 0; font: 600 clamp(1.4rem, 2.6vw, 1.9rem)/1.2 var(--display); color: var(--cci-ink); }
:lang(th) .cci-band h2 { font-weight: 500; line-height: 1.5; }
.cci-slogan { margin: 0; font: 800 1.05rem/1.3 var(--sans); letter-spacing: 0.02em; color: #fff; }
.cci-about { margin: 0.2rem 0 0; font-size: 0.95rem; line-height: 1.6; }
.cci-quote { margin: 0.4rem 0 0; padding-left: 0.9rem; border-left: 3px solid var(--cci-ink); }
.cci-quote p { margin: 0 0 0.2rem; font: italic 500 1.02rem/1.5 var(--display); }
.cci-quote footer { font-size: 0.85rem; }
.cci-link { justify-self: start; margin-top: 0.4rem; padding: 0.5rem 1rem; border-radius: 999px; background: var(--cci-ink); color: #fff; font-weight: 600; text-decoration: none; }
.cci-link:hover { background: #000; }
.cci-badge {
  display: inline-grid; place-items: center; padding: 0.1rem 0.4rem; border-radius: 4px;
  background: var(--cci); color: var(--cci-ink); font: 800 0.72rem/1.4 var(--sans); letter-spacing: 0.04em;
}
.cci-badge.large { padding: 0.45rem 0.8rem; border-radius: 10px; background: #fff; color: var(--cci); font-size: 1.5rem; letter-spacing: 0.02em; }
.cci-mark { display: inline-flex; align-items: center; gap: 0.35rem; color: inherit; text-decoration: none; white-space: nowrap; }
.cci-mark img { height: 1.1rem; width: auto; }
.cci-mark:hover span:last-child { text-decoration: underline; }
.foot-name { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

/* Photos, or quiet placeholders until they are added. */
.site-photo { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder {
  display: grid; place-items: center; align-content: center; gap: 0.4rem; width: 100%; height: 100%;
  background: repeating-linear-gradient(135deg, var(--card) 0 14px, var(--paper-2) 14px 28px);
  color: var(--ink-soft); font-size: 0.8rem;
}
.cci-photo .photo-placeholder { background: repeating-linear-gradient(135deg, #f99a43 0 16px, #f58d2e 16px 32px); color: var(--cci-ink); }
.photo-placeholder svg { width: 4.5rem; height: auto; fill: none; stroke: var(--gold); stroke-width: 1.4; stroke-linejoin: round; }
.cci-photo .photo-placeholder svg { stroke: var(--cci-ink); }
.story { overflow: hidden; }
.story-photo { height: 12rem; margin: -1.4rem -1.5rem 0.4rem; }
@media (max-width: 860px) {
  .cci-band { grid-template-columns: 1fr; }
  .cci-photo, .cci-photo .site-photo, .cci-photo .photo-placeholder { min-height: 12rem; }
  .cci-text { padding: 1.5rem; }
}
.stopped .reply { display: grid; justify-items: start; gap: 0.5rem; }
/* The real CCI logo: the white one sits straight on the orange band; the small mark
   shows only the college's seal, the left end of the logo. */
.cci-logos img { height: 3.6rem; background: none; padding: 0; border-radius: 0; }
.cci-emblem { display: inline-block; width: 0.82rem; height: 1.2rem; overflow: hidden; flex: none; }
.cci-emblem img { height: 100%; width: auto; max-width: none; margin-left: -0.15rem; }
@media (max-width: 860px) { .cci-logos img { height: 2.8rem; } }

/* Pricing: three plans side by side, the middle one marked. */
.pricing-head { max-width: 44rem; margin: 0 auto 2.5rem; text-align: center; }
.pricing-head h1 { margin: 0 0 0.75rem; font-size: clamp(2.3rem, 5vw, 3.4rem); text-wrap: balance; }
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 0 0 4.5rem; align-items: stretch; }
@media (max-width: 900px) { .plans { grid-template-columns: minmax(0, 1fr); max-width: 30rem; margin-left: auto; margin-right: auto; } }
.plan {
  position: relative; display: flex; flex-direction: column; padding: 1.6rem 1.5rem 1.75rem;
  border: 1px solid var(--line); border-radius: 18px; background: var(--card);
}
.plan-featured { border-color: var(--gold-line); box-shadow: 0 30px 70px -40px var(--shadow), inset 0 0 0 1px var(--gold-line); }
.plan h2 { margin: 0; font-family: var(--display); font-size: 2rem; font-weight: 600; }
.plan-badge {
  position: absolute; top: 1.4rem; right: 1.4rem; margin: 0; padding: 0.2rem 0.65rem; border-radius: 999px;
  background: var(--gold-tint); color: var(--gold); font-size: 0.75rem; font-weight: 600;
}
.plan-for { margin: 0.35rem 0 1.1rem; color: var(--ink-soft); font-size: 0.95rem; min-height: 2.9em; }
.plan-price { display: flex; align-items: baseline; gap: 0.5rem; margin: 0 0 1.25rem; }
.plan-price b { font-family: var(--display); font-size: 2.6rem; font-weight: 600; line-height: 1; font-variant-numeric: lining-nums; }
.plan-price span { color: var(--ink-soft); font-size: 0.88rem; }
.plan-cta { width: 100%; justify-content: center; }
.plan-cta[disabled] { opacity: 0.6; cursor: default; filter: none; }
.plan-plus { margin: 1.4rem 0 0; font-weight: 600; font-size: 0.9rem; }
.plan-list { display: grid; gap: 0.6rem; margin: 1rem 0 0; padding: 0; list-style: none; font-size: 0.93rem; }
.plan-plus + .plan-list { margin-top: 0.6rem; }
.plan-list li { display: flex; gap: 0.6rem; align-items: flex-start; }
.plan-list svg { width: 18px; height: 18px; flex: none; margin-top: 0.15rem; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pricing-page .faq { max-width: 48rem; margin-left: auto; margin-right: auto; }
.pricing-page .faq .section-head { margin-bottom: 1.25rem; }

/* Privacy: one readable column. */
.privacy-head { max-width: 44rem; margin: 0 auto 2.5rem; }
.privacy-head h1 { margin: 0 0 0.75rem; font-size: clamp(2.2rem, 4.5vw, 3.2rem); text-wrap: balance; }
.privacy-head .privacy-date { margin-top: 0.75rem; color: var(--ink-soft); font-size: 0.85rem; }
.privacy-body { display: grid; gap: 2rem; max-width: 44rem; margin: 0 auto; line-height: 1.65; }
.privacy-body section { display: grid; gap: 0.6rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.privacy-body h2 { margin: 0; font: 600 1.35rem/1.25 var(--display); text-wrap: balance; }
.privacy-body p, .privacy-body ul { margin: 0; }
.privacy-body ul { display: grid; gap: 0.45rem; padding-left: 1.2rem; }
.privacy-body li::marker { color: var(--gold); }

/* Sign-in and sign-up: a photo panel beside the form on wide screens. */
.entry-split { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.entry-side { position: relative; min-width: 0; }
.entry-aside { display: none; }
@media (min-width: 960px) {
  .entry-split { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  .entry-aside {
    position: sticky; top: 0; display: flex; align-items: flex-end; height: 100vh; height: 100dvh; padding: 3rem;
    background:
      linear-gradient(180deg, rgba(8, 11, 20, 0.15) 0%, rgba(8, 11, 20, 0.55) 45%, rgba(8, 11, 20, 0.92) 100%),
      var(--entry-photo, linear-gradient(145deg, #1b2740, #0b0f1a)) center / cover no-repeat;
    color: #f3eee3;
  }
  .entry-split .entry-main { padding-top: 14vh; }
}
.entry-aside-text { display: grid; gap: 1rem; max-width: 30rem; }
.entry-aside .eyebrow { margin: 0; color: #e3bd62; }
.entry-aside-title { margin: 0; font: 600 clamp(2rem, 3vw, 2.7rem)/1.1 var(--display); text-wrap: balance; }
:lang(th) .entry-aside-title { font-weight: 500; line-height: 1.4; }
.entry-aside ul { display: grid; gap: 0.45rem; margin: 0; padding: 0; list-style: none; color: rgba(243, 238, 227, 0.85); }
.entry-aside li::before { content: "◆"; margin-right: 0.6rem; color: #e3bd62; font-size: 0.7em; vertical-align: 0.15em; }
.entry-aside .cci-mark { color: rgba(243, 238, 227, 0.8); }
.google-button {
  display: flex; align-items: center; justify-content: center; gap: 0.7rem; width: 100%; min-height: 2.9rem;
  padding: 0 1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--ink); font-weight: 500; text-decoration: none; transition: border-color 0.15s, background 0.15s;
}
.google-button:hover { border-color: var(--gold-line); background: var(--paper); }
.google-button svg { width: 1.15rem; height: 1.15rem; flex: none; }
.or-line { display: flex; align-items: center; gap: 0.8rem; margin: 1.25rem 0 0; color: var(--ink-soft); font-size: 0.82rem; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.or-line + form { margin-top: 1rem; }
.label-row { display: flex; justify-content: space-between; gap: 1rem; }
.label-row a { font-size: 0.82rem; }
.password-box { position: relative; display: block; }
.entry-card .password-box input { padding-right: 4.2rem; }
.show-password {
  position: absolute; right: 0.35rem; top: calc(50% + 0.175rem); transform: translateY(-50%);
  padding: 0.3rem 0.6rem; border: 0; border-radius: 8px; background: none; color: var(--ink-soft);
  font: inherit; font-size: 0.8rem; cursor: pointer;
}
.show-password:hover { color: var(--ink); background: var(--paper-2); }
.account-google { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; }
.account-google .google-button { width: auto; }
.google-on { margin: 0; color: var(--ready); font-size: 0.9rem; }

/* Narrow phones: the top links, language switch and both buttons still fit. */
@media (max-width: 430px) {
  .site-top { gap: 0.4rem; }
  .site-nav { gap: 0.25rem; }
  .site-nav .nav-link { padding-left: 0.2rem; padding-right: 0.2rem; font-size: 0.82rem; }
  .site-nav .button { padding: 0 0.6rem; font-size: 0.8rem; white-space: nowrap; }
  :lang(th) .site-nav .nav-link { font-size: 0.78rem; padding-left: 0.12rem; padding-right: 0.12rem; }
  :lang(th) .site-top .wordmark span { display: none; }
}

/* The light / dark switch beside the language switch: a moon in light, a sun in dark. */
.theme-toggle {
  display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; flex: none; padding: 0;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink-soft); cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--gold-line); }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-sun { display: block; }
  :root:not([data-theme="light"]) .theme-moon { display: none; }
}
:root[data-theme="dark"] .theme-sun { display: block; }
:root[data-theme="dark"] .theme-moon { display: none; }
.entry-top { display: flex; align-items: center; gap: 0.5rem; }
.stage-top .theme-toggle { width: 2rem; height: 2rem; }
@media (max-width: 430px) { .site-nav .theme-toggle { display: none; } }

/* Account: the plan and a place to use a code. */
.account-plan { margin: 0 0 0.75rem; }
.plan-pill { display: inline-block; padding: 0.05rem 0.6rem; border-radius: 999px; background: var(--gold-tint); color: var(--gold); }

/* A Pro-only model, for someone without Pro: shown, not choosable. */
.model-tile.locked { cursor: default; padding-right: 0.75rem; }
.model-tile.locked .tile-name, .model-tile.locked .tile-desc { color: var(--ink-soft); }
.tile-lock { display: block; margin-top: 0.35rem; color: var(--gold); font-size: 0.8rem; }
.plan-code { margin: 0.6rem 0 0; font-size: 0.85rem; text-align: center; }

/* The Library button and its menu; gold while answers are limited to the library. */
/* At rest it is only the book icon; when something is switched on it widens to say what. */
.library-chip:not(.is-on) { padding-left: 0.6rem; padding-right: 0.6rem; }
.library-chip:not(.is-on) .library-current, .library-chip:not(.is-on) .chev { display: none; }
.library-chip:not(.is-on) svg:first-child { width: 16px; height: 16px; }
.library-chip.is-on { background: var(--gold-tint); color: var(--gold); border-color: var(--gold-line); }
.library-current { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) {
  /* On a phone the row has no room to spare: the label shrinks to fit, and a visitor's
     "Browse models" text gives way while the Library choice is shown. */
  .composer-row .library-menu { min-width: 0; flex: 0 1 auto; }
  .composer-row .library-chip { max-width: 100%; }
  .library-current { max-width: 7rem; min-width: 0; }
  .composer-row:has(.library-chip.is-on) #model-current { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .composer-row:has(.library-chip.is-on) .model-chip .chev { display: none; }
  .composer-row .library-chip.is-on { gap: 0.3rem; }
}
.library-choice { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.45rem 0.2rem; cursor: pointer; }
.library-choice input { margin-top: 0.25rem; accent-color: var(--gold); }
.library-choice span { display: grid; gap: 0.1rem; }
.library-choice small { color: var(--ink-soft); font-size: 0.8rem; line-height: 1.4; }
.collection-select { width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: inherit; font: inherit; }
.collection-select option { background: var(--paper, #fff); color: var(--ink); }
.source-collection { margin-left: 0.4rem; padding: 0 0.45rem; border-radius: 999px; background: var(--gold-tint); color: var(--gold); font-size: 0.72rem; white-space: nowrap; }

/* The Developer guide, in the public pages' look. */
.guide-page { max-width: 48rem; margin: 0 auto; }
.guide h1 { margin: 0 0 1rem; font-size: clamp(2rem, 4.5vw, 3rem); text-wrap: balance; }
.guide h2 { margin: 2.2rem 0 0.6rem; font: 600 1.45rem/1.25 var(--display); scroll-margin-top: 1rem; }
.guide p, .guide li { line-height: 1.65; }
.guide .lead { font-size: 1.05rem; color: var(--ink-soft); }
.guide .toc { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; margin: 1rem 0 1.5rem; font-size: 0.9rem; }
.guide ul.plain { padding-left: 1.2rem; }
.guide pre { overflow-x: auto; padding: 0.8rem 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-size: 0.85rem; line-height: 1.5; }
.guide pre.prompt code { white-space: pre-wrap; }
.guide code { font-family: "Plex Mono", ui-monospace, Consolas, monospace; font-size: 0.88em; overflow-wrap: anywhere; }
.guide details { margin: 0.5rem 0 1rem; }
.guide details summary { cursor: pointer; color: var(--gold); }
.guide .note { color: var(--ink-soft); font-size: 0.9rem; }
.guide-lang-note { padding: 0.7rem 0.9rem; border-left: 3px solid var(--gold-line); background: var(--gold-tint); border-radius: 0 10px 10px 0; }

/* Touch screens: small icon buttons get a finger-sized area to tap, without looking bigger. */
@media (pointer: coarse) {
  .share-menu > summary { display: inline-grid; place-items: center; min-width: 2.5rem; min-height: 2.5rem; }
  .act, .edit-question { width: 2.5rem; height: 2.5rem; }
  .stage-top .theme-toggle { width: 2.4rem; height: 2.4rem; }
}

/* A photo dragged over the chat: the box says where to drop it. */
.composer-box.is-dropping { position: relative; border-color: var(--gold-line); border-style: dashed; }
.composer-box.is-dropping::after {
  content: attr(data-drop-text); position: absolute; inset: 0; display: grid; place-items: center;
  border-radius: inherit; background: color-mix(in srgb, var(--card) 88%, transparent); color: var(--gold); font-weight: 600; pointer-events: none;
}
