/*
 * 学割パズル UI
 * 配色A：ディープブルー #1E3A8A × ブライトブルー #2563EB / #3B82F6
 * 黒字達成のみ #059669、未達のみ #B45309
 */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --raised: #eef1f6;
  --text: #111827;
  --text-2: #4b5565;
  --text-3: #6b7487;
  --line: rgba(17, 24, 39, 0.1);
  --line-strong: rgba(17, 24, 39, 0.16);

  --brand-deep: #1e3a8a;
  --brand: #2563eb;
  --brand-light: #3b82f6;
  --brand-tint: #eff4ff;

  --profit: #059669;
  --loss: #b45309;

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  /* サブページ・記事ページ互換トークン */
  --text-muted: var(--text-2);
  --border: var(--line-strong);
  --primary: var(--brand);
  --radius: var(--r-lg);
  --shadow: none;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: var(--brand);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--brand-deep);
}

:focus-visible {
  outline: 2px solid var(--brand-light);
  outline-offset: 2px;
}

/* アイコン：線幅1.75の単色、文字色を継承 */
.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}

.icon-fill {
  fill: currentColor;
  stroke: none;
}

.icon-xs {
  width: 12px;
  height: 12px;
  margin-left: 2px;
  vertical-align: -1px;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* ヘッダー */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: block;
  flex-shrink: 0;
}

.brand-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--brand-deep);
}

.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  font-size: 13px;
  font-weight: 600;
}

.page-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--text-2);
  text-decoration: none;
}

.page-nav a:hover {
  color: var(--brand-deep);
  text-decoration: underline;
}

.simulator-title {
  margin-bottom: 24px;
  font-size: clamp(22px, 4vw, 34px);
  text-wrap: balance;
  line-height: 1.4;
}

.step-heading {
  margin-bottom: 12px;
}

.step-heading h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.4;
}

.step-one {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.step-two {
  margin-top: 28px;
}

.step-two p {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-2);
}

.step-label {
  color: var(--brand-deep);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}

.updated-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
}

/* 集計ボード（スティッキー） */
.scoreboard {
  position: sticky;
  top: 8px;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  box-shadow: 0 6px 20px rgba(17, 24, 39, 0.06);
  margin-bottom: 16px;
}

.controls-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.plan-pills {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  flex: 1 1 740px;
}

.plan-pills .seg {
  justify-content: center;
  align-items: center;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 14px;
  font-weight: 600;
  white-space: normal;
}

.plan-pills .seg:hover {
  border-color: var(--brand-deep);
}

.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}

.seg-sub {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--raised);
  border-radius: var(--r-md);
}

.era-pills .seg {
  font-size: 12px;
}

.era-pills .seg.active {
  background: var(--surface);
  color: var(--brand-deep);
  font-weight: 600;
}

.plan-pills .seg.active,
.maker-pills .chip.active {
  background: var(--brand-deep);
  color: #fff;
  border-color: var(--brand-deep);
}

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

.big-net {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.big-net.loss { color: var(--loss); }
.big-net.profit { color: var(--profit); }

.progress-track {
  height: 8px;
  background: var(--raised);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
}

.progress-fill.loss { background: var(--loss); }
.progress-fill.profit { background: var(--profit); }

.gauge-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2);
}

.gauge-meta strong {
  font-size: 16px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.plan-guide-link {
  font-size: 12px;
  white-space: nowrap;
}

.preset-bar,
.preset-buttons,
.cat-tabs,
.maker-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-bar,
.cat-tabs {
  margin-bottom: 16px;
}

.preset-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.preset-btn,
.reset-btn,
.cat-tab,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 36px;
  padding: 4px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
}

.preset-btn:hover,
.reset-btn:hover,
.cat-tab:hover,
.chip:hover {
  border-color: var(--brand-deep);
}

.reset-btn {
  margin-left: auto;
}

.cat-tab .icon {
  color: var(--brand-deep);
}

.piece-section {
  margin-bottom: 32px;
}

.piece-section .section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.eligibility-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--text-2);
  font-size: 12px;
}

.special-panel {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  margin-bottom: 12px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  font-weight: 600;
  cursor: pointer;
}

.toggle-label input {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--brand-deep);
}

.win-pc-controls {
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr);
  gap: 12px 24px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.win-pc-controls[hidden],
.eligibility-note[hidden] {
  display: none;
}

.pc-control-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}

.chip-sub {
  font-size: 11px;
}

.pc-estimate {
  text-align: right;
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}

.win-save {
  color: var(--brand-deep);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.slider-wrap input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--brand);
}

.budget-value {
  min-width: 80px;
  text-align: right;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.panel-note {
  grid-column: 1 / -1;
  color: var(--text-3);
  font-size: 12px;
}

/* 学割ピース */
.pieces-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 12px;
}

