:root {
  --bg: #0b0b0d;
  --bg-grad: radial-gradient(120% 80% at 50% -10%, #18181d 0%, #0b0b0d 60%);
  --surface: #16161a;
  --surface-2: #1d1d22;
  --surface-3: #25252b;
  --border: #2a2a32;
  --border-soft: #1f1f25;
  --text: #f5f5f7;
  --text-dim: #9a9aa5;
  --text-mute: #5d5d68;
  --accent: #e4ff4d;
  --accent-soft: rgba(228, 255, 77, 0.12);
  --danger: #ff5b73;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --nav-h: 72px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Noto Sans JP", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
  letter-spacing: -0.005em;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-grad);
}

#app {
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  user-select: none;
}

/* ===== ページ共通 ===== */
.page {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--safe-top);
  animation: pageIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  padding: 22px 22px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.page-eyebrow {
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.18em;
  margin-bottom: 4px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.025em;
}

.content {
  padding: 4px 22px 40px;
}

/* ===== カレンダーヘッダー ===== */
.cal-header {
  padding: 18px 18px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cal-title-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cal-title-wrap h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0 6px;
  letter-spacing: -0.02em;
  min-width: 110px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.title-btn {
  background: transparent;
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.title-btn svg { width: 22px; height: 22px; }
.title-btn:active { background: var(--surface-2); }

.today-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.today-pill:active { background: var(--surface-3); }

/* ===== 曜日ヘッダー ===== */
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 14px 6px;
}
.wd {
  text-align: center;
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 6px 0;
}
.wd.sun { color: #ff7088; }
.wd.sat { color: #6aa8ff; }

/* ===== カレンダーグリッド ===== */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 10px;
  gap: 2px;
}

.cal-cell {
  aspect-ratio: 1 / 1.05;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 5px 2px 4px;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
.cal-cell:active { background: var(--surface-2); }

.cal-cell.other-month .cell-num { color: #333339; }
.cal-cell.other-month .cell-dots { opacity: 0.5; }

.cell-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.cal-cell.sun .cell-num { color: #ff7088; }
.cal-cell.sat .cell-num { color: #6aa8ff; }

.cal-cell.today .cell-num {
  background: var(--accent);
  color: #1a1a00;
}

.cal-cell.selected:not(.today) .cell-num {
  background: var(--surface-3);
  border: 1.5px solid var(--accent);
  width: 26px;
  height: 26px;
}

.cell-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5px;
  justify-content: center;
  margin-top: 4px;
  min-height: 8px;
  max-width: 100%;
}
.cell-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cell-dot.more {
  background: var(--text-mute);
  font-size: 7px;
  width: auto;
  height: auto;
  padding: 0 3px;
  border-radius: 4px;
  color: var(--bg);
  font-weight: 700;
  line-height: 8px;
  display: flex;
  align-items: center;
}

.cell-emoji {
  font-size: 15px;
  line-height: 1;
}

.cal-cell.has-menu {
  background: color-mix(in srgb, var(--mc) 22%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mc) 36%, transparent);
}
.cal-cell.has-menu:active {
  background: color-mix(in srgb, var(--mc) 32%, transparent);
}
.cal-cell.has-menu.sun .cell-num,
.cal-cell.has-menu.sat .cell-num {
  color: var(--text);
}
.cal-cell.has-menu.today .cell-num {
  background: var(--accent);
  color: #1a1a00;
  box-shadow: 0 0 0 2px var(--bg);
}

/* ===== 選択日パネル ===== */
.day-panel {
  margin: 18px 14px 0;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
}

.day-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-soft), transparent);
}

.day-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 14px;
}

.day-panel-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.day-panel-date {
  font-size: 19px;
  font-weight: 700;
  margin-top: 3px;
  letter-spacing: -0.02em;
}

.day-panel-count {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

/* ===== 記録チップ ===== */
.records-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 6px;
  margin-bottom: 14px;
}
.records-list:empty::before {
  content: "まだ記録なし";
  font-size: 12px;
  color: var(--text-mute);
  padding: 2px 0;
}

.record-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 7px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--chip-bg, var(--surface-2));
  color: var(--chip-fg, var(--text));
  border: 1px solid var(--chip-border, var(--border));
  cursor: pointer;
  position: relative;
  animation: chipIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s, transform 0.1s;
}
.record-chip:active { transform: scale(0.94); opacity: 0.7; }
.record-chip .emoji { font-size: 14px; line-height: 1; }
.record-chip .chip-x {
  margin-left: 2px;
  font-size: 14px;
  line-height: 1;
  opacity: 0.55;
  font-weight: 500;
}

