/* ============================================================
   GlassNote v2 — リアル液体ガラス UI
   屈折(feDisplacementMap) + 立体ベベル + 多層シャドウ + 反射
   ============================================================ */

:root {
  --accent: #6C63FF;
  --accent-rgb: 108, 99, 255;
  --accent-light: rgba(var(--accent-rgb), 0.16);

  /* ガラス */
  --glass-frost: 6px;          /* backdrop ぼかし */
  --glass-opacity: 0.14;       /* ガラスの濃さ */
  --glass-tint-rgb: 255, 255, 255;
  --refract: url(#liquid-glass);
  --refract-soft: url(#liquid-glass-soft);

  /* 背景 */
  --bg-brightness: 0.55;
  --bg-blur: 0px;
  --bg-image: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);

  /* テキスト */
  --text-primary: rgba(255, 255, 255, 0.96);
  --text-secondary: rgba(255, 255, 255, 0.64);
  --text-muted: rgba(255, 255, 255, 0.40);

  /* ガラスの光学パラメータ（テーマで変わる） */
  --edge-hi: rgba(255, 255, 255, 0.9);   /* 縁のハイライト */
  --edge-lo: rgba(255, 255, 255, 0.04);  /* 縁の影側 */
  --sheen: rgba(255, 255, 255, 0.5);      /* 表面の映り込み */
  --depth: rgba(8, 10, 22, 0.55);          /* 落ち影の色 */

  --radius-sm: 14px;
  --radius-md: 22px;
  --radius-lg: 30px;
  --radius-xl: 38px;

  --font-size-base: 15px;
  --font-family: 'Noto Sans JP', 'Inter', 'Hiragino Kaku Gothic ProN', system-ui, sans-serif;

  --c-high: #FF5A5F;
  --c-mid: #F5A623;
  --c-low: rgba(255,255,255,0.35);
  --c-ok: #18C29C;

  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --header-h: 66px;
}

html[data-fontsize="small"]  { --font-size-base: 13.5px; }
html[data-fontsize="large"]  { --font-size-base: 17px; }

html[data-theme="light"] {
  --glass-opacity: 0.5;
  --text-primary: rgba(18, 20, 32, 0.92);
  --text-secondary: rgba(18, 20, 32, 0.6);
  --text-muted: rgba(18, 20, 32, 0.4);
  --c-low: rgba(18,20,32,0.4);
  --edge-hi: rgba(255, 255, 255, 0.95);
  --edge-lo: rgba(40, 50, 90, 0.10);
  --sheen: rgba(255, 255, 255, 0.65);
  --depth: rgba(60, 70, 110, 0.28);
}

/* ---------- リセット ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { font-size: var(--font-size-base); }
body {
  font-family: var(--font-family);
  color: var(--text-primary);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 1.35em; height: 1.35em; flex: none; }
::placeholder { color: var(--text-muted); }
.svg-filters { position: absolute; width: 0; height: 0; pointer-events: none; }

/* ---------- 背景 ---------- */
.bg-layer {
  position: fixed; inset: -30px; z-index: -2;
  background-image: var(--bg-image);
  background-size: cover; background-position: center;
  filter: brightness(var(--bg-brightness)) blur(var(--bg-blur));
  transition: filter .3s ease;
}
html[data-theme="light"] .bg-layer { filter: brightness(calc(var(--bg-brightness) + .35)) blur(var(--bg-blur)); }
/* ほんのり粒状感で“空気”を出す */
.bg-grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 3px 3px;
}

/* ============================================================
   ガラス本体（リアルガラスの核）
   ============================================================ */
