/* ==========================================================================
   米国株・高配当ETF 二重課税＆実質手取り配当シミュレーター
   Design System: Modern Clean Financial Dashboard (Navy & Emerald)
   Mobile-First, Zero External Dependencies
   ========================================================================== */

:root {
  /* Surfaces */
  --bg-page: #f3f6fa;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #eef2f6;

  /* Brand Navy */
  --navy-950: #091a2c;
  --navy-900: #0f2942;
  --navy-800: #163a5f;
  --navy-700: #1e4b7a;
  --navy-100: #e5eef7;
  --navy-50: #f1f6fb;

  /* Pattern ② Accent (Blue / Credit) */
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;
  --blue-border: #bfdbfe;

  /* Pattern ③ New NISA Accent (Emerald) */
  --emerald-800: #065f46;
  --emerald-700: #047857;
  --emerald-600: #059669;
  --emerald-500: #10b981;
  --emerald-100: #d1fae5;
  --emerald-50: #ecfdf5;
  --emerald-border: #86efac;

  /* Tax / Cost Accents */
  --rose-600: #dc2626;
  --rose-500: #ef4444;
  --rose-100: #fee2e2;
  --rose-50: #fef2f2;
  --amber-700: #b45309;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;
  --amber-50: #fffbeb;

  /* Typography & Borders */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-light: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Shape & Elevation */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 41, 66, 0.05);
  --shadow-card: 0 4px 18px rgba(15, 41, 66, 0.06), 0 1px 3px rgba(15, 41, 66, 0.04);
  --shadow-nisa: 0 8px 24px rgba(5, 150, 105, 0.12), 0 2px 6px rgba(5, 150, 105, 0.06);
  --shadow-float: 0 -6px 24px rgba(15, 41, 66, 0.14);

  /* Fonts */
  --font-sans: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Yu Gothic UI", Meiryo, sans-serif;
  --font-num: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Motion */
  --ease-fast: 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-med: 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-page);
  min-height: 100vh;
  padding-bottom: 84px;
}

.tabular-nums,
.num-input,
.num-value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus ring */
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  background: linear-gradient(135deg, var(--navy-950) 0%, var(--navy-900) 55%, var(--navy-800) 100%);
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 16px 18px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  transition: color var(--ease-fast);
}

.back-link:hover {
  color: #ffffff;
  text-decoration: underline;
}

.header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
  display: grid;
  place-items: center;
  margin-top: 2px;
}

.site-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.site-subtitle {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.45;
}

.header-actions {
  flex-shrink: 0;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  transition: background var(--ease-fast), border-color var(--ease-fast);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   Main Layout
   ========================================================================== */
.main-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 14px 28px;
}

/* ==========================================================================
   Mode Switch Tabs
   ========================================================================== */
.mode-tabs-wrap {
  margin-bottom: 16px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  background: var(--navy-100);
  border-radius: var(--radius-md);
  border: 1px solid #d5e2f0;
}

.mode-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 54px;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--navy-800);
  transition: background var(--ease-fast), color var(--ease-fast), box-shadow var(--ease-fast);
}

.mode-tab:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.55);
}

.mode-tab.is-active {
  background: var(--bg-card);
  color: var(--navy-950);
  box-shadow: 0 2px 8px rgba(15, 41, 66, 0.12);
}

.mode-tab-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.mode-tab.is-active .mode-tab-badge {
  color: var(--emerald-700);
}

.mode-tab-label {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

/* ==========================================================================
   Generic Card & Section Heading
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 16px;
  margin-bottom: 16px;
}

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

.section-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--navy-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-desc {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--emerald-50);
  border: 1px solid var(--emerald-100);
  color: var(--emerald-700);
  font-size: 11.5px;
  font-weight: 700;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald-500);
}

/* ==========================================================================
   Input Controls
   ========================================================================== */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.form-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy-900);
}

.sub-readout {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ETF Presets Grid */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 7px 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  background: var(--bg-subtle);
  color: var(--text-primary);
  text-align: center;
  transition: all var(--ease-fast);
}

.preset-btn:hover {
  border-color: var(--navy-700);
  background: var(--navy-50);
}

.preset-btn.is-active {
  border-color: var(--navy-900);
  background: var(--navy-900);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(15, 41, 66, 0.18);
}

.preset-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.preset-meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

.preset-btn.is-active .preset-meta {
  color: #bae6fd;
}

.field-note {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Unit Segmented Toggle */
.unit-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
}

