/* Yoto Companion — big, bright, friendly. */
:root {
  --coral: #FF5A36;
  --coral-dark: #E5431F;
  --coral-soft: #FFE6DF;
  --yellow: #FFD84D;
  --yellow-soft: #FFF5D1;
  --teal: #1FB5A4;
  --teal-soft: #D9F5F1;
  --purple: #7C5CFA;
  --purple-soft: #ECE6FF;
  --ink: #1F1F2E;
  --muted: #6E6A80;
  --line: #F1E6DA;
  --bg: #FFF7EF;
  --card: #FFFFFF;
  --ok: #19A974;
  --bad: #E5431F;
  --radius: 28px;
  --shadow: 0 2px 0 rgba(31, 31, 46, .04), 0 10px 30px rgba(31, 31, 46, .06);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Arial Rounded MT Bold", "Varela Round", system-ui, sans-serif;
  --accent: var(--coral);
  --accent-soft: var(--coral-soft);
  --tabbar-h: 84px;
}
.theme-teal   { --accent: var(--teal);   --accent-soft: var(--teal-soft); }
.theme-purple { --accent: var(--purple); --accent-soft: var(--purple-soft); }
.theme-yellow { --accent: #F5B700;       --accent-soft: var(--yellow-soft); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}
h1, h2 { margin: 0; line-height: 1.15; letter-spacing: -.01em; }
h1 { font-size: 34px; font-weight: 900; }
h2 { font-size: 22px; font-weight: 800; margin-bottom: 14px; }
h2.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
p { margin: 0; }
a { color: inherit; }
img { display: block; max-width: 100%; }
.icon { flex: none; }
.muted { color: var(--muted); }
.block { display: block; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.center form, form.center { display: flex; justify-content: center; }

/* ---------- Top bar + tabs ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px;
  background: var(--bg);   /* no backdrop-filter: it would trap the fixed mobile tab bar */
}
.brand img { height: 46px; width: auto; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 8px 8px env(safe-area-inset-bottom);
  background: var(--card);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -6px 30px rgba(31, 31, 46, .08);
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  text-decoration: none; font-weight: 800; font-size: 13px; color: var(--muted);
  border-radius: 20px;
}
.tab-icon { display: grid; place-items: center; width: 52px; height: 36px; border-radius: 18px; transition: background .15s; }
.tab.is-active { color: var(--ink); }
.tab-coral.is-active .tab-icon  { background: var(--coral);  color: #fff; }
.tab-teal.is-active .tab-icon   { background: var(--teal);   color: #fff; }
.tab-purple.is-active .tab-icon { background: var(--purple); color: #fff; }
.tab-yellow.is-active .tab-icon { background: var(--yellow); color: var(--ink); }
.badge {
  position: absolute; top: 2px; left: calc(50% + 12px);
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--coral); color: #fff; font-size: 13px; line-height: 22px; text-align: center;
  border: 2px solid #fff;
}

@media (min-width: 860px) {
  body { padding-bottom: 80px; }
  .topbar { padding: 16px 32px; }
  .tabs {
    position: static; display: flex; gap: 6px; height: auto; padding: 6px;
    border-radius: 999px; box-shadow: var(--shadow);
  }
  .tab { flex-direction: row; gap: 8px; padding: 6px 18px 6px 6px; font-size: 17px; border-radius: 999px; }
  .tab-icon { width: 44px; height: 44px; border-radius: 50%; }
  .badge { position: static; }
}

/* ---------- Page ---------- */
.page { max-width: 880px; margin: 0 auto; padding: 8px 16px 0; display: grid; gap: 18px; }
.hero {
  display: flex; align-items: center; gap: 18px;
  padding: 26px 24px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  position: relative; overflow: hidden;
}
.theme-yellow .hero { background: var(--yellow); color: var(--ink); }
.hero::after {
  content: ""; position: absolute; right: -40px; top: -50px; width: 180px; height: 180px;
  border-radius: 50%; background: rgba(255, 255, 255, .16);
}
.hero p { font-size: 18px; font-weight: 600; opacity: .92; margin-top: 4px; }
.hero-icon {
  flex: none; display: grid; place-items: center; width: 72px; height: 72px;
  border-radius: 24px; background: rgba(255, 255, 255, .22);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-big { padding: 36px 24px; display: grid; gap: 16px; justify-items: center; }
.card-big h2 { font-size: 26px; margin: 0; max-width: 520px; }
.card-big p { max-width: 460px; }
.card-attention { border: 3px solid var(--coral); }
.big-logo { width: 96px; height: 96px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row-between h2 { margin: 0; display: inline-flex; gap: 8px; align-items: center; }

.who { display: flex; align-items: center; gap: 14px; }
.who h2 { margin: 0; }
.avatar {
  display: grid; place-items: center; width: 60px; height: 60px; border-radius: 20px;
  background: var(--coral); color: #fff; font-size: 28px; font-weight: 900;
}
.avatar-teal { background: var(--teal); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 26px;
  border: 0; border-radius: 999px;
  font: inherit; font-weight: 800; font-size: 18px; text-decoration: none;
  cursor: pointer; transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 4px 0 var(--coral-dark); }
.btn-primary:active { box-shadow: 0 2px 0 var(--coral-dark); }
.btn-secondary { background: var(--card); color: var(--ink); border: 3px solid var(--line); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; }
.btn-xl { min-height: 68px; padding: 0 36px; font-size: 21px; }
.btn-small { min-height: 44px; padding: 0 18px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.btn-round {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
  border: 0; background: var(--ok); color: #fff; cursor: pointer;
}
.btn-round-ghost { background: #F3EEE8; color: var(--muted); }
.link-btn {
  background: none; border: 0; padding: 4px; font: inherit; font-weight: 800; color: var(--coral);
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}

/* ---------- Pills, chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  font-size: 15px; font-weight: 800; background: #F3EEE8; color: var(--muted); white-space: nowrap;
}
.pill .dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.pill-ok { background: #DFF6EC; color: var(--ok); }
.pill-off { background: #F3EEE8; color: #A39E9A; }
.pill-bad { background: var(--coral-soft); color: var(--bad); }
.pill-fun { background: var(--yellow-soft); color: #9A6B00; margin-top: 8px; padding: 6px 12px; }
.pill-ok .dot { animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 999px;
  background: var(--accent-soft); font-weight: 800; font-size: 16px;
}

/* ---------- Lists & steps ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px; border-radius: 20px; background: var(--bg);
}
.list-item .muted { display: block; font-size: 15px; }
.player-icon {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px;
  background: var(--coral); color: #fff;
}
.job-thumb { width: 52px; height: 66px; object-fit: cover; border-radius: 10px; background: #fff; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps a {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 20px;
  background: var(--bg); text-decoration: none; font-weight: 700;
}
.step-num {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: #fff; border: 3px solid var(--line); font-weight: 900;
}
.steps .is-done .step-num { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps .is-done .grow { color: var(--muted); text-decoration: line-through; }
.chev { font-size: 28px; color: var(--muted); }
.mini-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.mini-steps li {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px 10px 10px;
  border-radius: 999px; background: var(--accent-soft); font-weight: 700;
}
.mini-steps span {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 900;
}

/* ---------- Forms ---------- */
.field { display: grid; gap: 8px; margin-bottom: 22px; }
.field-label { font-weight: 800; }
.hint { font-size: 15px; color: var(--muted); }
.input {
  font: inherit; font-weight: 700; color: var(--ink);
  padding: 12px 16px; border-radius: 16px; border: 3px solid var(--line); background: #fff;
}
.input:focus { outline: none; border-color: var(--accent); }
.input-big { font-size: 34px; font-weight: 900; letter-spacing: .2em; width: 200px; text-align: center; }
.field-row { display: flex; align-items: center; gap: 16px; padding: 10px 0; }
.field-row + .field-row { border-top: 2px dashed var(--line); }
.time-row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.time-row label { display: flex; align-items: center; gap: 10px; font-weight: 700; }

.seg { display: inline-flex; padding: 6px; gap: 6px; border-radius: 999px; background: #F3EEE8; flex-wrap: wrap; }
.seg input, .option input, .tile input, .switch input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: 10px 20px; border-radius: 999px; font-weight: 800; cursor: pointer; color: var(--muted);
}
.seg input:checked + span { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.seg input:focus-visible + span, .option input:focus-visible + .option-body,
.tile input:focus-visible + .tile-body { outline: 3px solid var(--accent); outline-offset: 2px; }

.options { display: grid; gap: 10px; }
.option { position: relative; display: block; cursor: pointer; }
.option-body {
  display: grid; gap: 2px; padding: 16px 18px 16px 58px; border-radius: 20px;
  border: 3px solid var(--line); position: relative;
}
.option-body::before {
  content: ""; position: absolute; left: 18px; top: 50%; translate: 0 -50%;
  width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); background: #fff;
}
.option-body small { color: var(--muted); font-size: 15px; }
.option input:checked + .option-body { border-color: var(--accent); background: var(--accent-soft); }
.option input:checked + .option-body::before { border: 8px solid var(--accent); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.tile { position: relative; cursor: pointer; }
.tile-body {
  display: grid; justify-items: center; gap: 10px; padding: 20px 12px; border-radius: 22px;
  border: 3px solid var(--line); text-align: center;
}
.tile-icon {
  display: grid; place-items: center; width: 60px; height: 60px; border-radius: 20px;
  background: #F3EEE8; color: var(--muted);
}
.tile input:checked + .tile-body { border-color: var(--accent); background: var(--accent-soft); }
.tile input:checked + .tile-body .tile-icon { background: var(--accent); color: #fff; }

.switch { position: relative; flex: none; cursor: pointer; }
.switch span {
  display: block; width: 68px; height: 40px; border-radius: 999px; background: #E2DBD3; transition: background .15s;
}
.switch span::after {
  content: ""; position: absolute; top: 5px; left: 5px; width: 30px; height: 30px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); transition: left .15s;
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { left: 33px; }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.stepper { display: inline-flex; align-items: center; gap: 4px; padding: 5px; border-radius: 999px; background: #F3EEE8; }
.stepper button {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: #fff;
  font: inherit; font-size: 26px; font-weight: 900; color: var(--ink); cursor: pointer; box-shadow: var(--shadow);
}
.stepper input {
  width: 56px; border: 0; background: none; text-align: center; font: inherit; font-size: 22px; font-weight: 900;
  -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; }
.stepper-small button { width: 38px; height: 38px; font-size: 22px; }
.stepper-small input { width: 40px; font-size: 19px; }

.rules-form { display: grid; gap: 18px; }
.rules-form [data-auto-only] { display: grid; gap: 18px; transition: opacity .2s; }
.rules-form.is-off [data-auto-only] { opacity: .4; }
.save-bar {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); z-index: 5;
}
@media (min-width: 860px) { .save-bar { bottom: 16px; } }

/* ---------- Library ---------- */
.cards { display: grid; gap: 18px; }
.story { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.story-head { display: flex; gap: 16px; align-items: center; }
.story-head h2 { margin: 0 0 2px; }
.cover {
  flex: none; width: 96px; height: 96px; border-radius: 22px; overflow: hidden;
  background: var(--cover); display: grid; place-items: center;
  color: #fff; font-size: 44px; font-weight: 900;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .25);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.empty { padding: 4px 0; }
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.page-tile { display: grid; gap: 6px; align-content: start; }
.page-tile b { font-size: 16px; }
.page-tile small { font-size: 14px; margin-top: -4px; }
.page-tile .btn { width: 100%; padding: 0 10px; gap: 6px; white-space: nowrap; }
.page-thumb {
  position: relative; display: block; aspect-ratio: 8.5 / 11; border-radius: 16px; overflow: hidden;
  background: #F3EEE8; border: 3px solid var(--line);
}
.page-thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.page-tile.is-off .page-thumb img { filter: grayscale(1); opacity: .45; }
.page-flag {
  position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 6px 8px; border-radius: 10px;
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 800; text-align: center;
}
.story-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 14px; border-top: 2px dashed var(--line); }
.story-actions .btn { margin-left: auto; }
.demo-insert {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 16px; background: var(--yellow-soft); font-size: 15px; font-weight: 700;
}
.demo-insert select { font: inherit; padding: 4px 8px; border-radius: 10px; border: 2px solid var(--line); }

.library-tools { padding: 0 6px; }
.banner {
  padding: 16px 20px; border-radius: 20px; font-weight: 800;
  background: var(--coral-soft); color: var(--coral-dark); border: 3px solid var(--coral);
}
.debug pre {
  margin: 8px 0 0; padding: 14px; border-radius: 14px; background: var(--bg);
  font-size: 13px; line-height: 1.35; overflow: auto; max-height: 320px; white-space: pre-wrap; word-break: break-all;
}

/* ---------- Toasts & demo bar ---------- */
.toasts {
  position: fixed; top: 84px; left: 50%; translate: -50% 0; z-index: 30;
  display: grid; gap: 8px; width: min(560px, calc(100% - 24px));
}
.toast {
  padding: 16px 20px; border-radius: 20px; font-weight: 800;
  background: var(--ink); color: #fff; box-shadow: 0 12px 30px rgba(31, 31, 46, .25);
  animation: toast-in .25s ease-out; transition: opacity .3s, translate .3s;
}
.toast-error { background: var(--bad); }
.toast-info { background: var(--purple); }
.toast.is-gone { opacity: 0; translate: 0 -10px; }
@keyframes toast-in { from { opacity: 0; translate: 0 -10px; } }
.demo-bar {
  max-width: 880px; margin: 28px auto 0; padding: 0 16px;
  display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 14px; color: var(--muted);
}

@media (max-width: 520px) {
  h1 { font-size: 28px; }
  .hero { padding: 20px; }
  .hero-icon { width: 60px; height: 60px; }
  .card { padding: 20px; }
  .brand img { height: 38px; }
  .cover { width: 76px; height: 76px; }
  .pages { grid-template-columns: repeat(2, 1fr); }
}