.glass, .glass-strong, .glass-card {
  position: relative;
  isolation: isolate;
  background:
    linear-gradient(135deg,
      rgba(var(--glass-tint-rgb), calc(var(--glass-opacity) + 0.10)) 0%,
      rgba(var(--glass-tint-rgb), var(--glass-opacity)) 38%,
      rgba(var(--glass-tint-rgb), calc(var(--glass-opacity) - 0.04)) 62%,
      rgba(var(--glass-tint-rgb), calc(var(--glass-opacity) + 0.06)) 100%);
  /* ★ 背景をガラスに合わせて屈折・変形 */
  backdrop-filter: blur(var(--glass-frost)) saturate(185%) contrast(1.05) brightness(1.04) var(--refract);
  -webkit-backdrop-filter: blur(var(--glass-frost)) saturate(185%) contrast(1.05) brightness(1.04);
  border-radius: var(--radius-md);
  /* 多層シャドウで“浮いている厚いガラス”を表現 */
  box-shadow:
    0 1px 1px rgba(0,0,0,.06),
    0 4px 8px var(--depth),
    0 12px 28px color-mix(in srgb, var(--depth) 70%, transparent),
    0 28px 60px color-mix(in srgb, var(--depth) 45%, transparent),
    inset 0 1px 1px var(--edge-hi),
    inset 0 -10px 24px -16px rgba(255,255,255,.55),
    inset 0 0 0 1px rgba(255,255,255,.06);
}
.glass-card { backdrop-filter: blur(var(--glass-frost)) saturate(185%) contrast(1.05) brightness(1.04) var(--refract-soft); }

/* 縁のベベル（光を受ける側だけ明るいグラデ枠線） */
.glass::after, .glass-strong::after, .glass-card::after {
  content: ''; position: absolute; inset: 0; z-index: 2;
  border-radius: inherit; padding: 1.4px; pointer-events: none;
  background: linear-gradient(135deg,
    var(--edge-hi) 0%,
    rgba(255,255,255,.25) 22%,
    var(--edge-lo) 48%,
    rgba(255,255,255,.18) 78%,
    var(--edge-hi) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
/* 表面のスペキュラ反射（斜め上からの映り込み） */
.glass::before, .glass-strong::before, .glass-card::before {
  content: ''; position: absolute; z-index: 1; pointer-events: none;
  inset: 0; border-radius: inherit; overflow: hidden;
  background:
    radial-gradient(120% 80% at 18% -10%, var(--sheen) 0%, rgba(255,255,255,0) 42%),
    linear-gradient(180deg, rgba(255,255,255,.10) 0%, rgba(255,255,255,0) 18%);
  opacity: .85; mix-blend-mode: screen;
}
html[data-theme="light"] .glass::before,
html[data-theme="light"] .glass-strong::before,
html[data-theme="light"] .glass-card::before { mix-blend-mode: normal; opacity: .6; }

/* 強ガラス（モーダル・ドロワー）はより厚く */
.glass-strong {
  backdrop-filter: blur(calc(var(--glass-frost) + 8px)) saturate(190%) contrast(1.06) brightness(1.05) var(--refract);
  -webkit-backdrop-filter: blur(calc(var(--glass-frost) + 8px)) saturate(190%) contrast(1.06) brightness(1.05);
  box-shadow:
    0 2px 4px rgba(0,0,0,.10),
    0 16px 40px var(--depth),
    0 40px 90px color-mix(in srgb, var(--depth) 60%, transparent),
    inset 0 1px 1px var(--edge-hi),
    inset 0 -14px 30px -18px rgba(255,255,255,.6),
    inset 0 0 0 1px rgba(255,255,255,.08);
}

/* カードのホバー：少し持ち上がり、屈折が強まったように見せる */
.glass-card.hoverable {
  transition: transform .28s var(--spring), box-shadow .28s ease, background .28s ease;
}
.glass-card.hoverable:hover {
  transform: translateY(-3px);
  box-shadow:
    0 2px 3px rgba(0,0,0,.08),
    0 8px 16px var(--depth),
    0 18px 40px color-mix(in srgb, var(--depth) 75%, transparent),
    0 36px 80px color-mix(in srgb, var(--depth) 50%, transparent),
    0 0 0 1px rgba(var(--accent-rgb), .25),
    inset 0 1px 1px var(--edge-hi),
    inset 0 -10px 24px -16px rgba(255,255,255,.6);
}

/* ---------- レイアウト ---------- */
.app { display: flex; flex-direction: column; min-height: 100dvh; }

.header {
  position: sticky; top: 12px; z-index: 50;
  margin: 12px 16px 0;
  height: var(--header-h);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px 0 18px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.18rem; position: relative; z-index: 3; }
.logo-mark { color: var(--accent); display: grid; place-items: center; transition: color .25s ease; filter: drop-shadow(0 2px 6px rgba(var(--accent-rgb),.5)); }
.logo-mark svg { width: 1.7em; height: 1.7em; }
.logo-text em { font-style: normal; color: var(--accent); }

.search-box {
  flex: 1; max-width: 540px; margin-inline: auto; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  background: rgba(var(--glass-tint-rgb), 0.10);
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.4), inset 0 -2px 6px rgba(0,0,0,.12);
  border-radius: 999px; padding: 9px 16px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
html[data-theme="light"] .search-box { background: rgba(255,255,255,.5); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light), inset 0 1px 1px rgba(255,255,255,.4); }
.search-ic { color: var(--text-muted); }
.search-box input { flex: 1; background: none; border: none; outline: none; min-width: 0; }
.search-kbd { font-size: .72rem; color: var(--text-muted); border: 1px solid rgba(255,255,255,.25); border-radius: 6px; padding: 1px 7px; }

.body-row { display: flex; flex: 1; gap: 16px; padding: 16px; align-items: flex-start; }

.sidebar {
  width: 224px; flex: none;
  border-radius: var(--radius-lg);
  padding: 12px;
  position: sticky; top: calc(var(--header-h) + 36px);
  display: flex; flex-direction: column; gap: 4px;
  max-height: calc(100dvh - var(--header-h) - 60px);
}
.nav-item {
  position: relative; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-weight: 600;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
  width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(var(--glass-tint-rgb), .12); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-light); color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .4), 0 4px 14px -6px rgba(var(--accent-rgb), .5);
}
.nav-badge {
  margin-left: auto; min-width: 22px; text-align: center;
  font-size: .74rem; font-weight: 800; background: var(--accent); color: #fff;
  border-radius: 999px; padding: 2px 7px; box-shadow: 0 3px 8px rgba(var(--accent-rgb),.5);
}
.sidebar-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.12); position: relative; z-index: 3; }

