:root {
  --paper: #e7eee8;
  --paper-strong: #d8e5db;
  --panel: rgba(236, 244, 238, 0.93);
  --panel-strong: rgba(219, 233, 223, 0.96);
  --ink: #132018;
  --muted: #3f4b43;
  --line: rgba(0, 146, 70, 0.24);
  --green: #009246;
  --green-dark: #006b35;
  --red: #ce2b37;
  --white: #f4f5f0;
  --blue: #1d4ed8;
  --gold: #f2c94c;
  --purple: #7251a5;
  --shadow: 0 18px 45px rgba(0, 73, 36, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(242, 201, 76, 0.14), transparent 18%),
    radial-gradient(circle at bottom right, rgba(29, 78, 216, 0.1), transparent 16%),
    linear-gradient(100deg, #009246 0%, #009246 33.33%, #f4f5f0 33.33%, #f4f5f0 66.66%, #ce2b37 66.66%, #ce2b37 100%);
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 2rem 1.4rem;
  background:
    linear-gradient(180deg, rgba(0, 146, 70, 0.96), rgba(0, 93, 45, 0.97)),
    linear-gradient(135deg, rgba(242, 201, 76, 0.08), transparent);
  color: #ffffff;
}

.brand-block {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.brand-block h1,
.view-header h2,
.hero-panel h2,
.panel h3,
.flashcard h3 {
  font-family: "Baskerville Old Face", "Garamond", "Times New Roman", serif;
  letter-spacing: 0.02em;
}

.brand-block h1,
.view-header h2,
.hero-panel h2 {
  margin: 0.15rem 0 0.5rem;
}

.brand-block h1 {
  font-size: clamp(1.75rem, 3.4vw, 2.35rem);
}

.brand-block p,
.view-header p,
.hero-panel p,
.panel p,
.metric-card p,
.sidebar-note {
  line-height: 1.5;
}

.eyebrow {
  margin: 0;
  color: inherit;
  opacity: 0.78;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.main-nav {
  display: grid;
  gap: 0.55rem;
  margin: 1.1rem 0 1.8rem;
}

.main-nav button,
.lesson-list button,
.category-pills button {
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.main-nav button {
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  text-align: left;
}

.main-nav button:hover,
.main-nav button.active {
  background: rgba(206, 43, 55, 0.28);
  border-color: rgba(242, 201, 76, 0.5);
  transform: translateX(4px);
}

.sidebar-note {
  margin-top: 2rem;
  padding: 0.95rem;
  border: 1px solid rgba(242, 201, 76, 0.22);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(248, 250, 246, 0.86);
}

.tutorial-launch {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.2rem 0 0.8rem;
  padding: 0.95rem 1rem;
  border: 2px solid rgba(242, 201, 76, 0.78);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(242, 201, 76, 0.98), rgba(255, 255, 255, 0.96)),
    linear-gradient(135deg, rgba(0, 146, 70, 0.2), rgba(206, 43, 55, 0.18));
  color: var(--green-dark);
  box-shadow: 0 18px 34px rgba(3, 38, 24, 0.24);
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.tutorial-launch:hover,
.tutorial-launch:focus-visible,
.tutorial-launch.active {
  transform: translateY(-2px);
  border-color: #ffffff;
  box-shadow: 0 22px 42px rgba(3, 38, 24, 0.34);
  outline: none;
}

.tutorial-launch-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--red));
  color: #ffffff;
  font-weight: 800;
}

.tutorial-launch-title,
.tutorial-launch-copy {
  display: block;
}

.tutorial-launch-title {
  font-weight: 700;
  font-size: 1.04rem;
}

.tutorial-launch-copy {
  margin-top: 0.12rem;
  font-size: 0.82rem;
  color: #304329;
}

.content {
  padding: 1.25rem;
}

.view-stack {
  display: grid;
  gap: 1rem;
  max-width: 1180px;
  margin: 0 auto;
}

.view-header,
.hero-panel,
.panel,
.metric-card,
.flashcard {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  animation: rise 340ms ease;
}

.view-header {
  padding: 1.2rem;
}

.view-header h2 {
  font-size: clamp(1.5rem, 3vw, 2.15rem);
}

.hero-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(circle at top right, rgba(242, 201, 76, 0.18), transparent 22%),
    linear-gradient(145deg, rgba(236, 244, 238, 0.96), rgba(219, 233, 223, 0.94));
}

.hero-meter {
  display: grid;
  place-items: center;
  min-width: 9rem;
  min-height: 9rem;
  border: 10px solid rgba(0, 146, 70, 0.18);
  border-top-color: var(--green);
  border-radius: 50%;
}

.hero-meter span {
  font-size: 2rem;
  font-weight: 800;
}

.hero-meter small {
  max-width: 6rem;
  color: var(--muted);
  text-align: center;
}

.metric-grid,
.action-grid,
.dictionary-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.metric-card,
.panel {
  padding: 1rem;
}

.metric-card span {
  display: block;
  color: var(--green-dark);
  font-size: 2rem;
  font-weight: 850;
}

.metric-card h3,
.panel h3,
.flashcard h3 {
  margin: 0.2rem 0 0.35rem;
}