@keyframes chipIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.weight-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  margin-bottom: 12px;
}
.weight-icon { font-size: 18px; line-height: 1; }
.weight-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.weight-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  font-family: inherit;
  min-width: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}
.weight-input::-webkit-inner-spin-button,
.weight-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.weight-input::placeholder {
  color: var(--text-mute);
  font-weight: 600;
}
.weight-unit {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}
.weight-clear {
  background: transparent;
  border: none;
  color: var(--text-mute);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.weight-row.has-value .weight-clear { display: flex; }
.weight-clear:active { background: var(--surface-3); }

.weight-section {
  margin-bottom: 28px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
}
.weight-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.section-title-inline {
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0;
}
.weight-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 8px;
}
.wtab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  font-family: inherit;
}
.wtab.active {
  background: var(--surface-3);
  color: var(--text);
}

.weight-kpi {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.weight-kpi .kpi-card {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.weight-kpi .kpi-card.primary {
  background: linear-gradient(135deg, rgba(228, 255, 77, 0.15), rgba(228, 255, 77, 0.04));
  border: 1px solid rgba(228, 255, 77, 0.25);
}
.weight-kpi .kpi-label {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.weight-kpi .kpi-value {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  margin-top: 2px;
  color: var(--text);
}
.weight-kpi .kpi-card.primary .kpi-value { color: var(--accent); }
.weight-kpi .kpi-value .unit {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  margin-left: 1px;
}
.weight-kpi .kpi-value.up { color: #ff7088; }
.weight-kpi .kpi-value.down { color: #51cf66; }
.weight-kpi .kpi-value .arrow {
  font-size: 14px;
  font-weight: 700;
  margin-right: 2px;
}

.weight-chart-wrap {
  height: 180px;
  position: relative;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 6px 6px;
}
#weightChart { width: 100%; height: 100%; display: block; }

.weight-empty {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-mute);
  font-size: 13px;
}

.quick-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.quick-divider::before,
.quick-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}
.quick-divider span {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  font-weight: 700;
  text-transform: uppercase;
}

.quick-menus {
  display: flex;
  gap: 6px;
  padding: 2px 0 4px;
}

.quick-menus:empty::before {
  content: "メニュータブから追加してください";
  font-size: 12px;
  color: var(--text-mute);
  padding: 14px 0;
  display: block;
  text-align: center;
  width: 100%;
}

.quick-menu-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 4px 9px;
  background: var(--mbg, var(--surface-2));
  border: 1px solid var(--mborder, var(--border));
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s;
}
.quick-menu-btn:active {
  transform: scale(0.94);
}
.quick-menu-btn .emoji {
  font-size: 22px;
  line-height: 1;
}
.quick-menu-btn .label {
  font-size: 10px;
  color: var(--mfg, var(--text));
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.2;
  text-align: center;
  word-break: break-all;
  overflow-wrap: anywhere;
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.quick-menu-btn.recorded {
  position: relative;
}
.quick-menu-btn.recorded::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mc);
  box-shadow: 0 0 0 1.5px var(--surface);
}

/* ===== メニューリスト ===== */
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.menu-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--mcolor, var(--accent));
}
.menu-row:active { background: var(--surface-2); }