.main { flex: 1; min-width: 0; outline: none; padding-bottom: 40px; }

/* ---------- FAB ---------- */
.fab {
  display: none;
  position: fixed; right: 18px; bottom: 92px; z-index: 60;
  width: 60px; height: 60px; border-radius: 22px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 88%, white), var(--accent));
  color: #fff;
  box-shadow: 0 8px 24px rgba(var(--accent-rgb),.55), inset 0 1px 1px rgba(255,255,255,.6), inset 0 -6px 14px -8px rgba(0,0,0,.4);
  display: none; align-items: center; justify-content: center;
  transition: transform .25s var(--spring), box-shadow .25s ease;
}
.fab svg { width: 28px; height: 28px; }
.fab:active { transform: scale(.92); }

/* ---------- ボトムナビ ---------- */
.bottomnav {
  display: none;
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50;
  border-radius: var(--radius-lg); padding: 7px;
  padding-bottom: max(7px, env(safe-area-inset-bottom));
}
.bn-item {
  position: relative; z-index: 3;
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: .68rem; font-weight: 700;
  transition: color .2s ease, background .2s ease;
}
.bn-item svg { width: 1.5em; height: 1.5em; }
.bn-item.active { color: var(--accent); background: var(--accent-light); box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb),.3); }

/* ---------- ページ共通 ---------- */
.page { animation: pageIn .35s ease both; position: relative; z-index: 1; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 6px 2px 20px; }
.page-title { font-size: 1.6rem; font-weight: 900; margin: 0; letter-spacing: .01em; }
.page-sub { color: var(--text-secondary); font-size: .92rem; margin: 3px 2px 0; }
.spacer { flex: 1; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 800; letter-spacing: .06em; color: var(--text-secondary); text-transform: uppercase; margin: 0 2px 10px; }
.section-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* 内容は必ずガラス装飾の上に */
.widget > *, .todo-item > *, .note-card > *, .plan-item > *, .stat-chip > *,
.result-item > *, .cal > *, .day-panel > *, .modal > *, .drawer-body, .drawer-head { position: relative; z-index: 3; }

