/* Shared Tabletop Design System — 12 Palettes x Dark/Light + Ergonomics */
:root {
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --card-pad: 1rem;
  --grid-gap: 1rem;

  /* Default: Warm Walnut & Brass (Dark) */
  --bg: #14100d;
  --bg-glow: radial-gradient(ellipse at top, #241b14 0%, #14100d 62%);
  --surface: #1e1814;
  --surface-2: #28201a;
  --surface-elevated: #30261f;
  --shelf-lip: #543e2d;
  --border: #3a2e25;
  --border-strong: #524134;
  --text: #f5eee6;
  --muted: #b8a898;
  --accent: #e5a93c;
  --accent-soft: rgba(229, 169, 60, 0.16);
  --accent-ink: #1a1209;
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.15);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.15);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.16);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.15);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.42);
  --topbar-bg: rgba(22, 17, 14, 0.9);
}

/* Text size scaling */
:root[data-text-size="compact"] { font-size: 14px; }
:root[data-text-size="comfortable"] { font-size: 16px; }
:root[data-text-size="large"] { font-size: 18px; }

/* Density scaling */
:root[data-density="compact"] { --card-pad: 0.72rem; --grid-gap: 0.7rem; }
:root[data-density="cozy"] { --card-pad: 1rem; --grid-gap: 1rem; }
:root[data-density="spacious"] { --card-pad: 1.3rem; --grid-gap: 1.3rem; }

/* Reduced motion */
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* =========================================================
   12 CURATED PALETTES — DARK MODE
   ========================================================= */
:root[data-palette="walnut-brass"][data-mode="dark"] {
  --bg: #14100d; --bg-glow: radial-gradient(ellipse at top, #251c15 0%, #14100d 62%);
  --surface: #1e1814; --surface-2: #28201a; --surface-elevated: #312720; --shelf-lip: #5a4230;
  --border: #3b2f26; --border-strong: #554336; --text: #f5eee6; --muted: #b8a898;
  --accent: #e5a93c; --accent-soft: rgba(229, 169, 60, 0.16); --accent-ink: #1a1209;
  --topbar-bg: rgba(22, 17, 14, 0.92);
}

:root[data-palette="midnight-tavern"][data-mode="dark"] {
  --bg: #0d1321; --bg-glow: radial-gradient(ellipse at top, #17233d 0%, #0d1321 62%);
  --surface: #151e32; --surface-2: #1d2942; --surface-elevated: #243352; --shelf-lip: #364970;
  --border: #283654; --border-strong: #3d517a; --text: #eef2fa; --muted: #9eb0cf;
  --accent: #f0b44c; --accent-soft: rgba(240, 180, 76, 0.16); --accent-ink: #151007;
  --topbar-bg: rgba(14, 21, 36, 0.92);
}

:root[data-palette="forest-felt"][data-mode="dark"] {
  --bg: #0e1713; --bg-glow: radial-gradient(ellipse at top, #172b22 0%, #0e1713 62%);
  --surface: #15231c; --surface-2: #1d3026; --surface-elevated: #243c30; --shelf-lip: #375c49;
  --border: #263f32; --border-strong: #3a604c; --text: #edf7f1; --muted: #9cbba9;
  --accent: #6ec89b; --accent-soft: rgba(110, 200, 155, 0.16); --accent-ink: #081c12;
  --topbar-bg: rgba(15, 25, 20, 0.92);
}

:root[data-palette="terracotta-hearth"][data-mode="dark"] {
  --bg: #18100e; --bg-glow: radial-gradient(ellipse at top, #2c1a16 0%, #18100e 62%);
  --surface: #231714; --surface-2: #2f201b; --surface-elevated: #3a2822; --shelf-lip: #613c2f;
  --border: #422c25; --border-strong: #5e3f35; --text: #f9efeb; --muted: #c4a79e;
  --accent: #e67e51; --accent-soft: rgba(230, 126, 81, 0.17); --accent-ink: #1c0c06;
  --topbar-bg: rgba(26, 17, 15, 0.92);
}

:root[data-palette="royal-burgundy"][data-mode="dark"] {
  --bg: #190e13; --bg-glow: radial-gradient(ellipse at top, #2e1622 0%, #190e13 62%);
  --surface: #25151d; --surface-2: #311d27; --surface-elevated: #3d2431; --shelf-lip: #63354b;
  --border: #452836; --border-strong: #633b4f; --text: #faf0f4; --muted: #c7a7b5;
  --accent: #e29bb1; --accent-soft: rgba(226, 155, 177, 0.17); --accent-ink: #220b14;
  --topbar-bg: rgba(27, 15, 21, 0.92);
}

