/* ==========================================================================
   Kids Education — design system
   One stylesheet for every app. Component classes are documented in
   docs/CONVENTIONS.md. Apps may add their own CSS in
   static/<app>/<app>.css for app-specific layouts, using these tokens.
   ========================================================================== */

:root {
  /* Brand */
  --c-primary: #5b4bdb;
  --c-primary-600: #4a3bc6;
  --c-primary-50: #f0eeff;
  --c-primary-100: #e2deff;
  --c-sun: #ffc93c;
  --c-sun-50: #fff7e0;
  --c-coral: #ff6b6b;
  --c-coral-50: #ffeded;
  --c-mint: #2ec4b6;
  --c-mint-50: #e3f8f6;
  --c-sky: #4ea8de;
  --c-sky-50: #e6f3fb;
  --c-leaf: #6ab04c;
  --c-leaf-50: #edf7e8;

  /* Neutrals (warm) */
  --c-bg: #fffbf5;
  --c-surface: #ffffff;
  --c-surface-2: #fdf6ec;
  --c-border: #eadfce;
  --c-border-strong: #d8c8b0;
  --c-text: #2d2a32;
  --c-text-muted: #6b6573;
  --c-text-soft: #958e9c;

  /* Feedback */
  --c-success: #2f9e44;
  --c-success-50: #e9f7ec;
  --c-warning: #b7791f;
  --c-warning-50: #fff6e0;
  --c-danger: #d6336c;
  --c-danger-50: #ffe9f0;
  --c-info: #1c7ed6;
  --c-info-50: #e7f3fd;

  /* Premium */
  --c-premium: #b8860b;
  --c-premium-bg: linear-gradient(135deg, #ffe08a, #ffc93c);

  /* Type */
  --font-display: "Fredoka", "Baloo 2", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sheet: "Andika", "Nunito", sans-serif; /* worksheets: single-story a, clear letterforms */
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;
  --fs-4xl: clamp(2.25rem, 5vw, 3.25rem);

  /* Spacing scale */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(45, 42, 50, 0.06), 0 1px 3px rgba(45, 42, 50, 0.06);
  --shadow: 0 4px 14px rgba(45, 42, 50, 0.08);
  --shadow-lg: 0 12px 32px rgba(45, 42, 50, 0.12);
  --container: 1180px;
  --container-narrow: 760px;
  --header-h: 68px;
  --focus: 0 0 0 3px rgba(91, 75, 219, 0.35);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--c-primary); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--c-primary-600); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 var(--s-3); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--s-4); }
ul, ol { margin: 0 0 var(--s-4); padding-left: 1.25rem; }
hr { border: 0; border-top: 1px solid var(--c-border); margin: var(--s-6) 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
[x-cloak] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--c-primary); color: #fff; padding: var(--s-2) var(--s-4); z-index: 100; }
.skip-link:focus { left: var(--s-4); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--s-4); }
.container-narrow { width: 100%; max-width: var(--container-narrow); margin: 0 auto; padding: 0 var(--s-4); }
.section { padding: var(--s-7) 0; }
.section-sm { padding: var(--s-5) 0; }
.section-alt { background: var(--c-surface-2); }
.stack > * + * { margin-top: var(--s-4); }
.stack-sm > * + * { margin-top: var(--s-2); }
.stack-lg > * + * { margin-top: var(--s-6); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.cluster-lg { display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: center; }
.row { display: flex; gap: var(--s-4); align-items: center; }
.row-between { display: flex; gap: var(--s-4); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-auto-sm { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
/* Main content + sidebar */
.layout-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-6); align-items: start; }
.layout-sidebar-left { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--s-6); align-items: start; }
.sticky { position: sticky; top: calc(var(--header-h) + var(--s-4)); }
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-sidebar, .layout-sidebar-left { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  h1 { font-size: var(--fs-2xl); }
  .section { padding: var(--s-6) 0; }
}

