:root {
  --primary: #1a5fa8;
  --primary-dark: #0f3f72;
  --accent: #e8871a;
  --success: #2e7d32;
  --warning: #f57c00;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #666;
  --border: #dde3ed;
  --radius: 12px;
}

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

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 28px 20px 24px;
  text-align: center;
}
header h1 { font-size: 1.6rem; font-weight: 700; }
header p { font-size: 0.9rem; opacity: 0.85; margin-top: 6px; }

/* ===== Container ===== */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* ===== Section Card ===== */
.section-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.section-card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  border-left: 4px solid var(--primary);
  padding-left: 10px;
  margin-bottom: 18px;
}

/* ===== Form Elements ===== */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field label .required {
  color: #c62828;
  font-size: 0.75rem;
  margin-left: 4px;
}
.field select,
.field input[type="number"],
.field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s;
}
.field select:focus,
.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,95,168,0.1);
}

/* ===== Radio Groups ===== */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: normal;
  background: #f0f4fa;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  transition: all 0.2s;
}
.radio-group input[type="radio"] { display: none; }
.radio-group input[type="radio"]:checked + span {
  color: var(--primary);
  font-weight: 700;
}
.radio-group label:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ===== Checkboxes ===== */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (max-width: 480px) {
  .checkbox-grid { grid-template-columns: 1fr; }
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  background: #f9fafc;
}
.checkbox-item:hover { border-color: var(--primary); background: #eef3fb; }
.checkbox-item input[type="checkbox"] { accent-color: var(--primary); }
.checkbox-item.checked {
  border-color: var(--primary);
  background: #eef3fb;
  font-weight: 600;
}

/* ===== Submit Button ===== */
.btn-submit {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent), #c0621a);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 8px;
}
.btn-submit:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-submit:active { transform: translateY(0); }

/* ===== Results Section ===== */
#result-section { display: none; }
#result-section.visible { display: block; }

.result-header {
  text-align: center;
  padding: 20px 0 16px;
}
.result-header h2 {
  font-size: 1.3rem;
  color: var(--primary-dark);
}
.result-count {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ===== Result Card ===== */
.result-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.result-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.rank-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.rank-高 { background: #e8f5e9; color: var(--success); border: 1px solid #a5d6a7; }
.rank-中 { background: #fff8e1; color: var(--warning); border: 1px solid #ffe082; }

.result-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}
.result-category {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.result-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  background: #f4f7fb;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 0.75rem; color: var(--muted); }
.meta-value { font-weight: 700; color: var(--primary-dark); }

.reasons-list {
  font-size: 0.85rem;
  margin-bottom: 10px;
}
.reasons-list li {
  list-style: none;
  padding: 2px 0 2px 18px;
  position: relative;
  color: #2e7d32;
}
.reasons-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 700;
}

.warnings-list {
  font-size: 0.82rem;
  margin-bottom: 10px;
}
.warnings-list li {
  list-style: none;
  padding: 2px 0 2px 18px;
  position: relative;
  color: #b45309;
}
.warnings-list li::before {
  content: '⚠';
  position: absolute;
  left: 0;
}

.result-notes {
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 8px;
}

.btn-detail {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 18px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-detail:hover { background: var(--primary-dark); }

/* ===== No Results ===== */
.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.no-results p { font-size: 1rem; margin-bottom: 8px; }

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 30px;
  color: var(--primary);
  font-weight: 600;
}

/* ===== Back Button ===== */
.btn-back {
  display: block;
  width: fit-content;
  margin: 0 auto 20px;
  padding: 10px 24px;
  background: #fff;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-back:hover { background: var(--primary); color: #fff; }

footer {
  text-align: center;
  padding: 20px;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ===== Progress Bar ===== */
.progress-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0 8px;
  gap: 0;
}
.step-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.step-dot span {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #dde3ed;
  color: #999;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}
.step-dot small {
  font-size: 0.72rem;
  color: #999;
  white-space: nowrap;
  transition: color 0.3s;
}
.step-dot.active span {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(26,95,168,0.15);
}
.step-dot.active small { color: var(--primary); font-weight: 600; }
.step-dot.done span {
  background: var(--success);
  color: #fff;
}
.step-dot.done small { color: var(--success); }
.step-line {
  width: 60px;
  height: 2px;
  background: #dde3ed;
  margin: 0 4px;
  margin-bottom: 20px;
  transition: background 0.3s;
}
.step-line.done { background: var(--success); }

/* ===== Step Panels ===== */
.step-panel { display: none; }
.step-panel.active { display: block; }

/* ===== Step description ===== */
.step-desc {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ===== Field Row (2-column) ===== */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 540px) {
  .field-row { grid-template-columns: 1fr; }
}

/* ===== Field hint ===== */
.field-hint {
  font-size: 0.76rem;
  color: #888;
  margin-top: 4px;
}

/* ===== Needs Grid ===== */
.needs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 500px) {
  .needs-grid { grid-template-columns: 1fr; }
}
.need-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfd;
}
.need-item:hover { border-color: var(--primary); background: #eef3fb; }
.need-item input[type="checkbox"] { display: none; }
.need-item.selected {
  border-color: var(--primary);
  background: #eef3fb;
}
.need-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}
.need-text { display: flex; flex-direction: column; }
.need-text strong { font-size: 0.85rem; color: var(--text); }
.need-text small { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.need-item.selected .need-text strong { color: var(--primary); }

/* ===== Nav Buttons ===== */
.nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 16px;
  gap: 12px;
}
.btn-next {
  padding: 12px 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-left: auto;
}
.btn-next:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-back-step {
  padding: 12px 24px;
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-back-step:hover { background: var(--primary); color: #fff; }

/* ===== Result actions (retry / CSV) ===== */
.result-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.btn-retry,
.btn-csv {
  display: inline-block;
  width: fit-content;
  margin: 0;
  padding: 10px 24px;
  background: #fff;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-retry:hover,
.btn-csv:hover { background: var(--primary); color: #fff; }

/* ===== CTA card (consultation) ===== */
.cta-card {
  background: #f4f7fb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-top: 8px;
  text-align: center;
}
.cta-card h3 {
  font-size: 1rem;
  color: var(--primary-dark);
  margin-bottom: 8px;
}
.cta-card p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.6;
}
.btn-cta {
  display: inline-block;
  padding: 10px 22px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-cta:hover { background: var(--primary-dark); }

/* ===== Result section ===== */
#result-section { display: none; }
#result-section.visible { display: block; }
