/* デイ：スッキリした青白 / ナイト：青みのある黒 */
:root {
  --bg: #F1F7FB; --surface: #FFFFFF; --surface2: #E6EFF6; --ink: #13202B; --sub: #4A5E6F; --line: #D3E0EA;
  --shu: #C4412B; --shu-ink: #FFFFFF; --focus: #1F4F8F;
  --grain-op: .05; --shadow: 0 1px 0 rgba(19,32,43,.04), 0 12px 30px -18px rgba(19,45,70,.28);
  --sans: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  --tabh: 64px; --maxw: 520px;
}
:root[data-theme="night"] {
  --bg: #0C131A; --surface: #141E28; --surface2: #1C2733; --ink: #EAF1F7; --sub: #9DB0C1; --line: #263543;
  --shu: #E5705A; --shu-ink: #1A0E0B; --focus: #BCD3FF; --grain-op: .09;
  --shadow: 0 1px 0 rgba(255,255,255,.03), 0 14px 34px -18px rgba(0,0,0,.8);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: light; }
:root[data-theme="night"] { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.7; transition: background .35s, color .35s; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ヘッダ */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.logo { font-family: var(--sans); font-weight: 900; font-size: 20px; letter-spacing: .02em; }
.logo b { color: var(--shu); font-weight: 800; }
.logo sup { font-size: 9px; font-family: var(--sans); font-weight: 500; margin-left: 2px; color: var(--sub); }
.mode { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--surface2); border: 1px solid var(--line); border-radius: 999px; }
.mode button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--sub); min-height: 36px; }
.mode button[aria-pressed="true"] { background: var(--ink); color: var(--bg); font-weight: 700; }
.mode svg { width: 16px; height: 16px; }

main { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px calc(var(--tabh) + 36px + env(safe-area-inset-bottom)); }
.page-in { animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* タブ */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; padding: 0 12px max(10px, env(safe-area-inset-bottom)); pointer-events: none; }
.tabs .bar { pointer-events: auto; display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; max-width: var(--maxw); height: var(--tabh); background: var(--ink); color: var(--bg); border-radius: 22px; padding: 6px; box-shadow: 0 16px 36px -14px rgba(0,0,0,.5); }
.tabs button { border: 0; background: transparent; display: grid; place-items: center; gap: 0; align-content: center; border-radius: 16px; font-size: 11.5px; color: color-mix(in srgb, var(--bg) 62%, var(--ink)); }
.tabs button svg { width: 22px; height: 22px; }
.tabs button[aria-current="page"] { background: color-mix(in srgb, var(--bg) 16%, var(--ink)); color: var(--bg); font-weight: 700; }

/* 見出し・共通 */
.eyebrow { font-size: 12px; letter-spacing: .14em; color: var(--sub); }
.h1 { font-family: var(--sans); font-weight: 900; font-size: 28px; line-height: 1.35; letter-spacing: .01em; margin: 4px 0 2px; }
.h2 { font-family: var(--sans); font-weight: 700; font-size: 20px; margin: 0; }
.sec { margin-top: 30px; }
.sec-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.num { font-family: var(--sans); font-weight: 800; color: var(--shu); font-size: 20px; border: 1.5px solid var(--shu); width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 4px; line-height: 1; transform: rotate(-3deg); flex: none; }
.muted { color: var(--sub); font-size: 14px; }
.small { font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
hr.rule { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.btn { min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1.5px solid var(--ink); background: var(--ink); color: var(--bg); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.shu { background: var(--shu); border-color: var(--shu); color: var(--shu-ink); }
.btn.block { display: flex; width: 100%; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; color: var(--ink); min-height: 32px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface2); font-size: 13px; color: var(--ink); min-height: 34px; }
button.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 18px; height: 18px; border-radius: 50%; flex: none; border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); display: inline-block; }
.sw.lg { width: 28px; height: 28px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; min-height: 42px; border-radius: 10px; font-weight: 500; color: var(--sub); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg svg { width: 16px; height: 16px; }

.banner { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--surface2); border: 1px solid var(--line); font-size: 14px; }
.banner + .banner { margin-top: 8px; }

