:root {
  --ink: #16313a;
  --muted: #587078;
  --paper: #fffdf8;
  --cream: #f7f1e5;
  --teal: #1f6870;
  --teal-dark: #173d49;
  --gold: #d6a83d;
  --coral: #d46d55;
  --green: #2f7d62;
  --red: #b84c4c;
  --line: #d8e0dd;
  --shadow: 0 18px 50px rgba(25, 58, 63, .12);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(214, 168, 61, .15), transparent 26rem),
    radial-gradient(circle at 90% 20%, rgba(31, 104, 112, .12), transparent 30rem),
    var(--cream);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.65;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(214, 168, 61, .72);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: .7rem 1rem;
  color: var(--ink);
  background: white;
  border-radius: 12px;
}
.skip-link:focus { top: 1rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem clamp(1rem, 4vw, 4rem);
  color: white;
  background: rgba(23, 61, 73, .97);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 30px rgba(15, 47, 56, .18);
}

.brand {
  display: flex;
  align-items: center;
  gap: .8rem;
  color: white;
  background: transparent;
  border: 0;
  text-align: left;
}
.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: #18353e;
  background: var(--gold);
  border-radius: 14px;
  font-weight: 900;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.02rem; }
.brand small { color: #cfddda; font-size: .73rem; }

nav { display: flex; gap: .35rem; }
.nav-button {
  padding: .55rem .95rem;
  color: #e9f3f1;
  background: transparent;
  border: 0;
  border-radius: 999px;
}
.nav-button:hover, .nav-button.active { color: var(--teal-dark); background: white; }
.menu-button {
  display: none;
  padding: .35rem .7rem;
  color: white;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 12px;
}

main { min-height: calc(100vh - 190px); }
.page {
  width: min(1160px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 5rem) 0;
  animation: rise .35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(9px); } }

.eyebrow {
  margin: 0 0 .8rem;
  color: var(--coral);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.eyebrow.muted { color: var(--muted); }
h1, h2, h3 { margin-top: 0; line-height: 1.15; letter-spacing: -.02em; }
h1 { max-width: 950px; margin-bottom: 1.2rem; font: 700 clamp(2.5rem, 6vw, 5.1rem)/1.06 Georgia, serif; }
h2 { font: 700 clamp(1.85rem, 3.5vw, 3rem)/1.12 Georgia, serif; }
h3 { font-size: 1.22rem; }
.lead { max-width: 780px; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.28rem); }

