/* ==========================================================================
   Core — Calm Nordic Design System, light / dark.
   The edition's sheet (edition/edition.css) loads after this one and adds
   its worlds and its features' styles.
   Zero external requests, strict CSP (style-src 'self').
   ========================================================================== */

:root {
  --radius: 18px;
  --radius-sm: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --num-font: var(--font-sans);
}

/* ============ Light / dark tokens, and the default palette ============ */
/* The calm "cosy" palette is core's default; an edition's worlds override it
   with :root[data-world=...][data-mode=...] (one class higher, so they win). */

:root[data-mode="light"] {
  --bg: #F7F6F3; --surface: #FFFFFF; --surface-2: #F0EEE9; --border: #E4E1DA; --border-strong: #CCC7BC;
  --track: #EAE6DF; --text: #1A1917; --text-2: #383530; --muted: #716D66;
  --accent: #C25934; --link: #A44422; --button: #C25934; --button-text: #FFFFFF;
  --soft: #F9ECE6; --soft-text: #943C1E;
  --good: #237A4B; --good-soft: #E6F4EC; --good-border: #B5DFC7; --good-text: #155532; --on-good: #FFFFFF;
  --danger: #B8332A; --danger-soft: #FCECEB; --danger-border: #EAB8B4;
  --shadow: rgba(20, 20, 20, 0.08);
  --shadow-lg: rgba(20, 20, 20, 0.14);
  color-scheme: light;
}
:root[data-mode="dark"] {
  --bg: #121211; --surface: #1A1A18; --surface-2: #23221F; --border: #2E2D29; --border-strong: #46443E;
  --track: #282723; --text: #F4F3F0; --text-2: #DFDDD6; --muted: #9F9B93;
  --accent: #E88B66; --link: #F4A98B; --button: #E88B66; --button-text: #22120B;
  --soft: #2E1F19; --soft-text: #FFD6C4;
  --good: #6FD49A; --good-soft: #192B21; --good-border: #2B4B39; --good-text: #CBEED9; --on-good: #0E2B19;
  --danger: #F28B82; --danger-soft: #2D1A19; --danger-border: #5E2E2B;
  --shadow: rgba(0, 0, 0, 0.36);
  --shadow-lg: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ============ Base ============ */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: var(--link); }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 1.65rem; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 0.95rem; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.good-text { color: var(--good); font-weight: 600; }
.num { font-family: var(--num-font); font-variant-numeric: tabular-nums; }
.min-w-0 { min-width: 0; }

.stack { display: flex; flex-direction: column; gap: 1.5rem; }
.stack-sm { display: flex; flex-direction: column; gap: 0.75rem; }
.stack-xs { display: flex; flex-direction: column; gap: 0.25rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.65rem; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.65rem; }
.push-right { margin-left: auto; }
.center { text-align: center; align-items: center; }

.eyebrow {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--accent);
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.section-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}
.section-divider { padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* ============ App Shell: Calm Nordic Left Sidebar + Main Stage ============ */

.shell {
  display: flex;
  min-height: 100vh;
}

.topbar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}
.topbar[hidden] { display: none; }

.topbar-inner {
  height: 100%;
  padding: 1.15rem 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}

.sidebar-top { display: flex; flex-direction: column; gap: 1.35rem; }

.brand {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.25rem 0.5rem;
  text-decoration: none; color: var(--text);
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 0.95rem; letter-spacing: -0.01em; }
.brand-world { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 0.25rem; }
.nav a {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 600; font-size: 0.88rem;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--soft); color: var(--soft-text); font-weight: 700; }

.sidebar-status {
  padding: 0.85rem 0.6rem 0;
  border-top: 1px solid var(--border);
}
.sidebar-parent-note { display: flex; align-items: center; gap: 0.45rem; }

