:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --text: #2b2b2b;
  --muted: #8a8780;
  --border: #e6e3dc;
  --accent: #e8743b;
  --accent-soft: #fbe7dc;
  --danger: #d64545;
  --danger-soft: #fbe3e3;
  --ok: #3f9a5f;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --radius: 16px;
  --topbar-h: 56px;
  --bottomnav-h: 0px;
  color-scheme: light;
  --pfc-p: #2a78d6; --pfc-f: #eb6834; --pfc-c: #1baf7a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pfc-p: #3987e5; --pfc-f: #d95926; --pfc-c: #199e70;
    --bg: #16181d; --surface: #1f2228; --surface-2: #272a31; --text: #ececec; --muted: #9a9ca3;
    --border: #2f333b; --accent: #f08a54; --accent-soft: #3a2a22; --danger: #ef6b6b; --danger-soft: #3b2324;
    --ok: #5cbf7d; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --pfc-p: #3987e5; --pfc-f: #d95926; --pfc-c: #199e70;
  --bg: #16181d; --surface: #1f2228; --surface-2: #272a31; --text: #ececec; --muted: #9a9ca3;
  --border: #2f333b; --accent: #f08a54; --accent-soft: #3a2a22; --danger: #ef6b6b; --danger-soft: #3b2324;
  --ok: #5cbf7d; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* スクロールバーが出ても横幅が変わらないよう、その分の幅を常に確保 */
html { scrollbar-gutter: stable; }
body {
  font-family: "M PLUS 1p", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-weight: 400;
  line-height: 1.7;
  letter-spacing: 0.03em;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ===== 上部バー・ナビ ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 max(24px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { white-space: nowrap; flex-shrink: 0; font-weight: 800; font-size: 17px; text-decoration: none; letter-spacing: 0.04em; }
.topnav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.navlink {
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  text-decoration: none; font-size: 14px; color: var(--muted);
}
.navlink:hover { background: var(--surface-2); color: var(--text); }
.navlink.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.bottomnav { display: none; }
.icon-btn.menu-btn { display: none; }

/* サイドバーの固定（広い画面）：左に常に表示し、ページはその右に */
/* サイドバーの固定ボタンはヘッダーの ☰ の右（広い画面だけ） */
.icon-btn.dock-btn { display: none; }
.dock-btn.on { color: var(--accent); background: var(--accent-soft); }
@media (min-width: 1024px) {
  .icon-btn.dock-btn { display: inline-flex; }
  /* 幅は開閉式のサイドバーと同じ 300px */
  /* ヘッダーは今まで通り画面の上いっぱいに（ロゴ・ピン留めした項目もそのまま）。サイドバーはヘッダーの下に */
  html[data-dock="1"] body { padding-left: 300px; }
  html[data-dock="1"] .topbar { margin-left: -300px; z-index: 30; }
  html[data-dock="1"] .drawer { transform: none; width: 300px; z-index: 25; box-shadow: none; }
  html[data-dock="1"] .drawer-backdrop { display: none; }
  /* 固定中に ☰ を押すと、固定はそのままでサイドバーを一時的にたたむ */
  html[data-dock="1"][data-dock-hide] body { padding-left: 0; }
  html[data-dock="1"][data-dock-hide] .topbar { margin-left: 0; }
  html[data-dock="1"][data-dock-hide] .drawer { transform: translateX(-105%); }
}

/* スマホ用サイドバー */
.drawer {
  /* 一番上のヘッダーには重ねない（ヘッダーの下から開く） */
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 40;
  width: min(300px, 82vw);
  padding: 12px 12px max(16px, env(safe-area-inset-bottom));
  background: var(--surface); border-right: 1px solid var(--border);
  box-shadow: 8px 0 30px rgba(0,0,0,.25);
  transform: translateX(-105%); transition: transform .22s ease;
  overflow-y: auto;
  overscroll-behavior: contain;      /* 端までスクロールしても後ろのページに伝えない */
}
.drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 35; background: rgba(0,0,0,.4); touch-action: none; }
.drawer-head .brand { display: none; }      /* ロゴはヘッダーに出ているので、サイドバーには出さない */
.drawer-head { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px 14px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.drawer-list { list-style: none; margin: 0; padding: 0; }
.drawer-list li { display: flex; align-items: center; gap: 4px; }
/* ドラッグ中のメニュー項目（body に置かれるので見た目をここで付ける） */
body > li.sortable-fallback { display: flex; align-items: center; gap: 4px; list-style: none; background: var(--surface); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); opacity: .95; }
body > li.sortable-fallback .drawer-link { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px 10px; text-decoration: none; }
/* サイドバーのグループ（見出しを押すと開閉） */
.drawer-list li.nav-group { display: block; }
.nav-group-list { list-style: none; margin: 0; padding: 0; }
.nav-group-head { display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 8px; padding: 6px 8px; border: 0; background: none;
  font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; text-align: left; letter-spacing: .04em; }
.nav-group-head:hover { color: var(--text); }
.nav-group-head .ic { transition: transform .15s; }
.nav-group.closed .nav-group-head .ic { transform: rotate(-90deg); }
.nav-group-count { margin-left: auto; font-weight: 500; font-size: 11px; }
.drawer-link {
  flex: 1; display: flex; align-items: center; gap: 12px;
  padding: 12px 10px; border-radius: 10px; text-decoration: none; font-size: 15px;
}
.drawer-link:hover { background: var(--surface-2); }
.drawer-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.drag-handle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 40px; color: var(--muted); cursor: grab; touch-action: none; flex-shrink: 0;
}
.drawer-list li.sortable-ghost { opacity: .4; }
.pin-btn { width: 40px; height: 40px; }
.pin-btn.on { color: var(--accent); }

/* ページの幅：標準は 1440px、「全画面」にすると画面いっぱい（右上のボタンで切り替え・端末ごとに保存） */
.wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