/* 染め(ヒーロー) */
.hero { position: relative; overflow: hidden; border-radius: 26px; padding: 22px 20px 20px; min-height: 236px; color: var(--hero-ink, var(--ink)); background: var(--hero, var(--surface)); border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); box-shadow: var(--shadow); transition: background .5s ease, color .4s ease; display: flex; flex-direction: column; justify-content: flex-end; }
.hero::before { content: ""; position: absolute; inset: 0; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>"); opacity: var(--grain-op); mix-blend-mode: multiply; pointer-events: none; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.34), rgba(255,255,255,0) 66%); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow { color: inherit; opacity: .78; }
.hero .cname { font-family: var(--sans); font-weight: 900; font-size: 44px; line-height: 1.15; margin: 6px 0 4px; letter-spacing: .02em; }
.hero .role { display: inline-block; font-size: 12px; padding: 2px 10px; border: 1px solid currentColor; border-radius: 999px; opacity: .85; margin-right: 8px; }
.hero p { margin: 8px 0 0; font-size: 15px; max-width: 30em; }
.hero .stamp { position: absolute; right: 16px; bottom: 16px; z-index: 1; width: 44px; height: 44px; border: 2px solid currentColor; border-radius: 6px; display: grid; place-items: center; font-family: var(--sans); font-weight: 800; font-size: 17px; opacity: .7; transform: rotate(6deg); }
.hero.empty { --hero: var(--surface); }
.alts { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.alts button { width: 44px; height: 44px; border-radius: 50%; border: 2px solid transparent; padding: 0; background: var(--c); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 22%, transparent); }
.alts button[aria-pressed="true"] { border-color: var(--surface); box-shadow: 0 0 0 2.5px var(--ink); }

/* 願い */
.wishes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wish { text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 16px; padding: 14px 14px; min-height: 76px; display: flex; align-items: center; gap: 10px; font-weight: 500; line-height: 1.45; }
.wish .dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--sub); flex: none; }
.wish[aria-pressed="true"] { border-color: var(--ink); background: var(--surface2); font-weight: 700; }
.wish[aria-pressed="true"] .dot { background: var(--shu); border-color: var(--shu); }

/* 手持ち */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.pick { width: 100%; text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; min-height: 56px; }
.pick + .pick { margin-top: 8px; }
.pick[aria-pressed="true"] { border-color: var(--ink); background: var(--surface2); }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface2); border: 1px solid var(--line); color: var(--sub); }
.tag.ok { color: var(--ink); border-color: var(--ink); }

/* 評価 */
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale button { min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-family: var(--sans); font-weight: 700; font-size: 18px; }
.scale button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.scale-label { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 6px; font-weight: 700; }
.scale-label small { font-weight: 400; color: var(--sub); font-size: 12px; }
textarea, input[type="text"], input[type="date"], input[type="time"], select { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 46px; }
textarea { resize: vertical; min-height: 84px; }

