:root {
  --ink: #111827;
  --muted: #5b6472;
  --line: #d7dce5;
  --paper: #f7f8fb;
  --panel: #ffffff;
  --blue: #2458d3;
  --blue-dark: #173f9b;
  --green: #12805c;
  --amber: #b45f06;
  --rose: #b42318;
  --shadow: 0 18px 55px rgba(18, 28, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  cursor: pointer;
}

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

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 2;
}

.brand-row,
.stage-toolbar,
.stage-actions,
.brand-actions,
.action-row,
.field-row,
.speech-tools {
  display: flex;
  align-items: center;
}

.brand-row,
.stage-toolbar {
  justify-content: space-between;
  gap: 18px;
}

.brand-actions {
  gap: 10px;
}

.field-row {
  gap: 14px;
}

.field {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
}

.field.wide {
  width: 100%;
}

.field span,
.kicker {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1;
}

h2 {
  font-size: clamp(28px, 4vw, 56px);
  line-height: 1.02;
}

input,
select,
textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  outline: none;
  padding: 13px 14px;
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
}

input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--blue);
  flex: 0 0 auto;
  padding: 0;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.check-card {
  display: flex;
  align-items: center;
  min-height: 58px;
  gap: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #f9fafc;
  padding: 10px 12px;
}

.check-card:has(input:checked) {
  border-color: var(--blue);
  background: #e8eefb;
}

.check-card span {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: none;
}

