:root {
  --paper: #fffaf0;
  --card: #ffffff;
  --ink: #1d1b18;
  --ink-soft: #5c574f;
  --line: #1d1b18;
  --accent: #ff6b4a;
  --accent-ink: #ffffff;
  --sun: #ffd34d;
  --mint: #bfe9d4;
  --radius: 18px;
  --shadow: 4px 4px 0 var(--ink);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 var(--font);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; padding-block: 8px 48px; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.75rem, 6vw, 2.5rem); letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }

a { color: inherit; }

.wrap { width: 100%; max-width: 960px; margin-inline: auto; padding-inline: var(--gutter); }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.lead { font-size: 1.1rem; color: var(--ink-soft); max-width: 36em; }

/* Header */
.site-header { padding-block: 12px; }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; font-size: 1.4rem; letter-spacing: -.02em; }
.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav a { text-decoration: none; font-weight: 700; padding: 8px 12px; border-radius: 999px; min-height: 40px; display: inline-flex; align-items: center; }
.site-nav a:hover { background: var(--sun); }
.lang-switch { border: 2px solid var(--line); font-size: .85rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 12px 22px; border: 2px solid var(--line); border-radius: 999px; background: var(--card); font: inherit; font-weight: 800; text-decoration: none; cursor: pointer; box-shadow: var(--shadow); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--block { width: 100%; }

/* Home */
.hero { padding-block: 24px 8px; }
.section { margin-top: 32px; }

.age-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 20px; }
.age-card { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; aspect-ratio: 1.15; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; }
a.age-card:hover { background: var(--sun); }
.age-card__num { font-size: 3rem; font-weight: 900; line-height: 1; }
.age-card__label { font-weight: 700; }
.age-card.is-soon { box-shadow: none; border-style: dashed; color: var(--ink-soft); }
.badge { position: absolute; top: 10px; right: 10px; font-size: .75rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--mint); color: var(--ink); }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 12px; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-weight: 600; }
.steps li::before { content: counter(step); flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--sun); border: 2px solid var(--line); font-weight: 900; }

/* Age page */
.page-head { padding-block: 16px 8px; }
.empty { background: var(--card); border: 2px dashed var(--line); border-radius: var(--radius); padding: 24px; text-align: center; color: var(--ink-soft); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin: 0 calc(var(--gutter) * -1) 16px; padding-inline: var(--gutter); scrollbar-width: none; }
.chip { flex: none; padding: 8px 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--card); color: inherit; font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.task-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.task-card { display: flex; flex-direction: column; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; text-decoration: none; min-width: 0; }
.task-card:hover { box-shadow: var(--shadow); }
.task-card[hidden] { display: none; }
.task-card__title { font-weight: 700; font-size: .9rem; line-height: 1.25; min-height: 2.5em; }
.task-card__art svg { display: block; width: 100%; height: auto; }

