:root {
  --primary: #0369a1;
  --primary-hover: #0284c7;
  --primary-rgb: 3, 105, 161;
  --primary-light: #e0f2fe;
  --primary-border: #bae6fd;
  --accent: #0284c7;
  --bg: #f9f7f4;
  --surface: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
  --transition: 0.15s ease;
}

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

body {
  font-family: 'Outfit', 'BIZ UDPGothic', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { letter-spacing: -0.01em; }

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, #0c4a6e 0%, #075985 60%, #0369a1 100%);
  color: white;
  padding: 1.5rem 1.25rem 1.25rem;
  text-align: center;
}

header h1 {
  font-size: clamp(1.15rem, 4vw, 1.6rem);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

header h1 .bi {
  font-size: 1em;
  opacity: 0.9;
}

.subtitle {
  font-size: 0.85rem;
  opacity: 0.88;
  margin-top: 0.35rem;
}

/* ===== Main layout ===== */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* ===== Ad units ===== */
.ad-unit {
  margin: 1.25rem 0;
  min-height: 8px;
}

/* ===== Privacy note ===== */
.privacy-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f0f9ff;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-size: 0.8rem;
  color: #0369a1;
  margin-bottom: 1rem;
}

.privacy-note .bi {
  flex-shrink: 0;
  font-size: 0.9rem;
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.04);
  margin-bottom: 1rem;
  transition: box-shadow var(--transition), transform var(--transition);
}

.card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-border);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.card h2 .bi {
  font-size: 1em;
}

/* ===== Toggle group (税制選択) ===== */
.toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.toggle-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.875rem 0.75rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition), transform 0.12s ease;
  min-height: 80px;
  text-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.toggle-btn .bi {
  font-size: 1.4rem;
  color: var(--muted);
  transition: color var(--transition);
}

.toggle-btn .toggle-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.toggle-btn small {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.2;
}

.toggle-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.15);
}

.toggle-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.toggle-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.toggle-btn.active .bi {
  color: var(--primary);
}

.toggle-btn.active .toggle-title {
  color: var(--primary);
}

/* ===== Input mode tabs ===== */
.input-mode-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
  gap: 0;
}

.tab-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ===== Field groups ===== */
.field-group {
  margin-bottom: 1.1rem;
}

.field-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.35rem;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-wrap input {
  flex: 1;
}

.unit {
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 2.5rem;
}

input[type="number"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 44px;
  font-family: inherit;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.hint {
  font-size: 0.78rem;
  color: #4b5563;
  margin-top: 0.3rem;
  line-height: 1.5;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.detail-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.5rem;
}

/* ===== Info banner ===== */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.875rem;
  font-size: 0.825rem;
  color: #92400e;
  line-height: 1.5;
}

.info-banner .bi {
  flex-shrink: 0;
  margin-top: 0.1rem;
  color: #f59e0b;
}

/* ===== Filing notice (確定申告必須の告知) ===== */
.filing-notice {
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
  color: #1e40af;
  padding: 0.5rem 0.875rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  margin: 0.75rem 0;
  line-height: 1.5;
}

/* ===== Result card ===== */
.result-card {
  border: 2px solid var(--primary-border);
}

.result-hero {
  background: linear-gradient(135deg, #0c4a6e, #0369a1);
  color: white;
  border-radius: var(--radius-sm);
  padding: 1.5rem 1.25rem;
  text-align: center;
  margin-bottom: 1rem;
}

.result-hero-label {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-bottom: 0.2rem;
}

.result-hero-amount {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.result-hero-sub {
  font-size: 0.875rem;
  opacity: 0.88;
  margin-top: 0.3rem;
}

/* ===== Verdict banner ===== */
.verdict-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.25rem;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  border: 2px solid var(--border);
  background: #f9fafb;
  color: var(--muted);
}

.verdict-banner.positive {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.verdict-banner.negative {
  background: #f9fafb;
  border-color: var(--border);
  color: var(--muted);
}

/* ===== Result grid ===== */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.result-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.875rem;
  text-align: center;
}

.result-item.highlight {
  background: var(--primary-light);
  border-color: var(--primary-border);
  grid-column: 1 / -1;
}

.result-item-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.result-item-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.result-item.highlight .result-item-value {
  font-size: 1.4rem;
  color: var(--primary);
}

/* ===== Chart ===== */
.chart-wrap {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: #fafafa;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.chart-wrap h3 {
  font-size: 0.875rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 0.75rem;
}

#breakdown-chart {
  max-height: 160px;
}