:root[data-palette="slate-teal"][data-mode="dark"] {
  --bg: #0f1419; --bg-glow: radial-gradient(ellipse at top, #182530 0%, #0f1419 62%);
  --surface: #172028; --surface-2: #1f2b36; --surface-elevated: #283644; --shelf-lip: #395066;
  --border: #2a3947; --border-strong: #3e5469; --text: #edf4f9; --muted: #98b0c4;
  --accent: #38bdf8; --accent-soft: rgba(56, 189, 248, 0.16); --accent-ink: #071926;
  --topbar-bg: rgba(16, 22, 28, 0.92);
}

:root[data-palette="nordic-birch"][data-mode="dark"] {
  --bg: #161614; --bg-glow: radial-gradient(ellipse at top, #252520 0%, #161614 62%);
  --surface: #21211d; --surface-2: #2c2c27; --surface-elevated: #363630; --shelf-lip: #545448;
  --border: #3a3a33; --border-strong: #535349; --text: #f3f2ec; --muted: #b0afa4;
  --accent: #a3b88c; --accent-soft: rgba(163, 184, 140, 0.17); --accent-ink: #131a0d;
  --topbar-bg: rgba(23, 23, 20, 0.92);
}

:root[data-palette="obsidian-amethyst"][data-mode="dark"] {
  --bg: #110f19; --bg-glow: radial-gradient(ellipse at top, #211a36 0%, #110f19 62%);
  --surface: #1a1728; --surface-2: #242038; --surface-elevated: #2e2847; --shelf-lip: #4d4278;
  --border: #332d4f; --border-strong: #4c4375; --text: #f2f0fa; --muted: #aba4c9;
  --accent: #b794f4; --accent-soft: rgba(183, 148, 244, 0.17); --accent-ink: #160c29;
  --topbar-bg: rgba(18, 16, 27, 0.92);
}

:root[data-palette="copper-espresso"][data-mode="dark"] {
  --bg: #150f0d; --bg-glow: radial-gradient(ellipse at top, #291b16 0%, #150f0d 62%);
  --surface: #221814; --surface-2: #2e201b; --surface-elevated: #3a2922; --shelf-lip: #664234;
  --border: #422e26; --border-strong: #5f4236; --text: #f7efe9; --muted: #bfa79a;
  --accent: #d98254; --accent-soft: rgba(217, 130, 84, 0.17); --accent-ink: #1c0d05;
  --topbar-bg: rgba(23, 16, 14, 0.92);
}

:root[data-palette="ocean-dusk"][data-mode="dark"] {
  --bg: #0c171c; --bg-glow: radial-gradient(ellipse at top, #152b34 0%, #0c171c 62%);
  --surface: #13232b; --surface-2: #1b303a; --surface-elevated: #233d4a; --shelf-lip: #365e70;
  --border: #25404d; --border-strong: #396073; --text: #edf6f9; --muted: #98b8c4;
  --accent: #fb7185; --accent-soft: rgba(251, 113, 133, 0.17); --accent-ink: #24070d;
  --topbar-bg: rgba(13, 24, 30, 0.92);
}

:root[data-palette="meadow-moss"][data-mode="dark"] {
  --bg: #13160f; --bg-glow: radial-gradient(ellipse at top, #22291a 0%, #13160f 62%);
  --surface: #1c2116; --surface-2: #262d1e; --surface-elevated: #303926; --shelf-lip: #4d5c3b;
  --border: #343e29; --border-strong: #4c5b3c; --text: #f3f6ec; --muted: #adb89d;
  --accent: #d4b748; --accent-soft: rgba(212, 183, 72, 0.17); --accent-ink: #1a1605;
  --topbar-bg: rgba(20, 24, 16, 0.92);
}

:root[data-palette="high-contrast"][data-mode="dark"] {
  --bg: #09090b; --bg-glow: #09090b;
  --surface: #141418; --surface-2: #1f1f25; --surface-elevated: #2a2a33; --shelf-lip: #52525b;
  --border: #3f3f46; --border-strong: #71717a; --text: #ffffff; --muted: #d4d4d8;
  --accent: #facc15; --accent-soft: rgba(250, 204, 21, 0.2); --accent-ink: #09090b;
  --topbar-bg: rgba(9, 9, 11, 0.96);
}

/* =========================================================
   12 CURATED PALETTES — LIGHT MODE
   ========================================================= */