.metric-card p {
  margin: 0;
  color: var(--muted);
}

.action-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.action-grid button,
.start-panel button,
.plan-actions button,
.study-controls button,
.quiz-actions button,
.choice-grid button {
  min-height: 2.65rem;
  padding: 0.7rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--green);
  background: linear-gradient(135deg, var(--green), var(--red));
  color: #ffffff;
  cursor: pointer;
  font-weight: 750;
}

.secondary,
.plan-actions button.secondary,
.study-controls button.secondary,
.quiz-actions button.secondary,
.choice-grid button.secondary {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--green-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.topic-bars {
  display: grid;
  gap: 0.65rem;
}

.topic-bar {
  display: grid;
  grid-template-columns: minmax(12rem, 0.32fr) 1fr;
  gap: 0.8rem;
  align-items: center;
}

.topic-bar span {
  color: var(--muted);
}

.topic-bar div {
  height: 0.65rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebe2;
}

.topic-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--red));
}

.start-panel {
  display: grid;
  gap: 0.7rem;
}

.start-panel button {
  width: fit-content;
}

.plan-rhythm {
  display: grid;
  gap: 0.8rem;
}

.rhythm-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.rhythm-grid div {
  display: grid;
  gap: 0.3rem;
  padding: 0.85rem;
  border: 1px solid rgba(0, 146, 70, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
}

.rhythm-grid strong {
  color: var(--green-dark);
}

.rhythm-grid span {
  color: var(--muted);
  line-height: 1.4;
}

.plan-grid {
  display: grid;
  gap: 0.9rem;
}

.plan-card {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 0.9rem;
}

.plan-step {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--red));
  color: #fff;
  font-size: 1.25rem;
  font-weight: 850;
}

.plan-card-body {
  display: grid;
  gap: 0.45rem;
}

.plan-card-body p {
  margin: 0;
}

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.lesson-layout,
.builder-layout {
  display: grid;
  grid-template-columns: minmax(250px, 0.38fr) 1fr;
  gap: 1rem;
}

.lesson-list {
  display: grid;
  gap: 0.55rem;
  align-content: start;
}

.lesson-list button {
  padding: 0.85rem;
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 22px rgba(31, 62, 43, 0.07);
}

.lesson-list button.active,
.lesson-list button:hover {
  border-color: rgba(242, 201, 76, 0.48);
  background: linear-gradient(135deg, rgba(0, 146, 70, 0.12), rgba(206, 43, 55, 0.08), rgba(255, 255, 255, 0.72));
}

.lesson-list span,
.lesson-list small {
  display: block;
}

.lesson-list small {
  margin-top: 0.25rem;
  color: var(--muted);
  line-height: 1.35;
}

.lesson-panel ul {
  display: grid;
  gap: 0.55rem;
  padding-left: 1.1rem;
}