.piece {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.piece:hover {
  border-color: var(--brand-light);
}

.piece.selected {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.piece-body {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 16px 16px 12px;
  border: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.piece-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex-shrink: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  color: transparent;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.piece-check .icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.25;
}

.piece-body:hover .piece-check {
  border-color: var(--brand-light);
}

.piece.selected .piece-check {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.piece-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.piece-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.piece-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
}

.piece-save {
  font-size: 16px;
  font-weight: 600;
  color: var(--brand-deep);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.piece-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}

.piece-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  font-size: 11px;
  line-height: 16px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--raised);
  color: var(--text-2);
}

.tag.limit {
  background: var(--brand-tint);
  color: var(--brand-deep);
}

.piece-details {
  margin-top: auto;
  border-top: 1px solid var(--line);
}

.piece-summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 16px 10px 48px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

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

.piece-summary::after {
  content: "▾";
  font-size: 11px;
  color: var(--text-3);
  transition: transform 0.15s ease;
}

.piece-details[open] .piece-summary::after {
  transform: rotate(180deg);
}

.piece-summary:hover {
  color: var(--text-1);
}

.piece-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  padding: 2px 16px 14px 48px;
}

.piece-note {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
}

.piece-links {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 12px;
}

/* アドバイス＆シェア */
.advice-box {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  padding: 8px 20px 20px;
  margin-bottom: 40px;
}

.advice-list {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.advice-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 1px solid var(--line);
}

.advice-item > .icon {
  margin-top: 3px;
  color: var(--text-3);
}

.advice-item.alert > .icon,
.advice-item.trend > .icon {
  color: var(--brand);
}

.advice-item strong {
  color: var(--text);
  font-weight: 600;
}

.advice-body {
  min-width: 0;
}

.advice-item ol {
  margin: 4px 0 0 1.4em;
}

.action-row {
  display: flex;
  gap: 8px 12px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.12s var(--ease);
}

.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.98);
}

.btn-primary {
  border: 1px solid var(--brand-deep);
  background: var(--brand-deep);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand);
  border-color: var(--brand);
}

.btn-secondary {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--raised);
}

.btn-secondary .icon {
  color: var(--text-3);
}

.copy-toast {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--brand);
}

/* ガイド系セクション（箱の入れ子をやめ、罫線で区切る） */
.guide-section {
  padding: 32px 0 0;
  border-top: 1px solid var(--line-strong);
}

.guide-section + .guide-section {
  margin-top: 40px;
}

.guide-section > .section-title,
.section-head {
  margin-bottom: 16px;
}

.pitfall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 20px 32px;
}

.pitfall-card {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.pitfall-card h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.pitfall-card .num {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.pitfall-card p {
  font-size: 13px;
  color: var(--text-2);
}

.guide-section > .panel-note {
  margin-top: 16px;
}

/* 金額換算外の優待 */
.extra-benefits ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 16px 32px;
  list-style: none;
}

.extra-benefits li {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.extra-benefits a {
  font-size: 14px;
  font-weight: 600;
}

.extra-benefits li p {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13px;
}

/* 解説記事 */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.more-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.more-link:hover {
  text-decoration: underline;
}

.article-list {
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
}

.article-list li + li {
  border-top: 1px solid var(--line);
}

.article-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.article-list li:first-child a {
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.article-list li:last-child a {
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.article-list a:hover {
  background: var(--brand-tint);
  color: var(--brand-deep);
}

.article-list a .icon {
  color: var(--text-3);
}

.article-list a:hover .icon {
  color: var(--brand);
}

/* フッター */
.site-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line-strong);
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin-bottom: 8px;
  font-size: 13px;
}

.site-footer a {
  color: var(--text-2);
}

.site-footer a:hover {
  color: var(--brand-deep);
}

@media (max-width: 740px) {
  .plan-pills {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .container {
    padding: 16px 12px 48px;
  }

  .site-header {
    gap: 4px 12px;
    margin-bottom: 28px;
  }

  .page-nav {
    gap: 4px 12px;
  }

  .scoreboard {
    top: 4px;
    padding: 12px;
  }

  .controls-row {
    margin-bottom: 12px;
  }

  .plan-pills .seg {
    flex-direction: column;
    gap: 0;
    padding: 4px 8px;
  }

  .win-pc-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .big-net {
    font-size: 24px;
  }

  .preset-label {
    flex-basis: 100%;
  }

  .reset-btn {
    margin-left: 0;
  }

  .special-panel,
  .advice-box {
    padding-left: 16px;
    padding-right: 16px;
  }

  .piece-body {
    padding: 12px 12px 8px;
  }

  .piece-foot {
    padding: 0 12px 12px 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