.icon-button,
.toolbar-icon,
.rate-button,
.speak-button,
.primary-button,
.secondary-button,
.answer-toggle,
.big-play-button,
.inline-rate {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.icon-button {
  width: 58px;
  background: var(--ink);
  color: #fff;
  font-size: 22px;
}

.settings-button {
  background: #e8eefb;
  color: var(--blue-dark);
}

.action-row {
  gap: 12px;
}

.primary-button,
.secondary-button {
  flex: 1;
  padding: 14px 16px;
  font-size: 18px;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.secondary-button {
  background: #e8eefb;
  color: var(--blue-dark);
}

.status {
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 30px;
  gap: 24px;
}

.stage-toolbar {
  min-height: 82px;
}

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

.toolbar-generate {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  padding: 12px 20px;
}

.toolbar-generate:hover {
  background: var(--blue-dark);
}

.toolbar-icon {
  width: 58px;
  background: #e8eefb;
  color: var(--blue-dark);
  font-size: 22px;
}

.speech-tools {
  display: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.speech-tools.visible {
  display: flex;
}

.rate-button {
  min-width: 72px;
  background: #e6eaf1;
  color: var(--ink);
  padding: 10px 12px;
}

.rate-button.active {
  background: var(--green);
  color: #fff;
}

.speak-button {
  min-width: 120px;
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
}

.listening-player {
  display: grid;
  gap: 14px;
  border: 4px solid var(--green);
  border-radius: 8px;
  background: #eaf8f2;
  padding: 18px;
}

.big-play-button {
  width: 100%;
  min-height: 96px;
  background: var(--green);
  color: #fff;
  font-size: clamp(34px, 5vw, 72px);
  line-height: 1;
}

.rate-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.rate-strip span {
  color: var(--ink);
  font-size: clamp(20px, 2vw, 30px);
  font-weight: 900;
}

.inline-rate {
  min-width: 98px;
  background: #d9efe7;
  color: var(--ink);
  font-size: clamp(20px, 2.2vw, 32px);
  padding: 10px 16px;
}

.inline-rate.active {
  background: var(--ink);
  color: #fff;
}

.content-area {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: clamp(22px, 3vw, 42px);
}

.empty-state {
  display: grid;
  place-content: center;
  min-height: 58vh;
  gap: 12px;
  text-align: center;
}

.empty-state strong {
  font-size: clamp(40px, 7vw, 84px);
  line-height: 1;
}

.empty-state span {
  color: var(--muted);
  font-size: clamp(22px, 3vw, 36px);
  font-weight: 800;
}

.practice-view {
  display: grid;
  gap: 24px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  border-radius: 999px;
  background: #edf1f7;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  padding: 10px 16px;
}

.prompt-text,
.passage,
.structure-box {
  font-size: clamp(30px, 4.2vw, 60px);
  font-weight: 900;
  line-height: 1.2;
}

.passage {
  font-size: clamp(28px, 3.4vw, 48px);
}

.question-list {
  display: grid;
  gap: 20px;
  counter-reset: question;
}

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

.question-stack {
  grid-template-columns: 1fr;
}

.question-item {
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 3px solid var(--line);
  border-radius: 8px;
  counter-increment: question;
}

.question-text {
  font-size: clamp(28px, 3.4vw, 48px);
  font-weight: 900;
  line-height: 1.18;
}

.question-columns .question-text,
.reading-questions .question-text {
  font-size: clamp(24px, 2.6vw, 38px);
}

.question-text::before {
  content: counter(question) ". ";
  color: var(--blue);
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #f9fafc;
  color: var(--ink);
  font-size: clamp(22px, 2.4vw, 36px);
  font-weight: 900;
  line-height: 1.15;
  padding: 15px 18px;
  text-align: left;
}

.option-label {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

.question-columns .option,
.reading-questions .option {
  min-height: 62px;
  font-size: clamp(20px, 2vw, 30px);
}

.reading-questions .option-label,
.question-columns .option-label {
  width: 36px;
  height: 36px;
  font-size: 19px;
}

.cloze-passage {
  white-space: pre-wrap;
}

.option.correct.show-answer,
.short-answer.show-answer {
  border-color: var(--green);
  background: #eaf8f2;
}

.short-answer {
  border: 2px dashed var(--line);
  border-radius: 8px;
  color: var(--green);
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 900;
  visibility: hidden;
  padding: 16px;
}

.short-answer.show-answer {
  visibility: visible;
}

.answer-toggle {
  justify-self: start;
  background: var(--amber);
  color: #fff;
  font-size: 20px;
  padding: 10px 16px;
}

.section-title {
  color: var(--rose);
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 900;
}

.reading-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
  gap: 22px;
  align-items: start;
}

.reading-passage,
.reading-questions {
  min-width: 0;
}

.reading-passage {
  position: sticky;
  top: 0;
  max-height: calc(100vh - 190px);
  overflow: auto;
  border-right: 4px solid var(--line);
  padding-right: 22px;
}

.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.vocab-item {
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  font-size: clamp(22px, 2.4vw, 34px);
  font-weight: 900;
}

.loading {
  display: grid;
  min-height: 52vh;
  place-items: center;
  color: var(--blue);
  font-size: clamp(36px, 6vw, 86px);
  font-weight: 900;
  text-align: center;
}

.error-box {
  border-left: 8px solid var(--rose);
  background: #fff2f0;
  border-radius: 8px;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 900;
  line-height: 1.25;
  padding: 24px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 20;
  background: rgba(17, 24, 39, 0.62);
  padding: 22px;
}

.modal-backdrop.visible {
  display: grid;
}

.settings-modal {
  display: grid;
  width: min(720px, 100%);
  gap: 20px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: clamp(22px, 3vw, 34px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.settings-note {
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
}

.settings-note strong {
  color: var(--ink);
}

body.fullscreen-mode .app-shell {
  grid-template-columns: 1fr;
}

body.fullscreen-mode .control-panel {
  display: none;
}

body.fullscreen-mode .stage {
  padding: 18px;
}

body.fullscreen-mode .content-area {
  max-height: calc(100vh - 124px);
}

body.fullscreen-mode .reading-passage {
  max-height: calc(100vh - 150px);
}

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

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

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

  .stage-actions {
    justify-content: flex-start;
  }

  .speech-tools {
    justify-content: flex-start;
  }

  .question-columns,
  .option-grid,
  .reading-layout {
    grid-template-columns: 1fr;
  }

  .reading-passage {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 4px solid var(--line);
    padding-right: 0;
    padding-bottom: 20px;
  }

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

@media (max-width: 560px) {
  .control-panel,
  .stage {
    padding: 18px;
  }

  .field-row,
  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  h1 {
    font-size: 28px;
  }
}
