:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --line: #d1d5db;
  --text: #111827;
  --muted: #4b5563;
  --blue: #2563eb;
  --green: #15803d;
  --red: #b91c1c;
  --yellow: #ca8a04;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled) {
  filter: brightness(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

button.danger {
  border-color: var(--red);
  background: #fff;
  color: var(--red);
}

button.warning {
  border-color: var(--yellow);
  background: #fef3c7;
  color: #713f12;
}

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

.view {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.is-hidden {
  display: none !important;
}

.title-view {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 320px);
  gap: 32px;
  align-items: center;
  min-height: calc(100vh - 64px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
}

h2 {
  margin: 0 0 12px;
}

h3 {
  margin: 8px 0;
}

.lead {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.2rem;
}

.button-grid {
  display: grid;
  gap: 12px;
}

.message {
  min-height: 24px;
  margin: 12px 0 0;
  font-weight: 700;
}

.message.info {
  color: var(--blue);
}

.message.success {
  color: var(--green);
}

.message.error {
  color: var(--red);
}

.message.warning {
  color: #854d0e;
}

.section-header,
.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

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

.stage-card,
.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.stage-card.is-locked {
  background: #f9fafb;
  color: var(--muted);
}

.stage-card-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.stage-number {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 800;
}

.status-badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.875rem;
  font-weight: 800;
}

.status-badge.success {
  background: #dcfce7;
  color: var(--green);
}

.status-badge.warning {
  background: #fef3c7;
  color: #854d0e;
}

.status-badge.muted {
  background: #e5e7eb;
  color: #4b5563;
}

dl {
  margin: 16px 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #eef2f7;
  padding: 8px 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 800;
}

.content-band,
.reflection-form {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.reflection-form {
  display: grid;
  gap: 14px;
}

.correct-structure-diagram {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: 8px 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.reflection-form label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

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

textarea {
  min-height: 78px;
  resize: vertical;
}

.result-shell .summary-card p {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
}

@media (max-width: 760px) {
  .title-view {
    grid-template-columns: 1fr;
    min-height: auto;
  }

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