.unit-btn {
  min-height: 30px;
  padding: 3px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  transition: all var(--ease-fast);
}

.unit-btn.is-active {
  background: var(--bg-card);
  color: var(--navy-900);
  box-shadow: var(--shadow-sm);
}

/* Numeric Input Box */
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-unit-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.form-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 56px 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
  -moz-appearance: textfield;
}

.form-input::-webkit-outer-spin-button,
.form-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.form-input:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(30, 75, 122, 0.14);
}

.form-input-compact {
  min-height: 42px;
  font-size: 16px;
  padding-right: 42px;
}

.input-unit {
  position: absolute;
  right: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
}

/* Quick Chips */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  flex: 1 1 auto;
  min-width: 66px;
  min-height: 36px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--navy-900);
  font-size: 12.5px;
  font-weight: 700;
  transition: all var(--ease-fast);
}

.chip-btn:hover {
  border-color: var(--navy-700);
  background: var(--navy-50);
}

.chip-btn.is-active {
  border-color: var(--navy-900);
  background: var(--navy-900);
  color: #ffffff;
}

/* Sliders */
.slider-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.slider-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
}

.slider-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.slider-input-wrap {
  width: 112px;
  flex-shrink: 0;
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: linear-gradient(
    to right,
    var(--navy-800) 0%,
    var(--navy-800) var(--fill-pct, 50%),
    #d8e2ee var(--fill-pct, 50%),
    #d8e2ee 100%
  );
  outline: none;
  margin: 4px 0;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--navy-900);
  box-shadow: 0 2px 6px rgba(15, 41, 66, 0.25);
  cursor: pointer;
  transition: transform var(--ease-fast), box-shadow var(--ease-fast);
}

.range-slider::-webkit-slider-thumb:hover,
.range-slider:active::-webkit-slider-thumb {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(15, 41, 66, 0.34);
}

.range-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--navy-900);
  box-shadow: 0 2px 6px rgba(15, 41, 66, 0.25);
  cursor: pointer;
}

.slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* Foreign Tax Credit Accordion */
.ftc-accordion {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  overflow: hidden;
}

.ftc-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  min-height: 48px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background var(--ease-fast);
}

.ftc-summary::-webkit-details-marker {
  display: none;
}

.ftc-summary:hover {
  background: var(--navy-50);
}

.ftc-summary-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ftc-summary-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy-900);
}

.ftc-summary-current {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.accordion-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--ease-med);
}

details[open] > summary .accordion-chevron {
  transform: rotate(180deg);
}

.ftc-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border-light);
  background: #ffffff;
}

.ftc-select-wrap {
  margin-top: 12px;
}

.form-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 36px 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23475569'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.form-select:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(30, 75, 122, 0.14);
}

.ftc-rate-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--blue-50);
  border: 1px solid var(--blue-border);
  color: var(--blue-700);
  font-size: 12px;
  font-weight: 700;
}

.ftc-disclaimer {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ==========================================================================
   Pre-tax Summary Strip & Highlight Insight Banner
   ========================================================================== */
.summary-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.summary-strip-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-strip-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.summary-strip-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-900);
}

.summary-strip-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: 4px;
}

/* Highlight Advantage Banner */
.insight-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #064e3b 0%, #047857 60%, #059669 100%);
  color: #ffffff;
  box-shadow: var(--shadow-nisa);
}

.insight-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  color: #a7f3d0;
}

.insight-content {
  min-width: 0;
}

.insight-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #a7f3d0;
  margin-bottom: 2px;
}

.insight-headline {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.45;
}

.insight-em {
  color: #fef08a;
  font-size: 1.12em;
  font-weight: 800;
}

.insight-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.86);
}

/* ==========================================================================
   3-Pattern Comparison Cards
   ========================================================================== */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.account-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform var(--ease-fast), box-shadow var(--ease-fast);
}

.account-card::before {
  content: "";
  display: block;
  height: 4px;
  width: 100%;
  background: var(--navy-700);
}

.account-card--tokutei::before {
  background: #64748b;
}

.account-card--ftc::before {
  background: var(--blue-600);
}

.account-card--nisa {
  border-color: var(--emerald-border);
  box-shadow: var(--shadow-nisa);
  background: linear-gradient(180deg, #f4fdf8 0%, #ffffff 34%);
}

.account-card--nisa::before {
  height: 5px;
  background: linear-gradient(90deg, var(--emerald-700), var(--emerald-500));
}

.account-card-inner {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 14px;
}

.account-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.account-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-bottom: 5px;
}

