:root {
  --paper: #fbf7ee;
  --line: #d9cfb6;
  --ink: #2b3a55;
  --ink-soft: #5b6b85;
  --necessary: #4a7fb5;
  --enjoy: #e89b4a;
  --waste: #8c8c8c;
  --bg: #f3ecd9;
  --shadow: 0 2px 6px rgba(43, 58, 85, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Yomogi', 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

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

button, [role="tab"], .tag, .key, .lock-key, .month-arrow, .help-btn, .settings-btn, .toast__action, .help-modal__close, summary {
  touch-action: manipulation;
}

input[type="number"], input[type="date"] {
  font-family: 'Klee One', 'Yomogi', sans-serif;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  background: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 27px,
    rgba(217, 207, 182, 0.4) 27px,
    rgba(217, 207, 182, 0.4) 28px
  );
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

/* ─── 上部 (タイトル + タブ) ─── */
.topbar {
  flex-shrink: 0;
  padding: 8px 22px 0;
  position: relative;
}

.help-btn {
  position: absolute;
  top: 6px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1.5px solid var(--ink-soft);
  background: var(--paper);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3.5px;
  padding: 0;
}

.help-btn__bar {
  width: 16px;
  height: 1.8px;
  background: var(--ink-soft);
  border-radius: 1px;
  transition: background 0.15s ease;
}

.help-btn:active {
  background: var(--ink-soft);
}

.help-btn:active .help-btn__bar {
  background: var(--paper);
}

.title {
  font-size: 22px;
  text-align: center;
  margin: 0 0 6px;
  letter-spacing: 0.05em;
  font-weight: 400;
}

.tabs {
  display: flex;
  border-bottom: 1.5px solid var(--line);
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 0 10px;
  font-size: 17px;
  color: var(--ink-soft);
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.tab.is-active {
  color: var(--ink);
}

.tab.is-active::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -1.5px;
  height: 3px;
  background: var(--ink);
  border-radius: 2px;
}

/* ─── ペインビューポート ─── */
.pane-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.panes {
  display: flex;
  width: 300%;
  height: 100%;
  will-change: transform;
}

.panes.is-animating {
  transition: transform 0.25s ease;
}

.pane {
  width: 33.3333%;
  flex-shrink: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px 22px 0;
  overflow: hidden;
}

/* ─── 入力 (書くペイン) ─── */
.entry {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 10px;
}

.date-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.date-label {
  font-size: 16px;
  color: var(--ink-soft);
}

.date-input {
  background: transparent;
  border: none;
  border-bottom: 1.5px dashed var(--ink-soft);
  font-size: 16px;
  color: var(--ink);
  padding: 1px 4px;
  outline: none;
}

.amount-field {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px 4px;
  border-bottom: 2px solid var(--ink);
}

.yen {
  font-size: 32px;
  font-family: 'Klee One', sans-serif;
  color: var(--ink-soft);
}

.amount-display {
  flex: 1;
  font-family: 'Klee One', sans-serif;
  font-size: 40px;
  font-weight: 600;
  text-align: right;
  color: var(--ink);
  min-width: 0;
  user-select: none;
  -webkit-user-select: none;
  letter-spacing: 0.02em;
}

.amount-display.is-empty {
  color: #c4baa0;
  font-weight: 400;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.key {
  background: var(--paper);
  border: 1.5px solid var(--ink-soft);
  border-radius: 14px;
  font-family: 'Klee One', sans-serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  padding: 14px 0;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.key:active {
  transform: translateY(1px);
  background: rgba(43, 58, 85, 0.08);
}

.key--back {
  font-size: 22px;
  color: var(--ink-soft);
}

.key--blank {
  background: transparent;
  border: none;
  cursor: default;
  pointer-events: none;
}

.key--blank:active { transform: none; background: transparent; }

.ask {
  font-size: 15px;
  color: var(--ink-soft);
  margin: 0;
  text-align: center;
}

.ask-hint {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  opacity: 0.7;
  margin-top: 1px;
}

.tags {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.tag {
  flex: 1;
  background: var(--paper);
  border: 1.5px solid var(--tag-color, var(--ink-soft));
  border-radius: 12px;
  padding: 14px 4px;
  font-size: 18px;
  font-weight: 500;
  color: var(--tag-color, var(--ink));
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}

.tag:active {
  transform: translateY(1px);
  background: var(--tag-tint, rgba(43, 58, 85, 0.08));
}

.tag--necessary { --tag-color: var(--necessary); --tag-tint: rgba(74, 127, 181, 0.13); }
.tag--enjoy     { --tag-color: var(--enjoy);     --tag-tint: rgba(232, 155, 74, 0.13); }
.tag--waste     { --tag-color: var(--waste);     --tag-tint: rgba(140, 140, 140, 0.13); }

.tag.is-saved {
  animation: tag-saved 0.36s cubic-bezier(0.2, 0.8, 0.3, 1.05);
}

@keyframes tag-saved {
  0% {
    background: var(--paper);
    color: var(--tag-color);
    transform: scale(1);
  }
  35% {
    background: var(--tag-color);
    color: var(--paper);
    transform: scale(1.06);
  }
  65% {
    background: var(--tag-color);
    color: var(--paper);
    transform: scale(1.02);
  }
  100% {
    background: var(--paper);
    color: var(--tag-color);
    transform: scale(1);
  }
}

/* ─── 月のまとめ (きろくペイン) ─── */
.month {
  flex-shrink: 0;
  margin-bottom: 10px;
  padding: 10px 12px 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 12px;
}

.month-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.month-label {
  font-size: 18px;
  margin: 0;
  font-weight: 400;
}

.month-arrow {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 2px 12px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

/* 上限エディタ */
.limits-editor {
  margin: 0 0 8px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0 10px;
}

.limits-editor > summary {
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 5px 0;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}

.limits-editor > summary::-webkit-details-marker { display: none; }

.limits-editor > summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.15s ease;
}

.limits-editor[open] > summary::before { transform: rotate(90deg); }

.limits-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-bottom: 6px;
}

.limit-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--ink-soft);
}

.limit-cell__label { text-align: center; }

.limit-input {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
  font-family: 'Klee One', sans-serif;
  font-size: 16px;
  color: var(--ink);
  width: 100%;
  outline: none;
  text-align: right;
  -moz-appearance: textfield;
}

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

.limit-input:focus { border-color: var(--ink-soft); }

.limits-hint {
  font-size: 11px;
  color: var(--ink-soft);
  opacity: 0.7;
  margin: 0 0 5px;
  text-align: center;
}

.summary {
  list-style: none;
  margin: 0;
  padding: 0;
}

.summary__row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  column-gap: 10px;
  padding: 5px 4px;
  border-bottom: 1px dotted var(--line);
}

.sum-label { font-size: 16px; }
.sum-label--necessary { color: var(--necessary); }
.sum-label--enjoy     { color: var(--enjoy); }
.sum-label--waste     { color: var(--waste); font-size: 14px; }

.sum-value {
  font-family: 'Klee One', sans-serif;
  font-size: 17px;
  font-weight: 600;
}

.sum-limit {
  font-size: 12px;
  color: var(--ink-soft);
  margin-left: 4px;
  font-family: 'Klee One', sans-serif;
}

.sum-diff {
  font-size: 11px;
  color: var(--ink-soft);
  font-family: 'Klee One', sans-serif;
  white-space: nowrap;
  min-width: 56px;
  text-align: right;
}

.sum-diff.is-up    { color: #c5604a; }
.sum-diff.is-down  { color: #5e8c5d; }

.summary__row.is-over .sum-label,
.summary__row.is-over .sum-value,
.summary__row.is-over .sum-limit {
  color: #c5604a;
}

.summary__row.is-over .sum-limit::after {
  content: '';
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  background-image: url('yabai.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  vertical-align: -0.22em;
  margin-left: 4px;
}

.summary__row.is-near .sum-limit { color: #b88736; }

.ratio-bar {
  display: flex;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 0;
  background: rgba(217, 207, 182, 0.5);
}

.ratio-bar__seg {
  height: 100%;
  transition: flex-basis 0.25s ease;
  flex: 0 0 0%;
}

.ratio-bar__seg--necessary { background: var(--necessary); }
.ratio-bar__seg--enjoy     { background: var(--enjoy); }
.ratio-bar__seg--waste     { background: var(--waste); }

.total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 2px solid var(--ink);
}

.total-label { font-size: 16px; }

.total-value {
  font-family: 'Klee One', sans-serif;
  font-size: 22px;
  font-weight: 600;
}

/* ─── 状態の吹き出し ─── */
.status-bubble {
  position: relative;
  flex-shrink: 0;
  margin: 0 4px 8px;
  background: var(--paper);
  border: 1.5px solid currentColor;
  border-radius: 14px;
  padding: 9px 14px;
  font-size: 15px;
  text-align: center;
  letter-spacing: 0.02em;
}

.status-bubble::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 30px;
  width: 12px;
  height: 12px;
  background: var(--paper);
  border-left: 1.5px solid currentColor;
  border-top: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.status-bubble.is-neutral { color: var(--ink-soft); }
.status-bubble.is-good    { color: #5e8c5d; }
.status-bubble.is-soft    { color: #b88736; }
.status-bubble.is-caution { color: var(--enjoy); }
.status-bubble.is-alert   { color: #c5604a; }

/* ─── 一覧 (記録) ─── */
.list-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}

.list-title {
  font-size: 15px;
  margin: 0 0 4px;
  font-weight: 400;
  color: var(--ink-soft);
  flex-shrink: 0;
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0 4px 8px 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.entry-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px dashed var(--line);
}

.entry-date {
  width: 50px;
  font-size: 14px;
  color: var(--ink-soft);
  font-family: 'Klee One', sans-serif;
}

.entry-amount {
  flex: 1;
  font-family: 'Klee One', sans-serif;
  font-size: 17px;
  font-weight: 600;
}

.entry-tag {
  font-size: 13px;
  padding: 2px 9px;
  border-radius: 10px;
  color: white;
  white-space: nowrap;
}

.entry-tag--necessary { background: var(--necessary); }
.entry-tag--enjoy     { background: var(--enjoy); }
.entry-tag--waste     { background: var(--waste); font-size: 12px; }

.entry-delete {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 20px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.entry-delete:active {
  background: rgba(43, 58, 85, 0.1);
}

.empty-msg {
  text-align: center;
  color: var(--ink-soft);
  padding: 16px 0;
  font-size: 14px;
  margin: 0;
}

.empty-msg.is-hidden,
.entry-list.is-hidden { display: none; }

.footnote {
  flex-shrink: 0;
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 4px 22px 6px;
  margin: 0;
  opacity: 0.7;
}

/* ─── 自動入力エントリの見た目 ─── */
.entry-item.is-auto .entry-amount,
.entry-item.is-auto .entry-date {
  color: var(--ink-soft);
  opacity: 0.85;
}

.entry-item.is-auto .entry-tag {
  opacity: 0.65;
}

.entry-auto-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(43, 58, 85, 0.12);
  color: var(--ink-soft);
  margin-right: 2px;
  letter-spacing: 0.05em;
  font-family: 'Yomogi', sans-serif;
  white-space: nowrap;
}

/* ─── カレンダー ─── */
.cal {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding-top: 2px;
}

.cal-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 0 2px 4px;
  flex-shrink: 0;
}

.cal-week__day {
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
  letter-spacing: 0.05em;
}

.cal-week__day--sun { color: #c5604a; }
.cal-week__day--sat { color: var(--necessary); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: 4px;
  flex: 1;
  min-height: 0;
  padding-bottom: 2px;
}

.cal-cell {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 0;
  overflow: hidden;
  position: relative;
  font-family: 'Klee One', sans-serif;
  transition: background 0.12s ease;
}

.cal-cell.is-blank {
  background: transparent;
  border-color: transparent;
  cursor: default;
  pointer-events: none;
}

.cal-cell.is-today {
  border: 1.5px solid var(--ink);
}

.cal-cell.is-future {
  background: rgba(255, 255, 255, 0.4);
  opacity: 0.55;
}

.cal-cell:active {
  background: rgba(43, 58, 85, 0.08);
}

.cal-cell__date {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.1;
}

.cal-cell.is-sun .cal-cell__date { color: #c5604a; }
.cal-cell.is-sat .cal-cell__date { color: var(--necessary); }

.cal-cell__amount {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 2px;
  line-height: 1;
  text-align: center;
  word-break: break-all;
}

.cal-cell.is-auto .cal-cell__amount {
  color: var(--ink-soft);
  font-weight: 400;
  opacity: 0.75;
}

.cal-cell__auto {
  font-size: 8.5px;
  color: var(--ink-soft);
  margin-top: 1px;
  opacity: 0.7;
  letter-spacing: 0.04em;
  font-family: 'Yomogi', sans-serif;
  line-height: 1;
}

.cal-hint {
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
  margin: 6px 0 0;
  flex-shrink: 0;
  line-height: 1.5;
  opacity: 0.85;
}

.cal-hint__auto {
  font-size: 10px;
  opacity: 0.75;
}

/* ─── 日付編集モーダル ─── */
.day-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.day-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.day-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 58, 85, 0.4);
  cursor: pointer;
}

.day-modal__sheet {
  position: relative;
  background: var(--paper);
  border-radius: 16px;
  padding: 18px 20px 16px;
  max-width: 400px;
  width: 100%;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 8px 32px rgba(43, 58, 85, 0.3);
  transform: scale(0.94);
  transition: transform 0.22s cubic-bezier(0.18, 0.85, 0.32, 1.1);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 27px,
    rgba(217, 207, 182, 0.4) 27px,
    rgba(217, 207, 182, 0.4) 28px
  );
}

.day-modal.is-open .day-modal__sheet {
  transform: scale(1);
}

.day-modal__close {
  position: absolute;
  top: 6px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--ink-soft);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}

.day-modal__close:active { background: rgba(43, 58, 85, 0.1); }

.day-modal__title {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 400;
  text-align: center;
  letter-spacing: 0.04em;
}

.day-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}

.day-list:empty + .day-empty { display: block; }
.day-list:not(:empty) ~ .day-empty { display: none; }

.day-empty {
  display: none;
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 10px 0 6px;
  margin: 0;
  opacity: 0.8;
}

.day-list__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--line);
  flex-wrap: wrap;
}

.day-list__amount-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.day-list__yen {
  color: var(--ink-soft);
  font-size: 14px;
  font-family: 'Klee One', sans-serif;
}

.day-list__amount {
  font-family: 'Klee One', sans-serif;
  font-size: 16px;
  font-weight: 600;
  padding: 4px 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 84px;
  text-align: right;
  outline: none;
  color: var(--ink);
  -moz-appearance: textfield;
}

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

.day-list__amount:focus { border-color: var(--ink-soft); }

.day-list__tags {
  display: flex;
  gap: 4px;
}

.day-list__tag {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 8px;
  border: 1.5px solid var(--tag-color, var(--ink-soft));
  color: var(--tag-color, var(--ink));
  background: var(--paper);
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.day-list__tag.is-active {
  background: var(--tag-color, var(--ink-soft));
  color: var(--paper);
}

.day-list__tag--necessary { --tag-color: var(--necessary); }
.day-list__tag--enjoy     { --tag-color: var(--enjoy); }
.day-list__tag--waste     { --tag-color: var(--waste); }

.day-list__delete {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 20px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  margin-left: auto;
}

.day-list__delete:active { background: rgba(43, 58, 85, 0.1); }

.day-list__auto {
  display: inline-block;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(43, 58, 85, 0.12);
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  font-family: 'Yomogi', sans-serif;
  flex-shrink: 0;
}

.day-list__item.is-auto .day-list__amount {
  color: var(--ink-soft);
  border-style: dashed;
}

.day-add {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.day-add__title {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0 0 8px;
  text-align: center;
  letter-spacing: 0.04em;
}

.day-add__amount {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 4px 8px;
  border-bottom: 1.5px solid var(--ink);
}

.day-add__amount .yen {
  font-size: 22px;
}

.day-add__amount input {
  flex: 1;
  font-family: 'Klee One', sans-serif;
  font-size: 22px;
  font-weight: 600;
  padding: 4px 0;
  background: transparent;
  border: none;
  outline: none;
  text-align: right;
  color: var(--ink);
  -moz-appearance: textfield;
  min-width: 0;
}

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

.day-add__tags {
  display: flex;
  gap: 8px;
}

.day-add__tag {
  flex: 1;
  padding: 10px 4px;
  font-size: 15px;
  font-family: inherit;
  border: 1.5px solid var(--tag-color, var(--ink-soft));
  border-radius: 10px;
  background: var(--paper);
  color: var(--tag-color, var(--ink));
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, transform 0.08s ease;
}

.day-add__tag:active {
  transform: translateY(1px);
  background: var(--tag-tint, rgba(43, 58, 85, 0.08));
}

.day-add__tag--necessary { --tag-color: var(--necessary); --tag-tint: rgba(74, 127, 181, 0.13); }
.day-add__tag--enjoy     { --tag-color: var(--enjoy);     --tag-tint: rgba(232, 155, 74, 0.13); }
.day-add__tag--waste     { --tag-color: var(--waste);     --tag-tint: rgba(140, 140, 140, 0.13); }

/* 狭い画面でのモーダル調整 */
@media (max-width: 360px) {
  .day-list__amount { width: 76px; font-size: 15px; }
  .day-list__tag { padding: 4px 7px; font-size: 11px; }
  .day-list__delete { width: 28px; height: 28px; font-size: 18px; }
  .cal-cell__amount { font-size: 10px; }
  .cal-cell__date { font-size: 11px; }
}

/* ─── トースト ─── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px) scale(0.96);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 15px;
  letter-spacing: 0.05em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1.1);
  z-index: 100;
  box-shadow: 0 4px 16px rgba(43, 58, 85, 0.2);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
}

.toast__action {
  background: transparent;
  border: 1.5px solid var(--paper);
  color: var(--paper);
  border-radius: 999px;
  padding: 4px 12px;
  margin-left: 12px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.toast__action:active {
  background: var(--paper);
  color: var(--ink);
}

.toast__action[hidden] { display: none; }

.toast--yabai::before {
  content: '';
  display: inline-block;
  width: 1.3em;
  height: 1.3em;
  background-image: url('yabai.svg');
  background-size: contain;
  background-repeat: no-repeat;
  vertical-align: middle;
  margin-right: 6px;
  flex-shrink: 0;
}

/* ─── 長押しヒント ─── */
.hint-pop {
  position: fixed;
  background: var(--ink);
  color: var(--paper);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 90;
  box-shadow: 0 4px 12px rgba(43, 58, 85, 0.25);
}

.hint-pop::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--ink);
}

.hint-pop.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ─── 使い方モーダル ─── */
.help-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.help-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.help-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 58, 85, 0.4);
  cursor: pointer;
}

.help-modal__sheet {
  position: relative;
  background: var(--paper);
  transform: scale(0.94);
  transition: transform 0.22s cubic-bezier(0.18, 0.85, 0.32, 1.1);
  border-radius: 16px;
  padding: 20px 22px 16px;
  max-width: 380px;
  width: 100%;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(43, 58, 85, 0.3);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 27px,
    rgba(217, 207, 182, 0.4) 27px,
    rgba(217, 207, 182, 0.4) 28px
  );
}

.help-modal.is-open .help-modal__sheet {
  transform: scale(1);
}

.help-modal__close {
  position: absolute;
  top: 6px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--ink-soft);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}

.help-modal__close:active { background: rgba(43, 58, 85, 0.1); }

.help-modal__title {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 400;
  text-align: center;
  letter-spacing: 0.05em;
}

.help-list {
  margin: 0 0 12px;
  padding-left: 22px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
}

.help-list li { margin-bottom: 4px; }
.help-list b { font-weight: 600; color: var(--ink); }

.help-modal__note {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  margin: 8px 0 0;
  opacity: 0.8;
}

.help-section__title {
  font-size: 16px;
  font-weight: 400;
  color: var(--ink);
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--line);
}

/* 設定行 */
.settings-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 10px;
  padding: 4px 2px;
}

.settings-row__label {
  font-size: 15px;
}

.settings-row__status {
  font-size: 13px;
  color: var(--ink-soft);
  font-family: 'Klee One', sans-serif;
}

.settings-row__actions {
  display: flex;
  gap: 6px;
}

.settings-btn {
  background: var(--ink);
  color: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

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

.settings-btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--ink-soft);
}

.settings-btn[hidden] { display: none; }

/* ─── ロック画面 ─── */
.is-locked .page { display: none; }
.is-locked .lock-screen { display: flex; }

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 27px,
    rgba(217, 207, 182, 0.4) 27px,
    rgba(217, 207, 182, 0.4) 28px
  );
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 22px;
}

.lock-screen.is-show { display: flex; }

.lock-screen__inner {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lock-screen__title {
  font-size: 24px;
  margin: 0 0 24px;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.lock-screen__dots {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
}

.lock-screen__dots span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: transparent;
  transition: background 0.1s ease, transform 0.1s ease;
}

.lock-screen__dots span.is-filled {
  background: var(--ink);
  transform: scale(1.1);
}

.lock-screen__dots.is-shake {
  animation: lock-shake 0.34s ease;
}

@keyframes lock-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  60% { transform: translateX(9px); }
  80% { transform: translateX(-4px); }
}

