:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;

  --ai: #6d28d9;
  --ai-soft: #f5f3ff;
  --ai-border: #ddd6fe;

  --pass: #059669;
  --pass-soft: #ecfdf5;
  --pass-border: #a7f3d0;

  --warn: #d97706;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;

  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 44px rgba(15, 23, 42, 0.14);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button, input, select {
  font-family: inherit;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.88rem;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.28);
}

.brand-sub {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-light);
  line-height: 1.1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.nav-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 9px;
  border-radius: 8px;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .header-inner {
    padding: 10px 12px;
    gap: 8px;
  }
  .brand {
    font-size: 0.9rem;
  }
  .brand-sub {
    font-size: 0.63rem;
  }
  .nav-link {
    font-size: 0.75rem;
    padding: 6px 6px;
  }
  .header-actions .btn-sm {
    padding: 6px 10px;
    font-size: 0.76rem;
    white-space: nowrap;
  }
}

.nav-link:hover {
  background: var(--surface-subtle);
  text-decoration: none;
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 46px;
}

.btn:active {
  transform: scale(0.985);
}

.btn-sm {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 0.82rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.btn-ai {
  background: linear-gradient(135deg, #6d28d9 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(109, 40, 217, 0.28);
}

.btn-ai:hover {
  filter: brightness(1.06);
  text-decoration: none;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: var(--surface-subtle);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-subtle);
}

.btn-pro {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fef08a;
  border-color: #334155;
}

.btn-pro:hover {
  filter: brightness(1.1);
}

/* Container */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

/* Hero & Dashboard */
.hero-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #4c1d95 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
}

.hero-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.pill-glass {
  background: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.pill-ai {
  background: var(--ai-soft);
  color: var(--ai);
  border: 1px solid var(--ai-border);
}

.pill-pass {
  background: var(--pass-soft);
  color: var(--pass);
  border: 1px solid var(--pass-border);
}

.pill-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

.pill-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.pill-field {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.hero-title {
  margin: 0 0 10px;
  font-size: clamp(1.38rem, 3.6vw, 1.95rem);
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.hero-desc {
  margin: 0 0 18px;
  font-size: 0.94rem;
  color: rgba(241, 245, 249, 0.9);
  max-width: 660px;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-cta-row .btn-white {
  background: #fff;
  color: #0f172a;
}

.hero-cta-row .btn-white:hover {
  background: #f1f5f9;
}

/* Cards & Grid */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

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

.section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-sub {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-light);
}

/* 3-Field Cutoff Meter */
.cutoff-overview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 720px) {
  .cutoff-overview {
    grid-template-columns: 230px 1fr;
    align-items: center;
  }
}

.total-score-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.total-score-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.total-score-value {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1.15;
  margin: 4px 0;
  letter-spacing: -0.03em;
}

.total-score-unit {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-light);
}

.field-meters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meter-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.meter-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.86rem;
}

.meter-name {
  font-weight: 700;
}

.meter-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meter-track {
  position: relative;
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: visible;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.meter-fill.pass { background: linear-gradient(90deg, #10b981, #059669); }
.meter-fill.warn { background: linear-gradient(90deg, #f59e0b, #d97706); }
.meter-fill.danger { background: linear-gradient(90deg, #ef4444, #dc2626); }
.meter-fill.empty { background: #94a3b8; }

.meter-line-300 {
  position: absolute;
  left: 30%;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #0f172a;
  opacity: 0.55;
}

.meter-line-600 {
  position: absolute;
  left: 60%;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #1d4ed8;
  opacity: 0.4;
}

.meter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--text-light);
}

/* Mode Selector Cards */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .mode-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.mode-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  color: var(--text);
}

.mode-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.mode-card.ai-card {
  background: linear-gradient(180deg, #faf5ff 0%, #ffffff 100%);
  border-color: var(--ai-border);
}

.mode-card.ai-card:hover {
  border-color: var(--ai);
}

.mode-card.weak-card {
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 100%);
  border-color: var(--warn-border);
}

.mode-card-title {
  font-size: 1rem;
  font-weight: 800;
  margin: 4px 0 2px;
}

.mode-card-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0;
}

.mode-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
}

/* Field quick pills */
.field-chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.field-chip {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.83rem;
  color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.field-chip:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.field-chip small {
  display: block;
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--text-light);
}

/* Quiz View */
.hidden {
  display: none !important;
}

.quiz-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.quiz-progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
}

.timer-badge.urgent {
  background: var(--danger);
}

.cbt-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.cbt-dot {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
}

.cbt-dot.current {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.cbt-dot.answered {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.cbt-dot.flagged::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  border: 1.5px solid #fff;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.question-text {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.72;
  margin: 0 0 18px;
  color: var(--text);
}

.choices-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 15px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.choice-btn.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.14);
}

.choice-btn.correct {
  border-color: var(--pass);
  background: var(--pass-soft);
}

.choice-btn.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.choice-btn:disabled {
  cursor: default;
}

.choice-label {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  margin-top: 1px;
}

.choice-btn.correct .choice-label {
  background: var(--pass);
  border-color: var(--pass);
  color: #fff;
}

.choice-btn.wrong .choice-label {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.choice-why {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Explanation Panel */
.explain-box {
  margin-top: 18px;
  border-radius: 14px;
  padding: 18px;
  border: 1.5px solid var(--border);
  background: var(--surface-subtle);
}

.explain-box.is-correct {
  background: var(--pass-soft);
  border-color: var(--pass-border);
}

.explain-box.is-wrong {
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.explain-verdict {
  font-size: 1.08rem;
  font-weight: 900;
  margin: 0 0 8px;
}

.explain-box.is-correct .explain-verdict { color: var(--pass); }
.explain-box.is-wrong .explain-verdict { color: var(--danger); }

.explain-body {
  margin: 0 0 12px;
  font-size: 0.92rem;
  white-space: pre-line;
}

.trap-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #d97706;
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 0.86rem;
  color: #78350f;
}

.trap-box strong {
  display: block;
  margin-bottom: 2px;
  color: #92400e;
}

.quiz-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

/* Result View */
.result-hero {
  text-align: center;
  padding: 24px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.result-hero.pass {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 1.5px solid var(--pass-border);
}

.result-hero.fail {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1.5px solid var(--danger-border);
}

.result-score-big {
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1.1;
  margin: 6px 0;
}

.review-item {
  border-top: 1px solid var(--border);
  padding: 14px 0;
}

.review-item:first-child {
  border-top: none;
  padding-top: 4px;
}

/* Pro Banner & Modal */
.pro-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  border-radius: var(--radius-md);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}

@media (min-width: 700px) {
  .pro-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.pro-banner h3 {
  margin: 0 0 5px;
  font-size: 1.08rem;
}

.pro-banner p {
  margin: 0;
  font-size: 0.86rem;
  color: #cbd5e1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  box-shadow: var(--shadow-lg);
}

.plan-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.plan-option {
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  background: var(--surface);
  text-align: left;
}

.plan-option.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.plan-price {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text);
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

/* SEO Topic Index & Question Page */
.topic-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 680px) {
  .topic-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

.topic-link-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 15px;
  color: var(--text);
  transition: border-color 0.15s ease;
}

.topic-link-card:hover {
  border-color: var(--primary);
  text-decoration: none;
}

.topic-link-title {
  font-weight: 800;
  font-size: 0.95rem;
  margin: 6px 0 4px;
}

.topic-link-snippet {
  font-size: 0.8rem;
  color: var(--text-light);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 16px;
  font-size: 0.8rem;
  color: var(--text-light);
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text-muted);
  cursor: pointer;
}