/* ===== 共通部品 ===== */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 12px; }
.pill-btn {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.pill-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.field {
  min-width: 0; width: 100%;
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 10px; padding: 8px 12px; font-size: 15px; outline: 0;
}
.field:focus { border-color: var(--accent); }
textarea.field { resize: vertical; line-height: 1.8; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .field { flex: 1; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1.8; }
.badge.p1 { background: var(--danger-soft); color: var(--danger); }
.badge.p3 { background: var(--surface-2); color: var(--muted); }
.badge.due { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.badge.due.today { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.badge.due.over { background: var(--danger-soft); color: var(--danger); font-weight: 700; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 800; margin: 0; }

/* ===== カード ===== */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-height: 30px; }
.card-head h2, .card > h2 {
  font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 0.12em; margin: 0;
}
.card > h2 { margin-bottom: 14px; }
.card-head h2 a { text-decoration: none; }
.card-go { margin-left: auto; gap: 2px; padding-right: 6px; flex-shrink: 0; }
.card-head .spacer + * ~ .card-go, .card-head .spacer ~ .card-go { margin-left: 0; }
.card-head h2 a:hover { color: var(--accent); }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

/* ===== ホーム：時計・検索 ===== */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.greeting { font-size: 14px; color: var(--muted); margin: 0; }
.clock { font-size: 56px; font-weight: 800; line-height: 1.1; letter-spacing: 0.02em; margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.date { font-size: 15px; color: var(--muted); margin: 4px 0 0; }
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 6px 6px 20px; box-shadow: var(--shadow); margin-bottom: 24px;
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; padding: 8px 0; }
.search button { border: 0; background: var(--accent); color: #fff; font-weight: 700; border-radius: 999px; padding: 10px 22px; cursor: pointer; }

/* ===== リンク ===== */
.link-group + .link-group { margin-top: 16px; }
.group-head {
  display: flex; align-items: center; gap: 4px;
  font-size: 14px; font-weight: 500; margin: 0 0 8px; cursor: pointer; user-select: none;
}
.group-head .ic { color: var(--muted); transition: transform .15s; }
.link-group.collapsed .group-head .ic { transform: rotate(-90deg); }
.link-group.collapsed .links { display: none; }
.group-head .count { color: var(--muted); font-size: 12px; font-weight: 400; }
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; min-height: 20px; }
.link {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 6px 10px; border-radius: 12px;
  text-decoration: none; color: var(--text); background: var(--surface-2);
  font-size: 12px; text-align: center; transition: transform .15s, background .15s;
}
.link:hover { transform: translateY(-2px); background: var(--accent-soft); }
.link img, .link .fallback { width: 28px; height: 28px; border-radius: 8px; }
.link .fallback { display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; }
.link .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
/* カーソルを乗せたら名前を即表示（マウスのある端末だけ） */
@media (hover: hover) {
  .link[data-name]:hover::after {
    content: attr(data-name);
    position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
    z-index: 10; pointer-events: none;
    padding: 4px 10px; border-radius: 8px;
    background: var(--text); color: var(--bg);
    font-size: 12px; font-weight: 500; white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
  }
}
.editing .link { cursor: grab; outline: 1px dashed var(--border); }
.editing .link:hover { transform: none; }
.link.frequent { background: transparent; border: 1px solid var(--border); }
.sortable-ghost { opacity: .35; }
/* リンクページ：グループをカード状に並べる */
.links-page .link-groups {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; align-items: start;
}
.links-page .link-group { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.links-page .link-group + .link-group { margin-top: 0; }
.links-page .links { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.links-tools { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ===== ToDo ===== */
.todo-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 10px; }
.todo-add .field { padding: 8px 10px; }
.todo-add .text { grid-column: 1 / -1; }
.todo-filter { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px; border-bottom: 1px dashed var(--border); font-size: 15px;
}
.todo-item:last-child { border-bottom: 0; }
.todo-item input[type="checkbox"] { width: 18px; height: 18px; margin-top: 0; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
/* 1行表示：やること（長ければ「…」）と、優先度・期限のバッジを同じ行に */
.todo-body { flex: 1; min-width: 0; cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.todo-text { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-meta { display: flex; gap: 6px; flex-shrink: 0; }
.todo-note { flex-basis: 100%; }
.todo-note { font-size: 12px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-item .grip { color: var(--muted); cursor: grab; touch-action: none; }
.done-toggle {
  display: flex; align-items: center; gap: 4px; width: 100%;
  margin-top: 8px; padding: 6px 4px; border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer;
}
.done-toggle .ic { transition: transform .15s; }
.done-toggle.open .ic { transform: rotate(180deg); }

/* ===== 天気 ===== */
.weather-now { display: flex; align-items: center; gap: 14px; }
.weather-icon { font-size: 48px; line-height: 1; }
.weather-temp { font-size: 40px; font-weight: 800; line-height: 1; }
.weather-desc { color: var(--muted); font-size: 14px; }
.weather-place { font-size: 13px; color: var(--muted); margin-top: 10px; }
.forecast { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.forecast div { background: var(--surface-2); border-radius: 10px; padding: 8px; text-align: center; font-size: 12px; }
.forecast b { display: block; font-size: 20px; font-weight: 400; margin: 2px 0; }
.forecast .hi { color: var(--accent); font-weight: 700; }
.forecast .lo { color: var(--muted); }

/* ===== ホーム：時計の右の天気 ===== */
.hero { flex-wrap: wrap; }
.hero-weather { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.hw-now { display: flex; align-items: center; gap: 10px; }
.hw-icon { font-size: 40px; line-height: 1; }
.hw-temp { font-size: 40px; font-weight: 800; line-height: 1; }
.hw-side { display: flex; flex-direction: column; align-items: flex-start; font-size: 13px; line-height: 1.5; }
.hw-place {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; cursor: pointer;
}
.hw-place:hover { color: var(--accent); }
.hw-days { display: flex; gap: 14px; font-size: 12px; flex-wrap: wrap; justify-content: flex-end; }
.hw-day { white-space: nowrap; }
/* 通知の設定 */
.push-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.push-dev { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.push-note { font-size: 13px; line-height: 1.7; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 0; }
.push-toggle { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; cursor: pointer; font-size: 14px; }
.push-toggle input { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 2px; flex-shrink: 0; }
.push-toggle small { display: block; }
.push-preview { margin-top: 8px; }
/* 子供の成績 */
.gr-trend { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.gr-card { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.gr-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.gr-card-value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gr-card-value small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.gr-diff { font-size: 12px; margin-left: 8px; font-weight: 700; }
.gr-diff.up, .gr-up { color: var(--accent); }
.gr-diff.down, .gr-down { color: var(--muted); }
.gr-spark { display: block; width: 100%; height: 56px; margin-top: 6px; overflow: visible; }
.gr-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.gr-avg { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.gr-mid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.gr-dot { fill: var(--accent); stroke: var(--surface-2); stroke-width: 1.5; }
.gr-bulk-head { display: grid; grid-template-columns: 160px 120px 1fr; gap: 10px; }
.gr-bulk-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 70px 80px 80px; gap: 6px; }
.gr-bulk-rows { display: grid; gap: 6px; max-height: 46vh; overflow-y: auto; overscroll-behavior: contain; }
.gr-bulk-label span { font-size: 11px; color: var(--muted); }
.gr-n { text-align: right; }
.gr-bulk-row .field { min-height: 34px; padding: 4px 8px; }
/* 成績：テストごとの比較（ダンベル図） */
.gr-cmp-summary { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 12px; }
.gr-cmp-summary > div { display: flex; flex-direction: column; }
.gr-cmp-summary b { font-size: 22px; font-variant-numeric: tabular-nums; }
.gr-cmp { display: grid; gap: 2px; }
.gr-cmp-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 120px; align-items: center; gap: 12px; min-height: 30px; }
.gr-cmp-row:not(.gr-cmp-axis):hover { background: var(--surface-2); border-radius: 8px; }
.gr-cmp-subj { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-track { position: relative; height: 22px; margin: 0 8px; }
.gr-track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--border); }
.gr-grid { position: absolute; top: 3px; bottom: 3px; border-left: 1px dashed var(--border); }
.gr-cmp-axis .gr-track { height: 16px; }
.gr-cmp-axis .gr-track::before { display: none; }
.gr-tick { position: absolute; transform: translateX(-50%); font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gr-gap { position: absolute; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; }
.gr-gap.up { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.gr-gap.down { background: color-mix(in srgb, var(--muted) 55%, transparent); }
.gr-dot-me, .gr-dot-avg { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; border: 2px solid var(--surface); }
.gr-dot-me { background: var(--accent); z-index: 1; }
.gr-dot-avg { background: var(--muted); }
.gr-cmp-val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gr-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.gr-key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; }
.gr-key.me { background: var(--accent); }
.gr-key.avg { background: var(--muted); }
.gr-key.gap { width: 16px; height: 4px; border-radius: 2px; }
.gr-key.gap.up { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.gr-key.gap.down { background: color-mix(in srgb, var(--muted) 55%, transparent); }
/* 成績：総順位 */
.gr-rank-chart { margin-bottom: 10px; }
.gr-rank-svg { display: block; width: 100%; height: auto; max-height: 180px; }
.gr-rank-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.gr-rank-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.gr-rank-label { fill: var(--text); font-size: 11px; font-weight: 700; }
.gr-rank-empty { font-size: 14px; font-weight: 500; }
.gr-bulk-head { grid-template-columns: 150px 110px 1fr 90px 90px !important; }
/* あとで読む：★保存・Instagram のプレビュー */
.later-row .icon-btn.kept { color: var(--accent); }
.later-row .actions .icon-btn { font-size: 17px; }
.ig-embed { width: 100%; height: min(70vh, 640px); border: 0; border-radius: 12px; background: #fff; }
/* 共有したときの送り先選び */
.share-url { margin: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; max-height: 4.5em; overflow: hidden; }
.share-url b { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }
.share-groups { align-items: center; }
.share-newgroup { width: 130px; min-height: 30px; padding: 3px 10px; font-size: 13px; }
.share-dests { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.share-dest { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); color: var(--text); text-align: left; cursor: pointer; }
.share-dest:hover { border-color: var(--accent); }
.share-dest.last { border-color: var(--accent); background: var(--accent-soft); }
.share-dest b { display: block; font-size: 15px; }
.share-dest small { display: block; font-size: 11px; color: var(--muted); }
.share-dest .ic { flex: none; color: var(--accent); }
/* 宿題 */
.hw-title { white-space: normal !important; overflow-wrap: anywhere; }
.hw-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.hw-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.badge.hw-st.done { background: var(--surface-2); color: var(--muted); }
.badge.hw-st.late { background: var(--danger-soft); color: var(--danger); }
.badge.hw-st.behind { background: var(--danger-soft); color: var(--danger); font-weight: 500; }
.badge.hw-st.today { background: var(--accent-soft); color: var(--accent); }
.badge.hw-st.plan { background: var(--surface-2); color: var(--text); font-weight: 500; }
.dl-row.hw-done .hw-title { text-decoration: line-through; color: var(--muted); }
.hw-bar { position: relative; display: block; height: 18px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.hw-bar > span { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 55%, transparent); }
.hw-bar b { position: relative; display: block; text-align: center; font-size: 11px; line-height: 18px; }
/* 記録のリスト（行きたいところ・見た読んだ・料理） */
.col-thumb { display: flex; align-items: center; justify-content: center; width: 56px; height: 42px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.col-thumb img { width: 100%; height: 100%; object-fit: cover; }
.col-thumb img.fav { width: 22px; height: 22px; object-fit: contain; }
.col-noimg { font-weight: 700; color: var(--muted); }
.dl-c.col-thumb-c { overflow: visible; }
.col-title { white-space: normal !important; overflow-wrap: anywhere; }
.col-link { margin-left: 6px; color: var(--muted); vertical-align: -2px; }
.col-stars { color: var(--accent); letter-spacing: 1px; font-size: 13px; }
.badge.col-st.want { background: var(--surface-2); color: var(--text); }
.badge.col-st.doing { background: var(--accent-soft); color: var(--accent); }
.badge.col-st.done { background: color-mix(in srgb, #3f9a5f 22%, transparent); color: #3f9a5f; }
/* 改修メモ */
.fb-body, .fb-note { white-space: normal !important; overflow-wrap: anywhere; }
.badge.fb-open { background: var(--surface-2); color: var(--text); }
.badge.fb-doing { background: var(--accent-soft); color: var(--accent); }
.badge.fb-done { background: var(--surface-2); color: var(--muted); }
.badge.fb-hold { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.push-type { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; padding: 4px 0 8px; border-bottom: 1px dashed var(--border); }
.push-type .push-toggle { flex: 1 1 320px; }
.push-time { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.push-time .field { width: 110px; min-height: 32px; padding: 3px 8px; }
.push-type .push-preview { flex-basis: 100%; margin-top: 0; }
.push-type .push-preview:empty { display: none; }
.notify-card { max-width: 860px; }
.push-sample { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.push-sample b { display: block; font-size: 14px; }

/* 雨・雪・凍結のお知らせ */
.wx-alerts { display: flex; flex-direction: column; gap: 8px; margin: -8px 0 20px; }
.wx-alert {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  font-size: 14px; line-height: 1.6; color: var(--text);
}
.wx-alert .wx-ic { font-size: 20px; line-height: 1.3; flex-shrink: 0; }
.wx-alert.snow { border-color: #5aa9e6; background: color-mix(in srgb, #5aa9e6 16%, var(--surface)); }
.wx-alert.snow.high { border-width: 2px; font-weight: 700; }
.wx-alert.freeze { border-color: #7fb8d8; background: color-mix(in srgb, #7fb8d8 12%, var(--surface)); }
.wx-alert.rain { border-color: var(--border); }
.wx-alert.rain.high { border-color: color-mix(in srgb, #5aa9e6 60%, var(--border)); }
.fc-snow { font-size: 11px; font-weight: 700; color: #5aa9e6; }
.hero-weather { cursor: pointer; border-radius: 12px; padding: 6px 8px; margin: -6px -8px; transition: background .15s; }
.hero-weather:hover, .hero-weather:focus-visible { background: var(--surface); outline: none; }

/* 天気の詳細（モーダル） */
dialog.wide { width: min(760px, calc(100% - 24px)); }
.fc { padding: 18px 20px 16px; }
.fc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.fc-head h3 { margin: 0; font-size: 17px; flex: 1; }
.fc-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .08em; margin: 14px 0 6px; }
.fc-strip { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.fc-hour {
  flex: 0 0 58px; text-align: center; padding: 8px 2px; border-radius: 12px; background: var(--surface-2);
  scroll-snap-align: start; font-variant-numeric: tabular-nums;
}
.fc-hour.now { background: var(--accent-soft); outline: 1px solid var(--accent); }
.fc-hour.newday { margin-left: 10px; position: relative; }
.fc-hour.newday::before {
  content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; border-left: 1px dashed var(--border);
}
.fc-time { font-size: 12px; color: var(--muted); }
.fc-hour.now .fc-time, .fc-hour.newday .fc-time { color: var(--text); font-weight: 700; }
.fc-ic { font-size: 22px; line-height: 1.5; }
.fc-temp { font-size: 15px; font-weight: 700; }
.fc-pop { font-size: 11px; color: var(--muted); }
.fc-pop.wet { color: var(--text); font-weight: 700; }
.fc-wind { font-size: 10px; color: var(--muted); }
.fc-week { display: flex; flex-direction: column; }
.fc-day {
  display: grid; grid-template-columns: 96px 32px 1fr auto 56px; align-items: center; gap: 8px;
  padding: 6px 4px; border-bottom: 1px dashed var(--border); font-size: 14px;
}
.fc-day:last-child { border-bottom: 0; }
.fc-day .fc-ic { font-size: 20px; text-align: center; }
.fc-desc { color: var(--muted); font-size: 13px; }
.fc-range { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fc-day .fc-pop { text-align: right; font-size: 12px; }

/* ===== 小さな一覧（ホームのノート・あとで読む・ニュース） ===== */
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { border-bottom: 1px dashed var(--border); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list a {
  display: flex; align-items: center; gap: 10px; padding: 8px 2px;
  text-decoration: none; font-size: 14px; min-width: 0;
}
.mini-list a:hover .t { color: var(--accent); }
.mini-list img { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; }
.mini-list .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .s { color: var(--muted); font-size: 11px; flex-shrink: 0; }

/* ===== 今日（習慣＋気分） ===== */
.today-habits { display: flex; flex-wrap: wrap; gap: 8px; }
.habit-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 14px;
  border: 1.5px solid var(--hc, var(--accent)); background: transparent; color: var(--text);
}
.habit-chip.done { background: var(--hc, var(--accent)); color: #fff; font-weight: 700; }
.mood-row { display: flex; gap: 6px; }
.mood {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 22px; cursor: pointer; filter: grayscale(1); opacity: .6;
}
.mood:hover { filter: none; opacity: 1; }
.mood.on { filter: none; opacity: 1; background: var(--accent-soft); border-color: var(--accent); }
.today-section + .today-section { margin-top: 16px; }
.today-section .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }

/* ===== ノート ===== */
.notes-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.notes-layout > .note-editor { min-width: 0; }      /* 横長の表で右側が押し広げられないように（表だけ横スクロール） */
/* 上に一覧・下に内容（メーラー型） */
.notes-layout.stack { grid-template-columns: minmax(0, 1fr); }
.notes-layout.stack .notes-side { position: static; max-height: none; }
.notes-layout.stack .note-list { max-height: 260px; overflow-y: auto; }
/* 表の行を押すと詳しく */
.md table.row-click tbody tr { cursor: pointer; }
.md table.row-click tbody tr:hover { background: var(--surface-2); }
.row-detail { display: grid; grid-template-columns: minmax(80px, max-content) 1fr; gap: 6px 14px; margin: 12px 0 0; }
.row-detail dt { color: var(--muted); font-size: .85em; padding-top: .2em; }
.row-detail dd { margin: 0; overflow-wrap: anywhere; }
.notes-side { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - var(--topbar-h) - 48px); }
.tag-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.note-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.note-item { padding: 10px 12px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; }
.note-item:hover { background: var(--surface-2); }
.note-item.active { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
.note-item .nt { font-weight: 700; font-size: 14px; display: flex; gap: 4px; align-items: center; }
.note-item .nt .ic { color: var(--accent); }
.note-item .ns { font-size: 12px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.note-item .nd { font-size: 11px; color: var(--muted); margin-top: 2px; }
.note-editor { min-height: 60vh; display: flex; flex-direction: column; gap: 10px; }
.note-title { font-size: 22px; font-weight: 800; border: 0; background: transparent; outline: 0; width: 100%; padding: 4px 0; }
.note-tags { border: 0; background: transparent; outline: 0; width: 100%; font-size: 13px; color: var(--muted); padding: 0; }
.note-body { flex: 1; min-height: 50vh; font-size: 15px; }
.note-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.note-status { font-size: 12px; color: var(--muted); }
.back-btn { display: none; }

.md { font-size: 15px; line-height: 1.85; overflow-wrap: anywhere; }
/* 文章が中心のところは、幅を広げても1行が長くなりすぎないように */
.md, .note-body, .ll-list .ll-body { max-width: 860px; }
html[data-width="full"] .wrap { max-width: none; }
.width-btn { display: none; }
@media (min-width: 1181px) { .width-btn { display: inline-flex; } }
.md h1, .md h2, .md h3 { line-height: 1.4; margin: 1.2em 0 .4em; }
.md h1 { font-size: 1.5em; } .md h2 { font-size: 1.3em; } .md h3 { font-size: 1.1em; }
.md p { margin: .5em 0; }
.md a { color: var(--accent); }
.md code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.md pre { background: var(--surface-2); padding: 12px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: .5em 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.md ul, .md ol { padding-left: 1.4em; }
/* 横長の表はカードからはみ出さず、表だけ横スクロールする */
.md table { border-collapse: collapse; display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 10px; white-space: nowrap; }
.md img { max-width: 100%; border-radius: 8px; }

/* ===== あとで読む・ニュース ===== */
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.feed-row:last-child { border-bottom: 0; }
.feed-row .thumb { width: 72px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.feed-row .fav { width: 20px; height: 20px; border-radius: 4px; flex-shrink: 0; }
.feed-row .main { flex: 1; min-width: 0; }
.feed-row .title { display: block; font-size: 15px; text-decoration: none; overflow-wrap: anywhere; }
.feed-row .title:hover { color: var(--accent); }
.feed-row.read .title { color: var(--muted); }
.feed-row .sub { font-size: 12px; color: var(--muted); }
.feed-row .actions { display: flex; gap: 2px; flex-shrink: 0; }
/* あとで読む：サムネイルは同じ大きさの枠にそろえる */
.later-row { align-items: flex-start; }
.later-thumb {
  flex: none; width: 128px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: var(--surface-2);
}
.later-thumb img:not(.fav) { width: 100%; height: 100%; object-fit: cover; }
.later-thumb .fav { width: 28px; height: 28px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.news-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.feed-side { list-style: none; margin: 0; padding: 0; }
.feed-side li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.feed-side li:hover { background: var(--surface-2); }
.feed-side li.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.feed-side .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-side .cnt { font-size: 12px; color: var(--muted); }
.feed-side .err { color: var(--danger); font-size: 11px; }
.help { font-size: 13px; color: var(--muted); }
.help code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.bookmarklet {
  display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--accent); color: #fff;
  text-decoration: none; font-weight: 700; font-size: 13px;
}

/* ===== YouTube ===== */
.yt-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.yt-avatar.fallback { display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.yt-side .yt-ch { cursor: grab; }
.yt-group-head { display: flex; align-items: center; gap: 2px; margin-top: 8px; padding: 2px 4px; border-radius: 10px; }
.yt-group-head.active { background: var(--accent-soft); }
.yt-group-head.active .yt-group-name { color: var(--accent); }
.yt-group-name {
  flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 4px 2px; cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .06em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.yt-group-name:hover { color: var(--text); }
.yt-group-head .cnt { font-size: 12px; color: var(--muted); padding-right: 6px; }
.yt-fold { width: 24px; height: 24px; }
.yt-fold-all { margin: 6px 4px 0; }
.yt-fold-all .btn { width: 100%; justify-content: center; color: var(--muted); }
.yt-fold-all .folded { display: inline-flex; transform: rotate(-90deg); }
.yt-fold .folded { display: inline-flex; transform: rotate(-90deg); }
.yt-group-list { min-height: 8px; padding-left: 6px; }
.yt-later.on { color: var(--accent); }
.yt-add { flex-wrap: wrap; }
.yt-add .field:first-child { flex: 1 1 280px; }
.yt-shorts-default { width: auto; flex: none; }
.yt-picker-btn { display: none; }
.yt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.yt-grid.home { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.yt-card { min-width: 0; }
.yt-thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.yt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.yt-thumb:hover img { transform: scale(1.03); }
.yt-new {
  position: absolute; top: 6px; left: 6px; padding: 0 8px; border-radius: 6px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; line-height: 1.8;
}
.yt-short {
  position: absolute; bottom: 6px; right: 6px; padding: 0 8px; border-radius: 6px;
  background: rgba(0,0,0,.7); color: #fff; font-size: 11px; font-weight: 700; line-height: 1.8;
}
.yt-card.watched .yt-thumb img { opacity: .55; }
.yt-meta { margin-top: 6px; }
.yt-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 14px; font-weight: 500; line-height: 1.5; text-decoration: none;
}
.yt-title:hover { color: var(--accent); }
.yt-card.watched .yt-title { color: var(--muted); }
.yt-sub { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.yt-sub span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yt-mark { width: 28px; height: 28px; }

/* ===== ライフログ ===== */
.ll-compose { display: flex; flex-direction: column; gap: 8px; }
.ll-input { font-size: 15px; resize: vertical; min-height: 64px; }
.ll-compose.compact .ll-input { min-height: 52px; }
.ll-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ll-row > .field { flex: 1; min-width: 140px; }
.ll-row > .ll-when { flex: 0 1 210px; min-width: 0; }
.ll-moods .mood { width: 34px; height: 34px; font-size: 18px; }
.ll-pos .chip { cursor: default; }
.ll-x { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 4px; font-size: 14px; }
.ll-filter { margin: 18px 0 12px; flex-wrap: wrap; }
.ll-day + .ll-day { margin-top: 18px; }
.ll-daylink { border: 0; background: none; padding: 0; color: inherit; font: inherit; cursor: pointer; }
.ll-daylink:hover { color: var(--accent); }
.ll-post { display: flex; gap: 12px; padding: 10px 2px; border-bottom: 1px dashed var(--border); align-items: flex-start; }
.ll-post:last-child { border-bottom: 0; }
.ll-time { flex-shrink: 0; width: 56px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.ll-mood { display: block; font-size: 18px; margin-top: 2px; }
.ll-main { flex: 1; min-width: 0; }
.ll-body { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.ll-tag { color: var(--accent); border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }
.ll-tags { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; font-size: 13px; }
.ll-tagpick { margin: 8px 0 2px; align-items: center; }
.ll-tagpick .chip { padding: 3px 10px; font-size: 13px; }
.chip.ghost { background: none; border-style: dashed; color: var(--muted); }
.ll-tagnew { width: 130px; min-height: 30px; padding: 4px 10px; font-size: 13px; }
.ll-hint { font-size: 11px; color: var(--muted); }
span.ll-tag { cursor: default; }
.ll-place { display: inline-block; margin-top: 4px; font-size: 13px; color: var(--muted); text-decoration: none; }
.ll-place:hover { color: var(--accent); }
.ll-place small { margin-left: 4px; text-decoration: underline; }
.ll-selbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ll-selbar:empty { display: none; }
.ll-selcount { font-weight: 700; font-size: 14px; }
.ll-list .money-day-head { align-items: center; gap: 10px; }
.ll-daycheck { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; }
.ll-daycheck input, .ll-check { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.ll-check { margin-top: 2px; }
.ll-list.selecting .ll-post { cursor: pointer; border-radius: 8px; }
.ll-list.selecting .ll-post:hover { background: var(--surface-2); }
.ll-list.selecting .ll-post.picked { background: var(--accent-soft); }
.ll-today { margin-top: 10px; }
.ll-today .ll-post { padding: 6px 0; }
.ll-today .ll-body { font-size: 14px; }

/* ===== 家計簿 ===== */
/* 集計タイル：横に詰めすぎて文字が切れないよう、PC は1段3枚（6枚なら2段）、スマホは2枚ずつ */
.kb-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(260px, calc((100% - 20px) / 3)), 1fr)); gap: 10px; }
.kb-kpis .stat { padding: 12px 14px; }
.kb-kpis .stat-label { align-items: flex-start; }
.kb-kpis .stat-value { font-size: 20px; overflow-wrap: anywhere; }
.kb-kpis .stat-main .stat-value { font-size: 22px; }
.meter.warn span { background: color-mix(in srgb, var(--accent) 70%, var(--danger)); }
.kb-points { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; margin: 0; font-size: 14px; line-height: 1.75; }
.kb-points dt { font-weight: 700; color: var(--muted); font-size: 13px; padding-top: 1px; }
.kb-points dd { margin: 0; }
.kb-form { display: grid; grid-template-columns: 84px 140px 150px minmax(0, 1fr) 110px minmax(0, 1fr) 150px auto; gap: 8px; margin-bottom: 12px; }
.kb-form .field { padding: 8px 10px; font-size: 14px; }
.kb-amount { text-align: right; font-weight: 700; }
.kb-table-wrap, .kb-entries { overflow-x: auto; }
.kb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kb-table th {
  text-align: left; font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap;
  padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.kb-table td { padding: 6px 8px; border-bottom: 1px dashed var(--border); white-space: nowrap; vertical-align: middle; }
.kb-table td.num, .kb-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.kb-table .kb-desc, .kb-table .kb-note { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.kb-table .kb-note { color: var(--muted); }
.kb-entry-table tbody tr { cursor: pointer; }
.kb-entry-table tbody tr:hover { background: var(--surface-2); }
.kb-entry-table tr.flat td { color: var(--muted); }
.kb-sub td { font-weight: 700; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.kb-total td { font-weight: 800; border-top: 2px solid var(--border); border-bottom: 0; }
.kb-bar { font-size: 10px; letter-spacing: -1px; color: var(--accent); }
.kb-verdict { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); }
.kb-verdict.v-超過, .kb-verdict.v-予算外 { background: var(--danger-soft); color: var(--danger); }
.kb-verdict.v-注意, .kb-verdict.v-積立不足 { background: var(--accent-soft); color: var(--accent); }
.kb-verdict.v-—, .kb-verdict.v-OK, .kb-verdict.v-定額どおり { color: var(--muted); }
.kb-link, .kb-edit { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: inherit; }
.kb-link:hover, .kb-edit:hover { color: var(--accent); text-decoration: underline; }
.kb-edit small { color: var(--accent); }
.kb-over small { color: var(--danger); font-weight: 700; }
.kb-cur { color: var(--accent) !important; }
.kb-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 2px; border-bottom: 1px dashed var(--border); font-size: 14px; }
.kb-line.strong { font-weight: 700; }
.kb-line .num { font-variant-numeric: tabular-nums; }
.kb-next { margin: 0; padding-left: 1.2em; font-size: 14px; line-height: 1.8; }
.kb-next li + li { margin-top: 6px; }
.kb-chart { display: flex; flex-direction: column; gap: 6px; }
.kb-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kb-legend .lg-bar { width: 14px; height: 10px; border-radius: 2px; background: var(--accent); margin-left: 8px; }
.kb-legend .lg-bar.over { background: var(--danger); }
.kb-legend .lg-tick { width: 2px; height: 14px; background: var(--text); margin-left: 8px; }
.kb-crow { display: grid; grid-template-columns: 110px 1fr 80px; align-items: center; gap: 10px; font-size: 13px; }
.kb-cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-ctrack { position: relative; height: 16px; }
.kb-cbar { position: absolute; left: 0; top: 0; height: 16px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--accent); }
.kb-cbar.over { background: var(--danger); }
.kb-ctick { position: absolute; top: -3px; width: 2px; height: 22px; background: var(--text); border-radius: 1px; }
.kb-cval { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.kb-diff { color: var(--accent); font-weight: 700; }
.kb-bh-months { align-items: center; }
#dlg .date-nav input[type="month"] { width: 170px; }
.kb-budget-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.kb-bd-head { display: grid; grid-template-columns: 200px 1fr; gap: 10px; align-items: end; }
.kb-bd-list { max-height: 52vh; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--border); }
.kb-bd-input { text-align: right; padding: 4px 8px; min-height: 32px; font-variant-numeric: tabular-nums; }
.kb-bd-input.invalid { border-color: var(--danger); }
.kb-bd .dl-c.r:last-child { overflow: visible; }
.kb-changed { background: var(--accent-soft); }
.kb-bd-total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kb-mh { font-size: 13px; color: var(--muted); margin: 18px 0 8px; }
.kb-master-list { margin-bottom: 8px; }

/* ===== 買い物リスト ===== */
.shop-form { display: grid; grid-template-columns: 1fr 180px auto; gap: 8px; }
.shop-input { font-size: 16px; }
.shop-suggest:not(:empty) { margin-top: 10px; }
.shop-group + .shop-group { margin-top: 14px; }
.shop-group-head {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 2px 6px; border-bottom: 1px solid var(--border);
}
.shop-group-head .btn { min-height: 28px; font-weight: 500; }
.shop-item { display: flex; align-items: center; gap: 12px; border-bottom: 1px dashed var(--border); }
.shop-check {
  flex-shrink: 0; width: 24px; height: 24px; margin: 8px 0 8px 4px; border-radius: 8px;
  border: 2px solid var(--border); background: var(--surface); cursor: pointer;
}
.shop-check:hover { border-color: var(--accent); background: var(--accent-soft); }
/* 1行表示：品名（長ければ「…」）と、カテゴリ・メモなどを同じ行の右に */
.shop-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border: 0; background: none; text-align: left; cursor: pointer; }
.shop-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 500; }
.shop-main .shop-meta { margin-left: auto; flex-shrink: 1; min-width: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.shop-qty { flex-shrink: 0; font-size: 13px; color: var(--accent); font-weight: 700; }
.shop-meta { font-size: 12px; color: var(--muted); }
.shop-undo {
  display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 10px;
  padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px;
}
.shop-chip { padding: 4px 12px; font-size: 13px; }
.shop-history { margin-top: 8px; }

/* ===== 配信スケジュール ===== */
.rel-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.rel-week.days-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rel-week.days-1 { grid-template-columns: minmax(0, 1fr); }
.rel-week.days-1 .rel-item, .rel-week.days-3 .rel-item { font-size: 14px; }
.rel-day { background: var(--surface-2); border-radius: 12px; padding: 8px; min-height: 90px; border: 1px solid transparent; }
.rel-day.today { border-color: var(--accent); background: var(--accent-soft); }
.rel-day-head { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.rel-day.today .rel-day-head { color: var(--accent); }
.rel-day .empty { font-size: 12px; padding: 0; }
.rel-item { display: flex; align-items: flex-start; gap: 6px; padding: 4px 0; font-size: 13px; }
.rel-item input { accent-color: var(--accent); flex-shrink: 0; margin-top: 3px; }
.rel-text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; overflow-wrap: anywhere; }
.rel-text .rel-service { flex-basis: 100%; }
.rel-group + .rel-group { margin-top: 6px; }
.rel-alldone { border: 0; cursor: pointer; }
/* ホームの買い物 */
.home-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; }
.home-shop-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; cursor: pointer; }
.home-shop-item input { width: 18px; height: 18px; accent-color: var(--accent); }
.card.folded .card-head { margin-bottom: 0; }
.rel-reg-group + .rel-reg-group { margin-top: 18px; }
.rel-reg-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 4px; border-bottom: 1px solid var(--border); }
.rel-reg-head b { font-size: 15px; }
.rel-group-head { font-size: 11px; color: var(--muted); margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 週表示はタイトルを1行にして、はみ出す分は「…」（全文はカーソルで） */
.rel-week.days-7 .rel-title { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rel-title { font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
a.rel-title:hover { color: var(--accent); }
.rel-service { font-size: 11px; color: var(--muted); }
.rel-item.done .rel-title { text-decoration: line-through; color: var(--muted); }

.rel-home { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 20px; }
.rel-home .rel-item { padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.rel-tomorrow { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* ===== サブスク ===== */
.subs-group + .subs-group { margin-top: 18px; }
.subs-group .money-day-head { font-weight: 700; color: var(--text); }
.subs-cats { display: grid; gap: 8px; max-width: 560px; }
.subs-cat { display: grid; grid-template-columns: 110px 1fr 90px; align-items: center; gap: 12px; font-size: 14px; }
.subs-cat .meter { margin-top: 0; }
.subs-cat .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ===== 明細型の一覧（dataList）：支出記録の明細と同じ見た目。今後の一覧はこれを基準にする ===== */
.dl-row {
  display: grid; grid-template-columns: var(--dl-cols); align-items: center; column-gap: 12px;
  padding: 8px 6px; border-bottom: 1px dashed var(--border); font-size: 14px; text-align: left;
}
.dl-row.click { cursor: pointer; }
.dl-row.click:hover { background: var(--surface-2); }
.dl-row.off { opacity: .5; }
.dl-row.kb-total { font-weight: 700; border-top: 1px solid var(--border); border-bottom: 0; }
.dl-th { border-bottom: 0; padding-top: 0; padding-bottom: 6px; font-size: 11px; color: var(--muted); }
.dl-c { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-c.r { text-align: right; font-variant-numeric: tabular-nums; }
.dl-c.b { font-weight: 700; }
.dl-c.m { font-size: 12px; color: var(--muted); }
.dl-c.act { display: flex; align-items: center; justify-content: flex-end; gap: 4px; overflow: visible; }
.dl-c.grip { display: flex; color: var(--muted); cursor: grab; }
.dl-br { display: none; }
/* 一覧の上で直せるセル（editableCell） */
.ed-cell { display: inline-block; min-width: 2.5em; min-height: 1.6em; max-width: 100%; border-radius: 6px; cursor: text; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; }
.ed-cell:hover, .ed-cell:focus-visible { outline: 1px dashed var(--border); outline-offset: 2px; }
.ed-cell.saving { opacity: .5; }
.ed-input { width: 100%; min-width: 64px; min-height: 30px; padding: 3px 8px; font-size: 13px; }
.ed-input.num { text-align: right; }
.dl-c:has(> .ed-cell) { overflow: visible; }
/* 見出しで並べ替え（▲▼ は並べ替え中の列だけ） */
table.kb-table > thead th, .dl.sortable > .dl-th > .dl-c:not(:empty) { cursor: pointer; user-select: none; }
table.kb-table > thead th:hover, .dl.sortable > .dl-th > .dl-c:not(:empty):hover { color: var(--text); }
.sorted { color: var(--accent) !important; }
.sorted::after { content: " ▼"; font-size: 9px; }
.sorted[data-dir="asc"]::after { content: " ▲"; }
.dl-body .sortable-ghost { opacity: .4; }

/* ===== 体重・食事 ===== */
.hl-body-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.hl-body-form > input { flex: 1 1 180px; }
.hl-num { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); position: relative; }
.hl-num .field { width: 110px; font-size: 20px; font-weight: 700; padding-right: 30px; font-variant-numeric: tabular-nums; }
.hl-num small { position: absolute; right: 10px; bottom: 11px; }
.hl-chart { min-height: 120px; }
.hl-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.hl-grid { stroke: var(--border); stroke-width: 1; }
.hl-axis { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.hl-goal { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.hl-avg { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.hl-dot { fill: color-mix(in srgb, var(--accent) 45%, var(--surface)); stroke: var(--surface); stroke-width: 1; }
.hl-dot.cur { fill: var(--accent); }
.hl-cross { stroke: var(--muted); stroke-width: 1; }
.hl-legend { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); }
.hl-key { display: inline-block; width: 14px; height: 8px; margin-left: 6px; }
.hl-key.dot { width: 8px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.hl-key.line { height: 2px; background: var(--accent); }
.hl-key.goal { height: 0; border-top: 1px dashed var(--muted); }
.hl-key.sw { width: 10px; height: 10px; border-radius: 3px; margin: 0 6px 0 0; }
.hl-meal-input { margin-bottom: 12px; }
.hl-meal-form { display: grid; grid-template-columns: 80px minmax(0, 1fr) minmax(0, 160px) 84px 64px 64px 64px auto; gap: 8px; }
.hl-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.hl-chips { align-items: center; flex: 1; min-width: 0; }
.hl-photo { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.hl-photo-head { display: flex; align-items: center; margin-bottom: 8px; }
.hl-photo-main { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 14px; align-items: start; }
.hl-photo-img { width: 100%; border-radius: 8px; object-fit: cover; aspect-ratio: 4 / 3; }
.hl-photo .dl-row.click:hover, .hl-photo .dl-row { background: none; }
.hl-photo-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.hl-slot { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.hl-preset { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.hl-preset-basis:empty { display: none; }
.hl-preset-basis { margin: 4px 0 0; }
.hl-pfc { margin-top: 14px; display: grid; gap: 8px; max-width: 620px; }
.hl-pfc-total { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hl-ratio { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; }
.hl-ratio span { flex-basis: 0; min-width: 0; }
.pfc-p { --c: var(--pfc-p); } .pfc-f { --c: var(--pfc-f); } .pfc-c { --c: var(--pfc-c); }
.hl-ratio span, .hl-key.sw, .hl-pfc-row .meter span { background: var(--c); }
.hl-pfc-row { display: grid; grid-template-columns: 110px 1fr 120px; align-items: center; gap: 12px; font-size: 13px; }
.hl-pfc-row .meter { margin-top: 0; background: var(--surface-2); }
.hl-pfc-name { display: flex; align-items: center; }
.hl-pfc-val { text-align: right; font-variant-numeric: tabular-nums; }
.hl-goal-line { border-top: 1px dashed var(--muted) !important; }
.cc-col.over .cc-bar { background: var(--danger); }
.cc-col.over.dim .cc-bar { background: color-mix(in srgb, var(--danger) 45%, var(--surface)); }

/* ===== メニューの未読バッジ ===== */
.navlink .ic, .drawer-link .ic { position: relative; }
.nav-badge {
  position: absolute; top: -6px; right: -10px; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 17px; text-align: center; letter-spacing: 0;
  box-shadow: 0 0 0 2px var(--bg);
}
.menu-btn { position: relative; }
.menu-btn.has-badge::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--bg);
}

/* ===== 日記 ===== */
.journal-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.date-nav { display: flex; align-items: center; gap: 6px; }
.date-nav h1 { font-size: 20px; min-width: 200px; text-align: center; }
.journal-body { min-height: 45vh; font-size: 16px; line-height: 1.9; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 12px; }
.calendar .wd { color: var(--muted); font-size: 11px; }
.calendar .day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 8px; cursor: pointer; border: 1px solid transparent; position: relative; line-height: 1.1;
}
.calendar .day:hover { background: var(--surface-2); }
.calendar .day.other { color: var(--muted); opacity: .4; }
.calendar .day.today { border-color: var(--accent); }
.calendar .day.sel { background: var(--accent); color: #fff; font-weight: 700; }
.calendar .day .m { font-size: 13px; }
.calendar .day.has:not(.sel)::after {
  content: ""; position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 700; }
.past-entry { padding: 10px 0; border-top: 1px dashed var(--border); }
.past-entry .pd { font-size: 12px; color: var(--muted); }
.past-entry .pb { font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 7.5em; overflow: hidden; }

/* ===== 習慣 ===== */
.habit-card { margin-bottom: 16px; }
.habit-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.habit-name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.habit-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--hc); }
.habit-stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.habit-stats b { color: var(--text); font-size: 15px; }
.heat-wrap { overflow-x: auto; margin-top: 12px; padding-bottom: 4px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 3px; width: max-content; }
.heat .c { width: 14px; height: 14px; border-radius: 3px; background: var(--surface-2); cursor: pointer; border: 0; padding: 0; }
.heat .c.on { background: var(--hc); }
.heat .c.future { visibility: hidden; }
.heat .c.today { outline: 1.5px solid var(--text); outline-offset: -1px; }
.week-row { display: flex; gap: 6px; margin-top: 12px; }
.week-row button {
  flex: 1; max-width: 56px; padding: 6px 0; border-radius: 10px; border: 1.5px solid var(--hc);
  background: transparent; font-size: 11px; cursor: pointer; line-height: 1.3;
}
.week-row button.on { background: var(--hc); color: #fff; font-weight: 700; }
.week-row button.plan:not(.on), .habit-cal button.plan:not(.on) { outline: 1.5px dashed var(--hc); outline-offset: -3px; }
.week-row button:disabled, .habit-cal button:disabled { opacity: .35; cursor: default; }
.week-row button.is-today, .habit-cal button.is-today { box-shadow: inset 0 0 0 1.5px var(--text); }
/* 表示の切り替え：3か月は大きめのマス、月はカレンダー、週は7日だけ */
.heat-wrap.quarter .heat { grid-template-rows: repeat(7, 20px); gap: 4px; }
.heat-wrap.quarter .heat .c { width: 20px; height: 20px; border-radius: 4px; }
.habit-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 44px)); gap: 4px; margin-top: 12px; }
.habit-cal-w { font-size: 11px; color: var(--muted); text-align: center; }
.habit-cal button { height: 36px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
.habit-cal button.on { background: var(--hc); color: #fff; font-weight: 700; }
/* グループ（例：掃除）とルーチンの状態 */
.habit-group { margin-bottom: 18px; }
.habit-group-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 4px 10px; }
.habit-group-toggle { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; color: var(--text); cursor: pointer; font-size: 16px; }
.habit-group-toggle .ic { transition: transform .15s; }
.habit-group.closed .habit-group-toggle .ic { transform: rotate(-90deg); }
.habit-group .habit-group-body { padding-left: 14px; border-left: 2px solid var(--border); }
.badge.rt-done { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-2); color: var(--muted); }
/* 1行表示（月・2週・週）：グループを1枚のカードにして項目を行で並べる */
.habit-list { padding: 4px 14px; margin-bottom: 16px; }
.habit-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.habit-row:last-child { border-bottom: 0; }
.habit-row .grip { color: var(--muted); cursor: grab; flex: none; }
/* 名前・サイクル・メモを1行に（長ければ「…」）。幅は固定して、日付のマスの位置を行ごとにそろえる */
.habit-row-name { flex: 0 0 260px; min-width: 0; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; }
.habit-row-name .habit-dot { flex: none; }
.habit-row-title { flex: none; max-width: 150px; overflow: hidden; text-overflow: ellipsis; font-weight: 700; font-size: 15px; }
.habit-row-sub { min-width: 0; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.habit-row-do { flex: none; width: 84px; justify-content: center; }
.habit-row-status { width: 84px; border: 0; background: none; padding: 0; cursor: pointer; text-align: right; }
.day-strip-head.nm .sd-h { height: 30px; line-height: 1; }
.habit-row-head { padding: 2px 0 0; border-bottom: 0; }
.habit-row-head .grip { width: 14px; }
.day-strip-head .sd-h { flex: 1 0 22px; max-width: 44px; position: relative; height: 26px; font-size: 10px; color: var(--muted); }
.day-strip-head.nm .sd-h { flex-basis: 18px; }
.sd-month { position: absolute; left: 1px; top: 0; font-size: 11px; font-weight: 700; color: var(--text); white-space: nowrap; }
.sd-dow { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; }
.sd-h.sun .sd-dow { color: #d66; }
.sd-h.sat .sd-dow { color: #5b9bd5; }
.sd-h.is-today .sd-dow { color: var(--text); font-weight: 700; }
.habit-memo { font-size: 12px; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.habit-row-status { flex: none; min-width: 74px; text-align: right; }
.day-strip { flex: 1 1 auto; min-width: 0; display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; }
.day-strip::-webkit-scrollbar { display: none; }
.day-strip .sd { flex: 1 0 22px; max-width: 44px; height: 32px; border: 0; border-radius: 6px; background: var(--surface-2); color: var(--text);
  font-size: 11px; line-height: 1.1; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; font-variant-numeric: tabular-nums; }
.day-strip .sd small { font-size: 9px; color: var(--muted); }
.day-strip .sd.sun small, .day-strip.nm .sd.sun { color: #d66; }
.day-strip .sd.sat small, .day-strip.nm .sd.sat { color: #5b9bd5; }
.day-strip .sd.on { background: var(--hc); color: #fff; font-weight: 700; }
.day-strip .sd.on small { color: #fff; }
.day-strip .sd.plan:not(.on) { outline: 1.5px dashed var(--hc); outline-offset: -3px; }
/* 次にやる日：赤い点線（未来でも薄くしない） */
.day-strip .sd.next:not(.on) { outline: 2px dashed var(--danger); outline-offset: -3px; opacity: 1; color: var(--danger); font-weight: 700; }
.day-strip .sd.is-today { box-shadow: inset 0 0 0 1.5px var(--text); }
.day-strip .sd.future { opacity: .35; cursor: default; }
.day-strip.nm .sd { flex-basis: 18px; height: 26px; }
.habit-row.st-overdue .habit-row-title { color: var(--danger); }
.day-strip-head:not(.nm) .sd-h { height: 16px; }
.habit-card.routine.st-overdue { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.week-row button b { display: block; font-size: 14px; }
.color-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== 支出記録 ===== */
.span-3 { grid-column: span 3; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.view.loading .grid { opacity: .55; transition: opacity .2s; }
.stat { padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.3; margin-top: 2px; overflow-wrap: anywhere; }
.stat.stat-main .stat-value { font-size: 32px; font-weight: 800; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.meter { height: 6px; border-radius: 999px; margin-top: 8px; overflow: hidden; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter.over { background: color-mix(in srgb, var(--danger) 18%, var(--surface)); }
.meter.over span { background: var(--danger); }
.period-title { display: flex; flex-direction: column; align-items: center; line-height: 1.3; min-width: 130px; }
.period-title h1 { font-size: 20px; margin: 0; min-width: 0; }
.cat-sort .chip { cursor: grab; padding: 2px 6px 2px 4px; background: none; border-color: transparent; }
.cat-sort .chip:hover { border-color: var(--border); }
.cat-sort .chip .ic { color: var(--muted); }
.small-select { width: auto; max-width: 180px; padding: 4px 10px; font-size: 13px; }
.add-chip { border-style: dashed; color: var(--muted); padding: 2px 10px; }
.add-chip:hover { color: var(--accent); border-color: var(--accent); }
.cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; vertical-align: middle; }
.money-amount-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.money-amount-row > span { font-size: 24px; font-weight: 700; color: var(--muted); }
.money-amount { font-size: 26px; font-weight: 700; padding: 6px 12px; }
.money-day + .money-day { margin-top: 14px; }
.money-day-head {
  display: flex; justify-content: space-between; font-size: 12px; color: var(--muted);
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
/* 明細：列幅を固定した表形式 */
.money-row {
  display: grid; grid-template-columns: 112px minmax(0, 150px) minmax(0, 1fr) 76px 88px 28px;
  grid-template-areas: "cat shop memo method amt more";
  align-items: center; column-gap: 12px; width: 100%;
  padding: 8px 6px; border: 0; border-bottom: 1px dashed var(--border); background: none; text-align: left; cursor: pointer;
  font-size: 14px;
}
.money-row:hover { background: var(--surface-2); }
.money-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 一覧の上で直せるセル */
.money-row { cursor: default; }
.mc-edit { cursor: text; border-radius: 6px; min-height: 1.6em; }
.mc-edit:hover, .mc-edit:focus-visible { outline: 1px dashed var(--border); outline-offset: 2px; }
.mc-edit.saving { opacity: .5; }
.mc-input { width: 100%; min-height: 30px; padding: 3px 8px; font-size: 13px; }
.mc-amt .mc-input { text-align: right; }
.mc-more { grid-area: more; width: 28px; height: 28px; font-weight: 700; color: var(--muted); }
.money-th { cursor: default; border-bottom: 0; padding-top: 0; padding-bottom: 6px; font-size: 11px; color: var(--muted); }
.money-th:hover { background: none; }
.mc-cat { grid-area: cat; }
.mc-shop { grid-area: shop; font-weight: 700; }
.mc-memo { grid-area: memo; }
.mc-method { grid-area: method; font-size: 12px; color: var(--muted); }
.mc-amt { grid-area: amt; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.money-th .mc-amt, .money-th > :nth-child(5) { text-align: right; }
.money-sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.money-sort:hover { color: var(--text); }
.mc-date { font-weight: 400; }
.money-cat {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
  font-size: 12px; padding: 1px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid transparent;
}
.money-cat.colored {
  background: color-mix(in srgb, var(--cc) 22%, var(--surface));
  border-color: color-mix(in srgb, var(--cc) 60%, transparent);
}

/* 横棒（カテゴリ別） */
.hbars { display: flex; flex-direction: column; gap: 2px; }
.hbar {
  display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 10px;
  padding: 5px 4px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left;
}
.hbar:hover, .hbar:focus-visible { background: var(--surface-2); outline: none; }
.hbar.dim { opacity: .4; }
.hbar-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 16px; display: flex; align-items: center; }
.hbar-fill { display: block; height: 16px; min-width: 2px; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar-val { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-val small { font-weight: 400; color: var(--muted); }

/* 縦棒（日別・月別） */
.cc-plot { position: relative; margin-left: 36px; }
.cc-grid { position: absolute; inset: 0; pointer-events: none; }
.cc-gl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.cc-gl span { position: absolute; right: calc(100% + 6px); top: -8px; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cc-cols { position: absolute; inset: 0; display: flex; align-items: stretch; }
.cc-col {
  position: relative; flex: 1; min-width: 0; display: flex; align-items: flex-end; justify-content: center;
  border: 0; padding: 0 1px; background: none; cursor: default;
}
.cc-col.pick { cursor: pointer; }
.cc-col:hover, .cc-col:focus-visible { background: color-mix(in srgb, var(--text) 5%, transparent); outline: none; }
.cc-bar { display: block; width: 100%; max-width: 24px; background: var(--accent); border-radius: 4px 4px 0 0; }
.cc-col.dim .cc-bar { background: color-mix(in srgb, var(--accent) 40%, var(--surface)); }
.cc-val { position: absolute; font-size: 11px; font-weight: 700; white-space: nowrap; color: var(--text); }
.cc-x { display: flex; margin-left: 36px; margin-top: 4px; }
.cc-read { display: flex; align-items: baseline; gap: 8px; min-height: 26px; margin: 0 0 6px 36px; font-size: 12px; color: var(--muted); }
.cc-read b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.cc-col.sel { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.cc-x span { overflow: visible; }
.cc-x span:last-child { direction: rtl; text-align: left; }
.cc-x span { flex: 1; min-width: 0; text-align: center; font-size: 10px; color: var(--muted); white-space: nowrap; }
.chart-tip {
  position: fixed; z-index: 60; pointer-events: none;
  padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0,0,0,.18); font-size: 12px; white-space: nowrap;
}
.chart-tip b { font-size: 14px; margin-right: 6px; }
.chart-tip span { color: var(--muted); }

/* ===== ダイアログ・トースト ===== */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: min(480px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.35); }
/* モーダルの中だけスクロールし、端まで行っても後ろへ伝えない */
dialog[open] { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
/* 重なりを開いている間：背面はスクロールもスワイプもさせない */
html.scroll-locked, html.scroll-locked body { overflow: hidden; overscroll-behavior: none; }
html.scroll-locked .bottomnav, html.scroll-locked .topbar { touch-action: none; }
/* 背面を止めている間もヘッダーは画面の上に残す（サイドバーはヘッダーの下に開くため） */
html.scroll-locked .topbar { position: fixed; top: 0; left: 0; right: 0; }
html.scroll-locked body { padding-top: var(--topbar-h); }
.dlg-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg-form h3 { margin: 0; font-size: 17px; }
/* 入力画面の上の帯：タイトルと「キャンセル・登録」。スクロールしても上に残る */
.dlg-head { position: sticky; top: -20px; z-index: 2; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: -20px -20px 0; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.dlg-head h3 { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.dlg-head .spacer { display: none; }
.dlg-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.dlg-field .field { color: var(--text); }
.dlg-actions { display: flex; gap: 8px; margin-top: 6px; }
.wd-row { display: flex; gap: 6px; flex-wrap: wrap; }
.wd-pick {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 14px;
}
.wd-pick input { position: absolute; opacity: 0; width: 0; height: 0; }
.wd-pick.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.wd-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dlg-form [data-field][hidden] { display: none !important; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch .sw {
  display: block; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
}
.swatch .sw.none { background: repeating-linear-gradient(45deg, var(--surface-2) 0 4px, var(--surface) 4px 8px); }
.swatch input:checked + .sw { box-shadow: 0 0 0 2px var(--text); }
.swatch input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.toast {
  position: fixed; left: 50%; z-index: 50;
  bottom: calc(var(--bottomnav-h) + max(20px, env(safe-area-inset-bottom)));
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== タブレット：全部はサイドバーに入れて、上にはピン留めした項目だけ ===== */
/* PC・タブレット：全部の機能はサイドバー（☰）に入れて、上にはピン留めした項目だけ */
.icon-btn.menu-btn { display: inline-flex; }
.topbar { gap: 10px; }
.topnav { justify-content: flex-start; min-width: 0; }
.topnav .navlink { position: relative; }
.topnav .navlink:not(.pinned) { display: none; }
@media (max-width: 860px) {
  .navlink .lbl { display: none; }
}
/* アイコンだけのメニューは、カーソルを乗せたら名前を即表示 */
/* PC でも全部の名前が並ばない幅では、上のメニューはアイコンだけ（名前はカーソルで） */
@media (max-width: 860px) and (hover: hover) {
  .topnav .navlink[data-name]:hover::after {
    content: attr(data-name);
    position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%);
    z-index: 30; pointer-events: none;
    padding: 4px 10px; border-radius: 8px;
    background: var(--text); color: var(--bg);
    font-size: 12px; font-weight: 500; white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
  }
}
@media (max-width: 960px) {
  .span-8, .span-4.weather { grid-column: span 12; }
  .span-4 { grid-column: span 6; }
  .span-5, .span-7 { grid-column: span 12; }
  .span-3 { grid-column: span 6; }
  .journal-layout { grid-template-columns: 1fr; }
}

/* ===== スマホ ===== */
@media (max-width: 640px) {
  /* 明細型の一覧：見出しを隠して2段に（1段目＝名前と金額など、2段目＝補足） */
  .dl-row.dl-th { display: none; }
  .habit-row { flex-wrap: wrap; }
  .habit-row-name { flex: 1 1 140px; }
  .habit-row-head .habit-row-name, .habit-row-head .habit-row-status, .habit-row-head .habit-row-do, .habit-row-head .icon-btn { display: none; }
  .day-strip { order: 5; flex-basis: 100%; }
  .gr-bulk-head { grid-template-columns: 1fr 1fr !important; }
  .gr-cmp-row { grid-template-columns: 64px minmax(0, 1fr) 84px; gap: 6px; }
  .gr-bulk-head { grid-template-columns: 1fr 1fr; }
  .gr-bulk-head .dlg-field:nth-child(3) { grid-column: 1 / -1; }
  .gr-bulk-row { grid-template-columns: minmax(0, 1fr) 54px 46px 54px 46px; gap: 4px; }
  .kb-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kb-kpis .stat-value { font-size: 17px; }
  .kb-kpis .stat-main .stat-value { font-size: 20px; }
  .kb-bd-head { grid-template-columns: 1fr; }
  .kb-bd-input { width: 120px; }
  /* 食事の入力：1段目＝いつ・食べたもの、2段目＝kcal・P・F・C、3段目＝追加 */
  .hl-meal-form { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .hl-meal-form > select { grid-column: span 3; }
  .hl-meal-form > input[name="name"] { grid-column: span 9; }
  .hl-meal-form > input[name="store"] { grid-column: 1 / -1; }
  .hl-meal-form > .hl-n { grid-column: span 3; }
  .hl-meal-form button[type="submit"] { grid-column: 1 / -1; }
  .hl-pfc-row { grid-template-columns: 84px 1fr 96px; }
  .hl-photo-main { grid-template-columns: 1fr; }
  .hl-photo-img { max-height: 180px; }
  .later-thumb { width: 92px; }
  .later-row .actions { flex-direction: column; }
  .dl-row { display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 2px; }
  .dl-c[data-sm="lead"] { order: 0; flex: none; }
  .dl-c[data-sm="main"] { order: 1; flex: 1 1 0; }
  .dl-c[data-sm="end"] { order: 2; flex: none; }
  .dl-br { display: block; order: 3; flex-basis: 100%; height: 0; }
  .dl-c[data-sm="sub"] { order: 4; flex: 0 1 auto; font-size: 12px; color: var(--muted); }
  .dl-c[data-sm="sub"]:empty, .dl-c[data-sm="hide"] { display: none; }
  :root { --bottomnav-h: 60px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topnav { display: none; }
  .icon-btn.menu-btn { display: inline-flex; }
  .brand { flex: 1; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
  }
  .bottomnav .navlink {
    flex: 1; flex-direction: column; gap: 0; border-radius: 0; padding: 6px 0 0;
    font-size: 10px; letter-spacing: 0; border: 0; background: none; cursor: pointer;
  }
  .bottomnav .navlink.active { background: transparent; }
  .bottomnav .navlink .lbl { display: inline; }
  .wrap { padding: 20px 16px calc(var(--bottomnav-h) + 40px + env(safe-area-inset-bottom)); }
  .clock { font-size: 44px; }
  /* スマホ：天気は時計の右にコンパクトに（3日分は天気を押すと出る詳細で見る） */
  .hero { flex-wrap: nowrap; align-items: center; gap: 10px; }
  .hero > div:first-child { min-width: 0; }
  .date { font-size: 13px; white-space: nowrap; }
  .greeting { font-size: 13px; white-space: nowrap; }
  .hero-weather { flex-shrink: 0; align-items: flex-end; text-align: right; gap: 2px; margin: -6px -6px -6px 0; padding: 6px; }
  .hw-now { gap: 6px; }
  .hw-icon { font-size: 30px; }
  .hw-temp { font-size: 30px; }
  .hw-side { font-size: 12px; line-height: 1.4; }
  .hw-days { display: none; }
  .fc { padding: 14px 12px; }
  .fc-day { grid-template-columns: 96px 26px 1fr 46px; font-size: 13px; gap: 6px; }
  .fc-dname { white-space: nowrap; }
  .fc-desc { display: none; }
  .grid { gap: 14px; }
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .span-3 { grid-column: span 6; }
  /* 明細はスマホでは2段：カテゴリ｜購入元・メモ｜金額 */
  .money-row {
    grid-template-columns: 84px minmax(0, 1fr) auto 24px;
    grid-template-areas: "cat shop amt more" "cat memo method more";
    row-gap: 2px; column-gap: 10px;
  }
  .mc-method { text-align: right; }
  .yt-grid, .yt-grid.home { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  /* YouTube：チャンネル一覧は縦並び＆折りたたみ */
  .yt-side .feed-side { display: block; overflow: visible; }
  .yt-side .feed-side li { padding: 9px 8px; }
  .yt-panel { padding: 6px !important; }
  .yt-picker-btn {
    display: flex; align-items: center; gap: 6px; width: 100%; padding: 10px 8px;
    border: 0; background: none; color: var(--text); font-size: 14px; cursor: pointer; text-align: left;
  }
  .yt-picker-btn b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .yt-picker-btn .spacer { display: none; }
  .yt-picker-hint { white-space: nowrap; flex-shrink: 0; }
  .yt-picker-btn > .ic:last-child { transition: transform .15s; }
  .yt-panel.open .yt-picker-btn > .ic:last-child { transform: rotate(180deg); }
  .yt-panel:not(.open) .yt-side, .yt-panel:not(.open) .yt-panel-help { display: none; }
  .yt-panel.open .yt-picker-btn { border-bottom: 1px solid var(--border); margin-bottom: 6px; }
  .rel-week, .rel-week.days-3, .rel-week.days-1 { grid-template-columns: 1fr; }
  .shop-form { grid-template-columns: 1fr auto; }
  .shop-form .shop-input { grid-column: span 2; }
  .kb-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kb-points { grid-template-columns: 1fr; gap: 2px; }
  .kb-points dd { margin-bottom: 10px; }
  .kb-form { grid-template-columns: 1fr 1fr; }
  .kb-form [name=description], .kb-form [name=note] { grid-column: span 2; }
  .kb-form .btn { grid-column: span 2; }
  .kb-crow { grid-template-columns: 80px 1fr 64px; }
  .rel-day { min-height: 0; display: grid; grid-template-columns: 64px 1fr; align-items: start; }
  .rel-day > :not(.rel-day-head) { grid-column: 2; }
  .yt-title { font-size: 13px; }
  .money-th { display: none; }
  .stat-value { font-size: 18px; }
  .stat.stat-main .stat-value { font-size: 22px; }
  .links { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .link { padding: 12px 4px 8px; font-size: 11px; }
  .search button { padding: 10px 16px; }
  .notes-layout, .news-layout { grid-template-columns: 1fr; }
  .notes-side { position: static; max-height: none; }
  .notes-layout.editing .notes-side { display: none; }
  .notes-layout:not(.editing) .note-editor { display: none; }
  .back-btn { display: inline-flex; }
  .feed-row .thumb { width: 56px; height: 40px; }
  .date-nav h1 { min-width: 0; font-size: 17px; }
  .feed-side { display: flex; overflow-x: auto; gap: 4px; }
  .feed-side li { flex-shrink: 0; }
}

/* ===== 一覧表 ===== */
.sheet-tabs { margin-bottom: 12px; flex-wrap: wrap; }
.sheet-add { margin-bottom: 12px; gap: 8px; }
.sheet-add .field { flex: 1; min-width: 0; }
.sheet-check { width: 20px; height: 20px; cursor: pointer; }
.sheet-url { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.sheet-url a { display: inline-flex; color: var(--accent, inherit); }
.sheet-totals { margin-top: 10px; text-align: right; }
.sheet-hide { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; }
.sheet-cols { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.sheet-col { display: grid; grid-template-columns: minmax(0, 1fr) 110px 36px 36px; gap: 6px; align-items: center; }
.sheet-col .sheet-opts { grid-column: 1 / -1; }

/* ===== クイック入力・表示設定 ===== */
.quick-targets { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.quick-target { display: inline-flex; align-items: center; gap: 4px; }
.quick-mic { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; }
.quick-mic.on { background: var(--danger, #d33); color: #fff; border-color: transparent; animation: quick-pulse 1.2s ease-in-out infinite; }
@keyframes quick-pulse { 50% { opacity: .7; } }
.quick-fields { display: flex; flex-direction: column; gap: 10px; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.feat-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border, #ccc); border-radius: 8px; cursor: pointer; opacity: .55; }
.feat-item.on { opacity: 1; }
.feat-item.fixed { cursor: default; }
.view[data-view="sheets"] .card-head { flex-wrap: wrap; row-gap: 6px; }
.view[data-view="sheets"] .card-head h2 { white-space: nowrap; }
.apptest-row { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }

/* ライフログの処理済み */
.ll-done { opacity: .45; }
.ll-done:hover { opacity: 1; }
.ll-done.on { opacity: 1; color: var(--accent); }
.ll-post.done .ll-body, .ll-post.done .ll-body * { color: var(--muted); }
/* 取り消し線は文字より薄い色で（文字が読みにくくならないように） */
.ll-post.done .ll-body { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 45%, transparent); text-decoration-thickness: 1px; }
.ll-acts { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
/* スマホ：1段目に時刻とボタン、2段目に本文（本文を横幅いっぱいに） */
@media (max-width: 640px) {
  .ll-post { flex-wrap: wrap; row-gap: 2px; align-items: center; }
  .ll-post .ll-acts { flex-direction: row; margin-left: auto; }
  .ll-post .ll-main { order: 3; flex-basis: 100%; }
  .ll-post .ll-acts .icon-btn { width: 32px; height: 28px; }
}

/* ===== 音楽 ===== */
.mu-cands { margin: 8px 0; flex-wrap: wrap; }
.mu-cand small { opacity: .75; }
.mu-search { gap: 8px; margin-top: 8px; }
.mu-search .field { flex: 1; min-width: 0; }
.mu-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.mu-era { font-size: .95rem; margin: 16px 0 6px; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.mu-artist { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.mu-artist:last-child { border-bottom: 0; }
.mu-artist-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mu-memo { margin: 4px 0 0; white-space: pre-wrap; }
.mu-tracks, .mu-results { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mu-tracks li, .mu-results li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mu-tracks img, .mu-results img, .mu-noart { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.mu-noart { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--muted); }
.mu-title { flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: inherit; padding: 0; cursor: pointer; display: flex; flex-direction: column; font: inherit; }
.mu-title span, .mu-r-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mu-results label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; cursor: pointer; }
.mu-results li.done { opacity: .55; }
.mu-r-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mu-results { max-height: 55vh; overflow-y: auto; }
.mu-play { flex-shrink: 0; font-size: 12px; }
.mu-by { margin-top: 6px; }
.mu-work { display: contents; }
.mu-work.open { display: block; width: 100%; }
.mu-work-songs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px 12px; padding-left: 10px; border-left: 2px solid var(--accent); }
.mu-assist .tabs { flex-wrap: wrap; }

/* ===== 設定モーダル ===== */
.set-body { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.set-section h4 { margin: 0 0 6px; font-size: .95rem; }
.set-section h4 small { font-weight: 400; margin-left: 4px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.set-label { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 2px; }
.set-control { display: flex; justify-content: flex-end; }
.set-choice { flex-wrap: wrap; }
/* 音楽：モーダルは広め・候補の枠は高さ固定 */
dialog.xwide { width: min(960px, calc(100% - 24px)); }
.mu-assist { display: flex; flex-direction: column; height: min(720px, calc(100dvh - 72px)); }
.mu-box { flex: 1; min-height: 120px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin: 8px 0; display: flex; flex-direction: column; gap: 10px; }
.mu-box .mu-cands { margin: 0; align-content: flex-start; }
.mu-box .mu-cands:empty { display: none; }
.mu-by.off { visibility: hidden; }
.mu-assist .help { min-height: 2.6em; }
.mu-pick .mu-results { height: min(52vh, 480px); max-height: none; }
.mu-link { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mu-link:hover { color: var(--accent); }
.mu-song { display: flex; align-items: center; gap: 8px; width: 100%; }
.mu-song img, .mu-song .mu-noart { width: 28px; height: 28px; border-radius: 4px; flex-shrink: 0; object-fit: cover; }
.mu-song span:last-child { overflow: hidden; text-overflow: ellipsis; }
.mu-acts { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; }
/* ニュース：サムネイル・概要・文字つきボタン */
.news-row { align-items: flex-start; }
.news-thumb { flex: none; width: 120px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--surface-2); }
.news-thumb img:not(.fav) { width: 100%; height: 100%; object-fit: cover; }
.news-thumb .fav { width: 28px; height: 28px; }
.news-summary { margin: 2px 0 2px; font-size: 13px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.news-row .actions { flex-direction: column; align-items: stretch; gap: 4px; }
.news-act { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; justify-content: flex-start; }
@media (max-width: 640px) {
  .news-thumb { width: 84px; }
  .news-row { flex-wrap: wrap; }
  .news-row .main { flex: 1; min-width: 0; }
  .news-row .actions { flex-direction: row; width: 100%; justify-content: flex-end; }
}
.feat-grip { cursor: grab; color: var(--muted); display: inline-flex; margin-right: -2px; touch-action: none; }
.feat-item { user-select: none; -webkit-user-select: none; }
/* モーダルの削除の確認（上の帯が確認に変わる） */
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.dlg-confirm-msg { flex: 1 1 auto; min-width: 0; font-weight: 700; color: var(--danger); overflow-wrap: anywhere; }
/* ノートは横幅いっぱい（表が多いので 860px の上限を外す） */
.note-editor .note-body, .note-editor .md { max-width: none; }
/* 一覧表：列が多いときは表ごと横スクロール。文字は折り返して全部見せる */
.sheet-scroll { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.sheet-scroll .dl-c { white-space: normal; overflow-wrap: anywhere; }
.sheet-scroll .ed-cell { white-space: normal; text-overflow: clip; }
.sheet-col { grid-template-columns: minmax(0, 1fr) 110px 36px 36px 36px; }
.sheet-eye { opacity: .5; }
.sheet-eye.on { opacity: 1; }
/* 一覧表：折り返さない列・絞り込み */
.sheet-scroll .dl-c.nw, .sheet-scroll .dl-c.nw .ed-cell { white-space: nowrap; }
.sheet-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; }
.sheet-filters select.on { border-color: var(--accent); color: var(--accent); }
.sheet-filters .sheet-q { width: 180px; flex: 0 1 180px; }
/* 音楽：アーティストごとの折りたたみ */
.mu-listbar { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.mu-ghead { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px dashed var(--border); cursor: pointer; flex-wrap: wrap; }
.mu-ghead:hover { background: var(--surface-2); }
.mu-ghead .spacer { flex: 1; }
.mu-chev { display: inline-flex; transform: rotate(-90deg); transition: transform .15s; color: var(--muted); }
.mu-ghead.open .mu-chev { transform: none; }
.mu-gera { white-space: nowrap; color: var(--muted); font-size: 13px; min-width: 6.5em; }
.mu-gname { white-space: nowrap; }
.mu-group { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.mu-group > .mu-ghead { border-bottom: 0; }
.mu-group .dl { margin-left: 28px; }
.mu-group .mu-memo { margin: 0 0 4px 34px; }
/* 一覧表：スマホのカード表示 */
.sheet-cards { display: flex; flex-direction: column; gap: 8px; }
.sheet-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; background: var(--surface); }
.sheet-card:active { background: var(--surface-2); }
.sheet-card-head { display: flex; align-items: center; gap: 8px; }
.sheet-card-head b { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sheet-card-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.sheet-card-chips .chip { font-size: 12px; padding: 2px 8px; }
.sheet-card-row { display: grid; grid-template-columns: 5.5em 1fr; gap: 8px; font-size: 13px; margin-top: 4px; }
.sheet-card-row .k { color: var(--muted); }
.sheet-card-row .v { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .sheet-filters select, .sheet-filters .sheet-q { flex: 1 1 45%; width: auto; }
}
