/* AprendeAI v2 — design per Claude Design handoff (warm, rounded, Duolingo energy) */

:root {
  --bg: #fdf8f0;
  --card: #ffffff;
  --ink: #2d2436;
  --ink-soft: #6b5f78;
  --ink-faint: #a89b8a;
  --coral: #ff7a59;
  --coral-deep: #d95a3b;
  --coral-tint: #ffe3da;
  --purple: #8b5cf6;
  --purple-tint: #ede4fd;
  --teal: #14b8a6;
  --teal-deep: #0f9488;
  --teal-tint: #d9f2ee;
  --gold: #ffb03b;
  --line: #f0e6d8;
  --line-strong: #e8dfd0;
  --sand: #f3ecdf;
  --green: #1b7a4a;
  --green-tint: #e8f6ee;
  --green-deep: #155e3a;
  --yellow-tint: #fff3cd;
  --yellow-deep: #8a6d00;
  --red: #d9534f;
  --red-tint: #fdecea;
  --red-deep: #a12622;
  --rust: #c2410c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .pl-question { text-wrap: pretty; }
.chip svg, .lab-score svg, .done-stat svg { display: inline-block !important; vertical-align: -2px; }

h1, h2, h3 { font-weight: 900; line-height: 1.15; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.9rem, 5vw, 2.75rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.5rem); }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration: none; }

:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 200; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 0 0 12px 0; font-weight: 800; }
.skip-link:focus { left: 0; }

/* ---------- header ---------- */

#site-header { position: sticky; top: 0; z-index: 50; background: #fff; border-bottom: 2px solid var(--line); }
.header-inner { max-width: 1080px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.2rem; }
.logo-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, var(--coral), var(--gold)); box-shadow: 0 2px 6px rgba(255, 122, 89, 0.35); }
.main-nav { display: flex; gap: 8px; }
.main-nav a { padding: 7px 10px; border-radius: 10px; font-weight: 800; font-size: 0.9rem; color: var(--ink-soft); }
.main-nav a:hover { color: var(--ink); }
.main-nav .nav-apps:hover { color: var(--coral); }
.main-nav .nav-games:hover { color: var(--purple); }
.main-nav .nav-ai:hover { color: var(--teal-deep); }
.header-chips { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-left: auto; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px; font-size: 0.82rem; font-weight: 800; background: var(--sand); border: none; color: var(--ink); }
a.chip { cursor: pointer; transition: transform 0.08s; }
a.chip:hover { transform: translateY(-1px); filter: brightness(0.97); }
.chip-streak { background: var(--yellow-tint); color: var(--yellow-deep); }
.chip-xp { background: var(--green-tint); color: var(--green); }
.chip-gems { background: var(--purple-tint); color: #6d28d9; }
.chip-settings { cursor: pointer; }
.chip-checkpoint { background: var(--yellow-tint); color: var(--yellow-deep); font-size: 0.72rem; padding: 4px 10px; }

.lang-toggle { cursor: pointer; padding: 3px; background: var(--sand); font-family: inherit; }
.lang-toggle span { padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: 0.78rem; color: var(--ink-soft); }
.lang-toggle span.on { background: var(--ink); color: #fff; }

/* ---------- layout / cards / buttons ---------- */

#app { max-width: 1080px; margin: 0 auto; padding: 24px 24px 90px; }
.page { padding-top: 8px; }
.sub { color: var(--ink-soft); font-size: 1.02rem; font-weight: 600; max-width: 62ch; }

.card { background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 22px; }

.pill { display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--coral-tint); color: var(--rust); font-weight: 800; font-size: 0.82rem; margin-bottom: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 26px; border-radius: 14px; font-weight: 900; font-size: 0.98rem; border: none; cursor: pointer; font-family: inherit; transition: transform 0.07s; }
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 4px 0 var(--coral-deep); }
.btn-primary:hover:not(:disabled) { background: #e96a4b; }
.btn-primary:disabled { background: var(--sand); color: var(--ink-faint); box-shadow: none; cursor: default; }
.btn-ghost { background: #fff; border: 2px solid var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--coral); }

.bar { height: 8px; background: var(--sand); border-radius: 999px; overflow: hidden; }
.bar.big { height: 14px; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--coral), var(--gold)); transition: width 0.3s ease; min-width: 4px; }
.bar-fill.solid { background: var(--coral); }

/* ---------- hero / home ---------- */