:root[data-mode="light"] {
  --green: #15803d; --green-soft: rgba(21, 128, 61, 0.12);
  --red: #dc2626; --red-soft: rgba(220, 38, 38, 0.11);
  --amber: #b45309; --amber-soft: rgba(180, 83, 9, 0.12);
  --blue: #2563eb; --blue-soft: rgba(37, 99, 235, 0.11);
  --shadow-sm: 0 2px 8px rgba(24, 18, 12, 0.06);
  --shadow-md: 0 10px 26px rgba(24, 18, 12, 0.1);
}

:root[data-palette="walnut-brass"][data-mode="light"] {
  --bg: #f7f2ea; --bg-glow: radial-gradient(ellipse at top, #fffdf9 0%, #f5ede1 65%);
  --surface: #ffffff; --surface-2: #f3ebe0; --surface-elevated: #ebe0d0; --shelf-lip: #c4a482;
  --border: #e3d6c5; --border-strong: #ccb89f; --text: #221810; --muted: #6c5a49;
  --accent: #b87414; --accent-soft: rgba(184, 116, 20, 0.13); --accent-ink: #ffffff;
  --topbar-bg: rgba(250, 246, 240, 0.92);
}

:root[data-palette="midnight-tavern"][data-mode="light"] {
  --bg: #f1f4f9; --bg-glow: radial-gradient(ellipse at top, #ffffff 0%, #edf1f8 65%);
  --surface: #ffffff; --surface-2: #e9eff8; --surface-elevated: #dde6f4; --shelf-lip: #9cb0d4;
  --border: #d5dfef; --border-strong: #b6c6e2; --text: #111b2e; --muted: #516280;
  --accent: #b87a14; --accent-soft: rgba(184, 122, 20, 0.13); --accent-ink: #ffffff;
  --topbar-bg: rgba(245, 248, 252, 0.92);
}

:root[data-palette="forest-felt"][data-mode="light"] {
  --bg: #f0f6f2; --bg-glow: radial-gradient(ellipse at top, #ffffff 0%, #e9f3ed 65%);
  --surface: #ffffff; --surface-2: #e6f0ea; --surface-elevated: #d8e8df; --shelf-lip: #84b399;
  --border: #cfe1d7; --border-strong: #aecbb9; --text: #11241a; --muted: #4b6b59;
  --accent: #1f7a4e; --accent-soft: rgba(31, 122, 78, 0.12); --accent-ink: #ffffff;
  --topbar-bg: rgba(243, 249, 245, 0.92);
}

:root[data-palette="terracotta-hearth"][data-mode="light"] {
  --bg: #faf2ee; --bg-glow: radial-gradient(ellipse at top, #ffffff 0%, #f6eae4 65%);
  --surface: #ffffff; --surface-2: #f4e6df; --surface-elevated: #ebd7cd; --shelf-lip: #cf9c88;
  --border: #e6d2c8; --border-strong: #d1b3a5; --text: #291611; --muted: #755349;
  --accent: #c04d24; --accent-soft: rgba(192, 77, 36, 0.12); --accent-ink: #ffffff;
  --topbar-bg: rgba(252, 246, 243, 0.92);
}

:root[data-palette="royal-burgundy"][data-mode="light"] {
  --bg: #faf1f4; --bg-glow: radial-gradient(ellipse at top, #ffffff 0%, #f6e9ee 65%);
  --surface: #ffffff; --surface-2: #f4e5eb; --surface-elevated: #ebd5de; --shelf-lip: #cc94ab;
  --border: #e7d1da; --border-strong: #d3b2c0; --text: #29111b; --muted: #754c5e;
  --accent: #9c2d52; --accent-soft: rgba(156, 45, 82, 0.12); --accent-ink: #ffffff;
  --topbar-bg: rgba(252, 245, 248, 0.92);
}

:root[data-palette="slate-teal"][data-mode="light"] {
  --bg: #f1f5f9; --bg-glow: radial-gradient(ellipse at top, #ffffff 0%, #eaf0f6 65%);
  --surface: #ffffff; --surface-2: #e7eef5; --surface-elevated: #dae4ef; --shelf-lip: #94aec9;
  --border: #d2dee9; --border-strong: #b2c5d8; --text: #0f1c29; --muted: #4e647a;
  --accent: #0284c7; --accent-soft: rgba(2, 132, 199, 0.12); --accent-ink: #ffffff;
  --topbar-bg: rgba(244, 248, 252, 0.92);
}

