:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --danger: #c2410c;
  --danger-bg: #fff7ed;
  --success-bg: #ecfdf3;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

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

.hero {
  margin-bottom: 22px;
  text-align: center;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.85rem, 4vw, 2.8rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.25rem;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.card {
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.card-header p,
.footer,
.info-muted,
.notice-list {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 0.95rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
  outline: none;
}

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

.primary-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

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

.secondary-button {
  flex: 0 0 auto;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #344054;
  cursor: pointer;
  padding: 0 12px;
  font-weight: 800;
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.message:empty {
  display: none;
}

.hidden {
  display: none;
}

.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.result-heading h2 {
  margin-bottom: 0;
}

.grade-badge {
  flex: 0 0 auto;
  min-width: 116px;
  padding: 14px 18px;
  border-radius: 8px;
  background: var(--success-bg);
  color: #027a48;
  text-align: center;
  font-size: 1.55rem;
  font-weight: 900;
}

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

.result-item {
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.result-item span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.result-item strong {
  font-size: 1.45rem;
}

.cutoff-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.cutoff-table {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.cutoff-cell {
  padding: 12px;
  text-align: center;
  background: #fff;
}

.cutoff-cell + .cutoff-cell {
  border-left: 1px solid var(--line);
}

.cutoff-cell span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.cutoff-cell strong {
  display: block;
  margin-top: 4px;
}

.history-header {
  align-items: flex-start;
}

.empty-state {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  padding: 22px;
  text-align: center;
  font-weight: 700;
}

.chart-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chart-wrap canvas {
  display: block;
  min-width: 520px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.history-item strong {
  display: block;
  margin-bottom: 4px;
}

.history-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.diff-badge {
  flex: 0 0 auto;
  min-width: 68px;
  padding: 7px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 900;
}

.diff-badge.up {
  background: #dcfce7;
  color: #15803d;
}

.diff-badge.down {
  background: #fee2e2;
  color: #b91c1c;
}

.diff-badge.same {
  background: #e5e7eb;
  color: #475467;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.delete-history-button {
  min-height: 34px;
  border: 1px solid #fecaca;
  border-radius: 999px;
  background: #fff;
  color: #b91c1c;
  cursor: pointer;
  padding: 6px 10px;
  font-size: 0.86rem;
  font-weight: 900;
}

.delete-history-button:hover {
  background: #fee2e2;
}

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

.info-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.info-box span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.info-box strong {
  display: block;
  margin-top: 4px;
}

.notice-list {
  margin: 8px 0 18px;
  padding-left: 18px;
  font-size: 0.9rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.top-links-card {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.top-links-card .links {
  gap: 12px;
}

.link-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #1e40af;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
}

.link-chip:hover {
  border-color: var(--primary);
  background: #dbeafe;
}

.link-chip-prominent {
  min-height: 48px;
  border-color: #93c5fd;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 10px 16px;
  font-size: 1rem;
}

.link-type {
  margin-right: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.error-box {
  padding: 14px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
}

.footer {
  padding: 14px 4px 0;
  font-size: 0.88rem;
  text-align: center;
}

.footer p {
  margin-bottom: 8px;
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 24px, 960px);
    padding-top: 30px;
  }

  .card {
    padding: 18px;
  }

  .input-grid,
  .result-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .result-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .history-header,
  .history-item {
    align-items: stretch;
    flex-direction: column;
  }

  .top-links-card .links {
    display: grid;
    grid-template-columns: 1fr;
  }

  .link-chip-prominent {
    justify-content: center;
    width: 100%;
  }

  .secondary-button {
    width: 100%;
  }

  .history-actions {
    width: 100%;
  }

  .diff-badge,
  .delete-history-button {
    width: 100%;
  }

  .grade-badge {
    width: 100%;
  }

  .cutoff-table {
    grid-template-columns: 1fr;
  }

  .cutoff-cell + .cutoff-cell {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}
