/* rp bro — shared design tokens + shared primitives.
   OWNER: planner (FROZEN). ui seat and cards seat both USE this file and must NOT edit it.
   Seat-specific rules go to web/styles.css (ui) and web/cards/cards.css (cards).
   Theme: "sakura paper" (light) / "night indigo" (dark). Soft, round, Thai-first. */

:root {
  /* surfaces */
  --bg: #FFF8F3;
  --bg-2: #FFEFE6;
  --surface: #FFFFFF;
  --surface-2: #FFF3EC;
  --line: #F1DDD2;
  /* ink */
  --ink: #2B2440;
  --ink-2: #6B6480;
  --ink-3: #A39DB5;
  /* accents */
  --accent: #FF6F91;
  --accent-strong: #F04E78;
  --accent-ink: #FFFFFF;
  --accent-soft: #FFE1E8;
  --accent-2: #5B8DEF;
  --accent-2-soft: #E3ECFF;
  /* status */
  --ok: #2BB673;
  --warn: #F5A524;
  --danger: #E5484D;
  --danger-soft: #FFE5E6;
  /* chat bubbles */
  --bubble-user: #FFE1E8;
  --bubble-char: #FFFFFF;
  --bubble-system: #FFF3EC;
  /* cast accent colours (use for avatar rings / name colour of the default cast) */
  --mizuko: #4FB3E8;
  --hinoko: #FF7A3D;
  --denko: #9B6BFF;
  /* shape */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-pill: 999px;
  /* spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  /* type */
  --font: "Leelawadee UI", "Noto Sans Thai", "Sarabun", Tahoma, "Segoe UI", sans-serif;
  --font-mono: Consolas, "Cascadia Mono", monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --lh: 1.65;            /* Thai needs tall line-height (stacked vowels/tone marks) */
  /* elevation + motion */
  --shadow-1: 0 1px 2px rgba(43, 36, 64, .06), 0 2px 8px rgba(43, 36, 64, .06);
  --shadow-2: 0 8px 28px rgba(43, 36, 64, .16);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 160ms;
  /* layout */
  --tap: 44px;           /* minimum touch target */
  --nav-h: 58px;         /* phone bottom tab bar */
  --side-w: 232px;       /* desktop sidebar */
  --content-max: 860px;
  --bp-phone: 720px;     /* informational: media queries use (max-width: 720px) */
}

/* dark: follows the OS unless <html data-theme="light">; forced by <html data-theme="dark"> */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17141F; --bg-2: #1E1A2A; --surface: #241F33; --surface-2: #2D2740; --line: #3A3352;
    --ink: #F3EEFF; --ink-2: #B8B0D0; --ink-3: #7F789A;
    --accent: #FF7FA0; --accent-strong: #FF5E88; --accent-ink: #1B1020; --accent-soft: #4A2A3A;
    --accent-2: #7FA6FF; --accent-2-soft: #26304D;
    --danger-soft: #4A2326;
    --bubble-user: #4A2A3A; --bubble-char: #241F33; --bubble-system: #2D2740;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .25);
    --shadow-2: 0 8px 28px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #17141F; --bg-2: #1E1A2A; --surface: #241F33; --surface-2: #2D2740; --line: #3A3352;
  --ink: #F3EEFF; --ink-2: #B8B0D0; --ink-3: #7F789A;
  --accent: #FF7FA0; --accent-strong: #FF5E88; --accent-ink: #1B1020; --accent-soft: #4A2A3A;
  --accent-2: #7FA6FF; --accent-2-soft: #26304D;
  --danger-soft: #4A2326;
  --bubble-user: #4A2A3A; --bubble-char: #241F33; --bubble-system: #2D2740;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .25);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, .5);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh);
  -webkit-text-size-adjust: 100%;
  overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.35; margin: 0; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
a { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- shared primitives (class names are part of the contract) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 var(--sp-4);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-icon { width: var(--tap); padding: 0; }

.field { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-4); }
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.hint { font-size: var(--fs-xs); color: var(--ink-3); }
.input, .textarea, .select {
  width: 100%; min-height: var(--tap); padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
}
.textarea { min-height: 96px; resize: vertical; line-height: var(--lh); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--sp-4);
}
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 2px var(--sp-3); border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--ink); font-size: var(--fs-xs);
}
.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  object-fit: cover; object-position: center top;
  background: var(--bg-2); border: 2px solid var(--surface); box-shadow: var(--shadow-1);
}
.avatar-lg { width: 96px; height: 96px; }
.avatar-sm { width: 30px; height: 30px; }

.page { max-width: var(--content-max); margin: 0 auto; padding: var(--sp-4); }
.page-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.page-head h1 { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); }
.empty { text-align: center; color: var(--ink-2); padding: var(--sp-6) var(--sp-4); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4); background: rgba(23, 20, 31, .5);
}
.modal {
  width: min(480px, 100%); max-height: 90dvh; overflow: auto;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: var(--sp-5);
}
.modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4); flex-wrap: wrap; }

.toast-host {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--sp-4)); transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2); align-items: center;
  pointer-events: none; width: min(92vw, 420px);
}
.toast {
  background: var(--ink); color: var(--bg); padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-pill); box-shadow: var(--shadow-2); font-size: var(--fs-sm); max-width: 100%;
}
.toast-error { background: var(--danger); color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
