/* =============================================
   サブスク管理アプリ - 共通スタイル
   ============================================= */

/* ---------- CSS変数（カラーパレット） ---------- */
:root {
  --bg:       #f5f2ec;
  --yellow:   #f5df7a;
  --mint:     #a8dbc9;
  --pink:     #f5b8b8;
  --sky:      #a8d4f5;
  --peach:    #f5c9a0;
  --lavender: #c9b8f5;
  --text:     #2a2520;
  --text-sub: #9a9088;
  --border:   #e0dbd0;
}

/* ---------- リセット・ベース ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 88px;
  max-width: 430px;
  margin: 0 auto;
}

/* ---------- ページ切り替え ---------- */
.page { display: block; }
.page[hidden] { display: none; }

/* ---------- ヘッダー ---------- */
.header {
  background: var(--bg);
  padding: 20px 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--text);
}

.logo { font-family: 'Kaisei Opti', serif; font-size: 22px; font-weight: 700; }
.logo-sub { font-family: 'Caveat', cursive; font-size: 13px; color: var(--text-sub); margin-top: 2px; }

/* ---------- ボトムナビ ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg);
  border-top: 2px solid var(--text);
  display: flex;
  padding: 10px 0 20px;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

.nav-item svg { width: 28px; height: 28px; }

.nav-label {
  font-family: 'Caveat', cursive;
  font-size: 11px;
  color: var(--text-sub);
}

.nav-item.active .nav-label { color: var(--text); font-weight: 700; }

.nav-item.active svg path,
.nav-item.active svg rect,
.nav-item.active svg circle { stroke: var(--text); }

.nav-item:not(.active) svg path,
.nav-item:not(.active) svg rect,
.nav-item:not(.active) svg circle { stroke: var(--text-sub); }


/* =============================================
   ホーム画面
   ============================================= */

/* ヒーローエリア */
.hero-main {
  background: var(--yellow);
  padding: 24px 20px 20px;
  position: relative;
  overflow: hidden;
  border-top: 2px solid var(--text);
}

.hero-label { font-family: 'Caveat', cursive; font-size: 14px; color: #7a6f30; margin-bottom: 4px; }

.hero-amount {
  font-family: 'Kaisei Opti', serif;
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -2px;
}

.hero-amount-unit { font-size: 22px; vertical-align: super; margin-right: 2px; }
.hero-amount-sub { font-size: 13px; font-family: 'Noto Sans JP', sans-serif; color: #7a6f30; margin-top: 6px; }

.hero-deco-circle {
  position: absolute;
  right: 24px; top: 50%;
  transform: translateY(-50%);
  width: 80px; height: 80px;
  border: 2px dashed #c4b840;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Caveat', cursive;
  font-size: 12px;
  color: #7a6f30;
  text-align: center;
  line-height: 1.4;
}

/* 統計ブロック（月額契約・年間契約・合計） */
.stat-blocks {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-top: 2px solid var(--text);
}

.stat-block { padding: 14px 12px; border-right: 2px solid var(--text); }
.stat-block:last-child { border-right: none; }
.stat-block:nth-child(1) { background: var(--mint); }
.stat-block:nth-child(2) { background: var(--pink); }
.stat-block:nth-child(3) { background: var(--sky); }

.stat-block-label { font-family: 'Caveat', cursive; font-size: 12px; color: rgba(0,0,0,0.5); margin-bottom: 4px; }
.stat-block-value { font-family: 'Kaisei Opti', serif; font-size: 22px; font-weight: 700; line-height: 1; }
.stat-block-unit { font-size: 11px; font-family: 'Noto Sans JP', sans-serif; }

/* カテゴリフィルター */
.filter-section {
  padding: 14px 20px 0;
  border-top: 2px solid var(--text);
}

.filter-label { font-family: 'Caveat', cursive; font-size: 13px; color: var(--text-sub); margin-bottom: 8px; }

.filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
}

.filter-scroll::-webkit-scrollbar { display: none; }

.filter-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: white;
  transition: all 0.15s;
  min-width: 54px;
}

.filter-chip.active {
  background: var(--text);
  border-color: var(--text);
}

.filter-chip svg { width: 24px; height: 24px; }