.menu-row .emoji {
  font-size: 28px;
  width: 44px;
  height: 44px;
  background: var(--surface-2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-row-info { flex: 1; min-width: 0; }
.menu-row-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.menu-row-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.menu-row .drag-handle {
  color: var(--text-mute);
  padding: 6px;
}
.menu-row .drag-handle svg { width: 18px; height: 18px; }

.icon-btn-lg {
  background: var(--accent);
  color: #1a1a00;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn-lg svg { width: 22px; height: 22px; }
.icon-btn-lg:active { transform: scale(0.93); }

.hint-text {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin: 24px 0 0;
  letter-spacing: 0.02em;
}

.data-section {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
}
.data-section-title {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin: 0 0 14px;
}
.storage-info {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}
.storage-info .badge {
  background: var(--surface-2);
  color: var(--text-mute);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.storage-info .badge.ok {
  background: rgba(82, 207, 102, 0.15);
  color: #51cf66;
}
.storage-info .badge.warn {
  background: rgba(255, 169, 64, 0.15);
  color: #ffa940;
}

.data-hint {
  font-size: 11px;
  color: var(--text-mute);
  margin: 14px 0 0;
  line-height: 1.6;
  text-align: center;
  letter-spacing: 0.02em;
}

.uid-display {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.uid-display .uid-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.uid-display .uid-value {
  font-size: 11px;
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  letter-spacing: -0.02em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uid-display .uid-copy {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.uid-display .uid-copy:active { background: var(--surface-3); }

.data-btn {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-family: inherit;
  text-align: left;
  letter-spacing: -0.005em;
}
.data-btn:active { background: var(--surface-2); }
.data-btn svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }

.modal-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin: -4px 0 4px;
  line-height: 1.6;
}

/* Drag state */
.menu-row.dragging { opacity: 0.6; transform: scale(1.02); z-index: 10; }
.menu-row.drag-over { border-color: var(--accent); }

/* ===== 統計 ===== */
.stats-hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.streak-card {
  background: linear-gradient(135deg, #ff7034 0%, #ffa940 100%);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: #2a1500;
  position: relative;
  overflow: hidden;
}
.streak-card::after {
  content: "";
  position: absolute;
  top: -30%;
  right: -10%;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(255,255,255,0.2), transparent 70%);
}
.streak-flame {
  font-size: 38px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}
.streak-num {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.streak-label {
  font-size: 11px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

.hero-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.mini-stat {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}
.mini-num {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.mini-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.section-title {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 28px 0 12px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.section-title span {
  font-size: 10px;
  color: var(--text-mute);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: none;
}

.menu-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-stat-row {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.menu-stat-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.menu-stat-name {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.menu-stat-count {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--mcolor, var(--accent));
  letter-spacing: -0.02em;
}
.menu-stat-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}
.menu-stat-bar-fill {
  height: 100%;
  background: var(--mcolor, var(--accent));
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.weekday-stats {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 12px;
}
.wd-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.wd-bar-vis {
  height: 80px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.wd-bar-fill {
  width: 60%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.wd-bar-fill.empty {
  background: var(--surface-2);
}
.wd-bar-label {
  font-size: 10px;
  color: var(--text-mute);
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ===== ボトムナビ ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  background: rgba(11, 11, 13, 0.78);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  z-index: 50;
}
.nav-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-mute);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  cursor: pointer;
  transition: color 0.15s;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn span { font-size: 10px; font-weight: 600; letter-spacing: 0.03em; }
.nav-btn.active { color: var(--accent); }

/* ===== モーダル ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  animation: fadeIn 0.2s ease;
}
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 8px 22px calc(28px + var(--safe-bottom));
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-top: 1px solid var(--border);
}
.modal-handle {
  width: 38px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 6px auto 14px;
}
.modal-content h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
.modal-actions button { margin: 0; flex: 1; }

.field-label {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  margin: 16px 0 8px;
}

.text-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 16px;
  outline: none;
  font-family: inherit;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}
.text-input:focus {
  border-color: var(--accent);
  background: var(--bg);
}

.emoji-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  background: var(--surface-2);
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.emoji-opt {
  background: transparent;
  border: 1.5px solid transparent;
  padding: 6px 0;
  font-size: 22px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
}
.emoji-opt.selected {
  background: var(--bg);
  border-color: var(--accent);
}

.color-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.color-opt {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  position: relative;
  background-clip: padding-box;
}
.color-opt.selected {
  border-color: var(--text);
  transform: scale(1.05);
}
.color-opt::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--c);
}

/* ===== ボタン共通 ===== */
.btn-primary {
  background: var(--accent);
  color: #1a1a00;
  border: none;
  border-radius: var(--radius);
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  letter-spacing: -0.005em;
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:active { background: var(--surface-3); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 91, 115, 0.25);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  width: 100%;
  margin-top: 12px;
  cursor: pointer;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ===== トースト ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
  box-shadow: 0 14px 36px rgba(0,0,0,0.5);
  letter-spacing: -0.005em;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== 日付詳細モーダル ===== */
#dayDetailRecords .ddr-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
#dayDetailRecords .ddr-row .emoji {
  font-size: 22px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
#dayDetailRecords .ddr-row .ddr-name {
  font-weight: 600;
  flex: 1;
}
#dayDetailRecords .ddr-row .ddr-time {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
#dayDetailRecords .ddr-delete {
  background: transparent;
  border: none;
  color: var(--text-mute);
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
}
