*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --accent: #6C63FF;
  --accent-light: #ebe9ff;
  --bg: #FAFAFA;
  --card: #FFFFFF;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.04), 0 10px 24px rgba(0,0,0,0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,250,250,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
}

.navbar nav { display: flex; align-items: center; }

.navbar .logo {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--accent);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.hero {
  text-align: center;
  padding: 80px 24px 60px;
  max-width: 640px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.hero p {
  margin-top: 16px;
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.section {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 32px;
  letter-spacing: -0.02em;
}

.target-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.target-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 4px;
}

.target-pill {
  padding: 6px 16px;
  border-radius: 999px;
  border: 1.5px solid #e5e7eb;
  background: var(--card);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.target-pill:hover { border-color: var(--accent); color: var(--accent); }

.target-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tab-bar {
  display: flex;
  gap: 4px;
  background: #f1f1f4;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 28px;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.tab-panel { display: none; animation: fadeIn 0.25s ease; }
.tab-panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.field { margin-bottom: 20px; }

.field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
  outline: none;
}

.field input:focus { border-color: var(--accent); }

.field input::placeholder { color: #c5c7cd; }

.result-box {
  margin-top: 24px;
  text-align: center;
  padding: 28px 20px;
  border-radius: var(--radius);
  background: var(--bg);
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.result-pct {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.result-status {
  margin-top: 8px;
  font-size: 1rem;
  font-weight: 600;
}

.result-msg {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.color-green { color: var(--green); }
.color-yellow { color: var(--yellow); }
.color-red { color: var(--red); }

.result-placeholder {
  font-size: 0.9375rem;
  color: #b0b3bc;
}

.subject-list { display: flex; flex-direction: column; gap: 12px; }

.subject-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px 44px 44px;
  gap: 8px;
  align-items: end;
}

.subject-row .field { margin-bottom: 0; }

.subject-row input {
  padding: 10px 10px;
  font-size: 0.875rem;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: inherit;
  align-self: end;
}

.btn-remove {
  background: #fef2f2;
  color: var(--red);
}
.btn-remove:hover { background: #fee2e2; }

.btn-pct {
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 0.75rem;
  pointer-events: none;
}

.btn-add {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  border: 2px dashed #e5e7eb;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-add:hover { border-color: var(--accent); background: var(--accent-light); }

.overall-box {
  margin-top: 24px;
  padding: 20px;
  background: var(--bg);
  border-radius: var(--radius);
  text-align: center;
}

.overall-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.overall-pct {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.faq-list { display: flex; flex-direction: column; gap: 8px; }

.faq-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.faq-item h3 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
}

.faq-q {
  width: 100%;
  padding: 18px 20px;
  border: none;
  background: transparent;
  text-align: left;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.faq-q::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text-secondary);
  transition: transform 0.3s;
  flex-shrink: 0;
}

.faq-item.open .faq-q::after { content: '−'; }

.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
}

.faq-a-inner {
  padding: 0 20px 18px;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.faq-item.open .faq-a { max-height: 300px; }

.footer {
  text-align: center;
  padding: 40px 24px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(0,0,0,0.05);
}

.footer-inner {
  max-width: 720px;
  margin: 0 auto;
}

.footer-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 32px;
  text-align: left;
  margin-bottom: 28px;
}

.footer-nav h2 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 10px;
}

.footer-nav ul { list-style: none; }
.footer-nav li { margin-bottom: 6px; }
.footer-nav a {
  color: var(--text-secondary);
  text-decoration: none;
}
.footer-nav a:hover { color: var(--accent); }

.footer-badge { margin: 16px 0; }
.footer-copy { margin-top: 8px; }

.calc-btn {
  width: 100%;
  padding: 13px;
  margin: 4px 0 16px 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}
.calc-btn:hover { opacity: 0.88; }

.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1.5px solid #e5e7eb;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--accent); }

.breadcrumb {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 24px 0;
  font-size: 0.8125rem;
}
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  color: var(--text-secondary);
}
.breadcrumb li:not(:last-child)::after {
  content: '/';
  margin-left: 6px;
  color: #c5c7cd;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb [aria-current="page"] { color: var(--text); }

.prose h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 2rem 0 0.75rem;
}
.prose h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
}
.prose p { margin-bottom: 1rem; color: var(--text); }
.prose a { color: var(--accent); }
.prose ul, .prose ol { margin: 0 0 1rem 1.25rem; }
.prose li { margin-bottom: 0.4rem; }

.miss-table-wrap { overflow-x: auto; margin: 1.25rem 0 1.5rem; }
.miss-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.miss-table th, .miss-table td {
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
}
.miss-table th {
  background: var(--accent-light);
  font-weight: 700;
}
.miss-table td:first-child, .miss-table th:first-child { text-align: left; }

.related {
  margin-top: 8px;
}
.related ul { list-style: none; }
.related li { margin-bottom: 8px; }
.related a { color: var(--accent); font-weight: 600; text-decoration: none; }
.related a:hover { text-decoration: underline; }

[data-theme="dark"] {
  --bg: #0f0f13;
  --card: #1a1a24;
  --text: #f1f1f5;
  --text-secondary: #9ca3af;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.2), 0 10px 24px rgba(0,0,0,0.3);
  --accent-light: #2d2b4e;
}
[data-theme="dark"] .navbar {
  background: rgba(15,15,19,0.85);
  border-bottom-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .tab-bar { background: #1a1a24; }
[data-theme="dark"] .field input {
  background: #0f0f13;
  border-color: #2d2d3d;
  color: var(--text);
}
[data-theme="dark"] .target-pill {
  background: #1a1a24;
  border-color: #2d2d3d;
}
[data-theme="dark"] .footer {
  border-top-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .theme-toggle {
  border-color: #2d2d3d;
  color: var(--text);
}
[data-theme="dark"] .miss-table th, [data-theme="dark"] .miss-table td {
  border-bottom-color: #2d2d3d;
}

@media (min-width: 601px) and (max-width: 1024px) {
  .hero { padding: 64px 32px 48px; }
  .section { max-width: 720px; padding: 0 32px 80px; }
  .card { padding: 28px; }
  .tab-btn { font-size: 0.8rem; padding: 10px 10px; }
  .subject-row {
    grid-template-columns: 1fr 90px 90px 44px 44px;
  }
}

@media (max-width: 600px) {
  .hero { padding: 48px 20px 36px; }
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: 0.9375rem; }

  .section { padding: 0 16px 56px; }
  .card { padding: 20px 16px; }

  .navbar { padding: 0 16px; }
  .navbar .logo { font-size: 1.1rem; }
  .theme-toggle { padding: 5px 10px; font-size: 0.9rem; }

  .tab-bar { gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { font-size: 0.7rem; padding: 9px 6px; white-space: nowrap; flex: 0 0 auto; }

  .target-bar { gap: 6px; }
  .target-pill { padding: 5px 12px; font-size: 0.8125rem; }
  .target-label { font-size: 0.8125rem; }

  .result-pct { font-size: 2.25rem; }
  .result-msg { font-size: 1rem; }
  .result-box { padding: 20px 16px; }

  .calc-btn { padding: 15px; font-size: 1rem; }

  .subject-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .subject-row .field:first-child { grid-column: 1 / -1; }
  .subject-row .btn-pct { width: 100%; }
  .subject-row .btn-remove { width: 100%; }

  .faq-q { font-size: 0.875rem; padding: 16px; }
  .section-title { font-size: 1.25rem; }
  .footer-nav { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .hero h1 { font-size: 1.5rem; }
  .card { padding: 16px 12px; }
  .tab-btn { font-size: 0.65rem; padding: 8px 4px; }
  .result-pct { font-size: 2rem; }
  .target-pill { padding: 4px 10px; font-size: 0.75rem; }
}

@media (min-width: 1200px) {
  .section { max-width: 720px; }
  .hero { max-width: 720px; }
  .card { padding: 40px; }
}

@media (hover: none) {
  .calc-btn:hover { opacity: 1; }
  .target-pill:hover { border-color: #e5e7eb; color: var(--text-secondary); }
  .target-pill.active:hover { border-color: var(--accent); color: #fff; }
  .btn-add:hover { border-color: #e5e7eb; background: transparent; }
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .card { box-shadow: var(--shadow); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
