:root {
  color-scheme: light;
  --bg: #f3f5f6;
  --panel: #ffffff;
  --ink: #1d252b;
  --muted: #64717b;
  --border: #d5dde2;
  --border-strong: #9facb5;
  --accent: #c81924;
  --accent-dark: #9d111a;
  --accent-soft: #f8e8ea;
  --teal: #126b78;
  --green: #177245;
  --amber: #8d621d;
  --red-soft: #fbebed;
  --green-soft: #edf7f1;
  --blue-soft: #edf4f6;
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-rule {
  width: 4px;
  height: 34px;
  display: block;
  border-radius: 2px;
  background: var(--accent);
}

.brand-name,
.brand-subtitle {
  display: block;
}

.brand-name {
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.workspace {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(220px, 270px) minmax(0, 1fr);
  gap: 28px;
  flex: 1;
}

.subject-panel,
.study-panel {
  min-width: 0;
}

.subject-panel {
  align-self: start;
  padding-right: 24px;
  border-right: 1px solid var(--border);
}

.panel-heading,
.study-topline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-heading {
  align-items: center;
  margin-bottom: 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #46525b;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h2 {
  margin-top: 2px;
  font-size: clamp(1.45rem, 2vw, 1.85rem);
  line-height: 1.15;
}

.muted,
.deck-meta {
  color: var(--muted);
}

.deck-meta {
  font-size: 0.88rem;
}

.subject-list {
  display: grid;
  gap: 4px;
}

.subject-button {
  width: 100%;
  min-height: 58px;
  display: block;
  text-align: left;
  padding: 9px 10px 9px 12px;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
}

.subject-button:hover,
.subject-button:focus-visible {
  background: #ffffff;
  border-color: var(--border);
  border-left-color: var(--border-strong);
  outline: none;
}

.subject-button.active {
  background: #ffffff;
  border-color: var(--border);
  border-left-color: var(--accent);
}

.subject-name {
  display: block;
  font-weight: 760;
  margin-bottom: 4px;
}

.subject-info {
  color: var(--muted);
  font-size: 0.86rem;
}

.study-panel {
  min-height: 560px;
  padding: 0;
}

.study-topline {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.progress-summary {
  min-width: 160px;
  text-align: right;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.topic-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.topic-filters:empty {
  display: none;
}

.topic-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 720;
}

.topic-button:hover,
.topic-button:focus-visible {
  border-color: var(--border-strong);
  outline: none;
}

.topic-button.active {
  background: var(--blue-soft);
  border-color: #9fbac1;
  color: #204b55;
}

.topic-count {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.card-area {
  margin-top: 18px;
}

.flashcard {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: white;
}

.card-header,
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #f8fafb;
}

.card-header {
  border-bottom: 1px solid var(--border);
}

.card-footer {
  border-top: 1px solid var(--border);
}

.type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #46525b;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.card-position {
  color: var(--muted);
  font-size: 0.9rem;
}

.card-content {
  padding: 22px 18px;
}

.prompt {
  font-size: 1.08rem;
  line-height: 1.65;
}

.answer-block,
.explanation-block,
.feedback-block {
  margin-top: 18px;
  padding: 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.answer-block {
  background: #fafafa;
}

.explanation-block {
  background: #fff9eb;
  border-color: #e5cf94;
}

.feedback-block.correct {
  background: var(--green-soft);
  border-color: #afd9bf;
  color: #0e5b34;
}

.feedback-block.incorrect {
  background: var(--red-soft);
  border-color: #efb3b8;
  color: #8f111a;
}

.block-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.choice-button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 12px;
  font-weight: 720;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:disabled,
.ghost-button:disabled,
.choice-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-dark);
  outline: none;
}

.ghost-button,
.choice-button {
  background: white;
  color: var(--ink);
  border-color: var(--border);
}

.ghost-button:hover,
.ghost-button:focus-visible,
.choice-button:hover,
.choice-button:focus-visible {
  border-color: var(--border-strong);
  outline: none;
}

.choice-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.choice-option {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fbfcfd;
}

.choice-option input {
  margin: 4px 0 0;
  accent-color: var(--accent);
}

.choice-option.correct-choice {
  background: var(--green-soft);
  border-color: #9fd3b4;
}

.choice-option.wrong-choice {
  background: var(--red-soft);
  border-color: #ecadb3;
}

.true-false-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.choice-button.selected {
  background: var(--blue-soft);
  border-color: #9fbac1;
  color: #204b55;
}

.rich-text {
  overflow-wrap: anywhere;
}

.rich-text > * + * {
  margin-top: 0.8em;
}

.rich-text p,
.rich-text ul,
.rich-text ol {
  line-height: 1.65;
}

.rich-text ul,
.rich-text ol {
  padding-left: 1.3rem;
}

.rich-text code {
  padding: 0.12em 0.32em;
  border-radius: 4px;
  background: #eef2f4;
}

.empty-state,
.error-state {
  min-height: 320px;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  color: var(--muted);
}

.error-state {
  color: #8f111a;
  background: var(--red-soft);
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    padding: 14px 16px;
    flex-direction: column;
  }

  .header-actions,
  .actions {
    width: 100%;
  }

  .header-actions > button,
  .actions > button {
    flex: 1 1 130px;
  }

  .workspace {
    padding: 16px;
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .subject-panel {
    padding-right: 0;
    border-right: 0;
  }

  .study-panel {
    min-height: auto;
    padding: 0;
  }

  .study-topline {
    display: block;
  }

  .progress-summary {
    margin-top: 12px;
    text-align: left;
  }

  .card-header,
  .card-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