.filter-chip:not(.active) svg path,
.filter-chip:not(.active) svg rect,
.filter-chip:not(.active) svg circle,
.filter-chip:not(.active) svg line,
.filter-chip:not(.active) svg polyline,
.filter-chip:not(.active) svg ellipse { stroke: var(--text-sub); }

.filter-chip.active svg path,
.filter-chip.active svg rect,
.filter-chip.active svg circle,
.filter-chip.active svg line,
.filter-chip.active svg polyline,
.filter-chip.active svg ellipse { stroke: var(--bg); }

.filter-chip:not(.active) svg circle[fill]:not([fill="none"]) { fill: var(--text-sub); }
.filter-chip.active svg circle[fill]:not([fill="none"]) { fill: var(--bg); }

.filter-chip-label {
  font-family: 'Caveat', cursive;
  font-size: 11px;
  color: var(--text-sub);
  white-space: nowrap;
  font-weight: 700;
}

.filter-chip.active .filter-chip-label { color: var(--bg); }

/* サブスクリストエリア */
.list-area {
  padding: 0 20px;
  border-top: 2px solid var(--text);
}

.list-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 10px;
  border-bottom: 1.5px solid var(--border);
}

.list-section-tag { font-family: 'Caveat', cursive; font-size: 18px; font-weight: 700; }
.list-section-count { font-family: 'Caveat', cursive; font-size: 13px; color: var(--text-sub); }

.sub-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1.5px solid var(--border);
  cursor: pointer;
  position: relative;
}

.sub-color-bar { width: 4px; height: 48px; border-radius: 2px; flex-shrink: 0; }

.sub-icon-box {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: white;
  border-radius: 6px;
  border: 1.5px solid var(--border);
}

.sub-icon-box svg { width: 32px; height: 32px; }
.sub-info { flex: 1; min-width: 0; }
.sub-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.sub-cat { font-family: 'Caveat', cursive; font-size: 12px; color: var(--text-sub); }

.sub-period-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: 'Caveat', cursive;
  font-size: 10px;
  background: var(--peach);
  border-radius: 3px;
  padding: 2px 7px 2px 5px;
  margin-top: 3px;
  color: #7a4a20;
}

.sub-period-tag svg { width: 11px; height: 11px; flex-shrink: 0; }

.sub-price-area { text-align: right; flex-shrink: 0; }
.sub-price-main { font-family: 'Kaisei Opti', serif; font-size: 18px; font-weight: 700; line-height: 1.2; }
.sub-price-unit { font-size: 11px; font-family: 'Noto Sans JP', sans-serif; color: var(--text-sub); font-weight: 400; }
.sub-price-sub { font-family: 'Caveat', cursive; font-size: 11px; color: var(--text-sub); }

/* 追加ボタン（ヘッダー内） */
.header-add {
  font-family: 'Caveat', cursive;
  font-size: 15px;
  font-weight: 700;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
}

/* 空状態 */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-sub);
}

.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state-text { font-family: 'Caveat', cursive; font-size: 16px; }


/* =============================================
   グラフ画面
   ============================================= */

/* 月選択 */
.month-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 2px solid var(--text);
  background: white;
}