.account-card--tokutei .account-tag {
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.account-card--ftc .account-tag {
  background: var(--blue-100);
  color: var(--blue-700);
}

.account-card--nisa .account-tag {
  background: var(--emerald-100);
  color: var(--emerald-800);
}

.account-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy-950);
  line-height: 1.3;
}

.account-rate-badge {
  flex-shrink: 0;
  text-align: right;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
}

.account-card--nisa .account-rate-badge {
  background: var(--emerald-50);
  border-color: var(--emerald-border);
}

.rate-badge-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

.rate-badge-val {
  display: block;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--navy-900);
}

.account-card--nisa .rate-badge-val {
  color: var(--emerald-700);
}

/* Primary KPI Box inside Card */
.card-hero {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
}

.account-card--nisa .card-hero {
  background: var(--emerald-50);
  border-color: var(--emerald-100);
}

.card-hero-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-hero-yen {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--navy-950);
  line-height: 1.2;
}

.account-card--nisa .card-hero-yen {
  color: var(--emerald-800);
}

.card-hero-usd {
  margin-top: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Mode B Required Investment Block */
.required-invest-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--navy-50);
  border: 1px dashed #b6cbe2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.account-card--nisa .required-invest-box {
  background: #ffffff;
  border-color: var(--emerald-border);
}

.required-invest-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-800);
}

.required-invest-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--navy-950);
}

.account-card--nisa .required-invest-val {
  color: var(--emerald-700);
}

/* Key Metrics Row */
.card-metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-mini {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
}

.metric-mini-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.metric-mini-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--navy-900);
}

.account-card--nisa .metric-mini-val--accent {
  color: var(--emerald-700);
}

/* Visual Stacked Retention vs Tax Bar */
.ratio-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ratio-bar {
  display: flex;
  height: 8px;
  width: 100%;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--bg-muted);
}

.ratio-seg-net {
  background: var(--navy-800);
  transition: width var(--ease-med);
}

.account-card--ftc .ratio-seg-net {
  background: var(--blue-600);
}

.account-card--nisa .ratio-seg-net {
  background: var(--emerald-500);
}

.ratio-seg-us {
  background: #f59e0b;
  transition: width var(--ease-med);
}

.ratio-seg-jp {
  background: #ef4444;
  transition: width var(--ease-med);
}

.ratio-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  gap: 6px;
}

/* Tax Breakdown List */
.tax-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  font-size: 12.5px;
}

.tax-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tax-row-label {
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.swatch-us {
  background: #f59e0b;
}

.swatch-jp {
  background: #ef4444;
}

.swatch-refund {
  background: var(--blue-600);
}

.tax-row-val {
  font-weight: 700;
  color: var(--text-primary);
}

.tax-row-val--refund {
  color: var(--blue-700);
}

.tax-row--total {
  padding-top: 6px;
  margin-top: 2px;
  border-top: 1px dashed var(--border-light);
  font-weight: 700;
}

.tax-row--total .tax-row-val {
  color: var(--rose-600);
}

.account-card--nisa .tax-row--total .tax-row-val {
  color: var(--amber-700);
}

/* Card Footnote */
.card-footnote {
  margin-top: auto;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.account-card--nisa .card-footnote {
  background: rgba(5, 150, 105, 0.08);
  color: var(--emerald-800);
}

.account-card--ftc .card-footnote {
  background: var(--blue-50);
  color: #1e3a8a;
}

/* ==========================================================================
   FX Rate Matrix Table
   ========================================================================== */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x pan-y;
  overscroll-behavior-x: contain;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
  font-size: 13px;
}

.matrix-table th,
.matrix-table td {
  padding: 11px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.matrix-table th:first-child,
.matrix-table td:first-child {
  text-align: left;
}

.matrix-table thead th {
  background: var(--navy-50);
  color: var(--navy-900);
  font-size: 12px;
  font-weight: 700;
}

.matrix-table thead th.col-nisa {
  color: var(--emerald-800);
  background: var(--emerald-50);
}

.matrix-table tbody tr:last-child td {
  border-bottom: none;
}

.matrix-table tbody tr.is-current-row {
  background: #f0fdf4;
  font-weight: 700;
}

.matrix-table tbody tr.is-current-row td:first-child {
  box-shadow: inset 4px 0 0 var(--emerald-600);
}

.fx-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--emerald-600);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

.cell-nisa {
  color: var(--emerald-800);
  font-weight: 700;
}

.cell-diff {
  color: var(--emerald-700);
  font-weight: 700;
}

.cell-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ==========================================================================
   Memo / History Section
   ========================================================================== */
.memo-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.memo-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  font-size: 14px;
  color: var(--text-primary);
  background: #ffffff;
}