/* Task detail */
.back-link { display: inline-block; margin-block: 8px 12px; font-weight: 700; text-decoration: none; }
.task-detail__art { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.task-detail__art svg { display: block; width: 100%; height: auto; }
.task-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.task-actions .btn { flex: 1; }
.icon-heart { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; }
[data-like][aria-pressed="true"] { background: var(--sun); }
[data-like][aria-pressed="true"] .icon-heart { fill: var(--accent); stroke: var(--ink); }

.note { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.note h2 { font-size: 1rem; margin-bottom: 4px; }
.note p { margin: 0; }
.note--tip { background: var(--mint); }

/* Print builder */
.builder { display: grid; gap: 20px; }
.builder__controls { display: grid; gap: 16px; align-content: start; }
.field { border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 12px 14px 14px; margin: 0; display: grid; gap: 10px; min-width: 0; }
.field[hidden] { display: none; }
.field legend { font-weight: 800; padding: 0 6px; margin-left: -6px; }
.seg { display: flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg__btn { flex: 1; min-height: 44px; border: 0; background: var(--card); font: inherit; font-weight: 800; color: inherit; cursor: pointer; }
.seg__btn + .seg__btn { border-left: 2px solid var(--line); }
.seg__btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chips--wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; min-height: 36px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.text-field { display: grid; gap: 4px; font-weight: 700; font-size: .9rem; }
.text-field input, .share input { font: inherit; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); min-width: 0; }
.hint { margin: 0; font-size: .8rem; color: var(--ink-soft); }
.btn--small { min-height: 40px; padding: 6px 14px; font-size: .9rem; box-shadow: none; justify-self: start; }
.btn:disabled { opacity: .6; cursor: progress; }
.share { display: grid; gap: 6px; font-weight: 700; font-size: .9rem; }
.share[hidden] { display: none; }
.share__row { display: flex; gap: 8px; }
.share__row input { flex: 1; font-size: .85rem; }

.library { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 420px; overflow-y: auto; padding: 2px; }
.library__item { position: relative; display: grid; gap: 2px; padding: 6px; border: 2px solid #d8d2c6; border-radius: 12px; background: var(--card); font: inherit; font-size: .7rem; font-weight: 700; line-height: 1.2; text-align: left; color: inherit; cursor: pointer; }
.library__item svg { width: 100%; height: auto; display: block; }
.library__item[aria-pressed="true"] { border-color: var(--ink); background: #fff3c4; }
.library__badge { position: absolute; top: -6px; right: -6px; min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: 999px; background: var(--accent); color: #fff; border: 2px solid var(--ink); font-size: .75rem; }

.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }

/* A4 sheet (rozměry v cqw = % šířky A4, platí stejně pro náhled i tisk) */
.sheets { display: grid; gap: 16px; }
.sheet { container-type: inline-size; width: 100%; aspect-ratio: 210 / 297; background: #fff; color: #000; border: 1px solid #d8d2c6; border-radius: 6px; box-shadow: 0 6px 20px rgba(29, 27, 24, .12); display: flex; flex-direction: column; }
.sheet > * { margin-inline: 5.7cqw; }
.sheet__head { display: flex; gap: 6cqw; margin-top: 5.7cqw; font-size: 2.6cqw; font-weight: 700; }
.sheet__field { flex: 1; display: flex; align-items: flex-end; gap: 1.5cqw; }
.sheet__line { flex: 1; border-bottom: .3cqw solid #000; height: 3cqw; }
.sheet__day { flex: 1; text-align: right; font-size: 3.4cqw; font-weight: 900; }
.sheet__value { flex: 1; border-bottom: .3cqw solid #000; font-size: 3cqw; }
.sheet__grid { flex: 1; min-height: 0; display: grid; gap: 2.6cqw; margin-block: 2.6cqw; }
.sheet--1 .sheet__grid { grid-template: 1fr / 1fr; }
.sheet--2 .sheet__grid { grid-template: repeat(2, minmax(0, 1fr)) / 1fr; }
.sheet--4 .sheet__grid { grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr)); }
.sheet--6 .sheet__grid { grid-template: repeat(3, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr)); }
.sheet__cell { position: relative; margin: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 1cqw; padding: 2cqw; border: .45cqw solid #000; border-radius: 2.6cqw; }
.sheet__cell figcaption { font-weight: 800; font-size: 2.5cqw; line-height: 1.2; }
.sheet__art { min-height: 0; display: flex; }
.sheet__art svg { width: 100%; height: 100%; }
.sheet__instr { margin: 0; font-size: 1.9cqw; line-height: 1.3; color: #333; }
.sheet--1 .sheet__cell figcaption, .sheet--2 .sheet__cell figcaption { font-size: 3.6cqw; }
.sheet--1 .sheet__instr, .sheet--2 .sheet__instr { font-size: 2.8cqw; }
.sheet__foot { margin-bottom: 4cqw; text-align: right; font-size: 1.7cqw; color: #777; }
.sheet__reroll { position: absolute; top: 1.5cqw; right: 1.5cqw; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--ink); background: var(--sun); font-size: 1rem; font-weight: 900; cursor: pointer; color: var(--ink); }

/* Activity of the day */
.daily { display: grid; grid-template-columns: 1fr; gap: 12px; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; text-decoration: none; }
.daily:hover { background: #fffdf6; }
.daily__art svg { display: block; width: 100%; height: auto; }
.daily__body { display: grid; gap: 6px; align-content: center; }
.daily__badge { position: static; justify-self: start; background: var(--sun); }
.daily__title { font-size: 1.35rem; line-height: 1.2; }
.daily__text { color: var(--ink-soft); }
.daily__cta { font-weight: 800; color: var(--accent); }

/* Prose */
.prose { max-width: 680px; padding-top: 16px; }
.prose h2 { margin-top: 1.6em; }
.prose ul { padding-left: 1.2em; display: grid; gap: 6px; }

/* Account */
.account-auth { max-width: 520px; padding-top: 16px; }
.account-perks { padding-left: 1.2em; margin: 0 0 20px; display: grid; gap: 4px; font-weight: 600; }
.account-card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.account-card h2 { margin-bottom: 10px; }
.account-form { display: grid; gap: 12px; }
.account-form .btn--small { justify-self: start; }
.account-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.account-head h1 { margin: 0; }
.account-weekly { display: grid; gap: 12px; background: #fff3c4; }
.account-weekly p { margin: 0; }
.account-inline { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.account-card details { border-top: 1px dashed #c9c2b4; padding-block: 10px; }
.account-card summary { cursor: pointer; font-weight: 700; }
.account-card details .account-form { margin-top: 10px; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.history li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.history a { font-weight: 700; }
.form-error { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: #ffe1d9; border: 2px solid var(--accent); font-weight: 700; }
.form-ok { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--mint); border: 2px solid var(--line); font-weight: 700; }
.btn--danger { background: #ffe1d9; }
.btn--google { gap: 12px; margin-bottom: 6px; }
.account-google-hint { margin: 0 0 4px; text-align: center; }
.age-card.is-child { background: var(--sun); }

.account-nick { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; background: #fff3c4; }
.account-nick .text-field { flex: 1; min-width: 200px; }
.children { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 10px; }
.child { display: grid; gap: 8px; padding: 12px; border: 2px solid var(--line); border-radius: 14px; background: var(--paper); }
.child__main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.child__main strong { font-size: 1.1rem; }
.child .btn--primary { justify-self: start; box-shadow: none; }
.child__edit summary, .child-add summary { cursor: pointer; font-weight: 700; }
.child__edit { border: 0; padding: 0; }
.child__edit form { margin-top: 8px; }
.child-add { border-top: 1px dashed #c9c2b4; padding-top: 10px; }
.child-add form { margin-top: 8px; }
.account-weekly-fallback { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }

/* Presence */
.presence { position: relative; display: inline-block; margin-top: 4px; }
.presence[hidden] { display: none; }
.presence__pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--card); font: inherit; font-size: .9rem; font-weight: 700; color: inherit; cursor: pointer; }
.presence__dot { width: 10px; height: 10px; border-radius: 50%; background: #2fb36d; animation: presence-pulse 2s infinite; }
@keyframes presence-pulse { 0% { box-shadow: 0 0 0 0 rgba(47, 179, 109, .55); } 70% { box-shadow: 0 0 0 8px rgba(47, 179, 109, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 179, 109, 0); } }
@media (prefers-reduced-motion: reduce) { .presence__dot { animation: none; } }
.presence__panel { position: absolute; z-index: 5; top: calc(100% + 8px); left: 0; min-width: 260px; max-width: min(340px, calc(100vw - 32px)); background: var(--card); border: 2px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; font-size: .9rem; }
.presence__panel[hidden] { display: none; }
.presence__panel ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.presence__panel a { font-weight: 700; }
.presence__panel .hint { margin: 8px 0 0; }

/* Footer */
.site-footer { padding-block: 24px; border-top: 2px dashed var(--line); font-size: .9rem; }
.site-footer p { margin: 0 0 4px; }

@media (min-width: 640px) {
  .account-weekly { grid-template-columns: 1fr auto; align-items: center; }
  .daily { grid-template-columns: 1fr 1fr; gap: 20px; }
  .age-grid { grid-template-columns: repeat(4, 1fr); }
  .task-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .btn--block { width: auto; }
}

@media (min-width: 900px) {
  .builder { grid-template-columns: 360px 1fr; align-items: start; }
  .builder__preview { position: sticky; top: 16px; }
  .library { grid-template-columns: repeat(2, 1fr); }
  .task-grid { grid-template-columns: repeat(4, 1fr); }
  .task-detail { display: grid; grid-template-columns: 3fr 2fr; gap: 0 24px; align-items: start; }
  .task-detail h1 { grid-column: 1 / -1; }
  .task-detail__art { grid-row: span 2; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; display: block; min-height: 0; }
  .site-header, .site-footer, .no-print, .back-link, .task-actions, .note--tip { display: none !important; }
  main.wrap { max-width: none; padding: 0; }
  .builder { display: block; }
  .sheets { display: block; }
  .sheet { width: 210mm; height: 296mm; aspect-ratio: auto; border: 0; border-radius: 0; box-shadow: none; break-after: page; }
  .sheet:last-child { break-after: auto; }
  .task-detail { display: block; padding: 15mm; font-size: 14pt; }
  .task-detail__art { border: 0; padding: 0; margin: 8mm 0; }
  .note { border: 0; padding: 0; }
  .note h2 { display: none; }
}
