:root {
  --bg: #fbf6ee;
  --paper: #fffdf8;
  --ink: #5b4a3f;
  --ink-soft: #8c7b6e;
  --line: #e6dccd;
  --peach: #f6c9b3;
  --mint: #bfe3d0;
  --sky: #c9ddf2;
  --lav: #dcd0f0;
  --yellow: #f7e3a1;
  --pink: #f4b8c8;
  --clean: #a9d9bd;
  --normal: #f5d98a;
  --messy: #f2a9a0;
  --radius-wobbly: 18px 22px 20px 24px / 24px 18px 22px 20px;
  --gauge: var(--yellow); /* 経験値ゲージの色（黄） */
  /* 端末の切り欠きやホームインジケーターの分。app.js が実測値（px）で上書きする */
  --inset-top: env(safe-area-inset-top, 0px);
  --inset-bottom: env(safe-area-inset-bottom, 0px);
  --safe-bottom: var(--inset-bottom);
  --header-top: calc(14px + var(--inset-top));
}

/* 全画面（ホーム画面から起動）のとき。メディアクエリが効かない端末向けに、JS で付ける印でも同じにする */
@media (display-mode: standalone) {
  :root {
    --header-top: max(4px, calc(var(--inset-top) - 6px));
  }
}

:root.is-standalone {
  --header-top: max(4px, calc(var(--inset-top) - 6px));
}

html { background: var(--paper); }

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Rounded Mplus 1c", "Yu Gothic", sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

/* ページ全体は固定し、本文（.main）だけをスクロールさせる。
   こうするとヘッダーとタブバーが慣性スクロールで動かない */
body {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: pan-x pan-y; /* ピンチズームとダブルタップ拡大を効かせない（スクロールだけ） */
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* アイコン（index.html のスプライトを use で参照） */
.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.18em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.icon-flame { width: 1.15em; height: 1.15em; color: #e0704a; --icon-fill-a: var(--peach); }
.icon-flame.icon-off { color: var(--ink-soft); --icon-fill-a: var(--line); }
.icon-timer { --icon-fill-a: var(--sky); }
.icon-sparkle { color: #c9a227; --icon-fill-a: var(--yellow); --icon-fill-b: var(--yellow); }

/* ヘッダー */
.header {
  flex: none;
  z-index: 10;
  /* 全画面ではステータスバーの下までヘッダーの色を伸ばし、その分の上余白は小さくする */
  padding: var(--header-top) 16px 10px;
  background: var(--bg);
  border-bottom: 2.5px solid var(--ink);
  border-image: none;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ヘッダーの1行: 「Lv. 称号」の札（背景が経験値ゲージ。押すと記録）と設定。開いている画面のボタンをもう一度押すとクエスト一覧へ */
.hd-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lv-gauge {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
  padding: 4px 10px 4px 12px;
  border: 2.2px solid var(--ink);
  border-radius: 14px 18px 16px 20px / 20px 14px 18px 16px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* 塗りが経験値の進み具合。境界線は付けない */
.lv-gauge-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--gauge);
  transition: width 0.5s ease;
}

.lv-gauge-text { position: relative; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* 現在の経験値は太字で大きく。「/ 次のレベルまで」は小さく添える */
.xp-now {
  position: relative;
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}
.xp-now strong { font-size: 20px; line-height: 1; font-weight: 700; color: var(--ink); }
.xp-now span { font-size: 11px; font-weight: 500; color: var(--ink-soft); }

/* メイン */
.main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* 本文は 900px までで中央寄せ。左右の余白で中央に置く */
  padding: 16px max(16px, calc((100% - 900px) / 2)) calc(32px + var(--safe-bottom));
}

.placeholder {
  padding: 40px 0;
  text-align: center;
  color: var(--ink-soft);
}

/* タブバー */
.tab {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
}

.tab-icon {
  display: block;
  height: 26px;
  transition: transform 0.15s ease;
}

.tab-svg {
  width: 26px;
  height: 26px;
  stroke-width: 1.8;
  --icon-fill-a: var(--line);
  --icon-fill-b: var(--paper);
}

.tab.is-active { color: var(--ink); }
.tab.is-active .tab-icon { transform: scale(1.1); }
.tab.is-active .tab-svg { stroke-width: 2; }

/* 札はナビの一員（押すと記録）。.tab の幅と色の指定を打ち消す */
.tab.lv-gauge { flex: 1; width: auto; height: auto; justify-content: space-between; color: var(--ink); font-family: inherit; text-align: left; }
.tab.lv-gauge:active { transform: translate(1px, 1px); }

/* 記録・設定を開いている間の閉じるボタン。右端に置く */
.hd-close {
  flex: none;
  width: 36px;
  height: 36px;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  border-radius: 50%;
}
.hd-close .icon { width: 26px; height: 26px; }
.hd-close:active { background: var(--line); }
.tab.is-active[data-tab="log"] .tab-svg { --icon-fill-a: var(--mint); --icon-fill-b: var(--ink); }
.tab.is-active[data-tab="settings"] .tab-svg { --icon-fill-a: var(--lav); --icon-fill-b: var(--paper); }

/* クエスト画面 */
.quest-section { margin-bottom: 18px; }

.quest-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: default;
}

.quest-details > summary {
  cursor: pointer;
  list-style: none;
  color: var(--ink-soft);
}

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

.quest-details > summary::before {
  content: '▸';
  font-size: 12px;
  transition: transform 0.15s ease;
}

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

.count {
  font-size: 12px;
  padding: 1px 8px;
  border: 1.8px solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
}

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

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

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px;
  box-shadow: 3px 3px 0 var(--line);
}

.task-row[data-status="overdue"],
.task-row[data-status="due"] { border-color: var(--ink); background: #fff6f2; }

.task-check {
  flex: none;
  width: 30px;
  height: 30px;
  border: 2.2px solid var(--ink);
  border-radius: 50% 45% 50% 45%;
  background: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease;
}

button.task-check:active { transform: scale(0.9); }

.task-check.is-done { background: var(--mint); }
.task-check.is-wait { background: var(--line); border-style: dashed; }
.task-check.is-popping { background: var(--mint); transform: scale(1.25); }

.task-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.task-title {
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.task-meta {
  font-size: 12px;
  color: var(--ink-soft);
}

.task-undo {
  flex: none;
  font-size: 12px;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 12px 14px 12px 14px / 14px 12px 14px 12px;
  background: var(--paper);
}


/* シート（追加・編集） */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(91, 74, 63, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-bottom: none;
  border-radius: 22px 26px 0 0 / 26px 22px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 560px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-bottom: 2.5px solid var(--ink); border-radius: var(--radius-wobbly); }
}

.sheet-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 700;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--ink);
  border-radius: 10px 12px 10px 12px / 12px 10px 12px 10px;
  padding: 8px 10px;
  font-size: 16px;
  width: 100%;
}

.field textarea { resize: vertical; }

.seg {
  display: flex;
  gap: 6px;
}

.seg-item {
  flex: 1;
  position: relative;
}

.seg-item input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.seg-item span {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  border: 2px solid var(--ink);
  border-radius: 12px 14px 12px 14px / 14px 12px 14px 12px;
  background: var(--bg);
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
}

.seg-item small { font-size: 10px; color: var(--ink-soft); }

.seg-item input:checked + span {
  background: var(--yellow);
  font-weight: 700;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.spacer { flex: 1; }

.btn {
  padding: 8px 16px;
  border: 2.2px solid var(--ink);
  border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px;
  background: var(--paper);
  font-weight: 700;
  font-size: 14px;
}

/* 一覧の末尾の追加ボタンは右寄せ */
#category-add-btn, #add-task-btn { display: block; margin-left: auto; }

.btn-primary { background: var(--mint); box-shadow: 2px 2px 0 var(--ink); }
.btn-primary:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.btn-danger { background: var(--messy); }

/* トースト */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 24px);
  transform: translateX(-50%);
  padding: 8px 18px;
  background: var(--yellow);
  border: 2.2px solid var(--ink);
  border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px;
  font-weight: 700;
  box-shadow: 3px 3px 0 var(--ink);
  z-index: 30;
  animation: toast-pop 0.25s ease;
  white-space: nowrap;
}

