:root {
  --greek-blue: #00319b;
  --greek-blue-light: #1769c2;
  --panel: #f7f8fb;
  --border: #d8dee9;
  --text-muted: #5c6675;
}

body {
  min-height: 100vh;
}

.page-content {
  margin-top: 2rem;
  margin-bottom: 5rem;
}

.study-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  padding-top: 1rem;
}

.study-nav > a {
  font-weight: 600;
}

.site-search {
  display: flex;
  gap: 0.4rem;
  width: min(100%, 30rem);
}

.site-search input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
}

.site-search button,
.study-options button,
.study-controls button,
.rating-controls button {
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.55rem 0.8rem;
  background: white;
}

.intro-panel,
.chapter-dashboard,
.search-result,
.overall-progress {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: white;
}

.intro-panel {
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.overall-progress,
.chapter-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.overall-progress > div,
.chapter-summary > div {
  padding: 0.9rem;
  text-align: center;
}

.overall-progress strong,
.chapter-summary strong {
  display: block;
  font-size: 1.5rem;
  color: var(--greek-blue);
}

.overall-progress span,
.chapter-summary span {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.chapter-table {
  width: 100%;
  margin-bottom: 1rem;
}

.chapter-table th,
.chapter-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #edf0f4;
  vertical-align: middle;
}

.chapter-table tr {
  height: auto;
}

.chapter-table .ch-title {
  text-align: left;
}

.mini-progress,
.progress-track {
  height: 0.4rem;
  background: #e7eaf0;
  border-radius: 999px;
  overflow: hidden;
}

.mini-progress {
  min-width: 7rem;
  margin-top: 0.25rem;
}

.mini-progress span,
.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--greek-blue-light);
  transition: width 0.2s ease;
}

.home-actions {
  text-align: right;
  margin-bottom: 3rem;
}

.chapter-dashboard {
  padding: 1rem;
  margin-bottom: 1.5rem;
  background: var(--panel);
}

.chapter-summary {
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 1rem;
}

.study-options {
  display: grid;
  grid-template-columns: minmax(16rem, 2fr) 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
}

.study-options fieldset {
  min-width: 0;
}

.study-options legend {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.study-options label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.study-options select {
  min-height: 2.45rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.4rem;
  background: white;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.button-group button.active,
.primary-action {
  background: var(--greek-blue);
  color: white;
  border-color: var(--greek-blue);
}

.option-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.progress-strip {
  display: grid;
  grid-template-columns: auto minmax(8rem, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.study-stage {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.study-card {
  width: 100%;
  min-height: 360px;
  perspective: 1200px;
  cursor: pointer;
  outline: none;
}

.study-card:focus-visible {
  outline: 3px solid #7aa7e7;
  outline-offset: 4px;
}

.study-card-inner {
  position: relative;
  width: 100%;
  min-height: 360px;
  transition: transform 0.45s ease;
  transform-style: preserve-3d;
}

.study-card.flipped .study-card-inner {
  transform: rotateY(180deg);
}

.study-card-face {
  position: absolute;
  inset: 0;
  min-height: 360px;
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0.4rem 1.4rem rgb(0 0 0 / 12%);
}

.study-card-front {
  background: var(--greek-blue);
  color: white;
}

.study-card-back {
  transform: rotateY(180deg);
  background: #f8fbff;
  border: 2px solid var(--greek-blue-light);
  color: #172033;
}

.card-category {
  position: absolute;
  top: 1rem;
  left: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  opacity: 0.8;
}

.greek-card-text {
  font-family: Perpetua, "Palatino Linotype", "Noto Serif", serif;
  font-size: clamp(2.2rem, 7vw, 4.5rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.card-answer {
  font-size: clamp(1.15rem, 2.5vw, 1.55rem);
  line-height: 1.5;
}

.card-answer p {
  margin: 0.35rem 0;
}

.card-answer .reverse-greek {
  font-family: Perpetua, "Palatino Linotype", "Noto Serif", serif;
  font-size: clamp(2rem, 6vw, 3.8rem);
}

.flip-hint {
  position: absolute;
  bottom: 1rem;
  font-size: 0.8rem;
  opacity: 0.75;
}

.related-link {
  margin-top: 1.3rem;
  font-size: 0.9rem;
}

.study-controls,
.rating-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}

.rating-controls button {
  min-width: 8rem;
}

.rating-again {
  border-color: #b33 !important;
}

.rating-hard {
  border-color: #b27b00 !important;
}

.rating-gotit {
  border-color: #27823c !important;
}

kbd {
  font-size: 0.72rem;
}

.keyboard-help {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.75rem;
}

.session-summary {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 0.6rem;
  background: #eef5ff;
}

.chapter-reset {
  margin-top: 2rem;
}

.search-page > .row {
  margin-top: 1rem;
}

.search-results {
  display: grid;
  gap: 0.8rem;
  margin: 1rem 0 4rem;
}

.search-result {
  padding: 1rem 1.1rem;
}

.search-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.search-greek {
  font-family: Perpetua, "Palatino Linotype", "Noto Serif", serif;
  font-size: 1.8rem;
  color: var(--greek-blue);
}

.search-answer {
  margin-top: 0.35rem;
}

@media (max-width: 900px) {
  .study-options {
    grid-template-columns: 1fr 1fr;
  }

  .study-options fieldset {
    grid-column: 1 / -1;
  }

  .chapter-summary {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .study-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .site-search {
    width: 100%;
  }

  .page-content {
    margin-top: 1rem;
  }

  .overall-progress,
  .chapter-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .study-options {
    grid-template-columns: 1fr;
  }

  .study-card,
  .study-card-inner,
  .study-card-face {
    min-height: 300px;
  }

  .study-card-face {
    padding: 2rem 1.2rem;
  }

  .progress-strip {
    grid-template-columns: auto 1fr;
  }

  #study-status {
    grid-column: 1 / -1;
  }

  .keyboard-help {
    display: none;
  }

  .chapter-table th:nth-child(3),
  .chapter-table td:nth-child(3) {
    display: none;
  }
}