/* ---------- ボタン ---------- */
.btn {
  position: relative; z-index: 3;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; font-weight: 700; font-size: .92rem;
  transition: transform .2s var(--spring), box-shadow .2s ease, filter .2s ease, background .2s ease;
  border: 1px solid transparent; white-space: nowrap;
}
.btn.primary {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 86%, white), var(--accent));
  color: #fff;
  box-shadow: 0 6px 20px rgba(var(--accent-rgb), .5), inset 0 1px 1px rgba(255,255,255,.5), inset 0 -4px 10px -6px rgba(0,0,0,.4);
}
.btn.primary:hover { transform: translateY(-2px); filter: brightness(1.06); }
.btn.ghost {
  background: rgba(var(--glass-tint-rgb), .12);
  border-color: rgba(255,255,255,.22);
  color: var(--text-primary);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.35);
}
.btn.ghost:hover { background: rgba(var(--glass-tint-rgb), .2); }
.btn.danger { background: linear-gradient(135deg, #ff7a7e, var(--c-high)); color: #fff; box-shadow: 0 6px 18px rgba(255,90,95,.5), inset 0 1px 1px rgba(255,255,255,.5); }
.danger-text { color: var(--c-high); }
.btn:active { transform: scale(.97); }

.icon-btn {
  position: relative; z-index: 3;
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  color: var(--text-secondary);
  background: rgba(var(--glass-tint-rgb), .1);
  border: 1px solid rgba(255,255,255,.2);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.4);
  transition: all .2s ease;
}
.icon-btn:hover { color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light), inset 0 1px 1px rgba(255,255,255,.4); }