.hero { display: grid; gap: 36px; padding: 28px 0 16px; grid-template-columns: 1fr; align-items: center; }
.hero-ctas { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.progress-card { display: flex; flex-direction: column; gap: 12px; }
.progress-head { display: flex; justify-content: space-between; font-weight: 800; font-size: 0.9rem; }
.progress-count { color: var(--coral); font-weight: 900; }

.streak-row { display: flex; align-items: center; gap: 12px; background: var(--yellow-tint); border-radius: 14px; padding: 10px 14px; }
.streak-flame { opacity: 0.55; }
.streak-flame.lit { opacity: 1; animation: flicker 1.6s ease infinite; }
@keyframes flicker { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.streak-info { display: flex; flex-direction: column; line-height: 1.3; }
.streak-info small { color: var(--yellow-deep); font-weight: 700; }

.mini-badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-badge { background: var(--bg); border-radius: 12px; padding: 12px 6px; text-align: center; font-weight: 800; font-size: 0.75rem; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.mini-badge .mb-icon { display: grid; place-items: center; height: 26px; }
.mini-badge.off { opacity: 0.4; }

.tracks-section, .badges-section { margin-top: 36px; }
.track-grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
.track-card { display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: 18px; transition: transform 0.12s; }
.track-card:hover { transform: translateY(-2px); }
.track-apps { border-top: 6px solid var(--coral); }
.track-apps:hover { border-color: var(--coral); }
.track-games { border-top: 6px solid var(--purple); }
.track-games:hover { border-color: var(--purple); }
.track-ai { border-top: 6px solid var(--teal); }
.track-ai:hover { border-color: var(--teal); }
.track-icon-wrap { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; }
.track-head-icon-wrap { width: 56px; height: 56px; border-radius: 16px; background: #fff; display: grid; place-items: center; flex: none; }
.track-card h3 { margin: 0; font-size: 1.15rem; }
.track-card p { color: var(--ink-soft); font-size: 0.88rem; font-weight: 600; flex: 1; margin: 0; }
.track-meta { display: flex; justify-content: space-between; font-weight: 800; font-size: 0.78rem; color: var(--ink-soft); }
.track-apps .track-meta { color: var(--coral); }
.track-games .track-meta { color: var(--purple); }
.track-ai .track-meta { color: var(--teal-deep); }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.badge-card { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 16px; display: flex; gap: 12px; align-items: center; opacity: 0.5; }
.badge-card.earned { border-color: var(--gold); opacity: 1; }
.badge-icon-wrap { width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center; }
.badge-txt { display: flex; flex-direction: column; gap: 2px; }
.badge-txt strong { font-size: 0.9rem; }
.badge-txt small { font-weight: 600; font-size: 0.78rem; color: var(--ink-soft); line-height: 1.4; }

/* ---------- track page ---------- */

.track-page { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.crumbs { font-weight: 800; font-size: 0.9rem; color: var(--ink-soft); align-self: flex-start; display: inline-block; margin-bottom: 8px; }
.crumbs:hover { color: var(--ink); }
.track-head { border-radius: 20px; padding: 26px 28px; display: flex; gap: 20px; align-items: flex-start; }
.track-head-icon { font-size: 2.5rem; }
.track-head-main { flex: 1; }
.track-head-main h1 { font-size: 1.9rem; margin-bottom: 4px; }
.track-head-main p { font-weight: 600; font-size: 0.92rem; color: var(--ink-soft); margin-bottom: 10px; }
.track-head-bar { display: flex; align-items: center; gap: 12px; font-weight: 900; font-size: 0.82rem; }
.track-head-bar .bar { flex: 1; background: #fff; height: 10px; }

.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson-row { display: flex; align-items: center; gap: 16px; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 14px 18px; transition: transform 0.1s; }
.lesson-row:not(.static):hover { border-color: #d9cbb5; transform: translateX(2px); }
.lesson-circle { width: 36px; height: 36px; min-width: 36px; border-radius: 999px; display: grid; place-items: center; font-weight: 900; font-size: 0.85rem; }
.lesson-circle.done { background: var(--green); color: #fff; }
.lesson-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lesson-row-title { font-weight: 900; font-size: 0.97rem; }
.lesson-row-sub { font-weight: 700; font-size: 0.75rem; color: var(--ink-faint); }
.lesson-row-arrow { color: #d9cbb5; font-weight: 900; font-size: 1.15rem; }

/* ---------- lesson player ---------- */

.player-page { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.pl-header { display: flex; align-items: center; gap: 14px; }
.pl-close { width: 40px; height: 40px; display: grid; place-items: center; color: var(--ink-faint); margin-left: -8px; }
.pl-close:hover { color: var(--ink); }
.pl-bar { flex: 1; }
.pl-count { font-weight: 800; font-size: 0.82rem; color: var(--ink-faint); white-space: nowrap; }

.pl-intro, .pl-done { display: flex; flex-direction: column; gap: 18px; align-items: center; text-align: center; padding: 24px 0 8px; }
.pl-avatar { border-radius: 999px; background: linear-gradient(135deg, var(--coral), var(--gold)); display: grid; place-items: center; flex: none; }
.pl-avatar-lg { width: 88px; height: 88px; box-shadow: 0 6px 18px rgba(255, 122, 89, 0.35); }
.pl-avatar-sm { width: 30px; height: 30px; }
.pl-avatar-xs { width: 28px; height: 28px; display: inline-grid; vertical-align: middle; }
.pl-trophy { width: 88px; height: 88px; border-radius: 999px; background: var(--green-tint); display: grid; place-items: center; }
.pl-speech { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 12px 20px; font-weight: 800; font-size: 0.95rem; color: var(--ink-soft); }
.pl-intro h1 { font-size: clamp(1.7rem, 4.5vw, 2.15rem); margin: 0; }
.pl-goal { background: var(--coral-tint); border-radius: 14px; padding: 16px 20px; display: flex; gap: 12px; align-items: flex-start; text-align: left; max-width: 560px; }
.pl-goal span { font-size: 1.25rem; }
.pl-goal div { font-weight: 700; font-size: 0.95rem; line-height: 1.55; color: #7c3416; }
.pl-meta { font-weight: 700; font-size: 0.82rem; color: var(--ink-faint); margin: 0; }

.pl-tag { font-weight: 900; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.tag-coral { color: var(--coral); }
.tag-purple { color: var(--purple); }
.tag-teal { color: var(--teal-deep); }
.tag-rust { color: var(--rust); }

.pl-learn, .pl-check, .pl-chat, .pl-lab { display: flex; flex-direction: column; gap: 14px; padding-top: 8px; }
.pl-learn h2 { font-size: 1.6rem; margin: 0; }
.pl-learn p { font-size: 1.06rem; line-height: 1.75; color: #4a4055; font-weight: 600; margin: 0; }
.chip-listen { align-self: flex-start; cursor: pointer; background: var(--purple-tint); font-family: inherit; }

.pl-question { font-weight: 900; font-size: 1.25rem; line-height: 1.35; }
.pl-opts { display: flex; flex-direction: column; gap: 10px; }
.pl-opt { text-align: left; background: #fff; border: 2px solid var(--line-strong); border-radius: 14px; padding: 13px 18px; font-weight: 800; font-size: 0.95rem; line-height: 1.4; cursor: pointer; font-family: inherit; color: var(--ink); }
.pl-opt:hover:not(:disabled) { border-color: var(--coral); }
.pl-opt.right { background: var(--green-tint); border-color: var(--green); color: var(--green-deep); }
.pl-opt.wrong { background: var(--red-tint); border-color: var(--red); color: var(--red-deep); }
.pl-opt.dim { opacity: 0.55; }
.pl-opt:disabled { cursor: default; }
.pl-feedback { font-weight: 800; font-size: 0.85rem; border-radius: 10px; padding: 10px 14px; }
.pl-feedback.ok { background: var(--green-tint); color: var(--green); }
.pl-feedback.bad { background: var(--red-tint); color: var(--red-deep); }

.pl-mission { background: var(--green-tint); border-radius: 14px; padding: 14px 18px; display: flex; gap: 12px; align-items: flex-start; }
.pl-mission span { font-size: 1.25rem; }
.pl-mission div { font-weight: 700; font-size: 0.92rem; line-height: 1.55; color: var(--green-deep); }

.mission-links { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 700; font-size: 0.82rem; color: var(--ink-soft); }
.mission-link { padding: 8px 14px; font-size: 0.82rem; width: auto; }

.chat-box { background: #fff; border: 2px solid var(--line); border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; }
.chat-msgs { display: flex; flex-direction: column; gap: 12px; padding: 18px; min-height: 180px; max-height: 340px; overflow-y: auto; }
.chat-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-row.user { justify-content: flex-end; }
.chat-fox { font-size: 1.4rem; flex: none; }
.chat-bubble { max-width: 80%; border-radius: 16px; padding: 10px 14px; font-weight: 700; font-size: 0.92rem; line-height: 1.55; }
.chat-row.bot .chat-bubble { background: var(--bg); border: 2px solid var(--line); }
.chat-row.user .chat-bubble { background: var(--coral); color: #fff; }
.chat-thinking { font-weight: 700; font-size: 0.82rem; color: var(--ink-faint); }
.chat-input-row { display: flex; gap: 10px; padding: 12px; border-top: 2px solid var(--line); background: var(--bg); }
.chat-input { flex: 1; min-width: 0; border: 2px solid var(--line-strong); border-radius: 12px; padding: 11px 14px; font-family: inherit; font-weight: 700; font-size: 16px; color: var(--ink); background: #fff; outline: none; }
.chat-input:focus { border-color: var(--coral); }
.btn-send { padding: 0 18px; min-width: 48px; min-height: 44px; flex: none; }

.pl-hint { font-weight: 700; font-size: 0.88rem; color: var(--ink-soft); margin: 0; }
.lab-input { min-height: 120px; border: 2px solid var(--line-strong); border-radius: 14px; padding: 14px 16px; font-family: inherit; font-weight: 700; font-size: 16px; line-height: 1.6; color: var(--ink); background: #fff; outline: none; resize: vertical; }
.lab-input:focus { border-color: var(--coral); }
.pl-lab .btn-primary { align-self: flex-start; }
.lab-result { border-radius: 14px; padding: 14px 18px; }
.lab-result.pass { background: var(--green-tint); color: var(--green-deep); }
.lab-result.norm { background: var(--yellow-tint); color: #7a5d00; }
.lab-score { font-weight: 900; font-size: 0.95rem; }
.lab-feedback { font-weight: 700; font-size: 0.9rem; line-height: 1.6; margin-top: 6px; }

.done-stats { display: flex; gap: 12px; }
.done-stat { border-radius: 14px; padding: 14px 22px; display: flex; flex-direction: column; gap: 2px; }
.done-stat strong { font-weight: 900; font-size: 1.25rem; }
.done-stat span { font-weight: 800; font-size: 0.75rem; }
.done-stat.xp { background: var(--green-tint); color: var(--green); }
.done-stat.streak { background: var(--yellow-tint); color: var(--yellow-deep); }

.chest-zone { text-align: center; }
.chest-btn { font-size: 3rem; background: none; border: none; cursor: pointer; padding: 4px; }
.chest-anim { display: inline-block; animation: wiggle 0.8s ease infinite; transition: transform 0.2s; }
.chest-anim.open { animation: none; transform: scale(1.25); }
@keyframes wiggle { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.chest-label { font-weight: 700; color: var(--ink-soft); font-size: 0.85rem; margin: 4px 0 0; }
.chest-result { font-size: 1.15rem; font-weight: 900; color: var(--purple); margin: 4px 0 0; }

.level-up { font-size: 1.05rem; font-weight: 900; color: var(--purple); animation: pop 0.4s ease; margin: 0; }

/* celebrations */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti-piece { position: absolute; top: -20px; display: block; animation: confetti-fall linear forwards; }
@keyframes confetti-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(var(--dx, 0), 105vh) rotate(var(--rot, 540deg)); opacity: 0; }
}
.float-xp {
  position: fixed; z-index: 210; pointer-events: none; transform: translateX(-50%);
  font-weight: 900; font-size: 1.05rem; color: var(--green);
  animation: float-up 1s ease-out forwards;
}
@keyframes float-up {
  0% { opacity: 0; margin-top: 0; }
  15% { opacity: 1; }
  100% { opacity: 0; margin-top: -60px; }
}
.gem-burst {
  position: absolute; left: 50%; top: 30%; pointer-events: none;
  animation: gem-fly 1.2s cubic-bezier(0.2, 0.8, 0.4, 1) forwards;
}
@keyframes gem-fly {
  0% { transform: translate(-50%, 0) scale(0.4); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--tx, 0px)), var(--ty, -80px)) scale(1); opacity: 0; }
}
.next-chest { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 0.85rem; color: #6d28d9; margin: 0; }
.chest-zone { position: relative; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.badge-pop { display: flex; align-items: center; gap: 10px; justify-content: center; background: var(--yellow-tint); border-radius: 12px; padding: 10px 16px; font-weight: 800; font-size: 0.9rem; }

.pl-footer { display: flex; align-items: center; gap: 14px; margin-top: 14px; border-top: 2px solid var(--line); padding-top: 18px; }
.pl-skip { background: none; border: none; font-family: inherit; font-weight: 800; font-size: 0.9rem; color: var(--ink-faint); cursor: pointer; }
.pl-skip:hover { color: var(--ink-soft); }
.pl-prev { background: #fff; border: 2px solid var(--line-strong); border-radius: 12px; width: 44px; height: 44px; font-size: 1.1rem; font-weight: 900; color: var(--ink-soft); cursor: pointer; font-family: inherit; }
.pl-prev:hover { border-color: var(--coral); color: var(--ink); }
.pl-spacer { flex: 1; }

/* ---------- rewards ---------- */

.gems-balance { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.gems-count { font-size: 1.4rem; font-weight: 900; color: #6d28d9; }
.reward-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.reward-card { text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.reward-icon { font-size: 2.4rem; }
.reward-card p { color: var(--ink-soft); font-size: 0.87rem; font-weight: 600; flex: 1; }
.reward-hint { font-size: 0.72rem; color: var(--ink-faint); font-weight: 700; }
.redeem-success { background: var(--green-tint); border-radius: 14px; padding: 14px 18px; margin-bottom: 16px; font-weight: 800; color: var(--green-deep); }
.voucher-code { font-family: ui-monospace, Menlo, monospace; font-size: 1.2rem; font-weight: 800; letter-spacing: 0.06em; color: var(--teal-deep); margin: 6px 0 0; }
.history-title { margin-top: 32px; }

/* ---------- graduation ---------- */

.grad-page { max-width: 720px; margin: 0 auto; position: relative; }
.grad-progress { text-align: center; display: flex; flex-direction: column; gap: 14px; }
.grad-remaining strong { font-size: 1.5rem; color: var(--coral); }
.grad-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.grad-confetti span { position: absolute; top: -30px; left: calc(5% * var(--i)); font-size: 1.3rem; animation: fall 3.2s linear infinite; animation-delay: calc(var(--i) * 0.23s); }
@keyframes fall { to { transform: translateY(110vh) rotate(340deg); opacity: 0.6; } }
.diploma { text-align: center; padding: 44px 32px; margin-top: 20px; border: 3px double var(--gold); }
.diploma-logo { width: 56px; height: 56px; border-radius: 16px; display: inline-grid; place-items: center; background: var(--coral); color: #fff; font-size: 1.7rem; font-weight: 900; margin-bottom: 12px; }
.diploma-title { font-size: 1.5rem; margin-bottom: 20px; }
.diploma-certifies { color: var(--ink-soft); margin-bottom: 4px; font-weight: 600; }
.diploma-name { font-size: 1.6rem; font-weight: 900; text-align: center; border: none; border-bottom: 2px solid var(--line); background: transparent; color: var(--ink); width: 90%; max-width: 400px; padding: 6px; font-family: inherit; outline: none; }
.diploma-name:focus { border-bottom-color: var(--coral); }
.diploma-body { margin: 16px auto 8px; max-width: 46ch; font-weight: 600; }
.diploma-date { color: var(--ink-soft); font-size: 0.92rem; font-weight: 600; }
.diploma-stats { display: flex; justify-content: center; gap: 18px; font-weight: 900; margin: 14px 0 20px; }
.diploma-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media print {
  #site-header, #site-footer, #tab-bar, .diploma-actions, .grad-confetti { display: none !important; }
  body { background: #fff; }
  .diploma { border: 3px double #b8860b; }
  .diploma-name { border-bottom: none; }
}

/* ---------- library ---------- */

.lib-track { margin-top: 28px; }
.lib-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.lib-card { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 6px; transition: transform 0.1s; }
.lib-card:hover { border-color: #d9cbb5; transform: translateY(-2px); }
.lib-card strong { font-size: 0.93rem; }
.lib-card small { font-weight: 600; font-size: 0.8rem; color: var(--ink-soft); line-height: 1.45; flex: 1; }
.lib-meta { font-weight: 800; font-size: 0.72rem; color: var(--ink-faint); }

.article-page { max-width: 720px; margin: 0 auto; }
.lesson-intro { font-size: 1.08rem; color: var(--ink-soft); font-weight: 600; }
.lesson-section h2 { margin-top: 1.5em; padding-bottom: 6px; position: relative; }
.lesson-section h2::after { content: ''; position: absolute; left: 0; bottom: 0; width: 44px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--coral), var(--gold)); }
.lesson-section p { font-weight: 600; color: #4a4055; }
.callout { border-radius: 16px; padding: 16px 18px; margin: 18px 0; display: flex; gap: 10px; }
.callout p { margin: 0; font-weight: 600; }
.callout-label { font-size: 1.1rem; }
.callout-tip { background: var(--yellow-tint); }
.callout-try { background: var(--green-tint); }
.code-block { margin: 18px 0; }
.code-block pre { background: #2d2436; color: #f5f0ff; padding: 16px; border-radius: 14px; overflow-x: auto; font-size: 0.83rem; line-height: 1.5; }
.code-block figcaption { font-size: 0.83rem; color: var(--ink-soft); margin-top: 6px; font-weight: 600; }

/* widgets (library) */
.widget-box { background: var(--purple-tint); border: 2px solid #dcd2f7; border-radius: 16px; padding: 18px; margin: 20px 0; }
.widget-title { font-weight: 900; margin: 0 0 4px; }
.widget-hint { color: var(--ink-soft); font-size: 0.87rem; font-weight: 600; margin-bottom: 10px; }
.widget-input { width: 100%; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line-strong); font-family: inherit; font-weight: 700; font-size: 0.92rem; margin-bottom: 8px; background: #fff; color: var(--ink); }
.widget-input:focus { border-color: var(--purple); outline: none; }
.tok-out, .temp-out { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0; min-height: 28px; }
.tok { padding: 2px 7px; border-radius: 7px; font-size: 0.82rem; font-weight: 800; background: var(--coral-tint); }
.tok-1 { background: var(--green-tint); } .tok-2 { background: var(--purple-tint); } .tok-3 { background: var(--yellow-tint); } .tok-4 { background: var(--teal-tint); }
.tok-count { font-weight: 900; color: var(--purple); margin: 0; }
.temp-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.temp-slider { flex: 1; accent-color: var(--purple); }
.temp-value { font-weight: 900; min-width: 2.5ch; }
.pb-out { background: #fff; border: 2px dashed var(--line-strong); border-radius: 12px; padding: 12px; white-space: pre-wrap; font-size: 0.83rem; min-height: 40px; font-family: ui-monospace, Menlo, monospace; }

/* ---------- settings ---------- */

.settings-page { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.settings-card h2 { font-size: 1.15rem; }
.ai-status { font-weight: 800; font-size: 0.9rem; color: var(--ink-faint); }
.ai-status.live { color: var(--green); }
.key-row { display: flex; gap: 10px; flex-wrap: wrap; }
.key-input { flex: 1; min-width: 200px; border: 2px solid var(--line-strong); border-radius: 12px; padding: 10px 14px; font-family: ui-monospace, Menlo, monospace; font-size: 0.9rem; outline: none; }
.key-input:focus { border-color: var(--coral); }
.settings-sub { margin-top: 20px; }
.voice-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.voice-label { font-weight: 900; font-size: 0.8rem; color: var(--ink-faint); width: 26px; }
.voice-select { flex: 1; min-width: 180px; border: 2px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; font-family: inherit; font-weight: 700; font-size: 0.9rem; background: #fff; color: var(--ink); }
.voice-preview { padding: 9px 16px; font-size: 0.85rem; }

/* ---------- footer / tab bar ---------- */

#site-footer { max-width: 1080px; margin: 0 auto; padding: 24px 24px 40px; color: var(--ink-soft); font-size: 0.88rem; font-weight: 600; text-align: center; }
#site-footer a { color: var(--coral); }

#tab-bar { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 80; background: rgba(255, 255, 255, 0.97); backdrop-filter: blur(10px); border-top: 2px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
#tab-bar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 12px; font-size: 0.66rem; font-weight: 800; color: var(--ink-soft); }
#tab-bar .tab-icon { font-size: 1.2rem; }
#tab-bar .tab.on { color: var(--coral-deep); background: var(--coral-tint); }

/* ---------- responsive ---------- */

@media (min-width: 720px) {
  .hero { grid-template-columns: 1.2fr 1fr; padding: 44px 0 16px; }
  .track-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 719px) {
  #tab-bar { display: flex; }
  #app { padding-bottom: 120px; }
  #site-footer { padding-bottom: 100px; }
  .main-nav { display: none; }
  .header-inner { gap: 10px; padding: 8px 14px; }
  .chip { font-size: 0.72rem; padding: 5px 10px; }
  .btn { width: 100%; }
  .hero-ctas { flex-direction: column; }
  .pl-footer .btn { width: auto; flex: 1; }
  .track-head { flex-direction: column; gap: 10px; }
}