/* カレンダー */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 8px 2px 8px; min-height: 92px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.day .dw { font-size: 11px; color: var(--sub); }
.day .dn { font-family: var(--sans); font-weight: 700; font-size: 18px; line-height: 1; }
.day.today .dn { color: var(--shu); }
.day[aria-pressed="true"] { border-color: var(--ink); background: var(--surface2); }
.dot-s { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; background: var(--c, transparent); color: var(--ci, var(--ink)); }
.dot-s.tentative { background: color-mix(in srgb, var(--c) 28%, transparent); border: 1.5px dashed var(--c); }
.dot-s.pinned { border: 2px solid var(--ink); }
.dot-s.worn { box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 25%, transparent); }
.dot-s.empty { border: 1px dotted var(--line); background: transparent; }
.dot-s.sm { width: 14px; height: 14px; }
.ev-mark { height: 4px; width: 20px; border-radius: 2px; background: var(--shu); }
.slot { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.slot:first-of-type { border-top: 0; }
.status { font-size: 12px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); }
.status.worn { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.status.pinned { border-color: var(--ink); }
.warn { color: var(--shu); font-size: 13px; font-weight: 700; }

/* レポート */
table.rep { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rep th, table.rep td { text-align: left; padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
table.rep th { font-weight: 500; color: var(--sub); font-size: 12px; border-top: 0; }
.spark { display: flex; gap: 3px; align-items: flex-end; height: 26px; }
.spark i { display: block; width: 8px; background: var(--ink); opacity: .75; border-radius: 2px 2px 0 0; }
.note-box { border-left: 3px solid var(--shu); padding: 8px 12px; background: var(--surface2); border-radius: 0 10px 10px 0; font-size: 14px; }

/* シート・トースト */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0 auto; max-width: var(--maxw); max-height: 88vh; overflow: auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 14px 18px calc(24px + env(safe-area-inset-bottom)); box-shadow: 0 -20px 50px rgba(0,0,0,.35); animation: up .28s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabh) + 30px + env(safe-area-inset-bottom)); z-index: 60; background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-size: 14px; display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px); box-shadow: 0 12px 30px rgba(0,0,0,.35); }
.toast button { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; min-height: 32px; }
.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.palette button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 10px 4px; display: grid; justify-items: center; gap: 6px; font-size: 12px; min-height: 76px; }
.palette button[aria-pressed="true"] { border-color: var(--ink); background: var(--surface2); }
.palette .sw { width: 28px; height: 28px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.f { display: block; font-size: 13px; color: var(--sub); margin: 12px 0 6px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch input { width: 22px; height: 22px; accent-color: var(--shu); }

[hidden] { display: none !important; }
.wish, .hero p, .h2, .banner { word-break: auto-phrase; text-wrap: pretty; }
.wish { font-size: 15px; }
.toast { width: max-content; }

/* ハンバーガーとドロワー */
.top { display: grid; grid-template-columns: 44px 1fr auto; }
.burger { width: 44px; height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; display: grid; place-items: center; padding: 0; }
.burger svg { width: 22px; height: 22px; }
.top .logo { text-align: left; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 340px); z-index: 55; background: var(--bg); border-right: 1px solid var(--line); padding: max(18px, env(safe-area-inset-top)) 18px 24px; overflow: auto; box-shadow: 20px 0 50px -20px rgba(0,0,0,.45); animation: slide .24s cubic-bezier(.2,.8,.2,1); }
@keyframes slide { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer .dh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.drawer .grp { font-size: 12px; color: var(--sub); letter-spacing: .12em; margin: 20px 4px 6px; }
.dl { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 0 14px; border: 0; background: transparent; border-radius: 14px; text-align: left; font-weight: 500; text-decoration: none; }
.dl svg { width: 22px; height: 22px; flex: none; }
.dl small { margin-left: auto; color: var(--sub); font-size: 12px; font-weight: 400; }
.dl[aria-current="page"] { background: var(--surface2); font-weight: 700; }
.dl.soon { color: var(--sub); }
.x { width: 44px; height: 44px; border: 0; background: var(--surface2); border-radius: 14px; font-size: 22px; line-height: 1; }

.dateline { margin: 6px 0 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-weight: 700; }
.dateline .s { font-size: 14px; color: var(--sub); font-weight: 500; }
.dateline .L { font-size: 36px; line-height: 1.15; font-weight: 900; letter-spacing: .01em; }

/* 狭い画面でヘッダを崩さない・スタンプが文字に重ならない */
.mode button { white-space: nowrap; padding: 6px 10px; font-size: 12.5px; gap: 4px; }
.mode svg { width: 15px; height: 15px; }
.top { gap: 8px; padding-left: 12px; padding-right: 12px; }
.logo { font-size: 18px; white-space: nowrap; }
.hero .stamp { top: 16px; bottom: auto; right: 16px; width: 38px; height: 38px; font-size: 15px; }
.hero .eyebrow { padding-right: 52px; }
@media (max-width: 360px) { .mode button span.t { display: none; } }
.dateline .md { display: inline-flex; align-items: baseline; gap: 2px; }
.dateline .u { font-size: 16px; font-weight: 700; color: var(--ink); margin-right: 4px; }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 64px; }
.bars .bc { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-width: 0; }
.bars i { display: block; width: 100%; max-width: 9px; background: var(--ink); border-radius: 2px 2px 0 0; }
.bars u { display: block; width: 100%; max-width: 9px; height: 3px; background: var(--shu); border-radius: 2px; text-decoration: none; }
.bars u.n { background: transparent; }
.num { font-size: 18px; font-weight: 900; transform: none; border-radius: 8px; }

.note-box.guard { border-left-color: var(--ink); line-height: 1.7; }
.note-box.guard b { font-size: 12px; letter-spacing: .12em; color: var(--sub); }

/* 磨き込み: 願いタイルの手応え / 選択チップの✓ / 下端の余白 */
.wish { transition: transform .12s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.wish:active { transform: scale(.98); }
.wish[aria-pressed="true"] { box-shadow: 0 2px 8px -2px rgba(19, 32, 43, .14); }
button.chip[aria-pressed="true"]::before { content: "✓"; font-weight: 900; margin-right: 2px; }
.chip { transition: background .15s ease, color .15s ease; }
.tabs { padding-bottom: max(10px, calc(env(safe-area-inset-bottom) + 4px)); }
