:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #f59e0b;
  --success: #16a34a;
  --error: #dc2626;
  --warning: #d97706;
  --text: #1e293b;
  --muted: #64748b;
  --line: #dbe4ef;
  --bg: #f8fafc;
  --card: #ffffff;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 38%, #eef5ff 100%);
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 28px clamp(16px, 5vw, 48px) 20px;
  max-width: 1180px;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.12;
  letter-spacing: 0;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.progress-pill {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  font-weight: 700;
}

.layout {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 40px;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 230px;
  gap: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls,
.stats {
  padding: 18px;
  align-self: start;
}

.question-panel {
  padding: clamp(18px, 4vw, 30px);
  min-height: 520px;
}

.control-row {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 120px;
  padding: 14px;
  resize: vertical;
  line-height: 1.6;
}

textarea:focus,
select:focus {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  border-color: var(--primary);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  color: var(--text);
}

.toggle input {
  width: 18px;
  height: 18px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  min-height: 44px;
  color: var(--text);
  background: #e2e8f0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  color: #fff;
  background: var(--primary);
}

button.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

button.secondary {
  color: #fff;
  background: #0f766e;
}

button.ghost {
  background: #f1f5f9;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.question-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-light);
  font-size: 12px;
  font-weight: 700;
}

.question-count {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 14px;
}

.question-panel h2 {
  margin: 0 0 18px;
  white-space: pre-wrap;
  font-size: clamp(19px, 3.4vw, 27px);
  line-height: 1.55;
  letter-spacing: 0;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
}

.word-bank span {
  padding: 7px 10px;
  border-radius: 7px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 700;
}

.hint-box,
.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  line-height: 1.7;
}

.hint-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
}

.feedback.correct {
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #14532d;
}

.feedback.wrong {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #7f1d1d;
}

.feedback.self {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
}

.feedback strong {
  display: block;
  margin-bottom: 6px;
}

.feedback ul {
  margin: 8px 0 0 20px;
  padding: 0;
}

.stats h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  font-weight: 800;
}

.note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .controls,
  .stats {
    order: initial;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding-top: 20px;
  }

  .layout {
    width: min(100% - 20px, 1180px);
    gap: 12px;
  }

  .question-panel {
    min-height: auto;
  }

  .button-row button {
    flex: 1 1 130px;
  }
}