:root[data-palette="nordic-birch"][data-mode="light"] {
  --bg: #f5f4ef; --bg-glow: radial-gradient(ellipse at top, #ffffff 0%, #efeee7 65%);
  --surface: #ffffff; --surface-2: #ecebe3; --surface-elevated: #e1e0d5; --shelf-lip: #b5b59e;
  --border: #dcdbd0; --border-strong: #c2c1b2; --text: #1e201b; --muted: #5f6156;
  --accent: #4d6b38; --accent-soft: rgba(77, 107, 56, 0.12); --accent-ink: #ffffff;
  --topbar-bg: rgba(247, 246, 242, 0.92);
}

:root[data-palette="obsidian-amethyst"][data-mode="light"] {
  --bg: #f5f2fa; --bg-glow: radial-gradient(ellipse at top, #ffffff 0%, #eee9f7 65%);
  --surface: #ffffff; --surface-2: #ece6f6; --surface-elevated: #dfd6f0; --shelf-lip: #b29fd9;
  --border: #dcd2ed; --border-strong: #c0b0de; --text: #1a122b; --muted: #5d5178;
  --accent: #6d28d9; --accent-soft: rgba(109, 40, 217, 0.12); --accent-ink: #ffffff;
  --topbar-bg: rgba(247, 245, 252, 0.92);
}

:root[data-palette="copper-espresso"][data-mode="light"] {
  --bg: #f8f2ee; --bg-glow: radial-gradient(ellipse at top, #ffffff 0%, #f4eae3 65%);
  --surface: #ffffff; --surface-2: #f1e6de; --surface-elevated: #e7d7cb; --shelf-lip: #c79a7f;
  --border: #e3d2c6; --border-strong: #cbb2a1; --text: #26160f; --muted: #6e5245;
  --accent: #a84f22; --accent-soft: rgba(168, 79, 34, 0.12); --accent-ink: #ffffff;
  --topbar-bg: rgba(251, 246, 243, 0.92);
}

:root[data-palette="ocean-dusk"][data-mode="light"] {
  --bg: #eff6f8; --bg-glow: radial-gradient(ellipse at top, #ffffff 0%, #e7f1f5 65%);
  --surface: #ffffff; --surface-2: #e4eff3; --surface-elevated: #d5e5ec; --shelf-lip: #89b4c4;
  --border: #cde0e8; --border-strong: #abc7d3; --text: #0f2129; --muted: #4b6875;
  --accent: #d13452; --accent-soft: rgba(209, 52, 82, 0.12); --accent-ink: #ffffff;
  --topbar-bg: rgba(242, 248, 250, 0.92);
}

:root[data-palette="meadow-moss"][data-mode="light"] {
  --bg: #f4f6ee; --bg-glow: radial-gradient(ellipse at top, #ffffff 0%, #edf1e4 65%);
  --surface: #ffffff; --surface-2: #e9eedf; --surface-elevated: #dde4ce; --shelf-lip: #aebd8c;
  --border: #d7dfc7; --border-strong: #bac7a3; --text: #1c2113; --muted: #586347;
  --accent: #856e12; --accent-soft: rgba(133, 110, 18, 0.13); --accent-ink: #ffffff;
  --topbar-bg: rgba(246, 248, 241, 0.92);
}

:root[data-palette="high-contrast"][data-mode="light"] {
  --bg: #ffffff; --bg-glow: #ffffff;
  --surface: #f8f9fa; --surface-2: #eceef1; --surface-elevated: #dfe3e8; --shelf-lip: #52525b;
  --border: #71717a; --border-strong: #18181b; --text: #09090b; --muted: #3f3f46;
  --accent: #1d4ed8; --accent-soft: rgba(29, 78, 216, 0.12); --accent-ink: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.98);
}

/* =========================================================
   BASE TYPOGRAPHY & PRIMITIVES
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-glow);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
  margin: 0;
}

a { color: var(--accent); }
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.svg-icon { flex-shrink: 0; vertical-align: middle; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title { font-size: 1.2rem; font-weight: 700; line-height: 1.15; }
.brand-subtitle { font-size: 0.78rem; color: var(--muted); margin: 0.1rem 0 0; }

/* Desktop pill tabs */
.nav-pills {
  display: inline-flex;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.25rem;
  border-radius: var(--radius-pill);
}

.nav-pill {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: var(--radius-pill);
  padding: 0.45rem 0.9rem;
  font-size: 0.86rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-pill:hover { color: var(--text); }
.nav-pill.active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Mobile bottom nav */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 0.35rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
}

