:root {
  --bg: #F3F4F1;
  --card: #FFFFFF;
  --ink: #1B1F27;
  --sub: #5B6170;
  --line: #E2E4DD;
  --field: #D5D8D0;
  --accent: #0F5E57;
  --accent-dark: #12312E;
  --p0: #2456B8; --p0-bg: #E6EDFA;
  --p1: #B4471A; --p1-bg: #FBEAE1;
  --danger: #B4342A;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  color: var(--ink);
  font-family: 'Zen Kaku Gothic New', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-family: Outfit, system-ui, sans-serif; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { height: 100%; }
.splash { height: 100%; display: grid; place-items: center; color: var(--sub); }

/* ===== レイアウト ===== */
.shell { height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(var(--safe-top) + 14px) 20px 10px;
}
.top h1 { margin: 0; font-size: 24px; letter-spacing: .02em; }
.main { flex: 1; overflow-y: auto; padding: 0 16px 20px; }
.tabs {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; border: 0; background: none; font-size: 10px; color: #6B7180;
}
.tab.on { color: var(--accent); font-weight: 700; }

/* ===== 部品 ===== */
.card { background: var(--card); border-radius: 18px; }
.pad { padding: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--sub); font-size: 13px; }
.h2 { margin: 20px 4px 10px; font-size: 16px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }

.btn {
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap;
}
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--field); font-weight: 500; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 12px; }
.btn.danger { background: none; color: var(--danger); border: 0; font-weight: 500; }
.btn:disabled { opacity: .5; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; border-radius: 22px; color: var(--ink);
}

.field {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--field); border-radius: 14px; background: var(--card); font-size: 16px;
}
.field:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.lbl, span.lbl { display: block; font-size: 13px; color: var(--sub); margin: 0 0 6px 4px; }

.chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.chip.p0 { color: var(--p0); background: var(--p0-bg); }
.chip.p1 { color: var(--p1); background: var(--p1-bg); }
.chip.soft { color: var(--accent); background: #E3F1EE; font-weight: 500; }
.chip.gray { color: #4A505C; background: #EEEFEA; font-weight: 500; }
.err { color: var(--danger); font-size: 13px; margin: 8px 4px 0; }

/* ===== ログイン・初期設定 ===== */
.center { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--safe-top) + 24px) 24px 32px; max-width: 440px; margin: 0 auto; gap: 16px; }
.brand { font-size: 32px; font-weight: 700; margin: 0; }
.switch { background: none; border: 0; color: var(--accent); min-height: 44px; font-size: 14px; }