/* ===== Checklist ===== */
.checklist-wrap {
  margin-bottom: 1.25rem;
}

.checklist-wrap h3 {
  font-size: 0.875rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 0.625rem;
}

.checklist {
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.check-ok {
  color: #15803d;
}

.check-ok .bi {
  color: #22c55e;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.check-ng {
  color: var(--muted);
}

.check-ng .bi {
  color: #ef4444;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

/* ===== Disclaimer ===== */
.disclaimer {
  font-size: 0.76rem;
  color: #9ca3af;
  line-height: 1.6;
}

/* ===== How-to section ===== */
.howto-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.04);
  margin-top: 0.5rem;
}

.howto-section > h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-border);
}

/* ===== Steps ===== */
.steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.steps li {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
}

.steps li strong {
  color: var(--text);
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

/* ===== Reference links ===== */
.ref-links {
  padding-left: 1.25rem;
  font-size: 0.8375rem;
  color: #374151;
  line-height: 1.9;
  margin-bottom: 0.75rem;
}

.ref-links li { margin-bottom: 0.2rem; }
.ref-links a { color: #1e40af; text-decoration: underline; }
.ref-links a:hover { color: #1e3a8a; }

.disclaimer-note {
  font-size: 0.8rem;
  color: #6b7280;
  background: #f8f9fa;
  border-left: 3px solid #d1d5db;
  padding: 0.625rem 0.875rem;
  border-radius: 0 6px 6px 0;
  line-height: 1.7;
  margin-top: 0.75rem;
}

.disclaimer-note strong { color: #374151; }

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.check-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.check-table th {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  padding: 0.5rem 0.625rem;
  text-align: left;
  font-size: 0.8rem;
}

.check-table td {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid #f3f4f6;
  color: var(--muted);
  vertical-align: top;
}

.check-table td.yes {
  color: #15803d;
  font-weight: 700;
  white-space: nowrap;
}

.check-table td.no {
  color: #ef4444;
  font-weight: 700;
  white-space: nowrap;
}

/* ===== Accordion ===== */
.accordion-group {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.accordion-item {
  border-bottom: 1px solid var(--border);
}

.accordion-item:last-child { border-bottom: none; }

.accordion-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  list-style: none;
  background: #fff;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background var(--transition);
  color: var(--text);
}

.accordion-summary::-webkit-details-marker { display: none; }
.accordion-summary:hover { background: #f0f9ff; }

.accordion-icon::after {
  content: '+';
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--muted);
  display: inline-block;
  width: 20px;
  text-align: center;
}

details[open] > .accordion-summary .accordion-icon::after { content: '−'; }

.accordion-body {
  padding: 0.25rem 1.1rem 1.1rem;
  background: #fff;
}

.accordion-body p,
.accordion-body dl,
.accordion-body ul,
.accordion-body ol {
  font-size: 0.875rem;
  color: var(--muted);
}

.accordion-body dt {
  font-weight: 700;
  color: var(--text);
  margin-top: 0.75rem;
}

.accordion-body dd {
  margin-left: 1rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

/* ===== Next step block ===== */
.next-step-block {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
}

.next-step-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.625rem;
}

.next-step-link {
  display: block;
  padding: 0.625rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  transition: background var(--transition), box-shadow var(--transition), transform 0.12s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.next-step-link:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
  transform: translateY(-1px);
}

.next-step-link:active {
  transform: translateY(0);
  box-shadow: none;
}

.next-step-link:last-child {
  margin-bottom: 0;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 2.5rem 1rem;
  font-size: 0.85rem;
  color: #9ca3af;
}

footer a {
  color: #6b7280;
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* ===== Responsive ===== */
@media (max-width: 440px) {
  .toggle-group {
    grid-template-columns: 1fr;
  }

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

  .result-item.highlight {
    grid-column: auto;
  }

  .toggle-btn {
    min-height: 60px;
    flex-direction: row;
    gap: 0.625rem;
    text-align: left;
    padding: 0.75rem 1rem;
  }

  .toggle-btn .bi {
    font-size: 1.2rem;
    flex-shrink: 0;
  }

  .toggle-btn small {
    display: none;
  }
}

@media (min-width: 600px) {
  header h1 { font-size: 1.6rem; }
  main { padding: 1.5rem 2rem; }

  .checklist {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 900px) {
  main { padding: 2rem; }
}
