:root {
  --paper: #f7f1e5;
  --paper-2: #fffdf8;
  --ink: #26221c;
  --muted: #70695f;
  --line: #d9ccb6;
  --gold: #9d6f21;
  --blue: #2f6f9f;
  --green: #3f7b59;
  --red: #a33b3b;
  --shadow: 0 12px 35px rgba(66, 47, 23, .10);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(181, 133, 62, .10), transparent 30rem),
    linear-gradient(180deg, #fbf8f1, var(--paper));
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.foundation-app { width: min(1440px, calc(100% - 32px)); margin: 28px auto 60px; }
.foundation-hero {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 24px;
  padding: 30px; border: 1px solid var(--line); border-radius: 20px;
  background: rgba(255, 253, 248, .91); box-shadow: var(--shadow);
}
.foundation-kicker { color: var(--red); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: .78rem; }
.foundation-hero h1 { margin: 7px 0 10px; font-family: Cardo, Georgia, serif; font-size: clamp(2rem, 4vw, 3.45rem); line-height: 1; }
.foundation-hero p { max-width: 880px; margin: 0; color: var(--muted); line-height: 1.65; font-family: "Source Serif 4", Georgia, serif; font-size: 1.08rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; min-width: 260px; justify-content: flex-end; }
button, .button-link {
  appearance: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  background: var(--paper-2); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none; transition: transform .12s, border-color .12s, background .12s;
}
button:hover, .button-link:hover { transform: translateY(-1px); border-color: var(--gold); }
button.primary { color: white; border-color: var(--gold); background: var(--gold); }
button.danger { color: var(--red); }

.foundation-layout { display: grid; grid-template-columns: 315px minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
.foundation-panel { border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 253, 248, .94); box-shadow: var(--shadow); }
.foundation-dashboard { position: sticky; top: 18px; padding: 22px; }
.foundation-dashboard h2, .foundation-main h2 { margin: 0 0 12px; font-family: Cardo, Georgia, serif; }
.progress-track { height: 11px; overflow: hidden; background: #ebe3d4; border-radius: 999px; }
.progress-track > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #c49440); transition: width .25s; }
.dashboard-line { display: flex; justify-content: space-between; gap: 12px; margin: 9px 0 18px; color: var(--muted); font-size: .9rem; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 16px 0; }
.stat { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #faf6ee; }
.stat strong { display: block; color: var(--gold); font-size: 1.35rem; }
.stat span { color: var(--muted); font-size: .74rem; line-height: 1.25; }
.mastery-title { margin: 20px 0 8px; font-weight: 800; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.domain { margin: 11px 0; }
.domain-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: .78rem; }
.domain .progress-track { height: 7px; }
.dashboard-controls { display: grid; gap: 8px; margin-top: 18px; }

.foundation-main { min-width: 0; padding: 24px; }
.system-map { padding: 19px; border: 1px solid #d8b878; border-radius: 15px; background: linear-gradient(135deg, #fff9eb, #f7ead0); }
.system-map strong { display: block; margin-bottom: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; }
.map-steps { display: flex; align-items: stretch; gap: 7px; }
.map-step { flex: 1; display: grid; place-items: center; min-height: 64px; padding: 9px; border: 1px solid rgba(157,111,33,.35); border-radius: 10px; background: rgba(255,255,255,.72); text-align: center; font-weight: 750; line-height: 1.25; }
.map-arrow { display: grid; place-items: center; color: var(--gold); font-size: 1.35rem; }
.system-map p { margin: 11px 0 0; color: var(--muted); font-family: "Source Serif 4", Georgia, serif; }
.choice-only-note { margin: 16px 0; padding: 12px 14px; border-left: 4px solid var(--green); background: rgba(63,123,89,.08); color: var(--muted); }
.activity-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.activity-card { display: flex; flex-direction: column; min-height: 185px; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.activity-card .activity-icon { font-size: 1.4rem; }
.activity-card h3 { margin: 8px 0 6px; font-family: Cardo, Georgia, serif; font-size: 1.25rem; }
.activity-card p { flex: 1; margin: 0 0 15px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.activity-result { margin-top: 8px; color: var(--green); font-size: .78rem; font-weight: 800; }

.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.quiz-head button { padding: 8px 11px; }
.quiz-progress { color: var(--muted); font-weight: 700; }
.question-card { padding: clamp(18px, 4vw, 34px); border: 1px solid var(--line); border-radius: 16px; background: white; }
.question-card h3 { margin: 0 0 20px; font-family: Cardo, Georgia, serif; font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1.35; }
.greek-text { font-family: Cardo, "Palatino Linotype", serif; }
.choices { display: grid; gap: 10px; }
.choice { width: 100%; text-align: left; line-height: 1.35; padding: 13px 15px; }
.choice.correct { border-color: var(--green); background: rgba(63,123,89,.10); color: #25543a; }
.choice.wrong { border-color: var(--red); background: rgba(163,59,59,.08); color: #7f2929; }
.choice:disabled { cursor: default; transform: none; opacity: 1; }
.confidence-row { display: flex; flex-wrap: wrap; gap: 8px; margin: -5px 0 16px; }
.confidence-row button.selected { border-color: var(--blue); background: rgba(47,111,159,.10); color: var(--blue); }
.audio-prompt { display: flex; gap: 9px; align-items: center; margin-bottom: 18px; }
.audio-prompt button { color: white; border-color: var(--blue); background: var(--blue); }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; line-height: 1.5; }
.feedback.good { background: rgba(63,123,89,.10); border: 1px solid rgba(63,123,89,.35); }
.feedback.bad { background: rgba(163,59,59,.08); border: 1px solid rgba(163,59,59,.30); }
.feedback p { margin: 5px 0 12px; color: var(--muted); }
.score-card { padding: 28px; text-align: center; border: 1px solid var(--line); border-radius: 16px; background: white; }
.score-card .score { margin: 10px 0; color: var(--gold); font-family: Cardo, Georgia, serif; font-size: 4rem; }
.score-card .controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; }
.empty-state { padding: 30px; text-align: center; color: var(--muted); }

@media (max-width: 1050px) {
  .foundation-hero { display: block; }
  .hero-actions { min-width: 0; justify-content: flex-start; margin-top: 18px; }
  .foundation-layout { grid-template-columns: 1fr; }
  .foundation-dashboard { position: static; }
}
@media (max-width: 760px) {
  .foundation-app { width: min(100% - 18px, 1440px); margin-top: 10px; }
  .foundation-hero, .foundation-main, .foundation-dashboard { padding: 17px; }
  .activity-grid { grid-template-columns: 1fr; }
  .map-steps { display: grid; }
  .map-arrow { transform: rotate(90deg); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

[data-theme="dark"] body { background: #181612; color: #eee5d6; }
[data-theme="dark"] .foundation-panel,
[data-theme="dark"] .foundation-hero,
[data-theme="dark"] .activity-card,
[data-theme="dark"] .question-card,
[data-theme="dark"] .score-card { background: #24201a; color: #eee5d6; border-color: #554a3b; }
[data-theme="dark"] .stat,
[data-theme="dark"] button,
[data-theme="dark"] .button-link { background: #2d2821; color: #eee5d6; border-color: #625542; }
[data-theme="dark"] .system-map { background: #302719; }
[data-theme="dark"] .map-step { background: #24201a; }
