:root {
  color-scheme: light;
  --ink: #102033;
  --muted: #5f7184;
  --paper: #f7f9fc;
  --panel: #ffffff;
  --line: #d7e1ea;
  --brand-blue: #0c5fa8;
  --brand-blue-dark: #083f75;
  --brand-blue-soft: #e9f3fb;
  --brand-gold: #f4a51c;
  --brand-gold-dark: #c97905;
  --rose: #b8485d;
  --shadow: 0 22px 70px rgba(8, 63, 117, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(12, 95, 168, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(12, 95, 168, 0.07) 1px, transparent 1px),
    linear-gradient(135deg, #f7f9fc 0%, #edf5fb 46%, #fff7ea 100%);
  background-size: 34px 34px, 34px 34px, auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: #aab6af;
}

button.primary,
.mode-switch button.active {
  border-color: var(--brand-blue);
  background: var(--brand-blue);
  color: #fff;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
}

.brand-block,
.topbar,
.panel-row,
.controls,
.rating-row,
.session-strip,
.quiz-actions,
.learn-cues {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--brand-blue), var(--brand-blue-dark));
  color: #fff;
  box-shadow: 0 14px 34px rgba(8, 63, 117, 0.24);
}

.brand-mark img {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.eyebrow,
.prompt-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  max-width: 220px;
  font-size: 1.16rem;
  line-height: 1.15;
}

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
}

.panel-row {
  justify-content: space-between;
  gap: 12px;
}

.panel-row.small {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.meter {
  height: 9px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebe7;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-gold));
  transition: width 180ms ease;
}

.field-label {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  height: 42px;
  margin-bottom: 14px;
  padding: 0 12px;
}

.toggle-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.action-panel {
  display: grid;
  gap: 10px;
}

.study-area {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(320px, 1fr) auto auto auto;
  gap: 18px;
  padding: 34px;
  overflow: hidden;
}

.study-area::before {
  content: "";
  position: absolute;
  inset: 20px 20px auto auto;
  width: min(34vw, 420px);
  aspect-ratio: 1;
  opacity: 0.42;
  background-image:
    linear-gradient(90deg, rgba(12, 95, 168, 0.11) 1px, transparent 1px),
    linear-gradient(rgba(244, 165, 28, 0.16) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(135deg, #000, transparent 72%);
  pointer-events: none;
}

.topbar {
  position: relative;
  z-index: 1;
  justify-content: space-between;
  gap: 18px;
}

.topbar h2 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(1.4rem, 2.4vw, 2.35rem);
  line-height: 1.13;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 178px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
}

.mode-switch button {
  min-height: 34px;
  border: 0;
  background: transparent;
}

.session-strip {
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
  gap: 10px;
}

.session-strip span,
.learn-cues span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid rgba(12, 95, 168, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.session-strip span {
  padding: 0 12px;
}

.card-stage {
  display: grid;
  place-items: center;
  perspective: 1400px;
}

.flashcard {
  position: relative;
  width: min(780px, 100%);
  min-height: 420px;
  transform-style: preserve-3d;
  transition: transform 260ms ease;
  outline: none;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 420px;
  padding: clamp(28px, 6vw, 58px);
  border: 1px solid rgba(217, 222, 216, 0.96);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(241, 247, 252, 0.95)),
    linear-gradient(180deg, rgba(244, 165, 28, 0.14), transparent 26%);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
}

.card-back {
  transform: rotateY(180deg);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(232, 243, 251, 0.96)),
    linear-gradient(180deg, rgba(12, 95, 168, 0.13), transparent 28%);
}

.card-face::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 7px;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-gold));
}

.card-meta {
  position: absolute;
  top: 22px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.card-face h3 {
  margin-bottom: 18px;
  font-size: clamp(1.55rem, 3vw, 2.8rem);
  line-height: 1.08;
}

.card-front h3 {
  color: var(--brand-blue-dark);
}

.card-back h3 {
  color: var(--ink);
}

.scenario {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.2vw, 1.12rem);
  line-height: 1.55;
}

.learn-cues {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.learn-cues span {
  padding: 0 11px;
}

.quiz-panel {
  position: relative;
  z-index: 1;
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 36px rgba(8, 63, 117, 0.09);
}

.quiz-panel textarea {
  min-height: 92px;
  margin-bottom: 12px;
  padding: 12px;
  resize: vertical;
  line-height: 1.45;
}

.quiz-actions {
  justify-content: flex-end;
  gap: 10px;
}

.quiz-actions button {
  min-width: 128px;
}

.controls,
.rating-row {
  position: relative;
  z-index: 1;
  justify-content: center;
  gap: 12px;
}

.controls button {
  min-width: 118px;
}

.rating-row button {
  min-width: 112px;
}

.rating-row button[data-rating="again"] {
  border-color: rgba(187, 77, 95, 0.38);
}

.rating-row button[data-rating="mastered"] {
  border-color: rgba(12, 95, 168, 0.4);
}

.empty-state {
  position: absolute;
  inset: 50%;
  width: min(420px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .study-area {
    min-height: 680px;
    padding: 24px 16px 30px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .mode-switch {
    width: 100%;
  }

  .session-strip {
    gap: 8px;
  }

  .flashcard,
  .card-face {
    min-height: 390px;
  }

  .controls,
  .rating-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .controls button,
  .rating-row button {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .sidebar {
    padding: 18px 16px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .card-meta {
    position: static;
    margin-bottom: 28px;
  }

  .card-face {
    padding: 24px;
  }

  .controls,
  .rating-row {
    gap: 8px;
  }

  .quiz-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .quiz-actions button {
    min-width: 0;
  }
}
