:root {
  color-scheme: light;
  --ink: #202328;
  --muted: #667078;
  --paper: #f7f4ea;
  --surface: #ffffff;
  --line: #ded8c8;
  --green: #1f7a5d;
  --green-dark: #145640;
  --red: #c44438;
  --yellow: #f3c64e;
  --blue: #2e6f9f;
  --shadow: 0 18px 50px rgba(28, 32, 34, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Hiragino Sans", Meiryo, system-ui, sans-serif;
  line-height: 1.6;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.hero {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  background: #1f2a2d;
  color: #fff;
}

.hero-media {
  position: absolute;
  inset: 0;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(90deg, rgba(13, 20, 23, 0.82), rgba(13, 20, 23, 0.5) 48%, rgba(13, 20, 23, 0.12)),
    linear-gradient(0deg, rgba(13, 20, 23, 0.6), transparent 38%);
}

.topbar,
.hero-copy,
main {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
}

.grade-tabs,
.hero-actions,
.exam-actions,
.form-actions,
.bank-actions {
  display: flex;
  align-items: center;
}

.grade-tabs {
  gap: 8px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.grade-tabs-large {
  flex: 0 0 auto;
  align-self: flex-start;
  gap: 10px;
  padding: 8px;
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
}

.grade-tab {
  min-width: 52px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.grade-tabs-large .grade-tab {
  min-width: 70px;
  min-height: 54px;
  font-size: 1.18rem;
}

.grade-tab.is-active {
  background: #fff;
  color: var(--green-dark);
}

.grade-tab.is-locked {
  cursor: not-allowed;
}

.hero-copy {
  width: min(1160px, calc(100% - 32px));
  margin: 110px auto 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--yellow);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  max-width: 720px;
  line-height: 0.98;
}

.title-kicker,
.title-grade {
  display: block;
}

.title-kicker {
  font-size: clamp(2.25rem, 5.4vw, 4.65rem);
  font-weight: 900;
}

.title-grade {
  margin-top: 10px;
  font-size: clamp(3rem, 7.6vw, 6.25rem);
  font-weight: 900;
}

.title-row {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.lead {
  max-width: 620px;
  margin: 22px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.08rem;
}

.grade-overview {
  display: grid;
  gap: 6px;
  max-width: 680px;
  margin-top: 18px;
  border-left: 5px solid var(--yellow);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 14px 16px;
}

.grade-overview strong {
  color: #fff;
  font-size: 1.05rem;
}

.grade-overview span {
  color: rgba(255, 255, 255, 0.86);
}

.hero-actions {
  gap: 12px;
  margin-top: 30px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border-radius: 8px;
  min-height: 42px;
  border: 0;
  text-decoration: none;
  font-weight: 800;
}

.primary-button {
  display: inline-grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  padding: 0 18px;
}

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

.secondary-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 16px;
}

.hero .secondary-button {
  border-color: rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.text-button {
  background: transparent;
  color: var(--green-dark);
  padding: 0 4px;
}

.icon-button {
  display: grid;
  width: 38px;
  place-items: center;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--ink);
  font-size: 1.2rem;
}

main {
  width: min(1160px, calc(100% - 32px));
  margin: -58px auto 64px;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.summary-band div {
  min-width: 0;
  background: #fffdf7;
  padding: 18px 20px;
}

.summary-band strong,
.summary-band span {
  display: block;
}

.summary-band strong {
  color: var(--green-dark);
  font-size: 1.65rem;
}

.summary-band span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.exam-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  margin-top: 24px;
  align-items: start;
}

.exam-main,
.result-panel,
.editor-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.exam-main,
.result-panel {
  padding: 24px;
}

.result-panel {
  position: sticky;
  top: 18px;
}

.section-heading {
  margin-bottom: 20px;
}

.section-heading h2,
.result-panel h2 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.25;
}

.editor-summary {
  display: grid;
  gap: 4px;
  margin: 10px 0 0;
  color: var(--muted);
}

.editor-summary strong {
  color: var(--ink);
}

.question-list {
  display: grid;
  gap: 16px;
}

.question-card {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: #fffdf7;
}

.question-card legend {
  padding: 0 8px;
  font-weight: 800;
}

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

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  color: var(--ink);
}

.choice input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.choice span {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: #edf3f5;
  color: var(--blue);
  font-weight: 900;
}

.choice strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.feedback {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.empty-state {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--muted);
  padding: 28px;
  text-align: center;
  font-weight: 700;
}

.question-card.is-correct {
  border-left-color: var(--green);
}

.question-card.is-wrong {
  border-left-color: var(--red);
}

.exam-actions {
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.result-panel p:not(.eyebrow) {
  margin: 12px 0 0;
  color: var(--muted);
}

.score-meter {
  height: 14px;
  overflow: hidden;
  margin-top: 20px;
  border-radius: 999px;
  background: #eee7d6;
}

.score-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  transition: width 240ms ease;
}

.certificate {
  margin-top: 22px;
  background: #fff8df;
  border: 1px solid #d9b85b;
  border-radius: 8px;
  padding: 10px;
}

.cert-border {
  display: grid;
  min-height: 220px;
  place-items: center;
  text-align: center;
  border: 2px solid #d9b85b;
  border-radius: 6px;
  padding: 18px;
}

.cert-border p {
  margin: 0;
  color: var(--red);
  font-size: 1.8rem;
  font-weight: 900;
}

.cert-border h3 {
  margin: 2px 0;
  font-size: 1.45rem;
}

.cert-border strong {
  font-size: 1.25rem;
}

.cert-border span,
.cert-border small {
  color: var(--muted);
  font-weight: 700;
}

.editor-section {
  margin-top: 24px;
  padding: 24px;
}

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

.question-form,
.question-bank {
  display: grid;
  gap: 12px;
}

label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 93, 0.16);
}

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

.form-actions {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.status-message {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.bank-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 16px;
}

.bank-item h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.bank-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.bank-actions {
  flex: 0 0 auto;
  gap: 8px;
}

.admin-page {
  background: var(--paper);
}

.admin-header {
  background: #1f2a2d;
  color: #fff;
  padding-bottom: 42px;
}

.admin-copy {
  width: min(1160px, calc(100% - 32px));
  margin: 52px auto 0;
}

.admin-copy h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4.4rem);
  line-height: 1.08;
}

.admin-copy p:not(.eyebrow) {
  max-width: 720px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.84);
}

.admin-grade-tabs {
  width: fit-content;
  margin-top: 22px;
}

.admin-main {
  margin-top: 24px;
}

.admin-main .editor-section {
  margin-top: 0;
}

.admin-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

@media (max-width: 920px) {
  .hero {
    min-height: 560px;
  }

  .hero-copy {
    margin-top: 78px;
    transform: none;
  }

  .title-row {
    flex-direction: column;
  }

  .exam-layout,
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .grade-tabs {
    justify-content: space-between;
  }

  .grade-tab {
    flex: 1;
    min-width: 0;
  }

  .grade-tabs-large {
    width: 100%;
  }

  .hero h1 {
    line-height: 1.02;
  }

  .title-kicker {
    font-size: 2.3rem;
  }

  .title-grade {
    font-size: 3rem;
  }

  .hero-actions,
  .exam-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-band,
  .choices,
  .choice-grid {
    grid-template-columns: 1fr;
  }

  .bank-item {
    align-items: stretch;
    flex-direction: column;
  }
}