/* ---------- Text utilities ---------- */
.text-muted { color: var(--c-text-muted); }
.text-soft { color: var(--c-text-soft); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.text-xl { font-size: var(--fs-xl); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-display { font-family: var(--font-display); }
.fw-bold { font-weight: 700; }
.lead { font-size: var(--fs-lg); color: var(--c-text-muted); }
.eyebrow { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--fs-xs); font-weight: 600; color: var(--c-primary); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.prose { max-width: 70ch; }
.prose h2 { margin-top: var(--s-6); }
.prose h3 { margin-top: var(--s-5); }
.prose li + li { margin-top: var(--s-1); }

/* Spacing utilities (sparingly) */
.mt-0 { margin-top: 0 !important; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0 !important; } .mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); } .mb-6 { margin-bottom: var(--s-6); }
.p-4 { padding: var(--s-4); } .p-5 { padding: var(--s-5); }
.w-full { width: 100%; }
.hidden { display: none !important; }
@media (max-width: 640px) { .hide-sm { display: none !important; } }
@media (min-width: 641px) { .show-sm { display: none !important; } }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--c-surface);
  --btn-fg: var(--c-text);
  --btn-border: var(--c-border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 0.6rem 1.15rem;
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md); line-height: 1.2;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 2px solid var(--btn-border); border-radius: var(--radius-pill);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { color: var(--btn-fg); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled], .btn.is-disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { --btn-bg: var(--c-primary); --btn-fg: #fff; --btn-border: var(--c-primary); }
.btn-primary:hover { --btn-bg: var(--c-primary-600); }
.btn-secondary { --btn-bg: var(--c-primary-50); --btn-fg: var(--c-primary-600); --btn-border: var(--c-primary-100); }
.btn-sun { --btn-bg: var(--c-sun); --btn-fg: #3d2e00; --btn-border: var(--c-sun); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--c-text); }
.btn-ghost:hover { --btn-bg: var(--c-surface-2); box-shadow: none; }
.btn-danger { --btn-bg: var(--c-danger-50); --btn-fg: var(--c-danger); --btn-border: #f6c2d4; }
.btn-premium { background: var(--c-premium-bg); color: #3d2e00; border-color: #f2b600; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: var(--fs-sm); }
.btn-lg { padding: 0.85rem 1.6rem; font-size: var(--fs-lg); }
.btn-block { display: flex; width: 100%; }
.btn-icon { padding: 0.45rem; border-radius: 50%; width: 2.25rem; height: 2.25rem; }
.link-button { background: none; border: 0; padding: 0; color: var(--c-primary); font: inherit; cursor: pointer; text-decoration: underline; }

/* ---------- Cards ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-body { padding: var(--s-5); }
.card-header { padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border); }
.card-footer { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--c-border); background: var(--c-surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-link { display: block; color: inherit; text-decoration: none; transition: transform 0.12s ease, box-shadow 0.15s ease; }
.card-link:hover { color: inherit; transform: translateY(-3px); box-shadow: var(--shadow); }
.card-media { aspect-ratio: 4 / 3; background: var(--c-surface-2); border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; display: grid; place-items: center; font-size: 3.5rem; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; margin: 0 0 var(--s-1); line-height: 1.3; }
.card-highlight { border: 2px solid var(--c-primary); box-shadow: var(--shadow); }
.panel { background: var(--c-surface-2); border-radius: var(--radius); padding: var(--s-5); }

/* ---------- Chips, badges, tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.65rem; border-radius: var(--radius-pill);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.5;
  background: var(--c-surface-2); color: var(--c-text); border: 1px solid var(--c-border);
  text-decoration: none; white-space: nowrap;
}
a.chip:hover { border-color: var(--c-primary); color: var(--c-primary); }
.chip.is-active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.chip-primary { background: var(--c-primary-50); color: var(--c-primary-600); border-color: var(--c-primary-100); }
.chip-sun { background: var(--c-sun-50); color: #7a5600; border-color: #ffe39a; }
.chip-mint { background: var(--c-mint-50); color: #137a71; border-color: #b5ebe5; }
.chip-coral { background: var(--c-coral-50); color: #b23a3a; border-color: #ffc9c9; }
.chip-sky { background: var(--c-sky-50); color: #1d6596; border-color: #bfe0f4; }
.badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.1rem 0.5rem; border-radius: var(--radius-sm); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; background: var(--c-surface-2); color: var(--c-text-muted); }
.badge-premium { background: var(--c-premium-bg); color: #4a3700; }
.badge-free { background: var(--c-leaf-50); color: #3b7a22; }
.badge-success { background: var(--c-success-50); color: var(--c-success); }
.badge-warning { background: var(--c-warning-50); color: var(--c-warning); }
.badge-danger { background: var(--c-danger-50); color: var(--c-danger); }
.badge-info { background: var(--c-info-50); color: var(--c-info); }

/* ---------- Forms ---------- */
.form { display: grid; gap: var(--s-4); }
.form-row { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.field { display: grid; gap: var(--s-1); }
.field > label, .label { font-weight: 700; font-size: var(--fs-sm); }
.field .help, .help { font-size: var(--fs-sm); color: var(--c-text-muted); }
.field .error, .errorlist { color: var(--c-danger); font-size: var(--fs-sm); list-style: none; padding: 0; margin: 0; }
.input, .select, .textarea,
.form input[type="text"], .form input[type="email"], .form input[type="password"], .form input[type="number"],
.form input[type="url"], .form input[type="search"], .form input[type="date"], .form select, .form textarea {
  width: 100%; padding: 0.6rem 0.8rem;
  font: inherit; color: var(--c-text);
  background: var(--c-surface); border: 2px solid var(--c-border); border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus,
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--focus); }
.textarea, .form textarea { min-height: 6rem; resize: vertical; }
.input-lg { padding: 0.85rem 1.1rem; font-size: var(--fs-lg); border-radius: var(--radius); }
.checkbox { display: flex; gap: var(--s-2); align-items: flex-start; font-weight: 400; }
.checkbox input { width: 1.15rem; height: 1.15rem; margin-top: 0.2rem; accent-color: var(--c-primary); }
.field.has-error .input, .field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--c-danger); }
/* Choice cards: radio/checkbox styled as selectable tiles */
.choice-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-body { display: block; height: 100%; padding: var(--s-4); border: 2px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); transition: border-color 0.15s, box-shadow 0.15s; }
.choice:hover .choice-body { border-color: var(--c-border-strong); }
.choice input:checked + .choice-body { border-color: var(--c-primary); box-shadow: var(--focus); background: var(--c-primary-50); }
.choice input:focus-visible + .choice-body { box-shadow: var(--focus); }
.search-bar { display: flex; gap: var(--s-2); }
.search-bar .input { flex: 1; }

/* ---------- Alerts & messages ---------- */
.alert { padding: var(--s-3) var(--s-4); border-radius: var(--radius-sm); border: 1px solid transparent; display: flex; gap: var(--s-3); align-items: flex-start; }
.alert-success { background: var(--c-success-50); border-color: #b9e4c3; color: #1f6b30; }
.alert-error, .alert-danger { background: var(--c-danger-50); border-color: #f6c2d4; color: #a3204f; }
.alert-warning { background: var(--c-warning-50); border-color: #f5dc9f; color: #7c5210; }
.alert-info { background: var(--c-info-50); border-color: #bcdcf7; color: #155ea3; }
.messages { position: fixed; top: calc(var(--header-h) + var(--s-3)); right: var(--s-4); z-index: 60; display: grid; gap: var(--s-2); max-width: min(420px, calc(100vw - 2rem)); }
.messages .alert { box-shadow: var(--shadow); }

/* ---------- Header / nav ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(255, 251, 245, 0.92); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--c-border); }
.site-header .container { height: var(--header-h); display: flex; align-items: center; gap: var(--s-5); }
.brand { display: flex; align-items: center; gap: var(--s-2); font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xl); color: var(--c-text); text-decoration: none; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--c-sun); transform: rotate(-6deg); box-shadow: 0 2px 0 rgba(45, 42, 50, 0.12); transition: transform 0.2s ease; }
.brand-mark img { width: 88%; height: 88%; object-fit: contain; transform: rotate(6deg); }
.brand:hover .brand-mark { transform: rotate(0deg) scale(1.05); }
.brand-name { letter-spacing: -0.01em; }
.brand-first { color: var(--c-primary); }
.brand:hover { color: var(--c-text); }
.nav { display: flex; align-items: center; gap: var(--s-1); }
.nav a { padding: 0.45rem 0.8rem; border-radius: var(--radius-pill); color: var(--c-text); text-decoration: none; font-weight: 700; font-size: var(--fs-sm); }
.nav a:hover, .nav a.is-active { background: var(--c-primary-50); color: var(--c-primary-600); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.menu { position: relative; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--s-2); z-index: 70; }
.menu-panel a, .menu-panel button { display: flex; width: 100%; gap: var(--s-2); align-items: center; padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); color: var(--c-text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--c-surface-2); }
.menu-panel .menu-sep { height: 1px; background: var(--c-border); margin: var(--s-2) 0; }
.menu-panel .menu-label { padding: 0.25rem 0.75rem; font-size: var(--fs-xs); color: var(--c-text-soft); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.mobile-nav-toggle { display: none; }
@media (max-width: 900px) {
  .site-header .nav { display: none; }
  .mobile-nav-toggle { display: inline-flex; }
  .mobile-nav { display: grid; gap: var(--s-1); padding: var(--s-3) var(--s-4) var(--s-4); border-bottom: 1px solid var(--c-border); background: var(--c-bg); }
  .mobile-nav a { padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); color: var(--c-text); text-decoration: none; font-weight: 700; }
}
@media (min-width: 901px) { .mobile-nav { display: none !important; } }
.brand { white-space: nowrap; min-width: 0; }
.header-actions { min-width: 0; }
.mobile-nav .mobile-nav-account { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); margin-top: var(--s-2); }
.mobile-nav .mobile-nav-account .btn { justify-content: center; }
.mobile-nav .mobile-nav-account .btn-primary { color: #fff; }
@media (max-width: 640px) {
  /* Phones: logo, language flag, account and menu fit in one row (log in / sign up move into the menu). */
  .site-header .container { gap: var(--s-2); }
  .header-actions { gap: var(--s-1); }
  .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
}
@media (max-width: 380px) { .brand { font-size: var(--fs-lg); } }

/* Credit meter (header & dashboards) */
.credit-pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.7rem; border-radius: var(--radius-pill); background: var(--c-sun-50); border: 1px solid #ffe39a; font-weight: 700; font-size: var(--fs-sm); color: #7a5600; text-decoration: none; }
.meter { height: 10px; background: var(--c-surface-2); border-radius: var(--radius-pill); overflow: hidden; border: 1px solid var(--c-border); }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--c-mint), var(--c-primary)); border-radius: var(--radius-pill); }

/* ---------- Footer ---------- */
.site-footer { margin-top: var(--s-8); background: #2d2a32; color: #d9d4de; padding: var(--s-7) 0 var(--s-5); }
.site-footer a { color: #fff; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; color: #fff; }
.footer-grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: var(--s-6); }
.footer-grid h4 { color: #fff; font-size: var(--fs-md); }
.footer-grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-2); font-size: var(--fs-sm); }
.footer-bottom { margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid rgba(255, 255, 255, 0.12); font-size: var(--fs-sm); color: #a59fac; display: flex; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
/* Long words in a narrow column ("Pedagogiska resurser" on a small phone) wrap instead of widening the page */
.footer-grid > * { min-width: 0; overflow-wrap: anywhere; }

/* ---------- Page header, breadcrumbs, hero ---------- */
.page-header { padding: var(--s-6) 0 var(--s-5); }
.page-header h1 { margin-bottom: var(--s-2); }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: var(--s-2); font-size: var(--fs-sm); color: var(--c-text-muted); list-style: none; padding: 0; margin: 0 0 var(--s-3); }
.breadcrumbs li + li::before { content: "›"; margin-right: var(--s-2); color: var(--c-text-soft); }
.breadcrumbs a { color: var(--c-text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--c-primary); text-decoration: underline; }
.hero { padding: var(--s-8) 0 var(--s-7); background:
  radial-gradient(circle at 10% 20%, var(--c-sun-50) 0, transparent 35%),
  radial-gradient(circle at 90% 10%, var(--c-mint-50) 0, transparent 35%),
  radial-gradient(circle at 70% 90%, var(--c-primary-50) 0, transparent 40%); }
.hero h1 { font-size: var(--fs-4xl); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--s-1); border-bottom: 2px solid var(--c-border); margin-bottom: var(--s-5); overflow-x: auto; }
.tab { padding: 0.6rem 1rem; font-weight: 700; color: var(--c-text-muted); text-decoration: none; border: 0; background: none; border-bottom: 3px solid transparent; margin-bottom: -2px; cursor: pointer; font: inherit; font-weight: 700; white-space: nowrap; }
.tab:hover { color: var(--c-text); }
.tab.is-active { color: var(--c-primary); border-bottom-color: var(--c-primary); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--s-3); border-bottom: 1px solid var(--c-border); text-align: left; vertical-align: top; }
.table th { font-weight: 700; color: var(--c-text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.table-wrap { overflow-x: auto; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: var(--s-2); justify-content: center; align-items: center; margin: var(--s-6) 0; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 2.4rem; height: 2.4rem; padding: 0 0.6rem; display: inline-grid; place-items: center; border-radius: var(--radius-pill); border: 2px solid var(--c-border); text-decoration: none; font-weight: 700; color: var(--c-text); background: var(--c-surface); }
.pagination a:hover { border-color: var(--c-primary); color: var(--c-primary); }
.pagination .is-current { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* ---------- Modal (use <dialog class="modal">) ---------- */
dialog.modal { border: 0; padding: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: min(760px, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); background: var(--c-surface); color: var(--c-text); }
dialog.modal::backdrop { background: rgba(45, 42, 50, 0.45); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border); position: sticky; top: 0; background: var(--c-surface); z-index: 1; }
.modal-header h2, .modal-header h3 { margin: 0; font-size: var(--fs-xl); }
.modal-body { padding: var(--s-5); overflow-y: auto; }
.modal-footer { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--c-border); display: flex; gap: var(--s-2); justify-content: flex-end; }

/* ---------- Empty states, loading ---------- */
.empty { text-align: center; padding: var(--s-7) var(--s-4); border: 2px dashed var(--c-border); border-radius: var(--radius-lg); background: var(--c-surface); }
.empty-icon { font-size: 3rem; margin-bottom: var(--s-3); }
.spinner { width: 1.25rem; height: 1.25rem; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin 0.7s linear infinite; vertical-align: -0.2em; }
.spinner-lg { width: 2.5rem; height: 2.5rem; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
/* htmx: elements with .htmx-indicator are hidden until a request is in flight */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.htmx-request .hide-on-request, .htmx-request.hide-on-request { display: none; }
.loading-card { display: grid; place-items: center; gap: var(--s-3); padding: var(--s-7); text-align: center; color: var(--c-text-muted); }
.skeleton { background: linear-gradient(90deg, var(--c-surface-2) 25%, #fff 50%, var(--c-surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Ads ---------- */
.ad-slot { margin: var(--s-5) auto; text-align: center; min-height: 90px; }
.ad-slot-label { display: block; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-text-soft); margin-bottom: 2px; }
.ad-placeholder { display: grid; place-items: center; min-height: 90px; border: 2px dashed var(--c-border-strong); border-radius: var(--radius-sm); color: var(--c-text-soft); font-size: var(--fs-sm); background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(0, 0, 0, 0.02) 8px, rgba(0, 0, 0, 0.02) 16px); }
.ad-slot-sidebar .ad-placeholder { min-height: 250px; }

/* ---------- Premium upsell ---------- */
.upsell { border-radius: var(--radius-lg); padding: var(--s-5); background: linear-gradient(135deg, var(--c-primary-50), var(--c-sun-50)); border: 1px solid var(--c-primary-100); }
.upsell h3 { margin-bottom: var(--s-2); }
.lock-overlay { position: relative; }
.lock-overlay::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255, 251, 245, 0) 0%, var(--c-bg) 85%); pointer-events: none; }

