:root {
  /* 月ごとのテーマで app.js が上書きする */
  --sky1: #2b1a4f; --sky2: #3d2670; --bg: #2b1a4f; --hero: #ff8a1f; --ribbon: #ff5fa2;
  --ink: #21304a; --paper: #fffaf0; --line: #21304a; --muted: #5d6a82;
  --want: #ff4f8b; --ok: #3fbf6a; --warn: #ff3b30;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif; font-weight: 700; font-size: 15px; line-height: 1.5;
  padding-bottom: calc(92px + env(safe-area-inset-bottom)); overflow-x: hidden;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.pop { font-family: "Mochiy Pop One", sans-serif; font-weight: 400; }

/* ---- 空（ヘッダー） */
.sky {
  position: relative; overflow: hidden; color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 74px;
  background: linear-gradient(var(--sky1), var(--sky2));
}
#deco span { position: absolute; animation: tw 2.6s infinite ease-in-out; pointer-events: none; }
@keyframes tw { 50% { opacity: .3; transform: scale(.75) translateY(-4px); } }
.top-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { font-family: "Mochiy Pop One", sans-serif; font-weight: 400; font-size: 27px; margin: 0; text-shadow: 3px 3px 0 rgba(0,0,0,.28); white-space: nowrap; }
.top-btns { display: flex; gap: 6px; position: relative; z-index: 1; }
.round { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); background: rgba(255,255,255,.2); font-size: 18px; }
.round:disabled { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sub { position: relative; font-size: 13px; margin-top: 2px; }
.weather { position: relative; display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.wx { background: rgba(255,255,255,.2); border: 2px solid rgba(255,255,255,.45); border-radius: 12px; padding: 2px 9px; font-size: 12px; }
.wx.rain { background: rgba(80,160,255,.45); }
.updated { position: relative; font-size: 11px; opacity: .8; margin-top: 6px; font-weight: 500; }

/* ---- マスコット */
.guide { position: relative; z-index: 2; margin: -62px 14px 0; display: flex; align-items: flex-end; gap: 8px; }
.mascot { width: 96px; height: 104px; flex: none; animation: bob 2.4s infinite ease-in-out; }
.mascot svg { width: 100%; height: 100%; overflow: visible; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
.bubble {
  position: relative; background: #fff; border: 3px solid var(--line); border-radius: 20px; padding: 9px 13px;
  font-size: 15px; box-shadow: 4px 4px 0 var(--line); margin-bottom: 20px;
}
.bubble:before { content: ""; position: absolute; left: -14px; bottom: 14px; border: 8px solid transparent; border-right: 12px solid var(--line); }
.bubble b { color: #e0457b; }

main { max-width: 640px; margin: 0 auto; padding: 4px 16px 0; }
.view { display: none; }
.view.active { display: block; }

/* ---- 共通部品 */
.card {
  background: var(--paper); border: 3px solid var(--line); border-radius: 24px; box-shadow: 5px 5px 0 var(--line);
  padding: 13px 14px; margin-top: 16px;
}
.panel { background: var(--paper); border: 3px solid var(--line); border-radius: 20px; box-shadow: 4px 4px 0 var(--line); padding: 12px 14px; margin-top: 8px; }
.sec { color: #fff; font-family: "Mochiy Pop One", sans-serif; font-weight: 400; font-size: 18px; margin: 26px 0 8px; text-shadow: 2px 2px 0 rgba(0,0,0,.3); }
.sec-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note { color: rgba(255,255,255,.88); font-size: 13px; font-weight: 500; margin: 4px 0; }
.panel .note, dialog .note, details .note { color: var(--muted); }
.btn {
  border: 3px solid var(--line); border-radius: 16px; background: #fff; padding: 9px 10px; font-size: 14px;
  box-shadow: 3px 3px 0 var(--line); transition: transform .08s; text-decoration: none; color: var(--ink); text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.btn:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--line); }
.btn.primary { background: var(--hero); }
.btn.want { background: var(--want); color: #fff; }
.btn.want.on { background: #fff; color: var(--want); }
.btn.small { padding: 5px 9px; font-size: 12px; border-width: 2px; box-shadow: 2px 2px 0 var(--line); border-radius: 12px; }
.btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btns .btn { flex: 1 1 0; min-width: 0; white-space: nowrap; font-size: 13px; padding: 9px 4px; }
.mini-btn { border: 2px solid rgba(255,255,255,.7); background: rgba(255,255,255,.18); color: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; margin-top: 18px; }
.mini-btn[aria-pressed="true"], .mini-btn[aria-expanded="true"] { background: #fff; color: var(--ink); }
.chip, .chips select { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 11px; font-size: 13px; flex: 0 0 auto; }
.chip[aria-pressed="true"] { background: var(--hero); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
#search { width: 100%; margin-top: 8px; border: 2px solid var(--line); border-radius: 12px; padding: 7px 11px; background: #fff; }
.tag { display: inline-block; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 12px; margin: 2px 4px 0 0; }
.tag.free { background: #c9f7a8; }
.tag.paid { background: #ffd6d6; }
.tag.entry { background: #e8f3c9; }
.tag.warn { background: var(--warn); color: #fff; }
.tag.check, .warn-badge.check { background: #ffd34d; color: var(--ink); }

/* ---- 期間の切り替え */
.seg { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin-top: 18px; }
.seg button { border: 3px solid var(--line); background: #fff; border-radius: 14px; padding: 6px 0; font-size: 14px; box-shadow: 3px 3px 0 var(--line); }
.seg button.on { background: var(--hero); transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--line); }

/* ---- 評価のお願い（入力するまで毎回出る） */
.ask { animation: nudge 3.2s infinite; }
@keyframes nudge { 0%,88%,100% { transform: rotate(0); } 92% { transform: rotate(-1.5deg); } 96% { transform: rotate(1.5deg); } }
.ask .q { font-size: 15px; }
.faces { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 10px; }
.faces button { border: 3px solid var(--line); border-radius: 16px; background: #fff; padding: 6px 0; font-size: 12px; box-shadow: 3px 3px 0 var(--line); }
.faces span { display: block; font-size: 28px; line-height: 1.3; }
.linkish { background: none; border: 0; color: var(--muted); font-size: 12px; display: block; margin: 8px 0 0 auto; text-decoration: underline; }

/* ---- 決まった予定 */
.plan { background: #7fe0a0; }
.plan.canceled { background: #ffb3ad; }
.plan .lbl { font-family: "Mochiy Pop One"; font-size: 13px; }
.plan h3 { margin: 4px 0 2px; font-size: 17px; }
.checked { font-size: 12px; margin-top: 8px; font-weight: 500; }

/* ---- いちおし */
.hero { position: relative; background: var(--hero); border: 3px solid var(--line); border-radius: 28px; box-shadow: 6px 6px 0 var(--line); padding: 16px; margin-top: 30px; }
.ribbon { position: absolute; top: -17px; left: 18px; background: var(--ribbon); color: #fff; border: 3px solid var(--line); border-radius: 999px; padding: 3px 14px; font-family: "Mochiy Pop One"; font-size: 14px; box-shadow: 3px 3px 0 var(--line); }
.hero-top { display: flex; gap: 12px; align-items: center; margin-top: 6px; }
.big-emo { width: 80px; height: 80px; flex: none; border-radius: 22px; background: var(--paper); border: 3px solid var(--line); display: grid; place-items: center; font-size: 46px; }
.hero h2 { margin: 0; font-family: "Mochiy Pop One"; font-weight: 400; font-size: 21px; line-height: 1.3; word-break: break-word; }
.hero .meta { font-size: 13px; margin-top: 4px; }
.why { background: var(--paper); border: 3px dashed var(--line); border-radius: 16px; padding: 8px 12px; margin-top: 12px; font-size: 14px; }

/* ---- タイル */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.tile { position: relative; background: var(--paper); border: 3px solid var(--line); border-radius: 22px; box-shadow: 4px 4px 0 var(--line); padding: 11px; text-align: left; min-width: 0; }
/* 公式の画像（読めないときは絵文字） */
.thumb, .hero-img, .detail-img { position: relative; overflow: hidden; border: 3px solid var(--line); display: grid; place-items: center; }
.thumb img, .hero-img img, .detail-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb > span, .hero-img > span { position: absolute; right: 4px; bottom: 2px; font-size: 18px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.noimg > span { position: static !important; font-size: 34px !important; filter: none !important; }
.thumb { width: 100%; aspect-ratio: 4 / 3; border-radius: 14px; }
.hero-img { width: 104px; height: 104px; flex: none; border-radius: 20px; }
.hero-img.noimg > span { font-size: 48px !important; }
.detail-img { width: 100%; aspect-ratio: 4 / 3; border-radius: 18px; margin: 30px 0 10px; background: #fff; }
.detail-img img { object-fit: contain; }
.detail-img > span { display: none; }
.tile h3 { margin: 7px 0 2px; font-size: 14px; line-height: 1.35; word-break: break-word; }
.tile p { margin: 0; font-size: 12px; color: var(--muted); font-weight: 500; }
.heart { position: absolute; top: 4px; right: 4px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); background: #fff; display: grid; place-items: center; font-size: 16px; }
.tile .warn-badge { z-index: 3; position: absolute; left: -6px; top: -10px; background: var(--warn); color: #fff; border: 2px solid var(--line); border-radius: 999px; font-size: 11px; padding: 1px 8px; }
.tile.dim { opacity: .65; }
.empty { color: #fff; text-align: center; padding: 26px 8px; font-weight: 500; }
details.group { margin-top: 14px; }
details.group > summary { color: #fff; font-size: 14px; cursor: pointer; padding: 6px 2px; }
details.group .grid { margin-top: 8px; }

/* ---- こうほ・きろく */
.row-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; }
.row-item + .row-item { border-top: 2px dotted #c9c1b0; }
.row-item .e { font-size: 26px; line-height: 1.2; }
.row-item .t { flex: 1; min-width: 0; }
.row-item .t b { display: block; font-size: 14px; }
.row-item .t small { color: var(--muted); font-weight: 500; }
.who { display: inline-block; background: #ffe0ec; border: 2px solid var(--line); border-radius: 999px; font-size: 11px; padding: 0 7px; margin-right: 4px; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.boom-row { display: grid; grid-template-columns: 24px minmax(0,1fr) 34% 2.8em; align-items: center; gap: 6px; font-size: 13px; margin: 5px 0; white-space: nowrap; }
.bar { height: 10px; border-radius: 5px; background: #ece5d6; position: relative; overflow: hidden; border: 1px solid #d6cdb8; }
.bar i { position: absolute; top: 0; bottom: 0; }
.bar i.pos { left: 50%; background: #3fbf6a; }
.bar i.neg { right: 50%; background: #ff6b6b; }
.delta { font-size: 11px; text-align: right; }
.delta.up { color: #1f8f47; } .delta.down { color: #d33; }
.tag-row { display: grid; grid-template-columns: 24px 1fr auto auto auto auto; gap: 6px; align-items: center; padding: 6px 0; font-size: 13px; }
.tag-row button { border: 2px solid var(--line); background: #fff; border-radius: 10px; min-width: 32px; padding: 2px 6px; }
.tag-row button.ng-on { background: var(--warn); color: #fff; }
.src { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.panel input[type=text], .panel input[type=password] { width: 100%; border: 2px solid var(--line); border-radius: 10px; padding: 7px 10px; background: #fff; margin: 6px 0; }
.who-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.who-btns button { border: 3px solid var(--line); border-radius: 14px; background: #fff; padding: 6px 14px; box-shadow: 3px 3px 0 var(--line); }
.who-btns button.on { background: var(--hero); }
details.panel > summary { cursor: pointer; font-size: 14px; }

/* ---- 下のタブ */
.corner { position: fixed; right: 4px; bottom: calc(84px + env(safe-area-inset-bottom)); font-size: 38px; pointer-events: none; animation: bob 3s infinite; z-index: 4; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  background: var(--paper); border-top: 3px solid var(--line); padding: 7px 0 calc(7px + env(safe-area-inset-bottom));
}
.tabbar button { position: relative; border: 0; background: none; display: flex; flex-direction: column; align-items: center; font-size: 12px; gap: 2px; }
.tabbar span { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-size: 24px; border: 3px solid transparent; }
.tabbar button.on span { background: var(--hero); border-color: var(--line); box-shadow: 3px 3px 0 var(--line); }
.dot { position: absolute; top: -3px; right: -2px; background: var(--warn); color: #fff; border: 2px solid var(--line); border-radius: 999px; font-size: 10px; padding: 0 5px; min-width: 18px; text-align: center; }

/* ---- ダイアログ */
dialog { border: 3px solid var(--line); border-radius: 24px; padding: 16px; width: min(94vw, 440px); background: var(--paper); color: var(--ink); box-shadow: 6px 6px 0 var(--line); max-height: 88vh; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin: 0 0 4px; font-size: 17px; }
dialog label { display: block; margin-top: 10px; }
dialog input { width: 100%; border: 2px solid var(--line); border-radius: 10px; padding: 7px 10px; background: #fff; margin-top: 2px; }
.day-btns, .reason-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.day-btns button, .reason-btns button { border: 3px solid var(--line); border-radius: 14px; background: #fff; padding: 8px 4px; box-shadow: 3px 3px 0 var(--line); }
.day-btns button.on { background: var(--hero); }
.dlg-btns { display: flex; gap: 8px; margin-top: 14px; }
.dlg-btns .btn { flex: 1; }
.link { border: 0; background: none; color: var(--muted); margin-top: 12px; width: 100%; padding: 6px; }
.detail-head { display: flex; gap: 12px; align-items: center; }
.detail-head .big-emo { width: 64px; height: 64px; font-size: 36px; }
.detail-body { font-size: 14px; font-weight: 500; margin-top: 10px; }
.detail-body p { margin: 4px 0; }
.close-x { position: absolute; top: 10px; right: 12px; border: 2px solid var(--line); border-radius: 50%; width: 32px; height: 32px; background: #fff; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 14px; border: 2px solid #fff;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 92vw; text-align: center; z-index: 30;
}
#toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; } }