/* ===== カレンダー ===== */
.cal-head { display: flex; justify-content: space-between; align-items: center; }
.cal-head .num { font-size: 20px; font-weight: 700; }
.week, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.week { font-size: 11px; color: var(--sub); margin: 8px 0 4px; }
.day {
  height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; border-radius: 12px; background: none; font-family: Outfit, sans-serif; font-size: 15px; font-weight: 500;
}
.day.sun { color: var(--danger); } .day.sat { color: #2B5BB5; }
.day.today { border: 1.5px solid var(--accent); font-weight: 700; }
.day.sel { background: var(--accent); color: #fff; font-weight: 700; border: 0; }
.dots { display: flex; gap: 2px; height: 6px; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 3px; background: transparent; }
.dot.p0 { background: var(--p0); } .dot.p1 { background: var(--p1); } .dot.both { background: #2E9C8C; }
.day.sel .dot.p0, .day.sel .dot.p1, .day.sel .dot.both { box-shadow: 0 0 0 1.5px #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--sub); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* 持ち主ごとの色 */
.own-p0 { --oc: var(--p0); --ob: var(--p0-bg); }
.own-p1 { --oc: var(--p1); --ob: var(--p1-bg); }
.own-both { --oc: var(--accent); --ob: #E3F1EE; }
.chip.both { color: var(--accent); background: #E3F1EE; }

.seg { display: inline-flex; background: #E6E8E2; border-radius: 12px; padding: 3px; }
.seg button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 9px; background: none; font-size: 13px; color: var(--sub); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 700; }

.pick { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1.5px solid var(--ob); background: var(--card); color: var(--oc); font-size: 13px; }
.pick.on { background: var(--oc); border-color: var(--oc); color: #fff; font-weight: 700; }
.shift { min-height: 52px; padding: 6px 14px; border-radius: 14px; border: 1px solid var(--field); background: #FAFAF7; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
.shift:active { background: #E3F1EE; }

/* 時間軸 */
.allday { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #ECEDE8; }
.tl-chip { min-height: 32px; padding: 0 10px; border: 0; border-radius: 10px; background: var(--ob); color: var(--oc); font-weight: 700; font-size: 13px; }
.tl-box { max-height: 440px; overflow-y: auto; }
.tl { position: relative; margin: 8px 0; }
.tl-hour { position: absolute; left: 0; right: 0; border-top: 1px solid #ECEDE8; }
.tl-hour span { position: absolute; top: -8px; left: 8px; font-size: 11px; color: var(--sub); background: var(--card); padding-right: 4px; }
.tl-ev {
  position: absolute; border: 0; border-radius: 10px; padding: 4px 8px; text-align: left; overflow: hidden;
  background: var(--ob); color: var(--oc); display: flex; flex-direction: column; justify-content: flex-start; gap: 1px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04);
}
.tl-ev-title { font-size: 13px; font-weight: 700; line-height: 1.3; }
.tl-ev-time { font-size: 11px; opacity: .9; }
.tl-now { position: absolute; left: 48px; right: 4px; border-top: 2px solid var(--danger); }
.tl-now::before { content: ''; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 4px; background: var(--danger); }

.event-btn { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 0; background: none; text-align: left; }
.event-time { min-width: 52px; padding: 6px 8px; border-radius: 10px; font-size: 13px; font-weight: 700; text-align: center; background: var(--ob, #EEEFEA); color: var(--oc, var(--sub)); white-space: nowrap; }
.event-title { font-size: 15px; font-weight: 700; }
.comments { border-top: 1px solid #ECEDE8; background: #FAFAF7; padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 10px; border-radius: 0 0 18px 18px; }
.comment { display: flex; gap: 8px; font-size: 14px; line-height: 1.5; }
.form-card { display: flex; flex-direction: column; gap: 10px; }

/* ===== タスク ===== */
.task { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 4px; }
.check { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; flex-shrink: 0; }
.box { width: 24px; height: 24px; border-radius: 8px; border: 2px solid #9CA1AC; background: #fff; display: grid; place-items: center; }
.box.on { background: var(--accent); border-color: var(--accent); }
.task.done .task-title { color: #7A8090; text-decoration: line-through; }
.task-title { font-size: 15px; font-weight: 500; }

/* ===== 生活費 ===== */
.money { background: var(--accent-dark); color: #fff; border-radius: 22px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.money .label { font-size: 13px; color: #BFD9D5; }
.money .big { font-size: 40px; font-weight: 700; line-height: 1; }
.money .big.minus { color: #FFB38A; }
.bar { height: 10px; border-radius: 5px; background: #2C514D; overflow: hidden; }
.bar > div { height: 100%; border-radius: 5px; background: #5FD0BE; }
.bar > div.low { background: #E8833A; }
.money .foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding-top: 10px; border-top: 1px solid #2C514D; }
.tx { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #ECEDE8; }
.tx:last-child { border-bottom: 0; }

/* ===== メッセージ ===== */
.msgs { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.msg { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.msg.mine { align-items: flex-end; }
.bubble { max-width: 78%; padding: 10px 14px; font-size: 15px; line-height: 1.55; border-radius: 18px 18px 18px 6px; background: var(--card); white-space: pre-wrap; word-break: break-word; }
.msg.mine .bubble { background: var(--accent); color: #fff; border-radius: 18px 18px 6px 18px; }
.msg-meta { font-size: 11px; color: var(--sub); padding: 0 6px; }
.composer { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--bg); }
.composer .field { border-radius: 22px; min-height: 44px; }
.send { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--accent); display: grid; place-items: center; flex-shrink: 0; }

/* ===== 設定シート ===== */
.sheet-bg { position: fixed; inset: 0; background: rgba(20, 24, 30, .35); display: flex; align-items: flex-end; justify-content: center; z-index: 100; }
.sheet {
  width: 100%; max-width: 560px; max-height: 88%; overflow-y: auto; background: var(--bg);
  border-radius: 24px 24px 0 0; padding: 20px 16px calc(var(--safe-bottom) + 24px);
  display: flex; flex-direction: column; gap: 14px;
}
.sheet h2 { margin: 0; font-size: 20px; }
.code { font-family: Outfit, monospace; font-size: 28px; letter-spacing: .15em; font-weight: 700; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; background: #EEEFEA; padding: 10px 12px; border-radius: 10px; }
.empty { padding: 24px; text-align: center; color: var(--sub); font-size: 14px; }

/* ===== 写真アイコン ===== */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #E6E8E2; font-weight: 700; color: #fff; box-sizing: border-box; }
.avatar.ini.p0 { background: var(--p0); }
.avatar.ini.p1 { background: var(--p1); }
.avatar.ini.pet { background: #8A6A3D; }
.avatar.ini.gray, .avatar.ini.both { background: #8A909C; }
.family { display: inline-flex; align-items: center; min-width: 0; overflow: hidden; }
.family .avatar { border: 2px solid var(--bg); margin-left: -8px; }
.family .avatar:first-child { margin-left: 0; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.msg.mine .msg-row { justify-content: flex-end; }
.msg-row .bubble { max-width: calc(78vw - 40px); }
.comment { align-items: flex-start; }
.photo-pick { position: relative; display: inline-block; cursor: pointer; }
.photo-badge { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 11px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; border: 2px solid var(--card); }
.photo-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; min-width: 64px; }

/* ===== 月カレンダー（タイトル表示） ===== */
.cal-card { padding: 12px 6px 14px; }
.cal-card .cal-head { padding: 0 6px; }
.week span.sun { color: var(--danger); } .week span.sat { color: #2B5BB5; }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid #ECEDE8; }
.mcell {
  min-height: 78px; min-width: 0; padding: 3px 2px 4px; border: 0; border-bottom: 1px solid #ECEDE8; border-radius: 0;
  background: none; display: flex; flex-direction: column; align-items: stretch; gap: 2px; text-align: left; overflow: hidden;
}
.mcell.blank { background: #FAFAF7; }
.dnum { align-self: center; width: 24px; height: 22px; display: grid; place-items: center; border-radius: 11px; font-size: 13px; font-weight: 500; }
.mcell.sun .dnum { color: var(--danger); } .mcell.sat .dnum { color: #2B5BB5; }
.mcell.today .dnum { background: var(--accent); color: #fff; font-weight: 700; }
.mcell.sel { background: #E3F1EE; box-shadow: inset 0 0 0 2px var(--accent); border-radius: 8px; }
.mitem {
  display: block; font-size: 10px; line-height: 15px; height: 15px; padding: 0 3px; border-radius: 4px;
  background: var(--ob); color: var(--oc); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: clip;
}
.mitem.task { background: none; box-shadow: inset 0 0 0 1px var(--ob); font-weight: 500; }
.mitem.done { opacity: .5; text-decoration: line-through; }
.more { font-size: 10px; color: var(--sub); padding-left: 3px; line-height: 13px; }

/* ===== 通知 ===== */
.bell { position: relative; }
.badge {
  position: absolute; top: 5px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg);
}
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid #ECEDE8; }
.notice:last-child { border-bottom: 0; }
.notice.new { background: #F1F8F6; }
.notice-text { font-size: 14px; line-height: 1.5; word-break: break-word; }
.chip-btn { border: 0; min-height: 28px; cursor: pointer; }

/* ===== タスクのカテゴリ・場所・編集 ===== */
.cat-bar { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px; scrollbar-width: none; }
.cat-bar::-webkit-scrollbar { display: none; }
.cat-tab { flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--field); background: var(--card); font-size: 13px; color: var(--ink); white-space: nowrap; }
.cat-tab .num { color: var(--sub); font-size: 12px; margin-left: 2px; }
.cat-tab.on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.cat-tab.on .num { color: #C9CCD3; }
.cat-pick { min-height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--field); background: var(--card); font-size: 13px; }
.cat-pick.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.chip.cat { color: #5A4A2E; background: #F1EADB; font-weight: 500; }
.task-open { border: 0; background: none; padding: 0; text-align: left; color: inherit; min-height: 24px; }
.place { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--accent); text-decoration: none; min-height: 24px; }
.place span { text-decoration: underline; text-underline-offset: 2px; }

/* ===== 引っぱって更新 ===== */
.ptr { display: flex; align-items: flex-end; justify-content: center; gap: 8px; overflow: hidden; font-size: 13px; color: var(--sub); padding-bottom: 8px; box-sizing: border-box; }
.ptr-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; font-size: 16px; color: var(--accent); transition: transform .15s; }
.ptr-icon.spin { border: 2.5px solid #CFE3DF; border-top-color: var(--accent); border-radius: 50%; width: 16px; height: 16px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 猫のイラスト ===== */
.cat { display: block; flex-shrink: 0; }
.cat-pair { display: flex; align-items: flex-end; gap: 0; }
.cat-pair .cat:last-child { margin-left: -14px; transform: scaleX(-1); }
.center .cat-pair { margin-bottom: -6px; }
.splash { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.cat-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 16px 24px; }
.tabs-wrap { position: relative; }
.peek-cat { position: absolute; right: 22px; bottom: calc(100% - 3px); pointer-events: none; z-index: 1; animation: peek .5s ease-out; }
@keyframes peek { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.ptr-cat { display: block; transition: transform .1s; }
.all-done { display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin-bottom: 10px; }
.all-done > div { display: flex; flex-direction: column; gap: 2px; }
@media (prefers-reduced-motion: reduce) { .peek-cat { animation: none; } }

/* ===== 日付タップで出る登録パネル ===== */
.cal-wrap { min-height: 100%; }
.reg-panel { margin: 12px 0 4px; border: 1.5px solid var(--accent); box-shadow: 0 6px 20px rgba(15, 94, 87, .12); animation: regIn .18s ease-out; }
.reg-x { width: 36px; height: 36px; font-size: 22px; line-height: 1; color: var(--sub); }
@keyframes regIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .reg-panel { animation: none; } }

/* ===== カウントダウン ===== */
.cd { background: var(--accent-dark); color: #fff; border-radius: 20px; padding: 4px 14px; margin-bottom: 12px; display: flex; flex-direction: column; }
.cd-row { display: flex; flex-direction: column; gap: 0; width: 100%; padding: 8px 0 6px; border: 0; background: none; color: inherit; text-align: left; }
.cd-row + .cd-row { border-top: 1px solid #2C514D; }
.cd-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cd-label { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cd-title { font-size: 15px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-date { font-size: 11px; color: #BFD9D5; }
.cd-num { display: flex; align-items: baseline; gap: 2px; flex-shrink: 0; }
.cd-pre, .cd-unit { font-size: 12px; color: #BFD9D5; }
.cd-big { font-size: 26px; font-weight: 700; line-height: 1; color: #FFD27A; }
.cd-today { font-size: 20px; font-weight: 700; color: #FFD27A; }
.cd-track { position: relative; display: block; height: 4px; border-radius: 2px; background: #2C514D; margin: 23px 16px 2px 12px; }
.cd-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, rgba(95,208,190,.35), #5FD0BE); }
.cd-cat { position: absolute; bottom: -2px; transform: translateX(-66%); transition: left 1.6s cubic-bezier(.25,.8,.3,1); }
.cd-flag { position: absolute; right: -14px; bottom: -3px; color: #FFD27A; }
.cd-flag svg { width: 16px; height: 16px; }
.cd-rest { margin: 0; padding: 4px 0 10px; font-size: 11px; color: #BFD9D5; border-top: 1px solid #2C514D; }
.cd-empty { display: flex; align-items: center; gap: 10px; padding: 8px 14px; margin-bottom: 12px; border: 1.5px dashed #C9CDC4; border-radius: 16px; font-size: 12px; color: var(--sub); line-height: 1.5; }

/* ===== わすれないで ===== */
.remember { margin-top: 12px; border: 1.5px solid #E8833A; overflow: hidden; }
.remember-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 8px; background: #FFF4EC; font-size: 15px; }
.remember-head .num { font-size: 12px; color: #8A4A17; }
.remember-row { display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 4px; border-top: 1px solid #F1EDE7; }
.due-badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.due-badge.over { color: #fff; background: var(--danger); }
.due-badge.today { color: #fff; background: #C2561A; }
.due-badge.soon { color: #8A4A17; background: #FDE6D3; }
.due-badge.none { color: #4A505C; background: #EEEFEA; }
.imp-badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; color: #6E5200; background: #FFF1C2; white-space: nowrap; }

/* ===== 重要 ===== */
.task.imp { background: #FFFBEA; box-shadow: inset 0 0 0 1.5px #F0D27A; }
.star { width: 40px; height: 44px; border: 0; background: none; font-size: 22px; color: #C9CCD3; flex-shrink: 0; }
.star.on { color: #D9A200; }

/* ===== スイッチ ===== */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 6px 14px; border: 1px solid var(--field); border-radius: 14px; background: var(--card); cursor: pointer; }
.toggle { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 15px; background: #C9CCD3; position: relative; flex-shrink: 0; margin: 0; cursor: pointer; transition: background .15s; }
.toggle::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle:checked { background: var(--accent); }
.toggle:checked::after { left: 23px; }
.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== 編集画面・キーボード表示中の調整 ===== */
/* 編集画面を開いている間・入力中はタブバーと猫を隠す */
.shell:has(.sheet-bg) .tabs-wrap, body.typing .tabs-wrap { display: none; }
/* 編集画面の後ろがスクロールしないように */
.shell:has(.sheet-bg) .main { overflow: hidden; }
.sheet-bg { height: 100dvh; overscroll-behavior: contain; }
.sheet { max-height: 90dvh; overscroll-behavior: contain; }
/* iPhoneで日付・時間の入力欄がはみ出す問題 */
input[type="date"].field, input[type="time"].field {
  -webkit-appearance: none; appearance: none; display: flex; align-items: center;
  min-width: 0; max-width: 100%; text-align: left; line-height: 46px;
}
input[type="date"]::-webkit-date-and-time-value, input[type="time"]::-webkit-date-and-time-value { text-align: left; }
.row > .grow { min-width: 0; }

/* ===== 画面全体が動かないように固定 ===== */
html, body { overflow: hidden; overscroll-behavior: none; }
.shell { position: fixed; top: 0; bottom: 0; left: 0; right: 0; height: auto; }
.main { overscroll-behavior: contain; }

/* ===== 歩く猫の動き ===== */
.cat.walk .leg-in { transform-box: view-box; animation: catStep .46s ease-in-out infinite alternate; transform-origin: 0 0; }
.cat.walk .leg.b .leg-in { animation-delay: -.46s; }
.cat.walk .bob { animation: catBob .23s ease-in-out infinite alternate; }
.cat.walk .head { transform-box: fill-box; transform-origin: 30% 90%; animation: catHead .46s ease-in-out infinite alternate; animation-delay: -.1s; }
.cat.walk .tail { transform-box: fill-box; transform-origin: 100% 100%; animation: catTail .92s ease-in-out infinite alternate; }
.cat.walk .shadow { transform-box: fill-box; transform-origin: center; animation: catShadow .23s ease-in-out infinite alternate; }
@keyframes catStep { from { transform: rotate(20deg); } to { transform: rotate(-20deg); } }
@keyframes catBob { from { transform: translateY(0); } to { transform: translateY(-1.2px); } }
@keyframes catHead { from { transform: rotate(-2deg) translateY(.3px); } to { transform: rotate(2deg) translateY(-.4px); } }
@keyframes catTail { from { transform: rotate(-7deg); } to { transform: rotate(9deg); } }
@keyframes catShadow { from { transform: scaleX(1); } to { transform: scaleX(.92); } }
@media (prefers-reduced-motion: reduce) {
  .cat.walk .leg-in, .cat.walk .bob, .cat.walk .head, .cat.walk .tail, .cat.walk .shadow { animation: none; }
  .cd-cat { transition: none !important; }
}


/* ===== 起動画面・筆文字 ===== */
.splash { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding-bottom: 6vh; box-sizing: border-box; }
.splash-title, .brush { font-family: 'Yuji Boku', 'Zen Kaku Gothic New', serif; font-weight: 400; color: #1B1F27; letter-spacing: .08em; }
.splash-title { margin: 0 0 22px; font-size: 64px; line-height: 1; }
.splash .cat-pair { margin-bottom: 18px; }
.splash-sub { font-size: 12px; color: var(--sub); letter-spacing: .1em; }
.brand.brush { font-size: 48px; letter-spacing: .08em; }

/* ===== 未読バッジ ===== */
.tab-ico { position: relative; display: inline-flex; }
.tab-badge {
  position: absolute; top: -5px; left: 15px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  border: 2px solid var(--card);
}

/* ===== 吹き出し・既読・リアクション ===== */
button.bubble { border: 0; font: inherit; text-align: left; cursor: pointer; color: var(--ink); }
.msg.mine button.bubble { color: #fff; }
.read { color: var(--accent); font-weight: 700; }
.react-pick { display: flex; gap: 2px; padding: 4px 6px; margin: 2px 0 0 40px; background: var(--card); border-radius: 22px; box-shadow: 0 4px 16px rgba(20,24,30,.14); animation: regIn .15s ease-out; }
.msg.mine .react-pick { margin: 2px 0 0 0; }
.react-pick button { width: 40px; height: 40px; border: 0; background: none; font-size: 22px; border-radius: 20px; }
.react-pick button.on { background: #E3F1EE; }
.reacts { display: flex; gap: 4px; margin: -2px 0 0 44px; }
.msg.mine .reacts { margin: -2px 6px 0 0; }
.react { display: inline-flex; align-items: center; gap: 3px; min-height: 28px; padding: 0 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 14px; }
.react .num { font-size: 11px; color: var(--sub); }
.react.me { border-color: var(--accent); background: #E3F1EE; }

/* ===== 祝日 ===== */
.hol { display: block; font-size: 9px; line-height: 13px; height: 13px; padding: 0 2px; color: var(--danger); font-weight: 700; white-space: nowrap; overflow: hidden; text-align: center; }
.mcell.sel .hol { color: var(--danger); }
.hol-title { margin-left: 8px; font-size: 12px; font-weight: 700; color: var(--danger); background: #FBE7E4; padding: 2px 8px; border-radius: 10px; vertical-align: 2px; }

/* ===== 投資（デイトレ記録） ===== */
.gain { color: #C0392B; }
.loss { color: #2456B8; }
.money .big.num { font-size: 34px; }
.alert { margin-top: 12px; background: #FBF1DC; border: 1px solid #E2B45A; border-radius: 14px; padding: 10px 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.alert strong { color: #8A5A00; white-space: nowrap; }
.rules { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.stats { margin-top: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: hidden; }
.stat { padding: 12px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; border-right: 1px solid #ECEDE8; border-bottom: 1px solid #ECEDE8; }
.stat:nth-child(3n) { border-right: 0; }
.stat:nth-last-child(-n+3) { border-bottom: 0; }
.stat .muted { font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s { font-size: 11px; color: var(--sub); }
.cmp { display: grid; grid-template-columns: 4.5em 1fr auto; gap: 12px; align-items: center; font-size: 14px; }
.bar.light { height: 8px; background: #ECEDE8; }
.bar.light > div { background: var(--accent); }
.tx.trade { width: 100%; background: none; border: 0; border-bottom: 1px solid #ECEDE8; font: inherit; color: inherit; text-align: left; }
.tx.trade:last-child { border-bottom: 0; }
.tx.trade:active { background: #F6F7F4; }
.memo { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chip.warn { color: #8A5A00; background: #FBF1DC; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.plan { background: #F3F4F1; border-radius: 14px; padding: 10px 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.plan > div { display: flex; flex-direction: column; min-width: 0; }
.plan .muted { font-size: 11px; }
.plan .num { font-size: 15px; font-weight: 700; }
textarea.field.area { min-height: 72px; padding: 10px 14px; resize: vertical; font: inherit; font-size: 16px; color: inherit; }
select.field { appearance: auto; }
.sheet form .seg { display: flex; }
.sheet form .seg button { flex: 1; }

/* カレンダーの左右スワイプ */
.cal-swipe { touch-action: pan-y; overflow: hidden; }
.cal-title { display: inline-flex; align-items: center; gap: 8px; }
.cal-title .to-today { padding: 3px 10px; font-size: 12px; }
.mgrid.from-right { animation: cal-in-r .25s ease-out; }
.mgrid.from-left { animation: cal-in-l .25s ease-out; }
@keyframes cal-in-r { from { transform: translateX(24%); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes cal-in-l { from { transform: translateX(-24%); opacity: .2; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .mgrid.from-right, .mgrid.from-left { animation: none; } }

/* ===== レシピ ===== */
.rcp-cats { display: flex; gap: 6px; overflow-x: auto; margin: 12px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
.rcp-cats::-webkit-scrollbar { display: none; }
.rcp-cats .pick { flex: none; }
.rsort { width: auto; min-height: 34px; padding: 0 10px; font-size: 13px; font-weight: 500; }
.rcp-list { display: flex; flex-direction: column; gap: 10px; }
.rcp-item { display: flex; gap: 12px; align-items: center; padding: 10px; border: 0; width: 100%; font: inherit; color: inherit; text-align: left; }
.rcp-thumb { width: 72px; height: 54px; border-radius: 10px; object-fit: cover; flex: none; background: #EEEFEA; }
.rcp-thumb.none { display: grid; place-items: center; font-size: 24px; }
.rcp-title { font-size: 15px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.stars { color: #D9DBD4; letter-spacing: 1px; line-height: 1; }
.stars .on { color: #E2A33A; }
.rcp-view { gap: 12px; }
.rcp-view h2 { font-size: 19px; line-height: 1.35; }
.rcp-src { font-size: 12px; color: var(--accent); }
.rcp-memo { margin: 0; font-size: 13px; background: #F5F6F2; border-radius: 12px; padding: 10px 12px; white-space: pre-wrap; }
.servings .icon-btn.small { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--field); background: var(--card); font-size: 18px; }
.servings .icon-btn.small:disabled { opacity: .4; }
.ings { list-style: none; margin: 0; padding: 0; border-top: 1px solid #ECEDE8; }
.ings li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px solid #ECEDE8; font-size: 15px; cursor: pointer; }
.ings li .num { white-space: nowrap; font-weight: 500; }
.ings li .scaled { color: var(--accent); font-weight: 700; }
.ings li.grp { font-size: 12px; font-weight: 700; color: var(--sub); padding-top: 12px; cursor: default; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; gap: 10px; font-size: 15px; line-height: 1.6; cursor: pointer; }
.steps .sn { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; margin-top: 2px; }
.ings li.done, .steps li.done { color: #A3A7AF; text-decoration: line-through; }
.steps li.done .sn { background: #C9CCC4; }
.on-awake { border-color: var(--accent); color: var(--accent); }
.cooks .cook { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid #ECEDE8; }
.cooks .cook:last-child { border-bottom: 0; }
.cooklog { border: 2px solid var(--accent); }
.rate { display: flex; gap: 4px; }
.rate button { border: 0; background: none; font-size: 30px; line-height: 1; padding: 2px; color: #D9DBD4; }
.rate button.on { color: #E2A33A; }
.import-box { background: #F5F6F2; border-radius: 14px; padding: 12px; gap: 8px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font-size: 13px; text-align: left; text-decoration: underline; }
.rcp-cats .pick { --ob: var(--field); --oc: var(--accent); }

/* ===== ごみの日 ===== */
.gomi { display: block; font-size: 9px; line-height: 14px; height: 14px; padding: 0 2px; border-radius: 4px; background: #F1EADB; color: #6B5320; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.gomi-strip { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #F7F2E6; border: 1px solid #E8DCC0; border-radius: 14px; padding: 9px 14px; margin: 0 0 12px; font-size: 13px; }
.gomi-strip b { color: #5A4416; }
.gomi-ico { font-size: 16px; }
.gomi-day { background: #F7F2E6; border-radius: 12px; padding: 9px 14px; margin-bottom: 12px; font-size: 14px; }
.pick.wd { min-height: 34px; padding: 0 10px; --ob: var(--field); --oc: var(--accent); }
.gomi-form { border-top: 1px dashed var(--line); padding-top: 10px; }

/* ===== 投資：買えなかった日・ふりかえり ===== */
.chip.miss { color: #8A5A00; background: #FBF1DC; }
.tx.trade.miss { background: #FFFCF5; }
.alert.focus { background: #E3F1EE; border-color: #9CCBC3; }
.alert.focus strong { color: var(--accent); }
.week-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; background: #F3F4F1; border-radius: 12px; padding: 10px; }
.week-sum > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.week-sum .muted { font-size: 11px; }
.week-sum b { font-size: 15px; white-space: nowrap; }
.reviews { margin-top: 10px; }
.review { padding: 12px 16px; border-bottom: 1px solid #ECEDE8; }
.review:last-of-type { border-bottom: 0; }
.review p { margin: 6px 0 0; font-size: 14px; white-space: pre-wrap; }
.review p.next { color: var(--accent); font-weight: 500; }
.cap-edit { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid #2C514D; }
.cap-edit .field { min-height: 40px; }
