:root {
  --paper: #f3efe7;
  --paper-2: #fffaf1;
  --ink: #211b16;
  --muted: #7a6f63;
  --line: #ded3c5;
  --red: #c8452f;
  --green: #2f7d62;
  --gold: #c89433;
  --blue: #365f8f;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(33, 27, 22, .07);
  --font: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  font-family: var(--font);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 560;
  letter-spacing: -.01em;
  margin: 0;
}

p { line-height: 1.55; }
a { color: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 250, 241, .72);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 800;
  margin-bottom: 32px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-block;
  background: url("img/maestro_logo_ring.svg") center / contain no-repeat;
}

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

.nav { display: grid; gap: 8px; }
.nav a, .logout-form button, .quiet-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  text-decoration: none;
  font: inherit;
  padding: 10px 0;
  cursor: pointer;
}
.nav a:hover, .logout-form button:hover, .quiet-link:hover { color: var(--red); }
.logout-form { position: absolute; bottom: 24px; left: 24px; right: 24px; }

.content {
  width: min(1120px, 100%);
  padding: 36px clamp(18px, 4vw, 56px) 72px;
}

.hero-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}
.hero-row h1 { font-size: clamp(34px, 5vw, 64px); }
.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}
.metrics {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}
.metrics strong { color: var(--ink); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper-2);
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
}
.button.primary {
  background: var(--red);
  border-color: var(--red);
  color: white;
}
.button:focus, input:focus, textarea:focus, select:focus, button:focus, a:focus {
  outline: 3px solid rgba(200, 69, 47, .35);
  outline-offset: 2px;
}

.focus-band {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 24px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.notebook-card {
  display: block;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 241, .72);
  text-decoration: none;
}
.notebook-card h2 { font-size: 24px; }
.card-top { display: flex; gap: 14px; align-items: flex-start; }
.emoji { font-size: 34px; line-height: 1; }
.meta { color: var(--muted); font-size: 14px; }
.progress-line {
  height: 10px;
  overflow: hidden;
  background: #e6dacb;
  border-radius: 999px;
  margin: 16px 0 8px;
}
.progress-line span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message {
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.message.success { border-color: rgba(47, 125, 98, .4); color: var(--green); }
.message.error { border-color: rgba(200, 69, 47, .45); color: var(--red); }
.message.info { border-color: rgba(54, 95, 143, .4); color: var(--blue); }

.focus-strip {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 16px;
  background: rgba(255, 250, 241, .94);
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 16px;
}

.constellation {
  position: relative;
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 22% 12%, rgba(200, 69, 47, .08), transparent 20%),
    radial-gradient(circle at 80% 70%, rgba(54, 95, 143, .08), transparent 22%),
    var(--paper-2);
  overflow: hidden;
}
.topic-list {
  margin-top: 24px;
  display: grid;
  gap: 10px;
}
.topic-list h2 { font-size: 26px; }
.edit-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper-2);
  text-decoration: none;
}
.constellation-lines, .constellation-nodes {
  position: absolute;
  inset: 0;
}
.constellation-lines path {
  stroke: rgba(122, 111, 99, .38);
  stroke-width: 1.4;
  fill: none;
  vector-effect: non-scaling-stroke;
}
.star {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 148px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(52, 39, 28, .08);
}
.star small { display: block; color: var(--muted); font-weight: 600; margin-top: 4px; }
.star.available { border-color: rgba(200, 69, 47, .45); }
.star.completed { background: rgba(47, 125, 98, .1); border-color: rgba(47, 125, 98, .35); }
.star.locked { opacity: .56; cursor: not-allowed; }

.lesson {
  max-width: 720px;
  margin: 0 auto;
}
.lesson h1 { font-size: clamp(34px, 5vw, 58px); margin-bottom: 20px; }
.study-card {
  padding: 28px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.counter { color: var(--muted); font-weight: 700; }
.hidden { display: none !important; }
.lesson-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.options { display: grid; gap: 10px; margin-top: 16px; }
.option {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  text-align: left;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
}
.option.correct { border-color: var(--green); color: var(--green); }
.option.wrong { border-color: var(--red); color: var(--red); }
.explanation { color: var(--muted); }

.practice-form, .form-stack {
  display: grid;
  gap: 14px;
}
.practice-form label, .form-stack p {
  display: grid;
  gap: 6px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 9px;
  display: grid;
  gap: 10px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel, .form-page, .empty-state {
  width: min(520px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  box-shadow: var(--shadow);
}
.login-panel h1 { font-size: 48px; margin-top: 12px; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .logout-form { position: static; margin-top: 14px; }
  .hero-row, .focus-band { align-items: flex-start; flex-direction: column; }
  .constellation {
    min-height: 0;
    padding: 14px;
    overflow: visible;
  }
  .constellation-lines { display: none; }
  .constellation-nodes {
    position: relative;
    display: grid;
    gap: 10px;
  }
  .star {
    position: static;
    transform: none;
    width: 100%;
    min-height: 58px;
    font-size: 14px;
    text-align: left;
    padding: 10px 12px;
  }
}
