:root {
  --bg: #F6F5FA;
  --surface: #FFFFFF;
  --ink: #1C1A33;
  --ink-2: #5B5870;
  --ink-3: #6F6C84;
  --muted: #8A879E;
  --line: #E6E4F0;
  --line-2: #ECEAF3;
  --line-3: #F0EEF6;
  --field: #D9D6E5;
  --k: #534AB7;
  --k-bg: #ECEAFB;
  --m: #B8322C;
  --m-bg: #FBE8E6;
  --sun: #C0392B;
  --sat: #2B5BA8;
  --today: #FFF5DA;
  --danger: #A72D27;
  --danger-line: #E3B4B0;
  --scrim: rgba(20, 18, 40, 0.38);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Zen Kaku Gothic New', -apple-system, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 共通 ---------- */
.screen-wrap { position: fixed; inset: 0; display: flex; justify-content: center; }
.app {
  width: 100%; max-width: 560px; height: 100%; height: 100dvh;
  display: flex; flex-direction: column; background: var(--bg); position: relative;
}
.bar {
  height: 56px; flex: none; display: flex; align-items: center; gap: 4px;
  padding: 0 8px; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.ib { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; display: grid; place-items: center; flex: none; }
.ib:active { background: var(--line-2); }
.bar h1 { margin: 0; font-size: 18px; font-weight: 700; }
.bar .title { flex: 1; padding-left: 4px; }
.monthnav { flex: 1; display: flex; align-items: center; justify-content: center; gap: 2px; }
.monthnav h1 { min-width: 120px; text-align: center; }
.nav-sm { width: 40px; height: 44px; border: 0; background: transparent; display: grid; place-items: center; }
.pillbtn { height: 34px; padding: 0 12px; border: 1px solid var(--field); border-radius: 17px; background: var(--surface); font-size: 13px; font-weight: 500; }
.view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border-radius: 16px; }
.note { margin: 0; font-size: 12px; line-height: 1.7; color: var(--ink-3); }

/* ---------- カレンダー ---------- */
.calhead {
  flex: none; display: grid; grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr);
  background: var(--surface); border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700;
}
.calhead > div { padding: 8px 6px; display: flex; align-items: center; gap: 6px; border-left: 1px solid var(--line-2); }
.calhead > div:first-child { border-left: 0; }
.dot { width: 8px; height: 8px; border-radius: 4px; flex: none; }
.calhead .k { color: var(--k); } .calhead .k .dot { background: var(--k); }
.calhead .m { color: var(--m); } .calhead .m .dot { background: var(--m); }
.calview { background: var(--surface); padding-bottom: env(safe-area-inset-bottom); }
.row { display: grid; grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr); min-height: 50px; border-bottom: 1px solid var(--line-2); background: var(--surface); }
.row.today { background: var(--today); }
.datecell { padding: 8px 0 0 12px; display: flex; flex-direction: column; gap: 1px; }
.datecell .d { font-size: 17px; font-weight: 700; line-height: 1.1; }
.datecell .w { font-size: 11px; }
.datecell .hn { font-size: 9px; line-height: 1.2; color: var(--sun); padding-right: 2px; word-break: keep-all; }
.c-sun { color: var(--sun); } .c-sat { color: var(--sat); }
.cell { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 4px; border-left: 1px solid var(--line-2); min-width: 0; }
.ev {
  display: block; width: 100%; text-align: left; border: 0; border-radius: 6px; padding: 4px 7px;
  font-size: 12px; font-weight: 500; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ev.k { background: var(--k-bg); color: var(--k); }
.ev.m { background: var(--m-bg); color: var(--m); }
.ev.cont { opacity: 0.55; }
.ev.more { background: transparent; color: var(--ink-3); font-size: 11px; padding: 2px 7px; }
.addarea { flex: 1; min-height: 20px; border: 0; background: transparent; }

/* Masumi欄のタップエフェクト */
.fxwrap { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.fxflash { position: absolute; inset: 0; background: var(--m-bg); animation: fxFlash .65s ease-out forwards; }
.fxh { position: absolute; left: 50%; bottom: 6px; line-height: 0; opacity: 0; animation: fxUp .65s ease-out forwards; }
.fx1 { margin-left: -8px; } .fx2 { margin-left: -30px; animation-delay: .05s; } .fx3 { margin-left: 14px; animation-delay: .1s; }
.fx4 { margin-left: -20px; animation-delay: .15s; } .fx5 { margin-left: 4px; animation-delay: .08s; }
@keyframes fxUp { 0% { transform: translateY(0) scale(.4); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateY(-38px) scale(1.1); opacity: 0; } }
@keyframes fxFlash { 0% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fxh, .fxflash { animation-duration: .01s; } }

/* ---------- サマリ・アナリシス ---------- */
.seg2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; background: #E9E7F2; border-radius: 12px; }
.seg2 button { height: 36px; border: 0; border-radius: 9px; font-size: 14px; background: transparent; font-weight: 500; }
.seg2 button[aria-pressed="true"] { background: var(--surface); font-weight: 700; box-shadow: 0 1px 3px rgba(20, 18, 40, .08); }
.periodnav { display: flex; align-items: center; justify-content: space-between; }
.periodnav .label { font-size: 18px; font-weight: 700; }
.who { display: flex; gap: 8px; }
.who button { flex: 1; height: 38px; border-radius: 19px; font-size: 13px; border: 1px solid var(--field); background: var(--surface); font-weight: 500; }
.who button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 700; }
.total { padding: 16px 18px; display: flex; align-items: baseline; justify-content: space-between; }
.total .lb { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.total .n { font-size: 34px; font-weight: 700; }
.total .u { font-size: 14px; margin-left: 4px; color: var(--ink-2); }
.catlist { padding: 4px 18px; }
.catrow { display: flex; align-items: center; gap: 10px; min-height: 52px; border-bottom: 1px solid var(--line-3); }
.catrow:last-child { border-bottom: 0; }
.catrow .sw { width: 10px; height: 10px; border-radius: 5px; flex: none; }
.catrow .nm { flex: 1; font-size: 15px; font-weight: 500; }
.catrow .sub { font-size: 12px; color: var(--ink-3); }
.catrow .ct { min-width: 44px; text-align: right; font-size: 20px; font-weight: 700; }
.catrow.zero .nm, .catrow.zero .ct { color: #A3A0B5; }

.chartcard { padding: 16px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.chartcard h2 { margin: 0; font-size: 14px; font-weight: 700; padding-left: 4px; }
.chart { position: relative; height: 222px; padding-left: 22px; }
.tick { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--line); }
.tick span { position: absolute; left: 0; top: -8px; font-size: 10px; color: var(--muted); }
.cols { position: absolute; left: 22px; right: 0; top: 0; bottom: 0; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px; }
.col { border: 0; padding: 0; border-radius: 6px; background: transparent; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; }
.col[aria-pressed="true"] { background: var(--k-bg); }
.col .tt { font-size: 10px; font-weight: 700; text-align: center; color: #3D3A55; min-height: 14px; }
.col .stack { display: flex; flex-direction: column-reverse; margin: 0 3px; }
.col .sg { display: block; border-top: 1px solid #fff; }
.col .ml { font-size: 11px; text-align: center; height: 22px; line-height: 22px; color: var(--ink-2); }
.col[aria-pressed="true"] .ml { font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 4px 4px 0; }
.legend span { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #3D3A55; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.detail { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.detail .hd { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 700; }
.detail .hd span:last-child { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.drow { display: flex; align-items: center; gap: 8px; min-height: 36px; border-top: 1px solid var(--line-3); font-size: 13px; }
.drow .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drow .r { font-size: 11px; color: var(--ink-3); }
.drow .p { font-size: 11px; font-weight: 700; }
.empty { font-size: 13px; color: var(--muted); padding: 6px 0; }

/* ---------- 行きたいリスト ---------- */
.addrow { display: flex; gap: 8px; }
.text {
  flex: 1; min-width: 0; height: 46px; border: 1px solid var(--field); border-radius: 10px;
  padding: 0 12px; font-size: 16px; background: var(--surface); outline: none;
}
.text:focus { border-color: var(--k); }
.primary { height: 46px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--k); color: #fff; font-size: 14px; font-weight: 700; }
.primary:active { background: #3F3790; }
.wishlist { padding: 4px 6px 4px 14px; }
.wrow { display: flex; align-items: center; gap: 4px; min-height: 52px; border-bottom: 1px solid var(--line-3); }
.wrow:last-child { border-bottom: 0; }
.wrow input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--k); }
.wrow label { flex: 1; min-width: 0; padding: 14px 8px; font-size: 15px; word-break: break-word; }
.wrow.done label { text-decoration: line-through; color: var(--muted); }
.wrow .x { width: 40px; height: 40px; flex: none; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }

/* ---------- アカウント ---------- */
.prof { padding: 22px 18px; display: flex; align-items: center; gap: 14px; }
.avatar { width: 56px; height: 56px; border-radius: 28px; display: grid; place-items: center; font-size: 22px; font-weight: 700; color: #fff; flex: none; }
.prof .nm { font-size: 18px; font-weight: 700; }
.prof .sub { font-size: 13px; color: var(--ink-2); word-break: break-all; }
.kv { padding: 4px 18px; }
.kv > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line-3); font-size: 14px; }
.kv > div:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--ink-2); flex: none; }
.kv span:last-child { text-align: right; word-break: break-all; }
.danger { height: 52px; border-radius: 14px; border: 1px solid var(--danger-line); background: var(--surface); color: var(--danger); font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; }
.linkbtn { border: 0; background: transparent; color: var(--k); font-size: 13px; text-decoration: underline; padding: 10px; }

/* ---------- メニュー ---------- */
.drawer { position: fixed; inset: 0; z-index: 30; display: flex; }
.drawer nav {
  width: 280px; max-width: 80vw; height: 100%; background: var(--surface);
  padding: calc(18px + env(safe-area-inset-top)) 12px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 4px; box-shadow: 4px 0 24px rgba(20, 18, 40, .16);
  animation: slideIn .18s ease-out;
}
.drawer .brand { font-size: 22px; font-weight: 700; color: var(--k); padding: 6px 12px 18px; }
.drawer .item { height: 50px; border: 0; border-radius: 12px; display: flex; align-items: center; gap: 14px; padding: 0 14px; font-size: 15px; text-align: left; background: transparent; font-weight: 500; }
.drawer .item[aria-current="page"] { background: var(--k-bg); color: var(--k); font-weight: 700; }
.drawer .foot { margin-top: auto; padding: 12px 14px; font-size: 12px; color: var(--ink-3); }
.drawer .scrim { flex: 1; border: 0; background: var(--scrim); }
@keyframes slideIn { from { transform: translateX(-24px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- 登録シート ---------- */
.sheetwrap { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; background: var(--scrim); }
.sheetwrap .scrim { flex: 1; min-height: 40px; width: 100%; border: 0; background: transparent; }
.sheet {
  width: 100%; max-width: 560px; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px; max-height: 92dvh; overflow-y: auto;
  animation: sheetUp .2s ease-out;
}
@keyframes sheetUp { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.grip { width: 40px; height: 4px; border-radius: 2px; background: var(--field); align-self: center; flex: none; }
.sheet .hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet .hd h2 { margin: 0; font-size: 17px; font-weight: 700; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 12px; flex: none; }
.badge.k { background: var(--k-bg); color: var(--k); } .badge.m { background: var(--m-bg); color: var(--m); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > .lb { font-size: 13px; font-weight: 700; }
.cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cat { height: 54px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; border: 1.5px solid #E3E1EC; background: var(--surface); font-weight: 500; padding: 0 4px; }
.cat i { width: 10px; height: 10px; border-radius: 5px; display: block; }
.cat[aria-pressed="true"] { font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 36px; padding: 0 14px; border-radius: 18px; font-size: 13px; border: 1px solid var(--field); background: var(--surface); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.smallrow { display: flex; gap: 6px; }
.smallrow .text { height: 40px; }
.ghost { height: 40px; padding: 0 14px; border: 1px solid var(--field); border-radius: 10px; background: var(--surface); font-size: 13px; }
.stepper { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stepper button { width: 44px; height: 40px; border: 1px solid var(--field); border-radius: 10px; background: var(--surface); font-size: 18px; }
.stepper .v { min-width: 56px; text-align: center; font-size: 15px; font-weight: 700; }
.stepper .rg { font-size: 12px; color: var(--ink-2); }
.err { font-size: 13px; color: var(--danger); margin: 0; }
.actions { display: flex; gap: 8px; }
.actions button { height: 50px; border-radius: 14px; font-size: 15px; }
.actions .cancel { flex: 1; border: 1px solid var(--field); background: var(--surface); }
.actions .save { flex: 1; border: 0; background: var(--k); color: #fff; font-weight: 700; }
.actions .save:disabled { opacity: .6; }
.actions .del { padding: 0 16px; border: 1px solid var(--danger-line); background: var(--surface); color: var(--danger); font-weight: 700; font-size: 14px; }
.daylist { display: flex; flex-direction: column; gap: 6px; }
.daylist .ev { font-size: 14px; padding: 10px 12px; border-radius: 10px; }

/* ---------- ログイン ---------- */
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 32px; gap: 14px; max-width: 420px; width: 100%; margin: 0 auto; }
.logo { font-size: 30px; font-weight: 700; color: var(--k); text-align: center; }
.lead { margin: 0 0 18px; text-align: center; font-size: 14px; color: var(--ink-2); line-height: 1.7; }
.gbtn { height: 52px; border: 1px solid var(--field); border-radius: 14px; background: var(--surface); font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; }
.gbtn:disabled { opacity: .6; }
.big { height: 64px; border-radius: 16px; font-size: 18px; font-weight: 700; border: 2px solid transparent; }
.big.k { background: var(--k-bg); color: var(--k); border-color: var(--k); }
.big.m { background: var(--m-bg); color: var(--m); border-color: var(--m); }
.big:disabled { opacity: .45; }
.boot { flex: 1; display: grid; place-items: center; color: var(--ink-3); font-size: 14px; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 14px; padding: 10px 18px; border-radius: 22px; z-index: 50;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(20, 18, 40, .25);
}
