/* Layout: one centered column (zeszyt w kratkę), sticky header; panel rodzica = te same karty, gęściej. */
:root {
  --bg: #f3f6fb;
  --grid: #e3e9f3;
  --card: #ffffff;
  --ink: #1b2333;
  --muted: #5f6b80;
  --line: #d6deea;
  --accent: #2f62d8;
  --accent-ink: #ffffff;
  --accent-soft: #e6edfc;
  --ok: #17855a;
  --ok-soft: #e3f4ec;
  --bad: #c2413b;
  --bad-soft: #fbe9e8;
  --warn: #a8670a;
  --warn-soft: #fbf0dc;
  --font: "Nunito", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161f; --grid: #182031; --card: #1a2230; --ink: #e8edf5; --muted: #9aa6ba; --line: #2b3546;
    --accent: #7aa2ff; --accent-ink: #0d1424; --accent-soft: #1f2b45;
    --ok: #4cc98f; --ok-soft: #15301f; --bad: #ff7b72; --bad-soft: #3a1c1b; --warn: #f0b45c; --warn-soft: #3a2b12;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 .4em; text-wrap: balance; }
h2 { font-size: 1.3rem; margin: 1.2em 0 .5em; }
.lead { color: var(--muted); margin: 0 0 1.2em; }
.muted { color: var(--muted); font-size: .9rem; }
.error { color: var(--bad); font-weight: 600; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, calc((100vw - 900px) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { background: none; border: 0; font-weight: 800; font-size: 1.15rem; cursor: pointer; padding: 6px 0; }
.brand::before { content: "✎ "; color: var(--accent); }
.top-right { display: flex; align-items: center; gap: 10px; }
#who { font-weight: 700; color: var(--muted); }

main { max-width: 900px; margin: 0 auto; padding: 28px 16px 80px; }

button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .opt:focus-within {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.primary, .ghost, .danger {
  border-radius: 999px; padding: 10px 20px; font-weight: 700; border: 2px solid transparent;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:disabled { opacity: .6; cursor: default; }
.ghost { background: transparent; border-color: var(--line); }
.ghost:hover { border-color: var(--accent); }
.danger { background: transparent; color: var(--bad); border-color: var(--bad-soft); }
.danger:hover { background: var(--bad-soft); }
.big { font-size: 1.15rem; padding: 14px 28px; }
.small { font-size: .85rem; padding: 6px 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; align-items: center; }

/* wybór dziecka */
.kids { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kid {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 28px 16px; border-radius: var(--radius); border: 2px solid var(--line);
  background: var(--card); font-size: 1.3rem; font-weight: 800;
}
.kid:hover { border-color: var(--accent); transform: translateY(-2px); }
.avatar {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 2rem;
}

/* lista testów */
.tests { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.test-card {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 18px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--card);
}
.test-card:hover { border-color: var(--accent); }
.test-card strong { font-size: 1.15rem; line-height: 1.3; }
.subject { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 800; }
.desc { color: var(--muted); font-size: .95rem; }
.meta { color: var(--muted); font-size: .85rem; margin-top: auto; padding-top: 6px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 800; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.mid { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius); background: var(--warn-soft); margin-bottom: 20px;
}

/* rozwiązywanie */
.test-head { position: sticky; top: 57px; z-index: 4; background: var(--bg); padding: 8px 0 12px; }
.prog-row { display: flex; align-items: center; gap: 12px; }
.progress { flex: 1; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.counter { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
.qs { display: flex; flex-direction: column; gap: 16px; }
.q { border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 18px 20px 20px; margin: 0; min-width: 0; }
.q legend { display: contents; }
.q-head { display: flex; gap: 12px; align-items: baseline; margin-bottom: 14px; font-weight: 700; font-size: 1.1rem; }
.num {
  flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: .95rem;
}
.prompt { white-space: pre-wrap; }
.pts { margin-left: auto; color: var(--muted); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.options { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 12px; cursor: pointer;
}
.opt:hover { border-color: var(--accent); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.letter {
  flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  border: 2px solid var(--line); font-weight: 800; font-size: .9rem;
}
.opt:has(input:checked) .letter { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.answer {
  width: 100%; max-width: 420px; padding: 12px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--bg); font-size: 1.15rem;
}
textarea.answer { max-width: 100%; resize: vertical; }

/* wynik */
.score { text-align: center; padding: 28px 16px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--line); margin-bottom: 24px; }
.big-score { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.pct { font-size: 1.2rem; font-weight: 800; color: var(--accent); }
.score p { margin: .4em 0 0; font-size: 1.15rem; }
.review { display: flex; flex-direction: column; gap: 12px; }
.rev { border-radius: var(--radius); background: var(--card); border: 2px solid var(--line); border-left-width: 8px; padding: 14px 18px; }
.rev.ok { border-left-color: var(--ok); }
.rev.bad { border-left-color: var(--bad); }
.rev.open { border-left-color: var(--warn); }
.rev p { margin: .3em 0 0; }
.rev-head { display: flex; gap: 12px; align-items: baseline; font-weight: 700; }
.mark { margin-left: auto; font-weight: 800; white-space: nowrap; }
.rev.ok .mark { color: var(--ok); }
.rev.bad .mark { color: var(--bad); }
.rev.open .mark { color: var(--warn); font-size: .85rem; }
.lbl { color: var(--muted); }
.expl { color: var(--muted); font-size: .95rem; font-style: italic; }

/* panel rodzica */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.tab { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 16px; font-weight: 700; }
.tab.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs .ghost { margin-left: auto; }
.panel { display: flex; flex-direction: column; gap: 14px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between;
  padding: 14px 16px; border-radius: 12px; background: var(--card); border: 2px solid var(--line);
}
.row > div { min-width: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.table-wrap { overflow-x: auto; background: var(--card); border: 2px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
td.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.card { padding: 18px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--line); }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-form input, .inline-form select { padding: 10px 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); }
.code-area { width: 100%; min-height: 220px; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; padding: 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); }
.errors { margin: .5em 0 0; padding-left: 1.2em; color: var(--bad); }
.status { font-size: .8rem; font-weight: 800; padding: 2px 10px; border-radius: 999px; }
.status.printed { background: var(--accent-soft); color: var(--accent); }
.status.uploaded { background: var(--warn-soft); color: var(--warn); }
.status.graded { background: var(--ok-soft); color: var(--ok); }
.login { max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login input { padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 1.3rem; letter-spacing: .3em; }

/* sprawdzanie wydruku */
.grade-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.photos { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 90px); overflow: auto; }
.photos img { width: 100%; border-radius: 10px; border: 2px solid var(--line); cursor: zoom-in; }
.photos img.zoom { cursor: zoom-out; width: 200%; max-width: none; }
.grade-q { padding: 12px 14px; border-radius: 12px; background: var(--card); border: 2px solid var(--line); }
.grade-q .key { font-size: .9rem; color: var(--muted); margin: .3em 0; }
.grade-q .ai { font-size: .85rem; color: var(--warn); margin: .3em 0; }
.grade-q input.read { width: 100%; padding: 6px 10px; border-radius: 8px; border: 2px solid var(--line); background: var(--bg); font-size: .95rem; }
.toggle { display: flex; gap: 8px; margin-top: 8px; }
.toggle button { flex: 1; padding: 8px; border-radius: 10px; border: 2px solid var(--line); background: transparent; font-weight: 800; }
.toggle button.on-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.toggle button.on-bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px; text-align: center;
  border: 3px dashed var(--line); border-radius: var(--radius); background: var(--card); cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumbs img { height: 120px; border-radius: 8px; border: 2px solid var(--line); }

/* logowanie */
.login label { font-weight: 700; font-size: .9rem; margin-bottom: -6px; }
.login input { letter-spacing: normal; font-size: 1.1rem; }

/* profil i grywalizacja */
.profile {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center;
  padding: 18px 20px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--line); margin-bottom: 16px;
}
.level-badge {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; transform: rotate(-6deg);
  background: var(--accent); color: var(--accent-ink); font-size: 1.9rem; font-weight: 800;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, #000);
}
.level-badge span { transform: rotate(6deg); }
.profile-name { font-size: 1.4rem; font-weight: 800; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.level-title { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.xp { margin-top: 6px; }
.xp-track { height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; }
.xp-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--ok))); transition: width .6s; }
.xp-label { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.streak { text-align: center; min-width: 96px; }
.streak strong { display: block; font-size: 2rem; line-height: 1; color: var(--warn); font-variant-numeric: tabular-nums; }
.streak span { font-size: .8rem; color: var(--muted); }
.streak.cold strong { color: var(--muted); }
.nudge { margin: 0 0 16px; padding: 10px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.badge.new { background: var(--accent-soft); color: var(--accent); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 28px; align-items: start; }
.board-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; }
.board-head h2, .card > h2 { margin-top: 0; }
.board-list { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.board-list li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-areas: "place name xp" "place meta xp"; column-gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.board-list li.me { outline: 2px solid var(--accent); }
.place { grid-area: place; font-size: 1.3rem; font-weight: 800; text-align: center; }
.board-name { grid-area: name; font-weight: 800; }
.board-meta { grid-area: meta; font-size: .8rem; color: var(--muted); }
.board-xp { grid-area: xp; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.you { margin-left: 8px; font-size: .7rem; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); vertical-align: middle; }
.small-print { font-size: .8rem; margin: 6px 0 0; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.badge-tile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 12px 8px; border-radius: 12px; background: var(--bg); opacity: .45; filter: grayscale(1); }
.badge-tile.got { opacity: 1; filter: none; background: var(--warn-soft); }
.badge-tile strong { font-size: .85rem; line-height: 1.2; }
.badge-tile span:last-child { font-size: .72rem; color: var(--muted); line-height: 1.25; }
.badge-icon { font-size: 1.8rem; line-height: 1.2; }
.result-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.result-top .score { margin: 0; }
.xp-card { display: flex; flex-direction: column; gap: 8px; }
.xp-total { font-size: 2.4rem; font-weight: 800; color: var(--ok); line-height: 1.1; }
.xp-parts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.xp-parts li { display: flex; justify-content: space-between; gap: 12px; font-size: .95rem; }
.xp-parts strong { color: var(--ok); font-variant-numeric: tabular-nums; }
.level-up { margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.new-badges { display: grid; gap: 8px; }
.new-badges .badge-tile { flex-direction: row; text-align: left; gap: 10px; }
.pop { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(.7); } 70% { transform: scale(1.06); } 100% { transform: scale(1); } }

@media (max-width: 700px) {
  .profile { grid-template-columns: auto minmax(0, 1fr); }
  .streak { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px; text-align: left; }
  .two-col, .result-top { grid-template-columns: 1fr; }
  body { font-size: 16px; }
  .grade-layout { grid-template-columns: 1fr; }
  .photos { position: static; max-height: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