.dictionary-panel {
  display: grid;
  gap: 0.85rem;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.word-card {
  display: grid;
  gap: 0.25rem;
  min-height: 6.5rem;
  padding: 0.85rem;
  border: 1px solid rgba(0, 146, 70, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 22px rgba(16, 48, 31, 0.08);
}

.word-card strong {
  color: var(--green-dark);
  font-size: 1.05rem;
}

.word-card span {
  color: var(--red-dark);
  font-weight: 800;
}

.word-card small {
  color: var(--muted);
  line-height: 1.4;
}

.tag,
.chip,
.legend span {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 1.8rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.tag-sound { background: rgba(36, 90, 165, 0.12); color: var(--blue); }
.tag-gender { background: rgba(179, 52, 52, 0.12); color: var(--red); }
.tag-number { background: rgba(114, 81, 165, 0.12); color: var(--purple); }
.tag-verbs { background: rgba(31, 122, 77, 0.12); color: var(--green-dark); }
.tag-preps { background: rgba(189, 123, 22, 0.14); color: #81510e; }
.tag-travel { background: rgba(36, 90, 165, 0.1); color: var(--blue); }
.tag-patterns { background: rgba(31, 122, 77, 0.12); color: var(--green-dark); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}

.gender-m { background: rgba(36, 90, 165, 0.12); color: var(--blue); }
.gender-f { background: rgba(179, 52, 52, 0.12); color: var(--red); }
.number-pl { background: rgba(114, 81, 165, 0.12); color: var(--purple); }
.verb-end { background: rgba(31, 122, 77, 0.12); color: var(--green-dark); }
.prep-contract { background: rgba(189, 123, 22, 0.14); color: #81510e; }

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.category-pills button {
  padding: 0.55rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 146, 70, 0.12);
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
}

.category-pills button.active,
.category-pills button:hover {
  border-color: rgba(242, 201, 76, 0.5);
  background: linear-gradient(135deg, rgba(0, 146, 70, 0.14), rgba(206, 43, 55, 0.1));
  color: var(--green-dark);
}

.flashcard {
  display: grid;
  align-content: center;
  min-height: 18rem;
  padding: 1.5rem;
  cursor: pointer;
  background:
    radial-gradient(circle at top right, rgba(242, 201, 76, 0.18), transparent 24%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.7), rgba(219, 233, 223, 0.94));
}

.flashcard.flipped {
  background:
    radial-gradient(circle at top right, rgba(242, 201, 76, 0.2), transparent 24%),
    linear-gradient(145deg, rgba(0, 146, 70, 0.12), rgba(206, 43, 55, 0.1), rgba(255, 255, 255, 0.72));
}

.flashcard p:last-child {
  max-width: 50rem;
  font-size: clamp(1.15rem, 2.5vw, 1.65rem);
  line-height: 1.45;
}

.study-controls,
.quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.quiz-panel {
  display: grid;
  gap: 0.85rem;
}

.quiz-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.compact {
  min-height: auto;
  padding: 0.35rem 0.65rem;
}

.chip {
  background: #eef3ec;
  color: var(--muted);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.choice-grid button {
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  border: 1px solid var(--line);
  text-align: left;
}

.choice-grid button.selected {
  border-color: var(--green);
  background: rgba(0, 146, 70, 0.16);
}

.answer-input,
.select-row select {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: var(--ink);
}

.tile-builder {
  display: grid;
  gap: 0.65rem;
}

.tile-answer,
.sentence-output {
  min-height: 3.4rem;
  padding: 0.85rem;
  border: 1px dashed rgba(31, 122, 77, 0.36);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.feedback {
  padding: 0.85rem;
  border-radius: 16px;
  border: 1px solid transparent;
}

.feedback.correct {
  border-color: rgba(31, 122, 77, 0.28);
  background: rgba(31, 122, 77, 0.1);
}

.feedback.incorrect {
  border-color: rgba(179, 52, 52, 0.26);
  background: rgba(179, 52, 52, 0.09);
}

.builder-panel {
  display: grid;
  gap: 0.8rem;
  align-content: start;
}

.select-row {
  display: grid;
  gap: 0.35rem;
}

.select-row span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: capitalize;
}

.sentence-output .italian {
  margin: 0 0 0.2rem;
  color: var(--green-dark);
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 850;
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.tutorial-overlay[hidden] {
  display: none;
}

.tutorial-scrim {
  position: absolute;
  inset: 0;
  background: rgba(7, 16, 11, 0.62);
}

.tutorial-highlight {
  position: fixed;
  border: 3px solid var(--gold);
  border-radius: 22px;
  box-shadow:
    0 0 0 9999px rgba(7, 16, 11, 0.48),
    0 0 0 7px rgba(242, 201, 76, 0.22),
    0 20px 50px rgba(0, 0, 0, 0.28);
  transition: left 180ms ease, top 180ms ease, width 180ms ease, height 180ms ease;
}

.tutorial-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(25rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.1rem;
  border: 1px solid rgba(242, 201, 76, 0.58);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(245, 250, 247, 0.98), rgba(219, 233, 223, 0.98));
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.34);
  pointer-events: auto;
}

.tutorial-panel h2 {
  margin: 0.35rem 0 0.45rem;
  font-family: "Baskerville Old Face", "Garamond", "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
}

.tutorial-panel p {
  line-height: 1.5;
}

.tutorial-panel-header,
.tutorial-actions,
.tutorial-language-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.tutorial-panel-header {
  justify-content: space-between;
}

.tutorial-actions {
  justify-content: space-between;
  margin-top: 1rem;
}

.tutorial-language-actions {
  flex-wrap: wrap;
  margin-top: 1rem;
}

.tutorial-panel button {
  min-height: 2.45rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--green);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--green), var(--red));
  color: #ffffff;
  cursor: pointer;
  font-weight: 750;
}

.tutorial-panel button.secondary {
  border-color: rgba(29, 78, 216, 0.24);
  background: transparent;
  color: var(--blue);
}

.tutorial-icon-button {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
}

.tutorial-progress {
  display: flex;
  gap: 0.28rem;
  margin-top: 0.9rem;
}

.tutorial-progress span {
  height: 0.42rem;
  flex: 1 1 0;
  border-radius: 999px;
  background: rgba(0, 146, 70, 0.18);
}

.tutorial-progress span.active {
  background: linear-gradient(135deg, var(--green), var(--red));
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sentence-output p:last-child,
.note {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 960px) {
  .app-shell,
  .lesson-layout,
  .builder-layout,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .main-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid,
  .action-grid,
  .dictionary-summary,
  .word-grid,
  .rhythm-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-meter {
    min-width: 8rem;
    width: 8rem;
    min-height: 8rem;
  }
}

@media (max-width: 640px) {
  .content,
  .sidebar {
    padding: 0.8rem;
  }

  .main-nav,
  .metric-grid,
  .action-grid,
  .dictionary-summary,
  .word-grid,
  .rhythm-grid,
  .plan-card,
  .choice-grid,
  .topic-bar {
    grid-template-columns: 1fr;
  }

  .flashcard {
    min-height: 16rem;
  }

  .tutorial-panel {
    left: 0.75rem !important;
    right: 0.75rem !important;
    bottom: 0.75rem;
    width: auto;
  }

  .tutorial-actions,
  .tutorial-language-actions {
    align-items: stretch;
  }
}