/* ---------- 入力 ---------- */
.glass-input, .field input, .field select, .field textarea {
  width: 100%;
  background: rgba(var(--glass-tint-rgb), 0.1);
  border: 1px solid rgba(255,255,255,.2);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.12), inset 0 1px 1px rgba(255,255,255,.3);
  border-radius: var(--radius-sm); color: var(--text-primary);
  padding: 12px 15px; transition: border-color .2s ease, box-shadow .2s ease; outline: none;
}
html[data-theme="light"] .glass-input,
html[data-theme="light"] .field input,
html[data-theme="light"] .field select,
html[data-theme="light"] .field textarea { background: rgba(255,255,255,.6); }
.glass-input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light), inset 0 1px 2px rgba(0,0,0,.08);
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: .8rem; font-weight: 700; color: var(--text-secondary); }
.field textarea { resize: vertical; min-height: 92px; line-height: 1.65; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field select option { color: #222; background: #fff; }
input[type="date"], input[type="time"] { color-scheme: dark; }
html[data-theme="light"] input[type="date"], html[data-theme="light"] input[type="time"] { color-scheme: light; }

/* ---------- タグ ---------- */
.tag {
  display: inline-flex; align-items: center;
  background: var(--accent-light); border: 1px solid rgba(var(--accent-rgb), .3);
  border-radius: 999px; padding: 2px 11px; font-size: .74rem; font-weight: 700; color: var(--accent);
}
.tag.clickable { cursor: pointer; transition: all .15s ease; }
.tag.clickable:hover, .tag.on { background: var(--accent); color: #fff; }

/* ---------- ダッシュボード ---------- */
.dash-hero { margin: 4px 2px 22px; }
.dash-greet { font-size: clamp(1.6rem, 3.6vw, 2.3rem); font-weight: 900; margin: 0; line-height: 1.25; }
.dash-greet em { font-style: normal; color: var(--accent); }
.dash-date { color: var(--text-secondary); margin: 6px 0 0; font-weight: 500; }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.stat-chip { display: flex; align-items: center; gap: 10px; padding: 13px 20px; border-radius: var(--radius-md); font-size: .88rem; color: var(--text-secondary); font-weight: 600; }
.stat-chip b { font-size: 1.4rem; color: var(--text-primary); font-weight: 900; }
.stat-chip.warn b { color: var(--c-high); }

.dash-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.widget { padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.widget-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.widget-head h3 { font-size: 1rem; margin: 0; font-weight: 800; }
.widget-head .more { margin-left: auto; font-size: .78rem; color: var(--accent); font-weight: 700; }
.widget-head .more:hover { text-decoration: underline; }
.widget-ic { color: var(--accent); display: grid; place-items: center; font-size: 1.05rem; }

.empty { color: var(--text-muted); font-size: .88rem; padding: 20px 8px; text-align: center; line-height: 1.7; }
.empty .empty-ic { font-size: 1.7rem; display: block; margin-bottom: 6px; }

/* ---------- Todo ---------- */
.todo-add { display: flex; gap: 10px; margin-bottom: 16px; padding: 11px; border-radius: var(--radius-md); }
.todo-add input { flex: 1; background: none; border: none; outline: none; padding: 8px 12px; font-size: 1rem; box-shadow: none; }
.todo-add .btn { flex: none; }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.chip {
  padding: 8px 16px; border-radius: 999px; font-size: .82rem; font-weight: 700; color: var(--text-secondary);
  background: rgba(var(--glass-tint-rgb), .1); border: 1px solid rgba(255,255,255,.18);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.3); transition: all .18s ease;
}
.chip:hover { color: var(--text-primary); }
.chip.on { background: var(--accent); color: #fff; border-color: transparent; box-shadow: 0 4px 14px rgba(var(--accent-rgb), .45); }
.sort-select {
  margin-left: auto; background: rgba(var(--glass-tint-rgb), .1);
  border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 8px 14px;
  font-size: .82rem; font-weight: 600; color: var(--text-secondary); outline: none;
}
.sort-select option { color: #222; background: #fff; }

.todo-list { display: flex; flex-direction: column; gap: 10px; }
.todo-item { display: flex; align-items: flex-start; gap: 13px; padding: 15px 16px; animation: cardIn .3s ease both; }
.todo-item.done { opacity: .58; }
.todo-item.removing { animation: slideOut .25s ease forwards; }

.todo-check {
  position: relative; z-index: 3;
  flex: none; width: 26px; height: 26px; margin-top: 1px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.45);
  background: rgba(var(--glass-tint-rgb), .08);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.15);
  display: grid; place-items: center; transition: all .25s var(--spring); color: transparent;
}
html[data-theme="light"] .todo-check { border-color: rgba(20,20,30,.3); }
.todo-check svg { width: 15px; height: 15px; }
.todo-check:hover { border-color: var(--accent); transform: scale(1.12); }
.todo-item.done .todo-check { background: var(--accent); border-color: var(--accent); color: #fff; animation: pop .3s var(--spring); box-shadow: 0 4px 12px rgba(var(--accent-rgb),.5); }

.todo-body { flex: 1; min-width: 0; cursor: pointer; }
.todo-title { font-weight: 600; line-height: 1.45; word-break: break-word; }
.todo-item.done .todo-title { color: var(--text-muted); text-decoration: line-through; }
.todo-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: .76rem; color: var(--text-muted); }
.due { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.due.over { color: var(--c-high); } .due.today { color: var(--c-mid); }
.prio { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; }
.prio.high { background: var(--c-high); box-shadow: 0 0 8px rgba(255,90,95,.7); }
.prio.medium { background: var(--c-mid); box-shadow: 0 0 8px rgba(245,166,35,.5); }
.prio.low { background: var(--c-low); }

/* アクションは常時表示（スマホでも押せる） */
.todo-actions { display: flex; gap: 5px; flex: none; align-items: center; }
.mini-btn {
  position: relative; z-index: 3;
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--text-muted);
  background: rgba(var(--glass-tint-rgb), .08); transition: all .15s ease;
}
.mini-btn:hover { background: rgba(var(--glass-tint-rgb), .16); color: var(--text-primary); }
.mini-btn.del:hover { color: #fff; background: var(--c-high); box-shadow: 0 4px 12px rgba(255,90,95,.5); }
.mini-btn svg { width: 19px; height: 19px; }

.done-toggle { margin: 18px auto 0; display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: .84rem; font-weight: 700; }
.done-toggle:hover { color: var(--text-primary); }

/* ---------- プランナー ---------- */
.planner-grid { display: grid; grid-template-columns: minmax(310px, 420px) 1fr; gap: 16px; align-items: start; }
.cal { padding: 18px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-head h3 { margin: 0; font-size: 1.08rem; font-weight: 900; }
.cal-nav { display: flex; gap: 6px; }
.cal-table { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: .7rem; font-weight: 800; color: var(--text-muted); padding: 4px 0; }
.cal-dow.sun { color: var(--c-high); } .cal-dow.sat { color: #4a9eff; }
.cal-cell {
  position: relative; z-index: 3;
  aspect-ratio: 1; border-radius: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .88rem; font-weight: 700; color: var(--text-secondary); transition: all .15s ease;
}
.cal-cell:hover { background: rgba(var(--glass-tint-rgb), .12); }
.cal-cell.dim { opacity: .3; }
.cal-cell.today { color: var(--accent); box-shadow: inset 0 0 0 1.5px rgba(var(--accent-rgb), .55); }
.cal-cell.sel { background: var(--accent); color: #fff !important; box-shadow: 0 6px 16px rgba(var(--accent-rgb), .5); }
.cal-dots { display: flex; gap: 3px; height: 5px; }
.cal-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cal-cell.sel .cal-dots i { background: #fff; }
.cal-dots i.todo-dot { background: var(--c-mid); }

.day-panel { padding: 20px; }
.day-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.day-head h3 { margin: 0; font-size: 1.12rem; font-weight: 900; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.plan-item { display: flex; gap: 13px; padding: 14px 16px; border-left: 4px solid var(--plan-color, var(--accent)); animation: cardIn .3s ease both; align-items: center; }
.plan-time { flex: none; font-size: .8rem; font-weight: 700; color: var(--text-secondary); min-width: 84px; line-height: 1.5; cursor: pointer; }
.plan-time b { display: block; color: var(--text-primary); }
.plan-body { flex: 1; min-width: 0; cursor: pointer; }
.plan-title { font-weight: 700; }
.plan-note { font-size: .8rem; color: var(--text-secondary); margin-top: 3px; line-height: 1.55; }

/* ---------- メモ ---------- */
.notes-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.note-card { padding: 17px 18px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; min-height: 132px; animation: cardIn .3s ease both; }
.note-card.pinned { box-shadow:
    0 1px 1px rgba(0,0,0,.06), 0 8px 20px var(--depth), 0 22px 48px color-mix(in srgb, var(--depth) 45%, transparent),
    0 0 0 1.5px rgba(var(--accent-rgb), .5), inset 0 1px 1px var(--edge-hi); }
.note-tools { position: absolute; top: 11px; right: 11px; z-index: 4; display: flex; gap: 4px; }
.note-pin, .note-del {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: var(--text-muted);
  background: rgba(var(--glass-tint-rgb), .12); transition: all .2s var(--spring);
}
.note-pin:hover { background: rgba(var(--glass-tint-rgb), .2); color: var(--text-primary); }
.note-pin.on { color: var(--accent); }
.note-pin.on svg { transform: rotate(40deg); }
.note-del:hover { color: #fff; background: var(--c-high); }
.note-pin svg, .note-del svg { width: 17px; height: 17px; transition: transform .2s var(--spring); }
.note-title { font-weight: 800; padding-right: 76px; word-break: break-word; }
.note-preview { font-size: .82rem; color: var(--text-secondary); line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.note-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.note-date { font-size: .7rem; color: var(--text-muted); margin-left: auto; }

/* ---------- マークダウン ---------- */
.md { line-height: 1.8; font-size: .95rem; word-break: break-word; }
.md h1 { font-size: 1.4rem; margin: .6em 0 .4em; border-bottom: 1px solid rgba(255,255,255,.15); padding-bottom: .25em; }
.md h2 { font-size: 1.2rem; margin: .6em 0 .35em; }
.md h3 { font-size: 1.05rem; margin: .5em 0 .3em; }
.md p { margin: .5em 0; }
.md ul, .md ol { margin: .4em 0; padding-left: 1.5em; }
.md li { margin: .2em 0; }
.md li.task { list-style: none; margin-left: -1.3em; display: flex; gap: 8px; align-items: baseline; }
.md li.task input { accent-color: var(--accent); }
.md blockquote { margin: .6em 0; padding: .4em 1em; border-left: 3px solid var(--accent); background: rgba(var(--accent-rgb), .1); border-radius: 0 10px 10px 0; color: var(--text-secondary); }
.md code { background: rgba(var(--glass-tint-rgb), .14); border-radius: 6px; padding: .15em .45em; font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
.md pre { background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-sm); padding: 14px; overflow-x: auto; }
html[data-theme="light"] .md pre { background: rgba(20,20,40,.06); }
.md pre code { background: none; padding: 0; }
.md a { color: var(--accent); text-decoration: underline; }
.md hr { border: none; border-top: 1px solid rgba(255,255,255,.15); margin: 1em 0; }
.md del { color: var(--text-muted); }

/* ---------- 検索結果 ---------- */
.search-section { margin-bottom: 24px; }
.result-item { padding: 14px 16px; margin-bottom: 8px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; }
.result-item .result-main { flex: 1; min-width: 0; }
.result-item mark { background: rgba(var(--accent-rgb), .4); color: inherit; border-radius: 3px; padding: 0 2px; }
.result-kind { font-size: .68rem; font-weight: 800; letter-spacing: .08em; color: var(--accent); text-transform: uppercase; }
.result-title { font-weight: 700; margin: 3px 0 1px; }
.result-sub { font-size: .8rem; color: var(--text-secondary); }

/* ---------- ドロワー ---------- */
.drawer-overlay, .modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(8, 10, 20, .42);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .2s ease;
}
.drawer {
  position: fixed; top: 12px; right: 12px; bottom: 12px; z-index: 95;
  width: min(370px, calc(100vw - 24px));
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column; animation: drawerIn .4s var(--spring);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 12px; }
.drawer-head h2 { margin: 0; font-size: 1.18rem; font-weight: 900; }
.drawer-body { overflow-y: auto; padding: 4px 22px 24px; }

.setting-group { margin-bottom: 24px; }
.setting-group h3 { font-size: .8rem; font-weight: 800; color: var(--text-secondary); letter-spacing: .04em; margin: 0 0 12px; }
.setting-hint { font-size: .72rem; color: var(--text-muted); margin: 8px 2px 0; line-height: 1.5; }

.swatch-row { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35);
  box-shadow: inset 0 2px 4px rgba(255,255,255,.4), 0 3px 8px rgba(0,0,0,.25);
  transition: transform .2s var(--spring), box-shadow .2s ease; position: relative;
}
.swatch:hover { transform: scale(1.16); }
.swatch.on { box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .5), inset 0 2px 4px rgba(255,255,255,.4); transform: scale(1.1); }
.swatch.on::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .8rem; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.swatch.grad { width: 54px; border-radius: 15px; }

.color-pick-row { display: flex; align-items: center; justify-content: space-between; font-size: .85rem; font-weight: 600; color: var(--text-secondary); margin-top: 12px; }
input[type="color"] { width: 46px; height: 34px; border: none; border-radius: 11px; background: none; cursor: pointer; padding: 0; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(255,255,255,.4); border-radius: 9px; }

.seg { display: flex; gap: 6px; background: rgba(var(--glass-tint-rgb), .08); border-radius: 999px; padding: 4px; box-shadow: inset 0 1px 2px rgba(0,0,0,.12); }
.seg-btn { flex: 1; padding: 9px 6px; border-radius: 999px; font-size: .82rem; font-weight: 700; color: var(--text-secondary); transition: all .2s ease; }
.seg-btn.on { background: var(--accent); color: #fff; box-shadow: 0 3px 12px rgba(var(--accent-rgb), .45); }

.slider-row { display: flex; flex-direction: column; gap: 9px; margin-bottom: 16px; }
.slider-row > span { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 600; color: var(--text-secondary); }
.slider-row output { color: var(--accent); font-weight: 800; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 7px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), rgba(var(--glass-tint-rgb), .18) var(--fill, 50%));
  box-shadow: inset 0 1px 2px rgba(0,0,0,.2); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e8e8ef); border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.4), inset 0 1px 2px rgba(255,255,255,.9); transition: transform .15s var(--spring);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

.file-btn { display: block; text-align: center; padding: 12px; border-radius: var(--radius-sm); border: 1.5px dashed rgba(255,255,255,.3); font-size: .85rem; font-weight: 600; color: var(--text-secondary); cursor: pointer; transition: all .2s ease; }
.file-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.bg-option { margin-top: 12px; }

/* ---------- モーダル ---------- */
.modal-overlay { z-index: 100; display: grid; place-items: center; padding: 18px; overflow-y: auto; }
.modal { width: min(620px, 100%); border-radius: var(--radius-lg); padding: 26px; animation: modalIn .32s var(--spring); max-height: calc(100dvh - 36px); overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 1.18rem; font-weight: 900; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 22px; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
.mode-toggle { display: flex; gap: 6px; }
.mode-toggle .chip { padding: 7px 14px; }

/* ---------- トースト（Undo対応） ---------- */
.toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast {
  background: rgba(22, 26, 44, .82);
  backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px; padding: 11px 14px 11px 20px; font-size: .88rem; font-weight: 600; color: #fff;
  box-shadow: 0 12px 34px rgba(0,0,0,.45), inset 0 1px 1px rgba(255,255,255,.3);
  animation: toastIn .35s var(--spring); display: flex; align-items: center; gap: 12px;
}
.toast .t-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-ok); flex: none; }
.toast.has-act { pointer-events: auto; }
.toast-act { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); color: #fff; font-weight: 800; font-size: .82rem; padding: 6px 14px; border-radius: 999px; transition: background .15s ease; }
.toast-act:hover { background: rgba(255,255,255,.3); }
.toast.out { animation: toastOut .25s ease forwards; }

/* ---------- アニメーション ---------- */
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(40px); height: 0; padding-block: 0; margin-bottom: -10px; } }
@keyframes drawerIn { from { transform: translateX(60px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes modalIn { from { transform: scale(.95) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(10px); opacity: 0; } }

.todo-list > *:nth-child(1), .notes-grid > *:nth-child(1), .timeline > *:nth-child(1) { animation-delay: 0ms; }
.todo-list > *:nth-child(2), .notes-grid > *:nth-child(2), .timeline > *:nth-child(2) { animation-delay: 45ms; }
.todo-list > *:nth-child(3), .notes-grid > *:nth-child(3), .timeline > *:nth-child(3) { animation-delay: 90ms; }
.todo-list > *:nth-child(4), .notes-grid > *:nth-child(4), .timeline > *:nth-child(4) { animation-delay: 135ms; }
.todo-list > *:nth-child(5), .notes-grid > *:nth-child(5), .timeline > *:nth-child(5) { animation-delay: 180ms; }
.todo-list > *:nth-child(n+6), .notes-grid > *:nth-child(n+6), .timeline > *:nth-child(n+6) { animation-delay: 220ms; }

:focus-visible { outline: 3px solid var(--accent-light); outline-offset: 2px; border-radius: 6px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(var(--glass-tint-rgb), .22); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--glass-tint-rgb), .38); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 900px) {
  .sidebar { width: 70px; padding: 10px 8px; align-items: center; }
  .nav-label, .nav-badge { display: none; }
  .nav-item { justify-content: center; padding: 13px; }
  .planner-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .header { margin: 10px 10px 0; padding: 0 8px 0 14px; height: 58px; gap: 8px; border-radius: var(--radius-md); }
  .logo-text { display: none; }
  .search-kbd { display: none; }
  .body-row { padding: 12px 10px 0; }
  .sidebar { display: none; }
  .bottomnav { display: flex; }
  .fab { display: flex; }
  .main { padding-bottom: 150px; }
  .dash-grid { grid-template-columns: 1fr; }
  .notes-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .field-row { flex-direction: column; gap: 0; }
  .stat-chip { flex: 1; min-width: calc(50% - 6px); justify-content: center; padding: 12px 8px; }
  .page-title { font-size: 1.4rem; }
  /* タップ領域を拡大 */
  .mini-btn { width: 42px; height: 42px; }
  .todo-check { width: 28px; height: 28px; }
  .modal { padding: 20px; }
  .modal-foot .btn { flex: 1; }
  .modal-foot .left { flex: 1 0 100%; order: 3; }
  /* モーダルをボトムシート化 */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 90dvh; animation: sheetIn .4s var(--spring); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .drawer { top: auto; right: 8px; left: 8px; bottom: 8px; width: auto; max-height: 84dvh; border-radius: var(--radius-lg); animation: sheetIn .4s var(--spring); }
  .day-head .btn { width: 100%; }
}
@keyframes sheetIn { from { transform: translateY(80px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* backdrop-filter 非対応ブラウザのフォールバック */
@supports not (backdrop-filter: blur(1px)) {
  .glass, .glass-strong, .glass-card { background: rgba(30, 34, 54, .82); }
  html[data-theme="light"] .glass, html[data-theme="light"] .glass-strong, html[data-theme="light"] .glass-card { background: rgba(245, 246, 252, .9); }
}