.who-button {
  display: flex; align-items: center; gap: 0.65rem;
  width: 100%; padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; text-align: left;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.who-button:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.who-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.who-label { font-weight: 700; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-sub { font-size: 0.72rem; color: var(--muted); }

/* ============ Main Stage (an edition's world atmospheres go on it, never on the sidebar) ============ */

.stage {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  overflow-x: hidden;
  background-color: var(--bg);
}

.world-backdrop {
  position: fixed;
  inset: 0;
  left: 232px;
  pointer-events: none;
  z-index: 0;
  color: var(--accent);
}
body:not(.has-sidebar) .world-backdrop { left: 0; }

.wrap {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 2rem 4.5rem;
}
.wrap.narrow { max-width: 680px; }

/* Page Header & Focus Bar */
.page-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}

.focus-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.focus-eyebrow { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.back-link {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: none; border: 0; padding: 0.25rem 0;
  color: var(--muted); font-size: 0.85rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.back-link:hover { color: var(--text); }

/* ============ Avatars ============ */

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 32px; height: 32px; border-radius: 50%; font-weight: 700; font-size: 0.85rem;
  background: var(--av-bg); color: var(--av-text);
}
.avatar.medium { width: 42px; height: 42px; font-size: 1rem; }
.avatar.large  { width: 76px; height: 76px; font-size: 1.75rem; }

:root[data-mode="light"] .c-lavender { --av-bg: #E0E7FF; --av-text: #3730A3; }
:root[data-mode="light"] .c-amber    { --av-bg: #FEF3C7; --av-text: #92400E; }
:root[data-mode="light"] .c-sky      { --av-bg: #E0F2FE; --av-text: #075985; }
:root[data-mode="light"] .c-rose     { --av-bg: #FCE7F3; --av-text: #9D174D; }
:root[data-mode="light"] .c-mint     { --av-bg: #DCFCE7; --av-text: #166534; }

:root[data-mode="dark"] .c-lavender { --av-bg: #322C52; --av-text: #DCD4FF; }
:root[data-mode="dark"] .c-amber    { --av-bg: #463318; --av-text: #FDE2B0; }
:root[data-mode="dark"] .c-sky      { --av-bg: #163644; --av-text: #C4EEFA; }
:root[data-mode="dark"] .c-rose     { --av-bg: #471F32; --av-text: #FAD2E5; }
:root[data-mode="dark"] .c-mint     { --av-bg: #173B2E; --av-text: #C8F5E2; }

/* ============ Cards, Buttons, Inputs ============ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 42px; padding: 0 1.05rem;
  border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 0.88rem; text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn-primary { background: var(--button); border-color: var(--button); color: var(--button-text); font-weight: 600; }
.btn-primary:hover:not(:disabled) { opacity: 0.92; border-color: var(--button); }
.btn-big { min-height: 48px; padding: 0 1.4rem; font-size: 0.95rem; }
.btn-sm { min-height: 34px; padding: 0 0.75rem; font-size: 0.8rem; }
.btn-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.85rem; }
.member-card { padding: 1.1rem 1.25rem; }
.member-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.member-card-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.85rem;
  padding-top: 0.75rem; border-top: 1px solid var(--border);
}

.capture-bar { padding: 0.9rem 1.05rem; gap: 0.65rem; }
.capture-input {
  width: 100%; min-height: 4.75rem; border: 0; background: transparent;
  padding: 0.25rem 0.15rem; font-size: 0.98rem; line-height: 1.5; font-weight: 500;
  color: var(--text); outline: none; resize: vertical;
}
.capture-meta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding-top: 0.65rem; border-top: 1px solid var(--border);
}
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }
.btn-icon { width: 40px; min-height: 40px; padding: 0; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.input, textarea.input, select.input {
  width: 100%; min-height: 44px; padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-weight: 500; font-size: 0.92rem;
  transition: border-color 0.15s ease;
}
.input:focus, textarea.input:focus, select.input:focus { border-color: var(--accent); outline: none; }
.input-sm { min-height: 36px; padding: 0.4rem 0.7rem; font-size: 0.84rem; }
textarea.input { resize: vertical; }
::placeholder { color: var(--muted); opacity: 0.85; }

.field { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.86rem; color: var(--text-2); }
.check { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 36px; font-weight: 500; font-size: 0.88rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--button); }
.check-all { font-weight: 600; padding-right: 0.75rem; margin-right: 0.15rem; border-right: 1px solid var(--line); }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 0.4rem; font-weight: 600; font-size: 0.86rem; color: var(--text-2); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; gap: 0.35rem;
  min-height: 34px; padding: 0 0.8rem;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); color: var(--muted); font-weight: 600; font-size: 0.8rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.chip:has(input:checked) span { border-color: var(--accent); background: var(--soft); color: var(--soft-text); }
.chip:has(input:focus-visible) span { outline: 2.5px solid var(--accent); outline-offset: 2px; }

.tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.65rem; border-radius: 999px;
  background: var(--soft); color: var(--soft-text);
  font-weight: 600; font-size: 0.76rem;
}
.tag.neutral { background: var(--surface-2); color: var(--muted); }

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); display: inline-block; flex: 0 0 auto; }

/* ============ Progress Bar & Progress Ring ============ */

.progress { height: 7px; border-radius: 99px; background: var(--track); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width 0.3s ease; }

.progress-ring {
  position: relative; width: 38px; height: 38px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
}
.progress-ring svg { transform: rotate(-90deg); display: block; }
.progress-ring .ring-track { fill: none; stroke: var(--surface-2); stroke-width: 3; }
.progress-ring .ring-fill { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 0.3s ease; }
.progress-ring.done .ring-fill { stroke: var(--good); }
.progress-ring .ring-label {
  position: absolute; font-size: 0.64rem; font-weight: 700;
  font-family: var(--num-font); font-variant-numeric: tabular-nums;
}

/* ============ Who's Here & PIN Pad ============ */

.who-stage { padding-top: 2.5rem; gap: 2rem; }
.who-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 180px));
  justify-content: center; gap: 1rem;
  list-style: none; margin: 0; padding: 0; width: 100%;
}
.who-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
  width: 100%; padding: 1.5rem 1rem;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.who-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 10px 24px -12px var(--shadow-lg); }
.who-name { font-size: 1rem; font-weight: 700; }

.pin-form { max-width: 340px; margin: 0 auto; width: 100%; }
.pin-pad { max-width: 280px; width: 100%; margin: 0 auto; align-items: center; text-align: center; }
.pin-pad:focus { outline: none; }
.pin-dots { display: flex; gap: 0.65rem; justify-content: center; min-height: 18px; padding: 0.25rem 0; }
.pin-dots span { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--border-strong); transition: background-color 0.12s ease; }
.pin-dots span.on { background: var(--accent); border-color: var(--accent); }
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.55rem; width: 100%; }
.pin-key {
  min-height: 52px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  font-size: 1.2rem; font-weight: 600; cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.pin-key:hover:not(:disabled) { border-color: var(--border-strong); }
.pin-key:active:not(:disabled) { transform: scale(0.96); }
.pin-key.ok { background: var(--button); border-color: var(--button); color: var(--button-text); font-size: 0.9rem; }
.pin-key:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ Ideas: Visual Project Cards + Finished at Bottom ============ */

.idea-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem; list-style: none; margin: 0; padding: 0;
}
.idea-card {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between; gap: 1rem;
  height: 100%; padding: 1.15rem 1.2rem;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.idea-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 10px 24px -14px var(--shadow-lg); }
.idea-card-link { color: inherit; text-decoration: none; }
.idea-card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.idea-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.idea-card-lead { display: flex; align-items: flex-start; gap: 0.75rem; min-width: 0; }
.idea-kind-label { font-size: 0.72rem; font-weight: 600; color: var(--accent); text-transform: capitalize; }
.idea-card .title { font-size: 0.98rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.idea-card-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding-top: 0.7rem; border-top: 1px solid var(--border);
}

.tag-list { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.15rem; }
.tag-pill {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center;
  padding: 0.14rem 0.55rem; border-radius: 999px;
  border: 1px solid transparent;
  background: var(--soft); color: var(--soft-text);
  font-size: 0.74rem; font-weight: 600; line-height: 1.4;
  text-decoration: none; cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}
.tag-pill:hover { border-color: var(--accent); }
.tag-pill[aria-pressed="true"] { background: var(--button); color: var(--button-text); border-color: var(--button); }

.tag-filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.tag-filter {
  display: inline-flex; align-items: center; min-height: 32px;
  padding: 0.22rem 0.75rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}
.tag-filter:hover { border-color: var(--border-strong); color: var(--text); }
.tag-filter[aria-pressed="true"] { background: var(--button); border-color: var(--button); color: var(--button-text); }

.tag-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.tag-suggest {
  padding: 0.18rem 0.55rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-2);
  font-size: 0.75rem; font-weight: 600; cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}
.tag-suggest:hover { border-color: var(--accent); color: var(--text); }
.tag-suggest[aria-pressed="true"] { background: var(--soft); border-color: var(--accent); color: var(--soft-text); }

.kind-badge {
  width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--soft); color: var(--soft-text);
}

.finished-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.7rem; list-style: none; margin: 0; padding: 0;
}
.finished-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; opacity: 0.88;
  transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.finished-row:hover { opacity: 1; border-color: var(--border-strong); transform: translateY(-1px); }
.finished-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.finished-title { font-weight: 600; font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tick-dot {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--good-soft); color: var(--good);
}

/* ============ Idea Detail & Steps ============ */

.detail { display: flex; flex-wrap: wrap; gap: 1.35rem; align-items: flex-start; }
.detail-main { flex: 999 1 440px; min-width: 0; display: flex; flex-direction: column; gap: 1.25rem; }
.detail-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 1rem; }

.idea-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.idea-title { font-size: 1.35rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; letter-spacing: -0.015em; }

.banner-good {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1.1rem; border-radius: var(--radius-sm);
  background: var(--good-soft); border: 1px solid var(--good-border); color: var(--good-text);
}

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.step { display: flex; align-items: center; gap: 0.45rem; }
.step-toggle {
  flex: 1; display: flex; align-items: center; gap: 0.75rem;
  min-height: 48px; padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg);
  text-align: left; font-weight: 500; font-size: 0.94rem; cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.step-toggle:hover:not(:disabled) { border-color: var(--border-strong); }
.step-toggle:disabled { cursor: default; }
.step-toggle .box {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  display: flex; align-items: center; justify-content: center; color: var(--on-good);
}
.step-toggle[aria-pressed="true"] { background: var(--good-soft); border-color: var(--good-border); color: var(--good-text); }
.step-toggle[aria-pressed="true"] .box { background: var(--good); border-color: var(--good); }
.step-toggle[aria-pressed="true"] .step-text { text-decoration: line-through; opacity: 0.68; }
.step-text { overflow-wrap: anywhere; }

/* ============ Row Lists & Progress Dots ============ */

.book-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.book-row {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
  padding: 0.75rem 0.95rem; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.book-row[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.dots { display: grid; grid-auto-flow: column; gap: 5px; }
.dots span { height: 5px; border-radius: 99px; background: var(--track); }
.dots span.on { background: var(--accent); }

/* ============ World Picker & Family Tabs ============ */

.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.9rem; }
.world-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem;
  padding: 0.9rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  text-align: left; cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease;
}
.world-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.world-card[aria-checked="true"] { border: 2px solid var(--accent); background: var(--soft); }
.world-card .art {
  width: 100%; height: 74px; border-radius: var(--radius-sm);
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.world-card-scene { width: 120px; height: 48px; }
.world-card strong { font-size: 0.96rem; }

.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px;
  border-radius: var(--radius-sm); background: var(--surface-2);
}
.segmented button {
  min-height: 34px; padding: 0 0.85rem;
  border-radius: calc(var(--radius-sm) - 3px); border: 0;
  background: transparent; color: var(--muted); font-weight: 600; font-size: 0.82rem; cursor: pointer;
}
.segmented button[aria-checked="true"] {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px var(--shadow);
}

.tab-bar {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  padding-bottom: 0.85rem; border-bottom: 1px solid var(--border);
}
.tab-btn {
  padding: 0.45rem 0.85rem; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--muted);
  font-weight: 600; font-size: 0.84rem; cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.tab-btn:hover { background: var(--surface-2); color: var(--text); }
.tab-btn[aria-selected="true"] { background: var(--soft); color: var(--soft-text); font-weight: 700; }

/* ============ Switch ============ */

.switch {
  appearance: none; flex: 0 0 auto; width: 46px; height: 26px; margin: 0; border-radius: 999px;
  background: var(--border-strong); position: relative; cursor: pointer; transition: background-color 0.16s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: left 0.16s ease;
}
.switch:checked { background: var(--button); }
.switch:checked::after { left: 23px; }

/* ============ Pairing, Dialogs & Toast ============ */

.age-select { width: auto; min-width: 4.5rem; }
.added { display: inline-flex; align-items: center; gap: 0.25rem; }

.pair-code {
  font-family: var(--font-mono); font-size: 2rem; font-weight: 700; letter-spacing: 0.14em;
  padding: 0.65rem 1.1rem; border-radius: var(--radius-sm);
  background: var(--soft); color: var(--soft-text); align-self: flex-start;
}

.pin-dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem; max-width: 22rem; width: calc(100% - 2rem);
}
.pin-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 40;
  padding: 0.7rem 1.15rem; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 0.88rem;
  box-shadow: 0 10px 28px var(--shadow-lg); max-width: calc(100% - 2rem);
}

/* ============ Unified Search ============ */

.search-bar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.85rem;
}
.search-bar-icon { display: inline-flex; color: var(--muted); flex: 0 0 auto; }
.search-input {
  flex: 1 1 auto; min-width: 0; border: 0; background: transparent;
  color: var(--text); font-size: 1rem; font-weight: 500; padding: 0.35rem 0;
  outline: none;
}
.search-input::placeholder { color: var(--muted); }
.search-results {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 0.55rem;
}
.search-result-row {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.search-result-row:hover {
  transform: translateY(-1px); border-color: var(--accent);
  box-shadow: 0 8px 20px -14px var(--shadow-lg);
}
.search-result-body {
  display: flex; flex-direction: column; gap: 0.15rem;
  min-width: 0; flex: 1;
}
.search-result-title { font-size: 0.95rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.search-snippet {
  font-size: 0.8rem; color: var(--soft-text); background: var(--soft);
  padding: 0.18rem 0.55rem; border-radius: 6px; align-self: flex-start;
  margin-top: 0.15rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============ Visibility Badges, Notes, Parked Banner ============ */

.vis-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.72rem; font-weight: 600; padding: 0.14rem 0.5rem;
  border-radius: 999px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); white-space: nowrap;
}
.vis-adults {
  background: var(--soft); color: var(--soft-text); border-color: transparent;
}
.vis-parked {
  background: var(--surface-2); color: var(--muted); font-style: italic;
}
.note-preview {
  color: var(--muted); font-size: 0.84rem; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.note-box {
  padding: 0.9rem 1.05rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border-left: 3px solid var(--border);
  white-space: pre-wrap; line-height: 1.6; overflow-wrap: anywhere;
}
.capture-notes {
  width: 100%; resize: vertical; min-height: 4.5rem;
  font-size: 0.92rem; line-height: 1.5;
}
.parked-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.7rem 0.95rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}

/* ============ Responsive: Mobile Bottom Navigation ============ */

@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .topbar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; height: auto; flex: none;
    border-right: 0; border-top: 1px solid var(--border);
  }
  .topbar-inner {
    flex-direction: row; align-items: center; justify-content: space-between;
    padding: 0.35rem 0.5rem; gap: 0.25rem;
  }
  .sidebar-top { flex-direction: row; align-items: center; flex: 1; gap: 0; }
  .brand, .sidebar-status, .who-meta { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; gap: 0; }
  .nav a {
    flex-direction: column; gap: 0.15rem; padding: 0.35rem 0.5rem;
    font-size: 0.68rem; background: transparent !important;
  }
  .nav a[aria-current="page"] { color: var(--accent); }
  .who-button { width: auto; padding: 0.25rem; border-radius: 50%; border: 0; background: transparent; }

  .world-backdrop { left: 0; }
  .wrap { padding: 1.25rem 1rem 5.5rem; }

  .toast { bottom: 4.5rem; }
}

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