:root {
  --bg: #f7f2e8;
  --surface: rgba(255, 252, 246, 0.82);
  --surface-strong: #fffdfa;
  --text: #18222d;
  --muted: #5f6b73;
  --line: rgba(24, 34, 45, 0.12);
  --primary: #0f766e;
  --primary-deep: #134e4a;
  --accent: #c96f2d;
  --success: #18634d;
  --danger: #9c2f2f;
  --radius-lg: 28px;
  --radius-md: 18px;
  --shadow: 0 20px 40px rgba(64, 47, 18, 0.12);
  --font-main: "Pretendard Variable", "Noto Sans KR", "Segoe UI", sans-serif;
  --font-display: "SUIT Variable", "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-main);
  background:
    radial-gradient(circle at top left, rgba(201, 111, 45, 0.22), transparent 28%),
    radial-gradient(circle at right 20%, rgba(15, 118, 110, 0.18), transparent 24%),
    linear-gradient(180deg, #fbf7f0 0%, #f7f2e8 45%, #efe5d4 100%);
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.page-heading h1,
.section-head h2,
.question-card h2,
.manager-card h2 {
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.content {
  padding-top: 0;
}

.global-actions,
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.page-heading {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 20px;
  align-items: stretch;
}

.page-heading > div:first-child,
.summary-band,
.exam-card,
.subject-card,
.question-card,
.empty-state,
.manager-card,
.flash-banner {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.page-heading h1 {
  margin: 10px 0 14px;
  font-size: clamp(2.1rem, 5vw, 4.2rem);
  line-height: 1.04;
}

.compact-heading h1,
.manager-header h2 {
  margin: 0;
}

.muted {
  color: var(--muted);
  line-height: 1.65;
}

.summary-band {
  display: grid;
  gap: 14px;
  align-content: center;
}

.summary-band > div,
.stats-row > div {
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  border: 1px solid rgba(24, 34, 45, 0.08);
}

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

.summary-band span,
.stats-row span {
  color: var(--muted);
  font-size: 0.92rem;
}

.summary-band strong,
.stats-row strong {
  margin-top: 8px;
  font-size: 1.4rem;
}

.section-head {
  margin: 36px 0 18px;
}

.eyebrow {
  margin: 0;
  color: var(--primary-deep);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.section-head h2,
.exam-card h3,
.subject-card h3,
.manager-card h2 {
  margin: 10px 0 8px;
}

.subject-card h3 {
  margin: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.manager-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.stats-row,
.chip-row,
.question-header,
.form-actions,
.filter-bar,
.choice-grid,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.card-actions,
.question-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-actions form {
  margin: 0;
}

.subject-actions {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

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

.subject-actions .button {
  width: 100%;
}

.subject-primary-actions .button {
  min-height: 52px;
  padding: 14px 18px;
  font-size: 1rem;
}

.subject-secondary-actions {
  gap: 10px;
}

.subject-secondary-actions .button {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.92rem;
  font-weight: 600;
}

.stats-row {
  margin: 20px 0;
}

.stats-row > div {
  flex: 1;
  min-width: 96px;
  background: rgba(15, 118, 110, 0.08);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary) 0%, #169288 100%);
  color: white;
  font-family: var(--font-main);
  line-height: 1.2;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(15, 118, 110, 0.2);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button.secondary {
  background: white;
  color: var(--primary-deep);
  border: 1px solid rgba(15, 118, 110, 0.18);
}

.button.secondary:hover {
  box-shadow: 0 14px 24px rgba(15, 118, 110, 0.08);
}

.button.secondary.danger-outline {
  color: var(--danger);
  border-color: rgba(156, 47, 47, 0.18);
}

.button.secondary.danger-outline:hover {
  box-shadow: 0 14px 24px rgba(156, 47, 47, 0.08);
}

.button.danger {
  background: linear-gradient(135deg, #b23b3b 0%, #8f2424 100%);
}

.button.danger:hover {
  box-shadow: 0 14px 24px rgba(156, 47, 47, 0.2);
}

.chip,
.badge,
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  font-family: var(--font-main);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.1;
  border: 1px solid rgba(24, 34, 45, 0.08);
  background: rgba(255, 255, 255, 0.78);
}

.subject-card .chip-row {
  margin-top: 14px;
  margin-bottom: 4px;
}

.home-exam-card {
  display: grid;
  gap: 24px;
  align-content: start;
}

.home-exam-title {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.08;
}

.home-exam-stats {
  margin: 0;
  gap: 14px;
}

.home-exam-stats > div {
  min-width: 120px;
  padding: 22px 20px;
}

.home-exam-stats span {
  font-size: 0.98rem;
}

.home-exam-stats strong {
  margin-top: 10px;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.home-exam-actions {
  display: grid;
  gap: 12px;
}

.home-exam-actions form {
  margin: 0;
}

.home-open-button {
  min-height: 58px;
  font-size: 1.02rem;
}

.home-exam-actions .button {
  width: 100%;
}

.chip.strong,
.filter-chip.active {
  background: var(--primary-deep);
  color: white;
}

.filter-bar {
  margin: 20px 0 18px;
}

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid rgba(24, 34, 45, 0.1);
  background: rgba(255, 255, 255, 0.78);
  font-weight: 700;
  color: var(--muted);
}

.tab-link.active {
  background: var(--primary-deep);
  color: white;
}

.filter-chip {
  color: var(--muted);
}

.manager-card,
.flash-banner {
  margin-top: 24px;
}

.manager-card + .card-grid,
.flash-banner + .card-grid {
  margin-top: 24px;
}

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

.flash-banner {
  background: rgba(24, 99, 77, 0.1);
  border-color: rgba(24, 99, 77, 0.18);
  color: var(--success);
  font-weight: 700;
}

.flash-banner.warning {
  background: rgba(156, 47, 47, 0.1);
  border-color: rgba(156, 47, 47, 0.18);
  color: var(--danger);
}

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

.progress-block,
.score-grid,
.review-list {
  margin-top: 24px;
}

.progress-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(24, 34, 45, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  transition: width 180ms ease;
}

.exam-mode-card {
  margin-top: 20px;
}

.exam-mode-form {
  margin-top: 22px;
}

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

.score-card,
.review-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.score-card span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.score-card strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.review-list {
  display: grid;
  gap: 18px;
}

.review-card.correct {
  border-color: rgba(24, 99, 77, 0.22);
}

.review-card.incorrect {
  border-color: rgba(156, 47, 47, 0.22);
}

.review-card.review {
  border-color: rgba(138, 90, 18, 0.22);
}

.review-card h3 {
  margin: 16px 0 14px;
  font-size: 1.15rem;
}

.review-card p {
  margin: 10px 0 0;
  line-height: 1.65;
}

.correct-chip {
  background: rgba(24, 99, 77, 0.12);
  color: var(--success);
  border-color: rgba(24, 99, 77, 0.18);
}

.danger-chip {
  background: rgba(156, 47, 47, 0.12);
  color: var(--danger);
  border-color: rgba(156, 47, 47, 0.18);
}

.review-chip {
  background: rgba(138, 90, 18, 0.12);
  color: #8a5a12;
  border-color: rgba(138, 90, 18, 0.18);
}

.result-actions {
  margin-top: 24px;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 34, 45, 0.42);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(520px, calc(100% - 24px));
  margin: min(12vh, 96px) auto 0;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.question-card h2 {
  margin: 18px 0 20px;
  font-size: 1.35rem;
}

.answer-form input[type="text"],
.answer-form textarea,
.editor-form input[type="text"],
.editor-form textarea,
.editor-form select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(24, 34, 45, 0.12);
  border-radius: var(--radius-md);
  background: white;
  color: var(--text);
  font: inherit;
}

.answer-form textarea,
.editor-form textarea {
  resize: vertical;
}

.answer-form textarea {
  min-height: 132px;
}

.choice-stack {
  display: grid;
  gap: 10px;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(24, 34, 45, 0.12);
  border-radius: var(--radius-md);
  background: white;
  cursor: pointer;
}

.choice.wide {
  width: 100%;
}

.choice input {
  accent-color: var(--primary);
}

.form-actions {
  margin-top: 16px;
}

.result-panel {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  line-height: 1.65;
  white-space: pre-line;
}

.result-panel.correct {
  background: rgba(24, 99, 77, 0.1);
  border-color: rgba(24, 99, 77, 0.18);
}

.result-panel.incorrect {
  background: rgba(156, 47, 47, 0.1);
  border-color: rgba(156, 47, 47, 0.18);
}

.result-panel.partial,
.result-panel.review,
.result-panel.warning {
  background: rgba(138, 90, 18, 0.1);
  border-color: rgba(138, 90, 18, 0.18);
}

.empty-state {
  text-align: center;
}

.editor-shell {
  border: 1px solid rgba(24, 34, 45, 0.1);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.45);
  overflow: hidden;
}

.editor-shell + .editor-shell {
  margin-top: 18px;
}

.editor-shell:last-child {
  margin-top: 18px;
}

.editor-toggle {
  cursor: pointer;
  list-style: none;
  padding: 18px 22px;
  font-weight: 700;
  background: rgba(15, 118, 110, 0.08);
}

.editor-toggle::-webkit-details-marker {
  display: none;
}

.editor-form,
.inline-delete-form,
.question-meta {
  padding: 20px 22px 22px;
}

.simple-form {
  padding: 0;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-weight: 700;
}

.field.full {
  grid-column: 1 / -1;
}

.inline-delete-form {
  padding-top: 0;
}

.top-delete-form {
  padding: 0;
  margin: 0;
}

@media (max-width: 880px) {
  .page-heading,
  .manager-grid,
  .manager-header,
  .editor-fields {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 600px) {
  .page-shell {
    width: min(100% - 20px, 1160px);
  }

  .subject-primary-actions,
  .subject-secondary-actions {
    grid-template-columns: 1fr;
  }

  .page-heading > div:first-child,
  .summary-band,
  .exam-card,
  .subject-card,
  .question-card,
  .empty-state,
  .manager-card,
  .flash-banner {
    padding: 22px;
  }

  .page-heading h1 {
    font-size: 2rem;
  }
}