.mobile-nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.4rem 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  cursor: pointer;
  min-height: 48px;
  justify-content: center;
}
.mobile-nav-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Buttons */
.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.52rem 0.92rem;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 38px;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
}
.btn.secondary:hover:not(:disabled) { background: var(--surface-elevated); }
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn.ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}
.btn.danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: transparent;
}
.btn.danger:hover:not(:disabled) { border-color: var(--red); }
.btn.sm { padding: 0.36rem 0.68rem; font-size: 0.8rem; min-height: 32px; }
.btn.lg { padding: 0.72rem 1.2rem; font-size: 0.96rem; min-height: 46px; }
.btn.icon-only { padding: 0.45rem; width: 38px; height: 38px; }
.btn.icon-only.sm { padding: 0.32rem; width: 32px; height: 32px; }

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* Inputs & forms */
input[type="text"],
input[type="search"],
input[type="number"],
input[type="url"],
input[type="password"],
input[type="date"],
select,
textarea {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  min-height: 40px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { width: 100%; min-height: 76px; resize: vertical; }

.field-label {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.42rem 0.78rem;
  border-radius: var(--radius-pill);
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
  user-select: none;
}
.chip-toggle:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.chip-toggle input { accent-color: var(--accent); }

/* Cards & surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--card-pad);
  box-shadow: var(--shadow-sm);
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.62rem;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.pill-badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill-badge.success { background: var(--green-soft); color: var(--green); border-color: transparent; }
.pill-badge.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.pill-badge.danger { background: var(--red-soft); color: var(--red); border-color: transparent; }

/* Segmented control */
.segmented-control {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.22rem;
  gap: 0.22rem;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.48rem 0.65rem;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.14s ease, color 0.14s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Modals */
dialog.modal {
  background: transparent;
  border: none;
  padding: 0;
  max-width: 600px;
  width: min(94vw, 600px);
  max-height: 90vh;
  color: var(--text);
  overflow: visible;
}
dialog.modal.modal-wide { max-width: 820px; width: min(95vw, 820px); }
dialog.modal.modal-sm { max-width: 460px; width: min(94vw, 460px); }
dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
}

.modal-shell {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.modal-header h3 { font-size: 1.08rem; font-weight: 700; }

.modal-body-scroll {
  padding: 1.1rem 1.2rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.2rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Appearance modal */
.pref-section { margin-bottom: 1.15rem; }
.pref-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.pref-sub { font-weight: 500; color: var(--muted); font-size: 0.76rem; }

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 0.55rem;
}

.palette-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s ease, transform 0.12s ease;
}
.palette-card:hover { border-color: var(--border-strong); }
.palette-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.palette-swatches {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(128, 128, 128, 0.25);
  flex-shrink: 0;
}
.palette-swatches span { width: 11px; height: 28px; display: block; }
.palette-meta { display: flex; flex-direction: column; min-width: 0; }
.palette-meta strong { font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-meta small { font-size: 0.7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  cursor: pointer;
}
.toggle-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Markdown Prose (Easy-Learn Quick-Start Guide Reader) */
.md-prose {
  font-size: 0.96rem;
  line-height: 1.65;
  color: var(--text);
}
.md-prose.reader-lg { font-size: 1.12rem; line-height: 1.72; }
.md-prose.reader-sm { font-size: 0.86rem; line-height: 1.55; }
.md-prose h2 {
  font-size: 1.1rem;
  color: var(--accent);
  margin: 1.15rem 0 0.45rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.md-prose h2:first-child { margin-top: 0; }
.md-prose h3 { font-size: 0.98rem; color: var(--text); margin: 0.9rem 0 0.3rem; }
.md-prose p { margin: 0 0 0.7rem; }
.md-prose ul, .md-prose ol { margin: 0 0 0.85rem; padding-left: 1.35rem; }
.md-prose li { margin-bottom: 0.38rem; }
.md-prose .game-term {
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
  font-weight: 700;
}
.md-prose .md-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}
.md-prose hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.7rem 1.15rem;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  z-index: 80;
  max-width: min(90vw, 420px);
}
.toast[data-variant="error"] { background: var(--red); color: #ffffff; }
.toast[data-variant="success"] { background: var(--green); color: #052e16; }

@media (max-width: 767.98px) {
  body { padding-bottom: 76px; }
  .toast { bottom: 5.2rem; right: 50%; transform: translateX(50%); text-align: center; }
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 2.25rem;
}
.app-footer a { color: var(--accent); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }
