/* Panel rodzica. Kolory marki Myśl po Myśli: granat, turkus, koral, krem. */
:root {
  --bg: #fbf6ef;
  --panel: #ffffff;
  --text: #1f2942;
  --muted: #646d85;
  --border: #ece3d6;
  --accent: #ef6f5e;
  --accent-text: #ffffff;
  --teal: #1f8a7e;
  --teal-soft: #e4f4f1;
  --gold: #9a6a00;
  --gold-soft: #fff1cf;
  --night: #172042;
  --ok: #1a7f37;
  --bad: #c0362c;
  --shadow: 0 10px 30px rgba(31, 41, 66, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1428;
    --panel: #181f3a;
    --text: #eef0f8;
    --muted: #a6aec8;
    --border: #2b3459;
    --accent: #ff8573;
    --accent-text: #221018;
    --teal: #6fd3c4;
    --teal-soft: #17403f;
    --gold: #ffd47a;
    --gold-soft: #3a3018;
    --night: #0a0f23;
    --ok: #5ad07a;
    --bad: #ff8b82;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

h2, h3 { margin: 0; line-height: 1.25; font-weight: 900; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
a { color: var(--teal); font-weight: 700; }
.hint { margin: 0; font-size: 14px; color: var(--muted); }
.warn { margin: 0; font-size: 14px; color: var(--bad); font-weight: 700; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.75; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Nagłówek ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--night);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 19px; font-weight: 900; }
.moon { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset -9px -4px 0 0 #ffcf66; transform: rotate(8deg); }
.tabs { display: flex; gap: 4px; background: rgba(255, 255, 255, 0.08); padding: 4px; border-radius: 999px; }
.tabs a { color: #cfd6ee; text-decoration: none; font-weight: 800; font-size: 15px; padding: 7px 16px; border-radius: 999px; white-space: nowrap; }
.tabs a[aria-current] { background: #fff; color: #172042; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 12px; text-align: center; }
.pill { justify-self: end; background: #ffcf66; color: #3a2a00; text-decoration: none; font-weight: 900; padding: 6px 16px; border-radius: 999px; white-space: nowrap; }

.banner { margin: 0; padding: 10px 24px; background: var(--bad); color: #fff; font-weight: 800; text-align: center; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; }
.narrow { max-width: 760px; margin: 0 auto; display: grid; gap: 16px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 20px 22px; box-shadow: var(--shadow); }

/* ---------- Nowa bajka ---------- */

.create { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.create form { display: grid; gap: 16px; }
.create .card { display: grid; gap: 14px; }
.step { display: inline-grid; place-items: center; width: 30px; height: 30px; margin-right: 10px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); font-size: 15px; }

.field { display: grid; gap: 5px; font-size: 14px; font-weight: 800; color: var(--muted); }
input, textarea { font: inherit; color: var(--text); background: var(--bg); border: 2px solid var(--border); border-radius: 12px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus { outline: 0; border-color: var(--teal); }
textarea { resize: vertical; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; color: var(--text); background: var(--panel); border: 2px solid var(--border); border-radius: 999px; padding: 6px 14px; }
.chip:hover { border-color: var(--teal); }
.chip[aria-pressed='true'] { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }
.chip.dashed { border-style: dashed; color: var(--muted); }
.child { display: inline-flex; }
.child .chip:first-child { border-radius: 999px 0 0 999px; }
.child .chip.remove { border-radius: 0 999px 999px 0; margin-left: -2px; padding: 6px 12px 6px 10px; color: var(--muted); }
.child .chip.remove:hover { border-color: var(--bad); color: var(--bad); }

fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 14px; font-weight: 800; color: var(--muted); margin-bottom: 6px; padding: 0; }
.ages label, .seg label, .option { position: relative; cursor: pointer; }
.ages input, .seg input, .option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ages { display: flex; flex-wrap: wrap; gap: 6px; }
.ages span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 2px solid var(--border); font-weight: 900; }
.ages input:checked + span { background: var(--teal); border-color: var(--teal); color: var(--panel); }

.more summary { cursor: pointer; font-weight: 800; color: var(--teal); }
.more summary small { color: var(--muted); font-weight: 600; }
.more .field { margin-top: 12px; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.option > span { display: grid; gap: 4px; height: 100%; align-content: start; padding: 14px 16px; border: 2px solid var(--border); border-radius: 16px; }
.option b { font-size: 17px; }
.option small { font-size: 13.5px; color: var(--muted); }
.option em { font-style: normal; font-weight: 900; color: var(--gold); }
.option input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.option input:disabled + span { opacity: 0.5; cursor: default; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg legend { grid-column: 1 / -1; float: left; width: 100%; }
.seg span { display: grid; text-align: center; padding: 8px; border: 2px solid var(--border); border-radius: 12px; font-weight: 900; }
.seg small { font-weight: 600; font-size: 12.5px; color: var(--muted); }
.seg input:checked + span { border-color: var(--teal); background: var(--teal-soft); }

input:focus-visible + span, .chip:focus-visible, .btn:focus-visible, .package:focus-visible, .tabs a:focus-visible { outline: 3px solid #ffcf66; outline-offset: 2px; }

.summary { position: sticky; top: 84px; border-radius: 22px; overflow: hidden; background: var(--night); color: #fff; box-shadow: var(--shadow); }
.summary .hint { color: #b7c0e0; }
.sky {
  height: 110px;
  background:
    radial-gradient(circle at 78% 42%, #ffcf66 0 22px, rgba(255, 207, 102, 0.22) 23px 36px, transparent 37px),
    radial-gradient(circle at 14% 30%, #fff 0 1.6px, transparent 2.4px),
    radial-gradient(circle at 31% 68%, #fff 0 1.2px, transparent 2px),
    radial-gradient(circle at 46% 24%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 60% 76%, #fff 0 1.2px, transparent 2px),
    radial-gradient(circle at 92% 82%, #fff 0 1.6px, transparent 2.4px),
    linear-gradient(180deg, #2b3a78, #172042);
}
.summary-body { display: grid; gap: 12px; padding: 4px 22px 22px; }
.summary h3 { font-size: 21px; }
.price-line { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid rgba(255, 255, 255, 0.15); padding-top: 12px; }
.price-line strong { font-size: 30px; color: #ffcf66; }
.summary .warn { color: #ffb3a8; }
.summary a { color: #ffcf66; }

.btn { font: inherit; font-weight: 900; font-size: 15px; cursor: pointer; color: var(--text); background: var(--panel); border: 2px solid var(--border); border-radius: 999px; padding: 8px 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; font-size: 18px; padding: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.summary .btn:not(.primary) { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.4); }

.progress { display: grid; gap: 8px; }
.progress p { margin: 0; font-size: 14.5px; font-weight: 700; }
.bar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: #ffcf66; transition: width 0.4s; }

/* ---------- Biblioteka ---------- */

.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-head h2 { font-size: 26px; }
#filtry, #wiek-filtry { margin-bottom: 18px; }
.ready-head { margin-top: 36px; }
.ready-head small { font-size: 16px; color: var(--muted); font-weight: 800; }
.books { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.book { display: grid; grid-template-rows: auto 1fr; background: var(--panel); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); }
.cover { position: relative; aspect-ratio: 3 / 2; background: linear-gradient(180deg, #2b3a78, #172042); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tag { position: absolute; top: 10px; left: 10px; font-size: 12px; font-weight: 900; padding: 3px 10px; border-radius: 999px; background: #ffcf66; color: #3a2a00; }
.book-body { display: grid; gap: 8px; align-content: space-between; padding: 14px 16px 16px; }
.empty { color: var(--muted); }

/* ---------- Gwiazdki ---------- */

.balance { border-radius: 22px; padding: 22px 24px; background: linear-gradient(135deg, #2b3a78, #172042); color: #fff; }
.balance p { margin: 0; }
.balance-n { font-size: 52px; font-weight: 900; color: #ffcf66; line-height: 1.2; }
.packages { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.package { font: inherit; color: var(--text); cursor: pointer; display: grid; gap: 2px; text-align: center; padding: 16px 12px; background: var(--panel); border: 2px solid var(--border); border-radius: 18px; }
.package:hover:not(:disabled) { border-color: var(--accent); }
.package:disabled { opacity: 0.55; cursor: default; }
.pk-name { font-weight: 800; color: var(--muted); }
.pk-stars { font-size: 30px; font-weight: 900; color: var(--gold); }
.pk-bonus { font-size: 13px; font-weight: 800; color: var(--ok); }
.pk-price { margin-top: 6px; background: var(--accent); color: var(--accent-text); border-radius: 999px; font-weight: 900; padding: 6px; }
.prices, .history ul { list-style: none; margin: 10px 0 0; padding: 0; font-size: 15px; }
.prices li, .history li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.history summary { cursor: pointer; font-weight: 900; }
.history .plus { color: var(--ok); font-weight: 800; white-space: nowrap; }
.history .minus { color: var(--bad); font-weight: 800; white-space: nowrap; }

/* ---------- Podgląd bajki ---------- */

dialog { width: min(920px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0 22px; border: 0; border-radius: 22px; background: var(--panel); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4); }
dialog::backdrop { background: rgba(10, 15, 35, 0.7); }
.pv-head { position: sticky; top: 0; display: flex; justify-content: space-between; gap: 12px; align-items: start; padding: 18px 0 10px; background: var(--panel); z-index: 1; }
.pv-note { margin: 0 0 14px; padding: 8px 14px; border-radius: 12px; background: var(--gold-soft); color: var(--gold); font-weight: 800; font-size: 14px; }
.pv-pages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.pv-pages li { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.pv-pages img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
.pv-pages p { margin: 0; padding: 12px 14px; font-size: 15px; }
.pv-pages .ending { grid-column: 1 / -1; text-align: center; font-weight: 800; background: var(--teal-soft); border: 0; }
.pv-foot { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 0 18px; margin-top: 16px; background: var(--panel); }
.pv-foot .danger { margin-left: auto; }

/* ---------- Logowanie i aktywacja ---------- */

.login { max-width: 440px; margin: 40px auto; padding: 0 16px; }
.login .card { display: grid; gap: 14px; }
.login input { text-align: center; letter-spacing: 0.08em; text-transform: uppercase; }
.login input::placeholder { text-transform: none; }
.code { margin: 0; padding: 16px; border-radius: 14px; background: var(--gold-soft); color: var(--gold); font-size: clamp(20px, 6vw, 26px); font-weight: 900; text-align: center; letter-spacing: 0.06em; user-select: all; }
.login a.btn { display: block; text-align: center; text-decoration: none; }
body.logged-out .tabs, body.logged-out .pill, body.logged-out main { display: none; }

/* ---------- Telefon ---------- */

@media (max-width: 860px) {
  .create { grid-template-columns: minmax(0, 1fr); }
  .summary { position: static; }
  .sky { height: 70px; }
}

@media (max-width: 720px) {
  .top { grid-template-columns: 1fr auto; padding: 10px 14px; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; }
  .tabs a { padding: 6px 10px; font-size: 14px; }
  main { padding: 16px 12px 40px; }
  .card { padding: 16px; }
  .options { grid-template-columns: 1fr; }
  .seg { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 400px) {
  .tabs a { padding: 6px 7px; font-size: 13px; }
  .books { grid-template-columns: minmax(0, 1fr); }
}
