:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #20242a;
  --muted: #68717d;
  --line: #d9dee6;
  --accent: #176c7a;
  --accent-strong: #0f4f5b;
  --accent-soft: #e4f4f6;
  --green: #167348;
  --red: #b23333;
  --yellow: #f3b33d;
  --shadow: 0 18px 50px rgba(26, 33, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 42px;
  line-height: 1;
}

h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

.topbar p,
.panel-head p,
.empty-state p {
  color: var(--muted);
}

.provider-pill {
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

.settings-panel,
.practice-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-panel {
  padding: 20px;
}

.settings-panel .panel-head {
  align-items: center;
  margin-bottom: 14px;
}

.settings-panel.is-collapsed .panel-head {
  margin-bottom: 0;
}

.settings-body {
  overflow: hidden;
}

.settings-panel.is-collapsed .settings-body {
  display: none;
}

.settings-toggle {
  min-width: 118px;
}

#settingsForm {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.settings-controls {
  grid-column: span 12;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
}

.settings-controls .field-row {
  width: min(240px, 100%);
}

.settings-controls .provider-field {
  width: min(360px, 100%);
}

#settingsForm .field-row {
  margin-bottom: 0;
}

#settingsForm fieldset {
  margin: 0;
}

#settingsForm fieldset:nth-of-type(1),
#settingsForm fieldset:nth-of-type(2),
#settingsForm fieldset:nth-of-type(3) {
  grid-column: span 12;
}

#settingsForm .primary-button {
  grid-column: span 12;
  align-self: end;
  justify-self: end;
  width: min(280px, 100%);
}

.practice-panel {
  min-height: 680px;
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

label,
legend {
  font-weight: 700;
}

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

input,
select {
  min-height: 40px;
  padding: 8px 10px;
}

textarea {
  min-height: 94px;
  padding: 12px;
  resize: vertical;
}

fieldset {
  margin: 18px 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

#topics.check-grid {
  grid-template-columns: 1fr;
}

.check-item {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  cursor: pointer;
}

.check-item input {
  width: 17px;
  min-height: 17px;
  accent-color: var(--accent);
}

.subchoice-group {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.subchoice-group.is-disabled {
  opacity: 0.5;
}

.subchoice-group.is-empty {
  border-color: #e2e6ec;
  background: #fafbfc;
}

.subchoice-group.is-partial {
  border-color: #e7c86c;
  background: #fffaf0;
}

.subchoice-group.is-complete {
  border-color: #9ac7bc;
  background: #f3fbf8;
}

.subchoice-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
}

.subchoice-count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  min-height: 24px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
}

.subchoice-group.is-empty .subchoice-count {
  background: #eef1f5;
  color: var(--muted);
}

.subchoice-group.is-partial .subchoice-count {
  background: #fff1c7;
  color: #71500b;
}

.subchoice-group.is-complete .subchoice-count {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.subchoice-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
}

.subchoice-body[hidden] {
  display: none;
}

.subchoice-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 5px 7px;
  border-radius: 5px;
  background: #f7f9fb;
  font-size: 13px;
  font-weight: 700;
}

.subchoice-item input {
  width: 15px;
  min-height: 15px;
  accent-color: var(--accent);
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
}

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

.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 360px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  text-align: center;
  padding: 24px;
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.tasks {
  display: grid;
  gap: 14px;
}

#practiceBody[hidden] {
  display: none;
}

.check-button {
  margin-top: 14px;
}

.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.task-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.badge {
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef1f5;
  color: #424b57;
  font-size: 12px;
  font-weight: 800;
}

.task-card h3 {
  margin-bottom: 10px;
  font-size: 17px;
  line-height: 1.35;
}

.task-card p {
  color: var(--muted);
}

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.option-item {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.option-item input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.results {
  margin-top: 18px;
}

.result-row {
  border-left: 4px solid var(--line);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fbfcfd;
}

.result-row.correct {
  border-left-color: var(--green);
}

.result-row.wrong {
  border-left-color: var(--red);
}

.result-row strong {
  display: block;
  margin-bottom: 4px;
}

.toast {
  border: 1px solid #f0d48a;
  border-radius: 6px;
  padding: 12px;
  background: #fff8e5;
  color: #674600;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

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

  #settingsForm {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  #settingsForm fieldset,
  #settingsForm fieldset:nth-of-type(1),
  #settingsForm fieldset:nth-of-type(2),
  #settingsForm fieldset:nth-of-type(3) {
    grid-column: span 6;
  }

  #settingsForm .primary-button {
    grid-column: span 6;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 34px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  #settingsForm {
    grid-template-columns: 1fr;
  }

  #settingsForm fieldset,
  #settingsForm fieldset:nth-of-type(1),
  #settingsForm fieldset:nth-of-type(2),
  #settingsForm fieldset:nth-of-type(3) {
    grid-column: span 1;
  }

  #settingsForm .primary-button {
    grid-column: span 1;
  }

  .settings-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .settings-controls .field-row {
    width: 100%;
  }

  .check-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
  }

  .ghost-button {
    width: 100%;
  }
}
