:root {
  --bg: #f6fbfc;
  --surface: #ffffff;
  --surface-soft: #eaf8f7;
  --line: #d8e8ec;
  --text: #20313d;
  --muted: #667987;
  --primary: #4f8fd7;
  --primary-dark: #2f6fb8;
  --mint: #4fb6b2;
  --coral: #ee806f;
  --yellow: #f3c95f;
  --shadow: 0 12px 30px rgba(35, 76, 99, 0.11);
  --focus: rgba(79, 143, 215, 0.18);
  --success: #1c6b51;
  --warning: #8a6200;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  line-height: 1.6;
}

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

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 1180px;
  min-height: 68px;
  margin: 0 auto;
  padding: 0 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 34px;
  border-radius: 8px;
  background: var(--mint);
  color: #fff;
  font-size: 13px;
}

.main-nav {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.main-nav a {
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.main-nav a:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.user-area {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  background: #fff;
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.page-shell {
  max-width: 1180px;
  min-height: calc(100vh - 140px);
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 28px;
  align-items: center;
  min-height: 460px;
}

.hero h1,
.page-title h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero p {
  max-width: 620px;
  color: var(--muted);
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-weight: 800;
  letter-spacing: 0;
}

.hero-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.mini-card {
  min-height: 96px;
  padding: 18px;
  border-radius: 8px;
  background: var(--surface-soft);
  font-weight: 800;
}

.mini-card:nth-child(2) { background: #eef4ff; }
.mini-card:nth-child(3) { background: #fff6dc; }
.mini-card:nth-child(4) { background: #fff0ee; }
.mini-card:nth-child(5) { grid-column: 1 / -1; background: #f2efff; }

.section-grid,
.dashboard-grid,
.action-grid,
.stats-grid {
  display: grid;
  gap: 16px;
}

.section-grid,
.dashboard-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.action-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 20px;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.card,
.stat-card,
.auth-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card {
  padding: 20px;
}

.card h2,
.auth-card h1 {
  margin: 0 0 10px;
  line-height: 1.25;
  letter-spacing: 0;
}

.card p {
  margin: 0;
  color: var(--muted);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head h2 {
  margin: 0;
}

.action-card {
  display: block;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.action-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.stat-card {
  padding: 20px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 32px;
  line-height: 1;
}

.page-title {
  margin-bottom: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

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

.btn-ghost {
  background: transparent;
}

.btn-danger {
  border-color: #f1b2aa;
  background: #fff1ef;
  color: #b84236;
}

.btn-small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.btn-large {
  min-height: 48px;
  padding: 0 20px;
}

.auth-layout {
  display: grid;
  place-items: center;
  min-height: 560px;
}

.auth-card {
  width: min(100%, 480px);
  padding: 28px;
}

.form-stack,
.filter-form {
  display: grid;
  gap: 14px;
}

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

.form-grid .full,
.form-stack .full {
  grid-column: 1 / -1;
}

label span,
.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid var(--focus);
  border-color: var(--primary);
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
}

.checkbox-label span {
  margin: 0;
}

.link {
  color: var(--primary-dark);
  font-weight: 800;
}

.tool-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.tool-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 900;
  text-align: center;
  box-shadow: var(--shadow);
}

.tool-card.is-active {
  border-color: var(--primary);
  background: #eef6ff;
  color: var(--primary-dark);
}

.tool-card.is-muted {
  color: var(--muted);
  background: #f8fafb;
}

.lab-stage {
  display: block;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.lab-stage canvas {
  display: block;
  width: 100%;
}

.simulation-root {
  min-height: 360px;
}

.interactive-lab {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  gap: 16px;
}

.lab-main,
.lab-side,
.lab-controls {
  display: grid;
  gap: 14px;
  align-content: start;
}

.lab-control {
  display: grid;
  gap: 7px;
  margin: 0;
}

.lab-control strong {
  color: var(--primary-dark);
}

.lab-control input[type="range"] {
  min-height: 28px;
  padding: 0;
  accent-color: var(--primary);
}

.lab-result-card,
.lab-explain-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lab-result-card h3,
.lab-explain-card h3 {
  margin: 0 0 12px;
  letter-spacing: 0;
}

.lab-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.lab-metric:last-child {
  border-bottom: 0;
}

.lab-metric span {
  color: var(--muted);
  font-weight: 800;
}

.lab-metric strong,
.big-number {
  color: var(--primary-dark);
  font-size: 24px;
  font-weight: 900;
}

.problem-box {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.problem-box.is-correct {
  border-color: #a8d9c5;
  background: #f5fffb;
}

.problem-box.is-wrong {
  border-color: #f0c5a8;
  background: #fff8f1;
}

.result-list {
  display: grid;
  gap: 14px;
}

.progress-list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.progress-list li {
  display: grid;
  gap: 7px;
}

.progress-list li div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-soft);
}

progress::-webkit-progress-bar {
  background: var(--surface-soft);
}

progress::-webkit-progress-value {
  background: var(--mint);
}

progress::-moz-progress-bar {
  background: var(--mint);
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
}

.alert-success { border-color: #a8d9c5; background: #eefaf5; color: #1c6b51; }
.alert-error { border-color: #f0b6b0; background: #fff1ef; color: #a83d35; }
.alert-info { border-color: #b9d8ff; background: #eef6ff; color: #225f9f; }

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.clean-list,
.badge-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.clean-list li {
  display: grid;
  gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.clean-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.clean-list span {
  color: var(--muted);
  font-size: 14px;
}

.badge-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.pill-done {
  background: #eefaf5;
  color: #1c6b51;
}

.pill-warn {
  background: #fff6dc;
  color: #8a6200;
}

.site-footer {
  padding: 24px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  background: #fff;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 980px) {
  .nav-wrap {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
  }

  .main-nav {
    display: none;
    order: 4;
    flex: 1 0 100%;
    align-items: stretch;
    overflow: visible;
    padding-top: 8px;
  }

  .main-nav.is-open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-area {
    order: 3;
  }

  .hero,
  .two-column,
  .interactive-lab {
    grid-template-columns: 1fr;
  }

  .section-grid,
  .dashboard-grid,
  .action-grid,
  .stats-grid,
  .tool-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 22px 14px 42px;
  }

  .user-area {
    width: 100%;
    justify-content: space-between;
  }

  .user-chip {
    min-width: 0;
    flex: 1 1 auto;
  }

  .hero {
    min-height: auto;
  }

  .hero h1,
  .page-title h1 {
    font-size: 34px;
  }

  .hero-panel,
  .section-grid,
  .dashboard-grid,
  .action-grid,
  .stats-grid,
  .tool-strip,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .main-nav.is-open {
    grid-template-columns: 1fr;
  }

  .card,
  .auth-card,
  .stat-card {
    padding: 16px;
  }

  .inline-actions {
    align-items: stretch;
  }

  .inline-actions .btn,
  .inline-actions form,
  .inline-actions button {
    width: 100%;
  }
}