.memo-input:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(30, 75, 122, 0.14);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--navy-900);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: background var(--ease-fast), transform var(--ease-fast);
}

.btn-primary:hover {
  background: var(--navy-800);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-text-danger {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color var(--ease-fast), background var(--ease-fast);
}

.btn-text-danger:hover {
  color: var(--rose-600);
  background: var(--rose-50);
}

.memo-empty {
  padding: 18px 14px;
  text-align: center;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 13px;
}

.memo-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memo-item {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  overflow: hidden;
  transition: border-color var(--ease-fast), background var(--ease-fast);
}

.memo-item:hover {
  border-color: var(--navy-700);
  background: var(--navy-50);
}

.memo-restore-btn {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.memo-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.memo-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy-950);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memo-mode-tag {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--navy-100);
  color: var(--navy-800);
}

.memo-meta {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.memo-result {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--emerald-700);
}

.memo-delete-btn {
  flex-shrink: 0;
  width: 44px;
  border: none;
  border-left: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  transition: background var(--ease-fast), color var(--ease-fast);
}

.memo-delete-btn:hover {
  background: var(--rose-50);
  color: var(--rose-600);
}

/* ==========================================================================
   Beginner Guide Accordions
   ========================================================================== */
.guide-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  overflow: hidden;
}

.guide-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  min-height: 48px;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy-900);
  cursor: pointer;
  list-style: none;
}

.guide-summary::-webkit-details-marker {
  display: none;
}

.guide-summary:hover {
  background: var(--navy-50);
}

.guide-body {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border-light);
  background: #ffffff;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.guide-body p {
  margin: 0 0 8px;
}

.guide-body p:last-child {
  margin-bottom: 0;
}

.formula-box {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--navy-50);
  border-left: 3px solid var(--navy-800);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy-900);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 4px 16px 28px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ==========================================================================
   Mobile Sticky Bottom Summary Bar
   ========================================================================== */
.mobile-sticky-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: rgba(15, 41, 66, 0.96);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 10px 14px;
  box-shadow: var(--shadow-float);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.mobile-sticky-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sticky-stat-label {
  display: block;
  font-size: 10.5px;
  color: #a7f3d0;
  font-weight: 700;
}

.sticky-stat-val {
  display: block;
  font-size: 15.5px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.25;
}

.sticky-jump-btn {
  flex-shrink: 0;
  min-height: 38px;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--emerald-500);
  color: #052e16;
  font-size: 12.5px;
  font-weight: 800;
  transition: background var(--ease-fast);
}

.sticky-jump-btn:hover {
  background: #34d399;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%) translateY(16px);
  z-index: 60;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: var(--navy-950);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 41, 66, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease-med), transform var(--ease-med);
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Ad Slot Wrapper (Future Monetization)
   ========================================================================== */
.ad-slot-middle {
  margin: 0 0 16px;
}

.ad-slot-middle:empty {
  display: none;
}

/* ==========================================================================
   Responsive Breakpoints (Tablet & Desktop)
   ========================================================================== */
@media (min-width: 640px) {
  .site-title {
    font-size: 1.32rem;
  }

  .main-container {
    padding: 20px 20px 36px;
  }

  .card {
    padding: 22px 22px;
  }

  .preset-grid {
    grid-template-columns: repeat(6, 1fr);
  }

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

  .mode-tab {
    flex-direction: row;
    gap: 8px;
    min-height: 48px;
  }

  .mode-tab-badge {
    margin-bottom: 0;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: rgba(15, 41, 66, 0.08);
  }

  .mode-tab.is-active .mode-tab-badge {
    background: var(--emerald-50);
  }
}

@media (min-width: 960px) {
  body {
    padding-bottom: 24px;
  }

  .mobile-sticky-bar {
    display: none;
  }

  .toast {
    bottom: 24px;
  }

  .comparison-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: stretch;
  }

  .account-card--nisa {
    transform: translateY(-2px);
  }

  .card-hero-yen {
    font-size: 1.62rem;
  }

  .bottom-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.95fr;
    gap: 16px;
    align-items: start;
  }
}