.lock-screen__hint {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 22px;
  min-height: 18px;
  text-align: center;
}

.lock-screen__pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
}

.lock-key {
  background: var(--paper);
  border: 1.5px solid var(--ink-soft);
  border-radius: 50%;
  width: 64px;
  height: 64px;
  font-size: 26px;
  font-family: 'Klee One', sans-serif;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  transition: transform 0.05s ease, background 0.15s ease;
}

.lock-key:active {
  transform: translateY(1px);
  background: rgba(43, 58, 85, 0.1);
}

.lock-key--back {
  font-size: 22px;
  color: var(--ink-soft);
}

.lock-key--ghost {
  font-size: 14px;
  color: var(--ink-soft);
  border-style: dashed;
  width: 64px;
  height: 64px;
}

.lock-key[hidden] { display: none; }

.lock-screen__forgot {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 13px;
  margin-top: 22px;
  cursor: pointer;
  text-decoration: underline dashed;
  text-underline-offset: 3px;
  -webkit-tap-highlight-color: transparent;
}

.lock-screen__forgot[hidden] { display: none; }

@media (max-height: 640px) {
  .lock-screen__title { font-size: 22px; margin-bottom: 18px; }
  .lock-key { width: 56px; height: 56px; font-size: 22px; }
  .lock-key--ghost { width: 56px; height: 56px; }
}

/* ─── 狭い画面 ─── */
@media (max-height: 640px) {
  .title { font-size: 20px; margin-bottom: 4px; }
  .topbar { padding: 6px 22px 0; }
  .tab { padding: 6px 0 8px; font-size: 16px; }
  .pane { padding: 8px 22px 0; }
  .entry { gap: 8px; }
  .amount-display { font-size: 36px; }
  .yen { font-size: 28px; }
  .amount-field { padding: 4px 12px 2px; }
  .key { padding: 12px 0; font-size: 24px; }
  .key--back { font-size: 20px; }
  .tag { padding: 12px 4px; font-size: 17px; }
  .ask { font-size: 14px; }
}

@media (max-width: 360px) {
  .pane { padding: 10px 14px 0; }
  .topbar { padding: 6px 14px 0; }
  .footnote { padding: 4px 14px 6px; }
}
