/* base.css — reset + element defaults */
*,*::before,*::after{ box-sizing:border-box; }
/* a11y utilities: visually-hidden text + a keyboard skip-link that appears on focus */
.sr-only{ position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
/* the per-route focus sentinel (app.js) — hidden focus target so route changes never ring or
   text-select the page <h1>. Belt-and-suspenders: no outline/shadow even if the clip is ignored. */
.route-focus:focus{ outline:none !important; box-shadow:none !important; }
.skip-link{ position:fixed; left:8px; top:-56px; z-index:100000; background:var(--blue-500,#1f70df); color:#fff; padding:10px 16px; border-radius:8px; text-decoration:none; font-weight:700; transition:top .15s ease; }
.skip-link:focus{ top:8px; outline:2px solid #fff; outline-offset:2px; }
#view:focus{ outline:none; }
html,body{ margin:0; padding:0; }
/* Kill iOS/iPadOS elastic overscroll: no rubber-band "pull-up" past the top that
   drags the sticky topbar (hamburger + search) down, and no scroll-chaining. */
html,body{ overscroll-behavior:none; }
html{ -webkit-text-size-adjust:100%; }
body{
  font-family:var(--font);
  font-size:var(--fs-md);
  line-height:1.55;
  color:var(--ink-900);
  background:var(--surface-2);
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
h1,h2,h3,h4{ margin:0 0 .4em; line-height:1.18; font-family:var(--font-display); font-weight:700; letter-spacing:-.015em; }
h1{ font-size:var(--fs-3xl); }
h2{ font-size:var(--fs-2xl); }
h3{ font-size:var(--fs-xl); }
h4{ font-size:var(--fs-lg); }
p{ margin:0 0 1em; color:var(--ink-700); }
a{ color:var(--blue-600); text-decoration:none; }
a:hover{ color:var(--blue-700); }
img{ max-width:100%; display:block; }
/* graceful image load: still-loading images ease in instead of hard-flashing. Cached
   images are marked .img-in immediately (no fade). */
img.img-pre{ opacity:0; }
img.img-in{ opacity:1; transition:opacity .45s ease; }
@media (prefers-reduced-motion:reduce){ img.img-pre, img.img-in{ opacity:1; transition:none; } }
button{ font-family:inherit; cursor:pointer; }
ul{ margin:0; padding:0; list-style:none; }
small{ font-size:var(--fs-sm); }
code,.mono{ font-family:ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* Thai text helper — used wherever Thai script appears */
.thai{ font-family:var(--font-thai); }

/* ---- Inline SVG icon system (replaces emoji) ---- */
.ico{ width:1.1em; height:1.1em; display:inline-block; vertical-align:-.16em; flex:none; stroke:currentColor; }

/* ---- Animated sound-wave brand device (audio = the signature interaction) ---- */
.wave{ display:inline-flex; align-items:center; gap:2px; height:1em; vertical-align:-.12em; }
.wave i{ width:2px; border-radius:2px; background:currentColor; height:36%; opacity:.85; }
.wave.is-playing i{ animation:wavePulse .9s ease-in-out infinite; }
.wave i:nth-child(1){ animation-delay:0s; } .wave i:nth-child(2){ animation-delay:.12s; height:64%; }
.wave i:nth-child(3){ animation-delay:.24s; height:100%; } .wave i:nth-child(4){ animation-delay:.36s; height:64%; }
.wave i:nth-child(5){ animation-delay:.48s; }
@keyframes wavePulse{ 0%,100%{ transform:scaleY(.4); } 50%{ transform:scaleY(1); } }

/* selection + focus */
::selection{ background:var(--blue-100); }
/* Focus halo REMOVED app-wide (owner order 2026-09-10): no blue ring on focused fields, tiles or buttons. */
:focus-visible{ outline:none; }
/* never show a text caret on non-editable elements (focusable tiles, nodes, buttons) */
:where(:not(input):not(textarea):not([contenteditable])){ caret-color:transparent; }
input, textarea, [contenteditable]{ caret-color:auto; }

/* scrollbar (webkit) */
::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-thumb{ background:var(--line-strong); border-radius:99px; border:2px solid var(--surface-2); }
::-webkit-scrollbar-thumb:hover{ background:var(--ink-400); }

/* utilities */
.muted{ color:var(--ink-500); }
.center{ text-align:center; }
.hidden{ display:none !important; }
.nowrap{ white-space:nowrap; }
.flex{ display:flex; }
.flex-col{ display:flex; flex-direction:column; }
.items-center{ align-items:center; }
.justify-between{ justify-content:space-between; }
.gap-1{ gap:var(--s1);} .gap-2{ gap:var(--s2);} .gap-3{ gap:var(--s3);} .gap-4{ gap:var(--s4);} .gap-5{ gap:var(--s5);}
.wrap{ flex-wrap:wrap; }
.mt-2{ margin-top:var(--s2);} .mt-3{ margin-top:var(--s3);} .mt-4{ margin-top:var(--s4);} .mt-5{ margin-top:var(--s5);} .mt-6{ margin-top:var(--s6);}
.mb-0{ margin-bottom:0;} .mb-2{ margin-bottom:var(--s2);} .mb-4{ margin-bottom:var(--s4);}
.grow{ flex:1; }
.fade-in{ animation:fadeIn .28s ease both; }
@keyframes fadeIn{ from{ opacity:0; transform:translateY(6px);} to{ opacity:1; transform:none;} }

/* respect reduced-motion: kill non-essential animation */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{ animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important; }
}


/* ============================================================
   DARK MODE OVERRIDES — element-level fixes a token flip can't reach
   (dark_mode_spec_2026-07 §3). Light output is unchanged; these only
   apply under OS-dark (no explicit choice) or data-theme="dark".
   ============================================================ */
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) ::selection{ background:color-mix(in srgb, var(--blue-400) 40%, transparent); }
  :root:not([data-theme="light"]) ::placeholder{ color:var(--ink-400); opacity:1; }
  :root:not([data-theme="light"]) input:-webkit-autofill, :root:not([data-theme="light"]) textarea:-webkit-autofill, :root:not([data-theme="light"]) select:-webkit-autofill{ -webkit-text-fill-color:var(--ink-900); -webkit-box-shadow:0 0 0 1000px var(--surface) inset; caret-color:var(--ink-900); }
}
:root[data-theme="dark"] ::selection{ background:color-mix(in srgb, var(--blue-400) 40%, transparent); }
:root[data-theme="dark"] ::placeholder{ color:var(--ink-400); opacity:1; }
:root[data-theme="dark"] input:-webkit-autofill, :root[data-theme="dark"] textarea:-webkit-autofill, :root[data-theme="dark"] select:-webkit-autofill{ -webkit-text-fill-color:var(--ink-900); -webkit-box-shadow:0 0 0 1000px var(--surface) inset; caret-color:var(--ink-900); }