.toast.is-levelup { background: var(--pink); }

@keyframes toast-pop {
  from { transform: translateX(-50%) translateY(10px) scale(0.9); opacity: 0; }
  to { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}

.timer-mini {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 12px 14px 12px 14px / 14px 12px 14px 12px;
  background: var(--mint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* 設定画面 */
.settings-section {
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 2px dashed var(--line);
}

.settings-section:last-child { border-bottom: none; }

.settings-heading {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
}

.settings-help {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.file-btn { display: inline-block; cursor: pointer; }

.json-category {
  width: 100%;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px 12px 10px 12px / 12px 10px 12px 10px;
  padding: 8px 10px;
  margin-top: 8px;
  resize: vertical;
}

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

.category-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 10px;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px;
  box-shadow: 3px 3px 0 var(--cat-color, var(--line)); /* 影はクエストの色 */
}

.category-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 2px 0;
}

.category-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.category-name { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.category-meta { font-size: 12px; color: var(--ink-soft); }
.category-overdue { color: #c85c4a; font-weight: 700; }

.category-edit {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.8px solid var(--line);
  border-radius: 10px 12px 10px 12px / 12px 10px 12px 10px;
  background: var(--bg);
  color: var(--ink-soft);
}
.category-edit .icon { width: 18px; height: 18px; --icon-fill-a: var(--paper); stroke-width: 2; }
.category-edit:active { background: var(--line); }

/* 「すべて」の行 */
.category-row--all { --cat-color: var(--line); }
.category-row--all .cat-icon { background: var(--paper); }
.category-row--all .cat-icon .icon { --icon-fill-a: var(--yellow); --icon-fill-b: var(--peach); }

/* やること画面の上の帯: 左に戻るボタン、中央に開いているクエスト */
.tasks-bar {
  display: grid;
  grid-template-columns: 40px 1fr 40px; /* 左右を同じ幅にして見出しを中央に */
  align-items: center;
  margin: 0 0 8px;
}
.tasks-back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  border-radius: 50%;
}
.tasks-back .icon { width: 24px; height: 24px; }
.tasks-back:active { background: var(--line); }
.tasks-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  min-width: 0;
}
.tasks-heading span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 並べ替えのつまみ。押したまま動かせるよう、ここではブラウザのスクロールを止める */
.drag-grip {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-right: -8px;
  color: var(--ink-soft);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.drag-grip .icon { width: 24px; height: 24px; }
.is-reordering { user-select: none; -webkit-user-select: none; }
/* ドラッグ中、ほかの行はすっと場所を空ける */
.is-reordering > :not(.is-dragging) { transition: transform 0.15s ease; }
.is-dragging {
  position: relative;
  z-index: 2;
  box-shadow: 5px 6px 0 var(--line);
  cursor: grabbing;
}
.is-dragging .drag-grip { cursor: grabbing; }


/* 記録画面 */
.log-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px;
  box-shadow: 3px 3px 0 var(--line);
}

.stat-icon { display: block; height: 22px; }
.stat-svg { width: 22px; height: 22px; stroke-width: 1.8; }
.stat-svg.i-flame { color: #e0704a; --icon-fill-a: var(--peach); }
.stat-svg.i-medal { color: var(--ink); --icon-fill-a: var(--yellow); --icon-fill-b: var(--pink); }
.stat-svg.i-check { color: var(--ink); --icon-fill-a: var(--mint); }
.stat-svg.i-sparkle { color: var(--ink); --icon-fill-a: var(--yellow); --icon-fill-b: var(--yellow); }
.stat-value { font-size: 20px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 10px; color: var(--ink-soft); white-space: nowrap; }

.log-section { margin-bottom: 22px; }

.log-heading {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.log-sub { font-size: 12px; font-weight: 500; color: var(--ink-soft); }

.cal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.cal-head .log-heading { margin: 0; flex: 1; text-align: center; justify-content: center; }
.icon-btn {
  border: 1.8px solid var(--ink);
  border-radius: 8px 10px 8px 10px / 10px 8px 10px 8px;
  background: var(--bg);
  line-height: 1;
}
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.cal-nav { width: 34px; height: 30px; font-size: 18px; }
/* カレンダーの「今日」ボタン */
.chip {
  flex: none;
  padding: 5px 12px;
  border: 2px solid var(--ink);
  border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px;
  background: var(--paper);
  font-size: 13px;
  color: var(--ink);
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: var(--radius-wobbly);
  padding: 8px;
  box-shadow: 3px 3px 0 var(--line);
}

.cal-weekday {
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
  padding-bottom: 2px;
}

.cal-weekday.is-weekend { color: var(--pink); }

.cal-cell {
  aspect-ratio: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.6px solid transparent;
  border-radius: 10px 12px 10px 12px / 12px 10px 12px 10px;
  background: var(--bg);
  font-size: 13px;
}

.cal-cell.is-blank { background: transparent; }
.cal-cell.is-future { opacity: 0.4; }
.cal-cell.heat-1 { background: #e3f1e8; }
.cal-cell.heat-2 { background: var(--mint); }
.cal-cell.heat-3 { background: #9ad3b4; font-weight: 700; }
.cal-cell.heat-4 { background: #78c49b; font-weight: 700; }
.cal-cell.is-today { border-color: var(--ink); }
.cal-cell.is-selected { box-shadow: 0 0 0 2.2px var(--ink); background-color: var(--yellow); }
.cal-cell.is-selected.heat-2, .cal-cell.is-selected.heat-3, .cal-cell.is-selected.heat-4 { background-color: #a9d9bd; }

.cal-count {
  position: absolute;
  right: 3px;
  top: 2px;
  font-size: 9px;
  color: var(--ink-soft);
}

.log-list, .bar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 12px 14px 12px 14px / 14px 12px 14px 12px;
}

.log-time { flex: none; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; width: 38px; }
.log-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.log-title { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.log-meta { font-size: 11px; color: var(--ink-soft); }
.log-xp { flex: none; font-size: 13px; font-weight: 700; color: #4f9a72; }

.week-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.week-stat strong { font-size: 18px; color: var(--ink); margin-right: 2px; }

.bar-row {
  display: grid;
  grid-template-columns: 6em 1fr 2em;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bar-track {
  height: 14px;
  border: 1.8px solid var(--ink);
  border-radius: 8px 10px 8px 10px / 10px 8px 10px 8px;
  background: var(--paper);
  overflow: hidden;
}

.bar-fill { display: block; height: 100%; background: var(--peach); border-right: 1.8px solid var(--ink); }
.bar-value { text-align: right; font-weight: 700; }

/* いまやる1つ */
.focus-card {
  position: relative;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-wobbly);
  box-shadow: 4px 4px 0 var(--peach);
  padding: 16px;
  margin-bottom: 16px;
  text-align: left;
}

.focus-card.is-empty { box-shadow: 4px 4px 0 var(--mint); text-align: center; }




.focus-title {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-align: center;
}

.focus-meta { margin-top: 4px; font-size: 13px; color: var(--ink-soft); text-align: center; }

.focus-note {
  margin-top: 8px;
  padding: 6px 10px;
  font-size: 13px;
  background: var(--bg);
  border-radius: 10px;
  white-space: pre-wrap;
}

.focus-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0 8px; color: var(--ink-soft); }
.focus-empty strong { font-size: 18px; color: var(--ink); }
.focus-empty span { font-size: 13px; }
.focus-empty-btn { margin-top: 8px; }
.focus-card.is-empty[data-empty="none"] { box-shadow: 4px 4px 0 var(--line); }
.focus-card.is-empty[data-empty="cleared"] { box-shadow: 4px 4px 0 var(--yellow); }


/* 演出 */
.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  overflow: hidden;
}

.fx-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1.6px solid var(--ink);
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

.fx-particle.is-circle { border-radius: 50%; }
.fx-particle.is-rect { width: 12px; height: 7px; border-radius: 2px; }
.fx-particle.is-star {
  width: 13px;
  height: 13px;
  border: none;
  clip-path: polygon(50% 0%, 63% 35%, 100% 38%, 71% 60%, 82% 100%, 50% 76%, 18% 100%, 29% 60%, 0% 38%, 37% 35%);
}
.fx-particle.is-spark { width: 5px; height: 14px; border-radius: 3px; }

.fx-float {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 4px 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  background: var(--yellow);
  border: 2.2px solid var(--ink);
  border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px;
  box-shadow: 3px 3px 0 var(--ink);
  white-space: nowrap;
  will-change: transform, opacity;
}

.fx-float.is-big { font-size: 24px; background: var(--pink); }
.fx-float.is-small { font-size: 14px; padding: 2px 9px; background: var(--paper); box-shadow: 2px 2px 0 var(--ink); }

@keyframes xp-gain {
  0% { box-shadow: 0 0 0 0 rgba(191, 227, 208, 0); transform: scale(1); }
  30% { box-shadow: 0 0 0 6px rgba(191, 227, 208, 0.9), 0 0 18px 4px rgba(247, 227, 161, 0.9); transform: scale(1.04); }
  100% { box-shadow: 0 0 0 0 rgba(191, 227, 208, 0); transform: scale(1); }
}

.lv-gauge.is-gaining { animation: xp-gain 0.8s ease-out; }
.lv-gauge.is-gaining .lv-gauge-fill { background: #f2cf6b; } /* ゲージが黄なので、光るときは少し濃い金 */

@keyframes levelup-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes levelup-out { from { opacity: 1; } to { opacity: 0; } }

@keyframes levelup-card {
  0% { transform: scale(0.4) rotate(-6deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .modal, .clear-card, .lv-gauge.is-gaining, .clear-num.is-boing { animation: none; }
}

/* 更新通知 */
.update-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 16px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 16px;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: var(--radius-wobbly);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 14px;
  font-weight: 700;
  z-index: 25;
  white-space: nowrap;
}

/* 一括追加 */
.bulk-category { font-family: inherit; font-size: 15px; line-height: 1.5; }

.bulk-result {
  margin-top: 10px;
  padding: 10px 14px;
  border: 2px dashed var(--ink-soft);
  border-radius: var(--radius-wobbly);
  font-size: 14px;
}

.bulk-result p { margin: 0 0 6px; }
.bulk-skip { color: var(--ink-soft); font-size: 13px; }
.bulk-result .btn-row { margin-top: 4px; }

/* クエストのタイマー（いまやるカード） */
.focus-combo {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 2px 9px;
  border: 2px solid var(--ink); border-radius: 12px 14px 12px 14px / 14px 12px 14px 12px;
  background: var(--yellow);
}
.focus-combo.is-zero { background: var(--line); color: var(--ink-soft); }

.qt { position: relative; display: flex; flex-direction: column; align-items: center; margin: 12px 0 4px; }
.qt-dial { position: relative; width: min(300px, 100%); aspect-ratio: 1; }
.qt-ring { width: 100%; height: 100%; overflow: visible; display: block; }
.qt-ring .qt-track { fill: var(--paper); stroke: #f1ece3; stroke-width: 9; }
.qt-ring .qt-fill { fill: none; stroke: #7fcaa2; stroke-width: 9; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 0.25s linear; }
.qt-ring .qt-edge { fill: none; stroke: var(--ink); stroke-width: 2.4; }
.qt.is-paused .qt-fill { stroke: #b9b0a6 !important; } /* 一時停止はグレー（実行中の色を上書き） */
.qt.is-timeup .qt-fill { stroke: #e6887a !important; }
.qt.is-break .qt-fill { stroke: #86b7e6; }
.qt-center { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 22%; box-sizing: border-box; pointer-events: none; }
.qt-seconds { height: 112px; display: flex; align-items: center; font-size: min(112px, 30vw); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.qt.is-timeup .qt-seconds { color: #c85c4a; }
.qt-slot { height: 40px; margin-top: 6px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.qt-ctl { pointer-events: auto; width: 44px; height: 40px; display: flex; align-items: center; justify-content: center; border: none; border-radius: 10px; background: transparent; color: var(--ink); box-shadow: none; }
.qt-ctl .icon { width: 30px; height: 30px; --icon-fill-a: currentColor; stroke-width: 2.2; }
.qt-ctl:active { transform: translate(1px, 1px); opacity: 0.6; }
.qt-ctl:disabled { opacity: 0.25; }
.qt-timeup { font-size: 13px; font-weight: 700; color: #c85c4a; padding: 2px 10px; border: 2px solid #c85c4a; border-radius: 12px 14px 12px 14px / 14px 12px 14px 12px; }

.qt-actions { display: flex; flex-direction: column; align-items: center; gap: 24px; margin-top: 12px; }
.qt-main { width: 78%; font-size: 20px; padding: 14px 16px; }
.qt-main { background: var(--yellow); } /* 「はじめる」「できた！」は黄（オレンジ系は怖い印象になるので避ける） */
.qt-main:disabled { opacity: 0.4; box-shadow: none; }
.qt-subrow { display: flex; justify-content: center; gap: 10px; width: 100%; }
.qt-small { font-size: 12px; padding: 6px 14px; box-shadow: none; }
.qt-small:active { transform: translate(1px, 1px); background: var(--bg); }
.qt-small:disabled { opacity: 0.35; }
.qt-quit { background: var(--paper); color: var(--ink); }


/* セッションのモーダル */
.modal {
  position: fixed; inset: 0; z-index: 35; display: flex; align-items: center; justify-content: center;
  background: rgba(91, 74, 63, 0.45); animation: levelup-in 0.25s ease-out;
}
.modal.is-leaving { animation: modal-out 0.28s ease-in forwards; pointer-events: none; }
@keyframes modal-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
.modal.is-leaving > * { animation: modal-card-out 0.28s ease-in forwards; }
@keyframes modal-card-out {
  from { transform: scale(1) translateY(0); }
  to { transform: scale(0.96) translateY(6px); }
}

.clear-card { position: relative; width: min(92vw, 340px); padding: 26px 22px 20px; text-align: center; background: var(--paper); border: 3px solid var(--ink); border-radius: 28px 34px 30px 36px / 36px 28px 34px 30px; box-shadow: 6px 6px 0 var(--mint); }
.clear-card.is-pop { animation: levelup-card 0.6s cubic-bezier(0.2, 1.4, 0.4, 1); }
.clear-ribbon { position: absolute; top: -16px; left: 50%; transform: translateX(-50%) rotate(-3deg); padding: 4px 18px; background: var(--mint); border: 2.4px solid var(--ink); border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px; font-size: 16px; font-weight: 700; white-space: nowrap; }
.clear-title { margin-top: 6px; font-size: 15px; font-weight: 700; color: var(--ink-soft); overflow-wrap: anywhere; }
.clear-rows { margin: 14px 0 8px; display: flex; flex-direction: column; gap: 6px; text-align: left; min-height: 40px; }
.clear-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; padding: 6px 10px; border: 2px dashed var(--line); border-radius: 12px; transition: opacity 0.25s, transform 0.25s; }
.clear-row small { color: var(--ink-soft); font-size: 11px; margin-left: 6px; }
.clear-row strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.clear-row.is-bonus { border-color: var(--yellow); background: #fffae6; }
.clear-row.is-hidden, .clear-combo.is-hidden, .clear-levelup.is-hidden { opacity: 0; transform: translateY(6px); }
.clear-total { position: relative; margin-top: 14px; padding: 14px 0 8px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; justify-content: center; gap: 4px; }
/* 数字の後ろに黄色い光のにじみ */
.clear-total::before { content: ''; position: absolute; left: 50%; top: 50%; width: 220px; height: 120px; transform: translate(-50%, -50%); background: radial-gradient(ellipse at center, rgba(247, 227, 161, 0.95) 0%, rgba(247, 227, 161, 0.5) 45%, rgba(247, 227, 161, 0) 72%); z-index: 0; pointer-events: none; }
.clear-plus { position: relative; z-index: 1; font-size: 26px; color: #c85c4a; }
.clear-num { position: relative; z-index: 1; font-size: 84px; display: inline-block; transform-origin: 50% 80%; color: var(--ink); text-shadow: 3px 3px 0 var(--yellow), 6px 6px 0 var(--peach); letter-spacing: 0.02em; }
.clear-num.is-boing { animation: boing 0.32s ease-out; }
.clear-total small { position: relative; z-index: 1; font-size: 18px; margin-left: 6px; color: var(--ink-soft); }
.clear-spark { position: absolute; top: 12px; width: 26px; height: 26px; color: #c9a227; --icon-fill-a: var(--yellow); --icon-fill-b: var(--yellow); z-index: 1; opacity: 0; }
.clear-spark.is-left { left: 14px; }
.clear-spark.is-right { right: 14px; top: 30px; }
.clear-card.is-final .clear-spark { animation: spark-pop 0.6s ease-out forwards; }
.clear-card.is-final .clear-spark.is-right { animation-delay: 0.15s; }
@keyframes spark-pop { 0% { transform: scale(0) rotate(-30deg); opacity: 0; } 60% { transform: scale(1.3) rotate(10deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes boing { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 70% { transform: scale(0.94); } 100% { transform: scale(1); } }
.clear-combo { display: inline-block; margin-top: 8px; padding: 3px 14px; background: var(--yellow); border: 2.2px solid var(--ink); border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px; font-weight: 700; transition: opacity 0.25s, transform 0.25s; }
.clear-combo.is-none { background: var(--line); color: var(--ink-soft); }
.clear-levelup { display: block; margin: 8px auto 0; width: max-content; padding: 3px 14px; background: var(--pink); border: 2.2px solid var(--ink); border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px; font-weight: 700; transition: opacity 0.25s, transform 0.25s; }
.clear-hint { margin-top: 12px; font-size: 11px; color: var(--ink-soft); }

.break-card { width: min(92vw, 340px); padding: 24px 22px 20px; text-align: center; background: var(--paper); border: 3px solid var(--ink); border-radius: 28px 34px 30px 36px / 36px 28px 34px 30px; box-shadow: 6px 6px 0 var(--sky); }
.break-title { font-size: 20px; font-weight: 700; }
.break-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.break-card .qt { margin: 14px 0 6px; }
.break-note { font-size: 13px; margin: 6px 0 14px; }

.sum-card { width: min(92vw, 340px); padding: 26px 22px 20px; text-align: center; background: var(--paper); border: 3px solid var(--ink); border-radius: 28px 34px 30px 36px / 36px 28px 34px 30px; box-shadow: 6px 6px 0 var(--peach); }
.sum-title { font-size: 20px; font-weight: 700; }
.sum-sub { font-size: 12px; color: var(--ink-soft); }
.sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 14px; }
.sum-cell { padding: 10px 6px; border: 2.2px solid var(--ink); border-radius: 14px 18px 16px 18px / 18px 14px 18px 16px; background: var(--bg); }
.sum-cell strong { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sum-cell strong small { font-size: 14px; }
.sum-cell span { font-size: 11px; color: var(--ink-soft); }
.sum-cell.is-main { background: var(--yellow); grid-column: 1 / -1; }
.sum-cell.is-main strong { font-size: 36px; }
.sum-best { font-size: 12px; color: #c85c4a; font-weight: 700; margin-bottom: 8px; }

/* 記録: ランキング */
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-row { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px 14px 12px 14px / 14px 12px 14px 12px; }
.rank-no { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--ink); border-radius: 50% 45% 50% 45%; font-size: 12px; font-weight: 700; background: var(--paper); }
.rank-row:nth-child(1) .rank-no { background: var(--yellow); }
.rank-row:nth-child(2) .rank-no { background: var(--line); }
.rank-row:nth-child(3) .rank-no { background: var(--peach); }
.rank-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rank-date { font-size: 12px; color: var(--ink-soft); }
.rank-meta { font-size: 12px; }
.rank-xp { font-size: 18px; font-weight: 700; color: #4f9a72; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-xp small { font-size: 11px; color: var(--ink-soft); font-weight: 500; }
.log-xp small { font-size: 11px; color: var(--ink-soft); font-weight: 500; }

/* タイマー右上のコンボ */
.qt-combo {
  position: absolute; right: 12px; top: 12px; z-index: 2;
  width: 48px; height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2.2px solid var(--ink); border-radius: 50% 45% 50% 45%; background: var(--yellow); line-height: 1;
}
.qt-combo strong { font-size: 18px; font-weight: 700; }
.qt-combo small { font-size: 8px; margin-top: 1px; }

/* コンボの札と重ならないよう、タイトルとメモは右側を空けて折り返す */
.focus-card.has-combo .focus-title,
.focus-card.has-combo .focus-meta { padding-left: 60px; padding-right: 60px; } /* コンボの札の分を左右そろえて中央を保つ */

/* タイマーの数字は1桁ずつ同じ幅で並べる */
.qt-seconds span { display: inline-block; width: 0.51em; text-align: center; }

/* ほかのやること: クエストごとの見出し */
.quest-subheading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.quest-subheading:first-of-type { margin-top: 4px; }

/* 確認ダイアログ */
#dialog-modal { z-index: 45; }
.dialog-card {
  width: min(88vw, 320px);
  padding: 22px 20px 16px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 24px 28px 26px 30px / 30px 24px 28px 26px;
  box-shadow: 6px 6px 0 var(--lav);
  animation: levelup-card 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.dialog-message { margin: 0 0 16px; font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* 次への待ちのカード: 待機中と同じ構造を透明な下敷きにして高さをそろえ、その上に専用の表示を重ねる */
.focus-card--countdown { position: relative; }
.focus-card--countdown > :not(.cd-overlay) { visibility: hidden; }
.cd-overlay { position: absolute; inset: 0; padding: 16px; /* カードの padding と合わせ、ボタンの位置をそろえる */ display: flex; flex-direction: column; text-align: center; }
.cd-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cd-title { font-size: 36px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.cd-sec { display: block; margin-top: 4px; font-size: 24px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.cd-meta { margin-top: 8px; font-size: 13px; color: var(--ink-soft); }
.cd-num { margin-top: 22px; font-size: 128px; font-weight: 700; line-height: 1; color: var(--ink); text-shadow: 4px 4px 0 var(--yellow); }
.cd-num.is-pop { animation: cd-pop 0.45s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes cd-pop {
  from { transform: scale(1.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.focus-card--countdown .qt-actions { margin-top: 12px; }
@media (prefers-reduced-motion: reduce) { .cd-num.is-pop { animation: none; } }


.qt-main .icon { width: 22px; height: 22px; vertical-align: -4px; margin-right: 2px; --icon-fill-a: currentColor; stroke-width: 2.2; }
.qt-main[data-qt="complete"] .icon { --icon-fill-a: var(--paper); }

/* 待機中のカードはタップで編集できる */
.focus-card.is-editable { cursor: pointer; }

/* クエスト（カテゴリー）の色付きアイコン */
.cat-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 50% 45% 50% 45%;
  border: 2px solid var(--ink); background: var(--cat-color, var(--line)); color: var(--ink);
}
.cat-icon .icon { width: 18px; height: 18px; --icon-fill-a: rgba(255, 253, 248, 0.7); stroke-width: 2; }
.cat-icon--lg { width: 44px; height: 44px; }
.cat-icon--lg .icon { width: 26px; height: 26px; }
.cat-icon--sm { width: 22px; height: 22px; border-width: 1.6px; margin-right: 6px; }
.cat-icon--sm .icon { width: 13px; height: 13px; }
.cat-icon--row { width: 34px; height: 34px; }
.cat-icon--row .icon { width: 20px; height: 20px; }

/* 色とアイコンの選択 */
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch {
  width: 34px; height: 34px; border-radius: 50% 45% 50% 45%; background: var(--cat-color);
  border: 2px solid var(--line);
}
.color-swatch.is-selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.icon-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.icon-choice {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1;
  border: 2px solid var(--line); border-radius: 10px 12px 10px 12px / 12px 10px 12px 10px; background: var(--bg); color: var(--ink);
}
.icon-choice .icon { width: 22px; height: 22px; --icon-fill-a: var(--cat-color); stroke-width: 2; }
.icon-choice.is-selected { border-color: var(--ink); background: var(--paper); box-shadow: 2px 2px 0 var(--ink); }