.month-btn {
  background: none;
  border: 1.5px solid var(--text);
  border-radius: 4px;
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.month-label { font-family: 'Kaisei Opti', serif; font-size: 18px; font-weight: 700; }

/* 先月比バナー */
.compare-banner {
  margin: 16px 20px 0;
  background: var(--mint);
  border-radius: 10px;
  border: 1.5px solid var(--text);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.compare-label { font-family: 'Caveat', cursive; font-size: 13px; color: var(--text-sub); }
.compare-value { font-family: 'Kaisei Opti', serif; font-size: 20px; font-weight: 700; }
.compare-badge {
  font-family: 'Caveat', cursive;
  font-size: 12px;
  background: var(--text);
  color: var(--bg);
  padding: 3px 10px;
  border-radius: 20px;
}

/* TOP3 */
.top3-section { padding: 16px 20px 0; }
.section-title { font-family: 'Caveat', cursive; font-size: 18px; font-weight: 700; margin-bottom: 10px; }

.top3-list { display: flex; flex-direction: column; gap: 8px; }

.top3-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  border-radius: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
}

.top3-rank { font-family: 'Kaisei Opti', serif; font-size: 20px; font-weight: 700; width: 24px; color: var(--text-sub); }
.top3-rank.first { color: var(--text); }
.top3-name { flex: 1; font-size: 13px; font-weight: 700; }
.top3-price { font-family: 'Kaisei Opti', serif; font-size: 16px; font-weight: 700; }
.top3-unit { font-size: 10px; color: var(--text-sub); font-family: 'Noto Sans JP', sans-serif; }

/* カテゴリ円グラフ */
.chart-section { padding: 16px 20px 0; }

.pie-area {
  background: white;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  padding: 16px;
}

.pie-wrap { display: flex; align-items: center; gap: 16px; }
.pie-svg { flex-shrink: 0; }

.legend { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.legend-name { font-size: 11px; font-weight: 700; flex: 1; }
.legend-pct { font-family: 'Caveat', cursive; font-size: 13px; font-weight: 700; }

/* 月別棒グラフ */
.bar-section { padding: 16px 20px 0; }

.bar-area {
  background: white;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  padding: 16px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
  margin-bottom: 6px;
}

.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-fill { width: 100%; border-radius: 4px 4px 0 0; border: 1.5px solid var(--text); }
.bar-label { font-family: 'Caveat', cursive; font-size: 10px; color: var(--text-sub); }
.bar-amount { font-family: 'Caveat', cursive; font-size: 9px; color: var(--text-sub); }

/* アラート */
.alert-section { padding: 16px 20px; }

.alert-card {
  background: var(--pink);
  border-radius: 10px;
  border: 1.5px solid var(--text);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.alert-icon svg { width: 24px; height: 24px; }
.alert-text-wrap { flex: 1; }
.alert-title { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.alert-body { font-family: 'Caveat', cursive; font-size: 13px; color: var(--text-sub); }


/* =============================================
   データ管理画面
   ============================================= */

.section { padding: 20px 20px 0; }
.section-title-data { font-family: 'Caveat', cursive; font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.section-desc { font-size: 12px; color: var(--text-sub); margin-bottom: 14px; line-height: 1.6; }

/* データ概要カード */
.summary-card {
  background: var(--yellow);
  border-radius: 12px;
  border: 1.5px solid var(--text);
  padding: 16px 20px;
  margin: 16px 20px 0;
}

.summary-label { font-family: 'Caveat', cursive; font-size: 13px; color: #7a6f30; margin-bottom: 8px; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary-item-label { font-family: 'Caveat', cursive; font-size: 11px; color: #7a6f30; }
.summary-item-value { font-family: 'Kaisei Opti', serif; font-size: 20px; font-weight: 700; }
.summary-item-unit { font-size: 11px; font-family: 'Noto Sans JP', sans-serif; }

/* ファイル情報カード */
.file-info-card {
  background: white;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.file-icon svg { width: 32px; height: 32px; }
.file-detail { flex: 1; }
.file-name { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.file-meta { font-family: 'Caveat', cursive; font-size: 12px; color: var(--text-sub); }
.file-badge {
  font-family: 'Caveat', cursive;
  font-size: 11px;
  background: var(--mint);
  border-radius: 4px;
  padding: 3px 8px;
  color: var(--text);
}

/* アクションボタン */
.action-btn {
  width: 100%;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1.5px solid var(--text);
  cursor: pointer;
  margin-bottom: 10px;
  background: white;
  font-family: 'Noto Sans JP', sans-serif;
}

.action-btn.primary { background: var(--text); color: var(--bg); }
.action-btn svg { width: 28px; height: 28px; flex-shrink: 0; }
.action-btn-text { flex: 1; text-align: left; }
.action-btn-title { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.action-btn-sub { font-family: 'Caveat', cursive; font-size: 12px; opacity: 0.7; }
.action-arrow { font-size: 18px; opacity: 0.5; }

/* プレビューカード */
.preview-card {
  background: white;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.preview-title { font-family: 'Caveat', cursive; font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.preview-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.preview-row:last-child { border-bottom: none; }
.preview-key { color: var(--text-sub); }
.preview-val { font-weight: 700; }

/* 注意書きカード */
.note-card {
  background: var(--peach);
  border-radius: 10px;
  border: 1.5px solid var(--text);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.note-icon { font-size: 18px; flex-shrink: 0; }
.note-text { font-family: 'Caveat', cursive; font-size: 13px; line-height: 1.6; color: #7a4a20; }


/* =============================================
   設定画面
   ============================================= */

.setting-section-title {
  font-family: 'Caveat', cursive;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.setting-group {
  background: white;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  overflow: hidden;
  margin-bottom: 4px;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.setting-row:last-child { border-bottom: none; }

.setting-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.setting-icon svg { width: 18px; height: 18px; }
.setting-text { flex: 1; }
.setting-label { font-size: 14px; font-weight: 700; margin-bottom: 1px; }
.setting-value { font-family: 'Caveat', cursive; font-size: 12px; color: var(--text-sub); }
.setting-arrow { color: var(--text-sub); font-size: 16px; }

/* トグルスイッチ */
.toggle {
  width: 44px; height: 24px;
  border-radius: 12px;
  border: 1.5px solid var(--text);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  background: white;
  transition: background 0.2s;
}

.toggle.on { background: var(--mint); }

.toggle-knob {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text);
  position: absolute;
  top: 2px; left: 2px;
  transition: left 0.2s;
}

.toggle.on .toggle-knob { left: 22px; }

/* セレクトボックス */
.setting-select {
  font-family: 'Caveat', cursive;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}

/* アプリ情報カード */
.app-info-card {
  background: var(--lavender);
  border-radius: 12px;
  border: 1.5px solid var(--text);
  padding: 20px;
  text-align: center;
  margin-bottom: 4px;
}

.app-info-logo { font-family: 'Kaisei Opti', serif; font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.app-info-ver { font-family: 'Caveat', cursive; font-size: 13px; color: var(--text-sub); margin-bottom: 12px; }
.app-info-badges { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.app-badge {
  font-family: 'Caveat', cursive;
  font-size: 11px;
  background: white;
  border-radius: 20px;
  padding: 4px 12px;
  border: 1.5px solid var(--border);
}


/* =============================================
   モーダル（追加・編集）
   ============================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 37, 32, 0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay[hidden] { display: none; }

.modal-sheet {
  background: var(--bg);
  width: 100%;
  max-width: 430px;
  border-radius: 16px 16px 0 0;
  border-top: 2px solid var(--text);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}

.modal-title {
  font-family: 'Kaisei Opti', serif;
  font-size: 18px;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-sub);
  padding: 4px 8px;
  line-height: 1;
}

.modal-body { padding: 20px 20px 0; }

/* フォーム共通 */
.form-group { margin-bottom: 16px; }

.form-label {
  font-family: 'Caveat', cursive;
  font-size: 15px;
  font-weight: 700;
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.required { color: #c05050; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 15px;
  background: white;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--text);
}

.form-textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.6;
}

/* 数値inputのスピナー非表示 */
.form-input[type="number"]::-webkit-inner-spin-button,
.form-input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.form-input[type="number"] { -moz-appearance: textfield; }

/* 支払いサイクルトグル */
.billing-toggle {
  display: flex;
  border: 1.5px solid var(--text);
  border-radius: 8px;
  overflow: hidden;
}

.billing-btn {
  flex: 1;
  padding: 11px;
  border: none;
  background: white;
  font-family: 'Caveat', cursive;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-sub);
  transition: all 0.15s;
}

.billing-btn:first-child { border-right: 1.5px solid var(--text); }
.billing-btn.active { background: var(--text); color: var(--bg); }

/* 金額入力 */
.price-input-wrap { position: relative; }

.price-symbol {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Kaisei Opti', serif;
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
}

.price-input { padding-left: 30px; }

/* モーダルフッター */
.modal-footer {
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-modal-save {
  width: 100%;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 10px;
  padding: 16px;
  font-family: 'Kaisei Opti', serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-modal-delete {
  width: 100%;
  background: white;
  color: #c05050;
  border: 1.5px solid #c05050;
  border-radius: 10px;
  padding: 14px;
  font-family: 'Caveat', cursive;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* サブスクカードのイニシャルアイコン */
.sub-icon-initial {
  font-family: 'Kaisei Opti', serif;
  font-size: 15px;
  font-weight: 700;
}