.hero {
  position: relative;
  padding: clamp(2.2rem, 5vw, 5.2rem);
  overflow: hidden;
  color: white;
  background: linear-gradient(135deg, #173d49 0%, #1f6870 72%, #3b827a 100%);
  border-radius: 34px;
  box-shadow: var(--shadow);
}
.hero::after {
  content: "198";
  position: absolute;
  right: -2rem;
  bottom: -4.5rem;
  color: rgba(255, 255, 255, .055);
  font: 900 16rem/1 Georgia, serif;
}
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow { color: #ffd97d; }
.hero .lead { color: #e3efed; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; margin-top: 2rem; }
.save-note { color: #dbeae7; font-size: .84rem; }

.primary, .secondary, .ghost, .danger {
  padding: .78rem 1.15rem;
  font-weight: 750;
  border: 0;
  border-radius: 14px;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.primary:hover, .secondary:hover, .ghost:hover, .danger:hover { transform: translateY(-2px); }
.primary { color: #17343b; background: var(--gold); box-shadow: 0 8px 22px rgba(214, 168, 61, .22); }
.secondary { color: white; background: var(--teal); }
.ghost { color: var(--teal-dark); background: #edf3f1; }
.danger { color: #8a3838; background: #fae7e4; }
.hero .ghost { color: white; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .3); }
.primary:disabled, .secondary:disabled, .ghost:disabled { opacity: .5; transform: none; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2.6rem;
}
.stat { padding: 1rem; background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .18); border-radius: 18px; }
.stat strong { display: block; color: #ffdd87; font: 700 2rem/1 Georgia, serif; }
.stat span { color: #dbeae7; font-size: .88rem; }

.section { margin-top: clamp(2.5rem, 6vw, 5rem); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.section-head p { margin: 0; color: var(--muted); }
.section-head .progress-summary { min-width: 220px; text-align: right; }
.progress-track { height: 10px; overflow: hidden; background: #dfe7e3; border-radius: 99px; }
.progress-track span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); border-radius: inherit; transition: width .25s; }

.method-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: .8rem;
  margin-top: 1rem;
  padding: 1.2rem;
  background: rgba(255, 253, 248, .82);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.method-step { display: flex; align-items: center; gap: .7rem; font-weight: 700; }
.method-step b { color: var(--coral); }
.method-arrow { color: var(--gold); font-weight: 900; }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.lesson-card {
  position: relative;
  min-height: 290px;
  display: flex;
  flex-direction: column;
  padding: 1.55rem;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(34, 72, 74, .07);
  text-align: left;
}
.lesson-card::before { content: ""; width: 56px; height: 6px; margin-bottom: 1.2rem; background: var(--accent, var(--teal)); border-radius: 6px; }
.lesson-card:hover:not(:disabled) { transform: translateY(-3px); box-shadow: var(--shadow); }
.lesson-card .number { position: absolute; right: 1rem; top: .2rem; color: rgba(20, 62, 71, .07); font: 700 6rem/1 Georgia, serif; }
.lesson-card p { color: var(--muted); }
.lesson-card footer { display: flex; justify-content: space-between; gap: .5rem; margin-top: auto; color: var(--muted); font-size: .82rem; }
.lesson-card.locked { opacity: .62; }
.lesson-card.done { border-color: rgba(47, 125, 98, .5); }
.lesson-card.done::before { background: var(--green); }
.card-top { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.article-pill, .status-pill, .duration-badge, .module-status {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .65rem;
  font-size: .74rem;
  font-weight: 850;
  border-radius: 999px;
}
.article-pill { color: var(--teal-dark); background: #e8f1ef; }
.status-pill { color: var(--muted); background: #edf1ef; }
.status-pill.done, .module-status.active { color: #23654e; background: #e3f4eb; }

.search-panel { padding: 1.25rem; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; }
.search-panel label { display: block; margin-bottom: .45rem; font-weight: 800; }
.search-panel input { width: 100%; padding: .85rem 1rem; color: var(--ink); background: white; border: 2px solid #d9e2df; border-radius: 14px; }
.search-results { display: grid; gap: .5rem; margin-top: .8rem; }
.search-result { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem .9rem; color: var(--ink); background: #f5f8f6; border: 0; border-radius: 12px; text-align: left; }
.search-result:hover { background: #e8f1ef; }

.law-map { display: grid; gap: 1rem; }
.title-group { padding: clamp(1.2rem, 3vw, 2rem); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 9px 25px rgba(34, 72, 74, .06); }
.title-group-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.title-group-head h2 { margin-bottom: .35rem; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.title-group-head p { margin: 0; color: var(--muted); }
.module-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; margin-top: 1.2rem; }
.module-row { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; padding: .8rem; background: #f7f8f4; border: 1px solid #e2e7e4; border-radius: 14px; }
button.module-row { width: 100%; color: var(--ink); text-align: left; }
.module-row.active { background: #eaf5f2; border-color: #b9d6ce; }
.module-number { display: grid; place-items: center; width: 36px; height: 36px; color: white; background: var(--teal-dark); border-radius: 11px; font-weight: 900; }
.module-row strong, .module-row small { display: block; }
.module-row small { color: var(--muted); }
.module-status { color: #6f7777; background: #e8ece9; white-space: nowrap; }

.breadcrumb { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin-bottom: 1.8rem; color: var(--muted); font-size: .88rem; }
.breadcrumb button { padding: 0; color: var(--teal); background: transparent; border: 0; font-weight: 750; }
.lesson-header { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 1rem; margin-bottom: 1.5rem; }
.lesson-header h1 { margin-bottom: .4rem; font-size: clamp(2.2rem, 5vw, 4rem); }
.lesson-header p { margin: 0; color: var(--muted); }
.duration-badge { color: var(--teal-dark); background: #e7efec; }

.audio-card, .paper-card, .quiz-card, .result-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(34, 72, 74, .07);
}
.audio-card { padding: 1.3rem; color: white; background: linear-gradient(120deg, var(--teal-dark), #225e68); border-color: transparent; }
.audio-heading { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; }
.audio-icon { display: grid; place-items: center; width: 62px; height: 62px; background: rgba(255, 255, 255, .12); border-radius: 20px; font-size: 1.8rem; }
.audio-heading span, .audio-heading strong { display: block; }
.audio-heading span { color: #d8e9e6; font-size: .82rem; }
.audio-heading strong { font-size: 1.15rem; }
.listened-badge { padding: .35rem .65rem; color: #d8ffe8 !important; background: rgba(52, 143, 101, .35); border-radius: 999px; font-weight: 800; }
.player-row { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; margin-top: 1.2rem; }
.round-control { width: 52px; height: 52px; display: grid; place-items: center; color: var(--teal-dark); background: var(--gold); border: 0; border-radius: 50%; font-weight: 900; }
.small-control, .speed-row button { padding: .5rem .75rem; color: white; background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .25); border-radius: 11px; }
.small-control:disabled { opacity: .45; }
.player-track { height: 9px; overflow: hidden; background: rgba(255, 255, 255, .17); border-radius: 99px; }
.player-track i { display: block; width: 0; height: 100%; background: var(--gold); border-radius: inherit; }
.player-meta { display: flex; justify-content: space-between; margin-top: .25rem; color: #cfe0dc; font-size: .75rem; }
.speed-row { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin-top: .9rem; color: #dceae7; font-size: .85rem; }
.speed-row button.active { color: var(--teal-dark); background: white; }
.audio-fallback { margin-top: 1rem; padding: .8rem; color: #ffe39a; background: rgba(0, 0, 0, .16); border-radius: 12px; }
.audio-fallback button { margin-left: .5rem; padding: .4rem .65rem; border: 0; border-radius: 9px; }

.transcript, .legal-panel { margin-top: 1rem; padding: 1.1rem 1.25rem; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; }
.transcript summary, .legal-panel summary { cursor: pointer; color: var(--teal-dark); font-weight: 850; }
.transcript-body, .legal-text { max-width: 86ch; margin: 1.2rem auto 0; font: 1.04rem/1.83 Georgia, serif; }
.legal-text { white-space: pre-wrap; }
.source-badge { display: inline-block; margin-top: 1rem; padding: .35rem .6rem; color: var(--muted); background: #edf1ef; border-radius: 9px; font-size: .75rem; }

.remember-panel { display: grid; grid-template-columns: 150px 1fr; gap: 1.2rem; margin-top: 1.2rem; padding: clamp(1.2rem, 3vw, 2rem); color: #553f10; background: #fbf1d6; border: 1px solid #ead89f; border-radius: var(--radius); }
.remember-label { font: 800 1.35rem/1.2 Georgia, serif; }
.remember-panel p { display: grid; grid-template-columns: 34px 1fr; gap: .7rem; align-items: start; margin: 0 0 .65rem; }
.remember-panel b { width: 32px; height: 32px; display: grid; place-items: center; color: white; background: var(--gold); border-radius: 9px; }

.quiz-wrap { margin-top: 1.4rem; }
.quiz-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.quiz-heading p { margin: 0; color: var(--muted); }
.quiz-count { min-width: 70px; padding: .55rem .7rem; color: var(--teal-dark); background: #e8f1ef; border-radius: 12px; text-align: center; font-weight: 900; }
.quiz-locked { padding: 2rem; text-align: center; }
.quiz-locked .lock-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto .8rem; background: #e8efec; border-radius: 18px; font-size: 1.6rem; }
.questions-stack { display: grid; gap: 1rem; }
.question-card { display: grid; grid-template-columns: 44px 1fr; gap: 1rem; padding: clamp(1.15rem, 3vw, 1.7rem); background: var(--paper); border: 1px solid var(--line); border-radius: 18px; }
.question-number { width: 42px; height: 42px; display: grid; place-items: center; color: white; background: var(--teal-dark); border-radius: 12px; font-weight: 900; }
.question-content h3 { margin-bottom: 1rem; }
.options-list { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.option { min-height: 82px; display: grid; grid-template-columns: 34px 1fr; gap: .7rem; align-items: center; padding: .75rem; color: var(--ink); background: #fff; border: 2px solid #d9e2df; border-radius: 14px; text-align: left; }
.option:hover:not(:disabled) { background: #f3f9f7; border-color: var(--teal); }
.option-letter { width: 34px; height: 34px; display: grid; place-items: center; background: #e7eeeb; border-radius: 10px; font-weight: 850; }
.option.selected { background: #e9f3f4; border-color: var(--teal); }
.option.selected .option-letter { color: white; background: var(--teal); }
.option.correct { background: #eaf7f0; border-color: var(--green); }
.option.correct .option-letter { color: white; background: var(--green); }
.option.wrong { background: #fbeeed; border-color: var(--red); }
.option.wrong .option-letter { color: white; background: var(--red); }
.feedback { margin-top: .8rem; padding: .85rem; background: #edf7f2; border-left: 5px solid var(--green); border-radius: 10px; }
.feedback.wrong { background: #fbedeb; border-color: var(--red); }
.quiz-submit { display: block; margin: 1.2rem auto 0; }

.result-card { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; margin-top: 1.2rem; padding: 1.3rem; }
.score-badge { width: 86px; height: 86px; display: grid; place-items: center; color: white; background: var(--teal); border-radius: 50%; font: 800 1.55rem/1 Georgia, serif; }
.result-card.success { border-color: rgba(47, 125, 98, .52); }
.result-card.retry { border-color: rgba(184, 76, 76, .5); }

.exam-lock, .empty { max-width: 760px; margin: 2rem auto; padding: 2rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.exam-status { margin: 1.2rem 0 2rem; }
.exam-status-row { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .35rem; color: var(--muted); font-size: .86rem; }
.article-reference { display: inline-block; margin-bottom: .45rem; color: var(--coral); font-size: .75rem; font-weight: 850; letter-spacing: .08em; }
.exam-result { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; margin: 1.5rem 0; padding: 1.4rem; color: white; background: linear-gradient(120deg, var(--teal-dark), var(--teal)); border-radius: var(--radius); }
.exam-result strong { font: 800 2.6rem/1 Georgia, serif; }
.exam-result span { color: #dce9e6; }

.progress-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.progress-card { padding: 1.35rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.progress-card .big { display: block; color: var(--teal); font: 800 2.4rem/1 Georgia, serif; }
.progress-card p { color: var(--muted); }
.mistake-list { display: grid; gap: .65rem; padding: 0; list-style: none; }
.mistake-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem .9rem; background: #fff7ef; border: 1px solid #eed7bf; border-radius: 12px; }

.site-footer { padding: 2rem 1rem 3rem; color: #667a80; text-align: center; font-size: .82rem; }
.site-footer p { margin: .25rem; }
.site-footer .legal-note { color: #8a6f3b; }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; max-width: 420px; padding: .8rem 1rem; color: white; background: var(--teal-dark); border-radius: 12px; box-shadow: var(--shadow); transform: translateY(160%); transition: transform .25s; }
.toast.show { transform: translateY(0); }

@media (max-width: 930px) {
  .card-grid, .progress-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-list { grid-template-columns: 1fr; }
  .method-strip { grid-template-columns: 1fr; }
  .method-arrow { display: none; }
  .method-step { justify-content: center; }
}

@media (max-width: 720px) {
  body { font-size: 17px; }
  .menu-button { display: block; }
  .topbar nav { display: none; position: absolute; left: 1rem; right: 1rem; top: 70px; padding: .7rem; background: var(--teal-dark); border-radius: 16px; box-shadow: var(--shadow); }
  .topbar nav.open { display: grid; }
  .nav-button { text-align: left; }
  .page { width: min(100% - 1rem, 1160px); padding-top: 1rem; }
  .hero { border-radius: 24px; }
  .stats, .card-grid, .progress-grid { grid-template-columns: 1fr; }
  .section-head, .lesson-header, .quiz-heading { display: block; }
  .section-head .progress-summary { margin-top: .7rem; text-align: left; }
  .options-list { grid-template-columns: 1fr; }
  .audio-heading { grid-template-columns: auto 1fr; }
  .listened-badge { grid-column: 1 / -1; width: max-content; }
  .player-row { grid-template-columns: auto 1fr; }
  .player-row .small-control { grid-column: 1 / -1; }
  .remember-panel { grid-template-columns: 1fr; }
  .result-card, .exam-result { grid-template-columns: 1fr; text-align: center; }
  .score-badge { margin: 0 auto; }
  .question-card { grid-template-columns: 1fr; }
  .title-group-head { display: block; }
  .module-row { grid-template-columns: auto 1fr; }
  .module-status { grid-column: 2; width: max-content; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