/* ---------- Cookie consent ---------- */
.consent { position: fixed; left: var(--s-4); right: var(--s-4); bottom: var(--s-4); z-index: 80; max-width: 720px; margin: 0 auto; background: var(--c-surface); border: 1px solid var(--c-border); box-shadow: var(--shadow-lg); border-radius: var(--radius); padding: var(--s-4) var(--s-5); display: flex; gap: var(--s-4); align-items: center; flex-wrap: wrap; }
.consent p { margin: 0; flex: 1 1 240px; min-width: 0; font-size: var(--fs-sm); }
@media (max-width: 640px) {
  .consent { padding: var(--s-3) var(--s-4); }
  /* Long button labels ("Experimente o Estúdio de Atividades") wrap on phones instead of widening the page */
  .btn { max-width: 100%; white-space: normal; text-align: center; }
}

/* ---------- Misc ---------- */
.emoji-xl { font-size: 3rem; line-height: 1; }
.icon-circle { width: 3rem; height: 3rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; background: var(--c-primary-50); flex: none; }
.divider-text { display: flex; align-items: center; gap: var(--s-3); color: var(--c-text-soft); font-size: var(--fs-sm); }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--c-border); }
.kbd { font-family: ui-monospace, monospace; font-size: var(--fs-xs); padding: 0.1rem 0.35rem; border: 1px solid var(--c-border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--c-surface); }
.list-check { list-style: none; padding: 0; }
.list-check li { position: relative; padding-left: 1.8rem; margin-bottom: var(--s-2); }
.list-check li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--c-mint-50); color: #137a71; font-weight: 800; display: grid; place-items: center; font-size: 0.8rem; }

@media print {
  .site-header, .site-footer, .no-print, .ad-slot, .consent, .messages { display: none !important; }
  body { background: #fff; }
}

/* Language flags (static/img/flags/*.svg: emoji flags don't show on Windows). */
.flag { display: inline-block; width: 1.25em; height: auto; border-radius: 2px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12); vertical-align: -0.15em; }
.lang-menu .menu-panel a { display: flex; align-items: center; gap: 0.5rem; }

/* ---------- Card thumbnails (apps.activities.thumbs) ----------
   Page 1 in miniature, whole (nothing cut off, so the activity is recognisable while browsing): a sheet of paper
   centred in a portrait picture area. The sheet's font size follows its width (worksheet.css), so it is the real
   page, only smaller. */
.card-media.activity-thumb, .studio-card-media.activity-thumb { aspect-ratio: 6 / 7; position: relative; display: grid; place-items: center; }
.activity-thumb-page { width: 84%; transform: rotate(-1.2deg); pointer-events: none; transition: transform 0.2s ease; }
.activity-thumb-page .worksheet.ws-mode-screen .ws-page { border-radius: 3px; border-color: #e3dccf; box-shadow: 0 2px 4px rgba(45, 42, 50, 0.08), 0 10px 24px rgba(45, 42, 50, 0.12); }
.activity-thumb-page .worksheet .ws-footer { display: none; }
.card-link:hover .activity-thumb-page, .studio-card:hover .activity-thumb-page { transform: rotate(0deg) translateY(-3px); }
/* The page as one image (public activities, apps.activities.snapshots): the same sheet of paper look */
.activity-thumb-image {
  position: absolute; top: 50%; left: 50%; height: 88%; width: auto; max-width: 84%; /* the whole page, by height */
  transform: translate(-50%, -50%) rotate(-1.2deg); border: 1px solid #e3dccf; border-radius: 3px; background: #fff;
  box-shadow: 0 2px 4px rgba(45, 42, 50, 0.08), 0 10px 24px rgba(45, 42, 50, 0.12); transition: transform 0.2s ease;
}
.card-link:hover .activity-thumb-image { transform: translate(-50%, calc(-50% - 3px)) rotate(0deg); }
.card-media .activity-thumb-picture, .studio-card-media .activity-thumb-picture { width: 58%; height: 58%; object-fit: contain; mix-blend-mode: multiply; } /* the picture's white melts into the tile */

/* Design illustrations ({% design_art %}): in place of an emoji, at the same font size. */
.design-art { display: inline-block; width: 1.25em; height: 1.25em; object-fit: contain; vertical-align: middle; }
/* Sizes where an illustration replaces a decorative emoji: bigger than the emoji, it carries detail. */
.icon-circle .design-art { width: 82%; height: 82%; }
.empty-icon .design-art { width: 6.5rem; height: 6.5rem; }
.site-footer .brand-first { color: var(--c-sun); }
