/* スイの夢日記 正式版。デザインは Codex の決定稿 docs/reviews/codex-2026-11-02-app-design/design.md (スマホ 375 が正本、PC は同じ画面を中央に)。
   文字は全部 HTML。札・紙は枠だけの絵 (LP の部品 + Codex の parts)。金縁は カード・手紙・主ボタン だけ。 */
:root {
  --sky: #bfddf5;
  --dawn: #f6d5d2;
  --cloud: #fff9ee;
  --ink: #153d4a;
  --sub: #4f6a72;
  --gold: #d7a63a;
  --gold-dark: #9b701b;
  --navy: #173c57;
  --rule: rgba(183, 203, 208, .55);
  --user-bubble: #e7f2fb;
  --danger: #a95d64;
  --danger-bg: #fff4f3;
  --line: rgba(21, 61, 74, .16);
  --font-hand: "Zen Kurenaido", "Zen Maru Gothic", sans-serif;
  --font-body: "Zen Maru Gothic", sans-serif;
  --app: 430px;
  --gutter: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.9;
  letter-spacing: .035em;
  background: linear-gradient(180deg, #e9f3fc 0%, var(--sky) 45%, var(--dawn) 100%) fixed;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); }
img { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
[hidden] { display: none !important; }

/* アプリ面 (375 基準、最大 430、PC は中央) */
.app { max-width: var(--app); margin: 0 auto; min-height: 100svh; position: relative; background: url("/img/a/bg-sky-portrait.webp") center top / cover no-repeat, linear-gradient(180deg, #e9f3fc, var(--sky) 45%, var(--dawn)); }
@media (min-width: 768px) {
  body { background: linear-gradient(rgba(255, 255, 255, .14), rgba(255, 255, 255, .14)), url("/img/a/bg-sky-landscape.webp") center / cover fixed, var(--sky); }
  .app { box-shadow: 0 0 0 1px rgba(255, 255, 255, .9), 0 0 24px rgba(21, 61, 74, .14); }
}
#main { padding: 0 var(--gutter) calc(96px + env(safe-area-inset-bottom)); }
body[data-view="auth"] #main, body[data-view="loading"] #main { padding-bottom: 32px; }

/* ヘッダー 56px */
.top { position: sticky; top: 0; z-index: 5; height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--gutter) 0; display: flex; align-items: center; justify-content: space-between; background: rgba(255, 249, 238, .92); border-bottom: 1px solid rgba(21, 61, 74, .12); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.brand-name { font-size: 15px; font-weight: 700; }
.top-date { font-size: 12px; color: var(--sub); }

/* 顔の丸 (絵 + 枠を重ねる) */
.face-frame { position: relative; display: inline-block; border-radius: 50%; overflow: hidden; flex: none; }
.face-frame::after { content: ""; position: absolute; inset: 0; background: url("/img/a/frame-face.webp") center / 100% 100% no-repeat; pointer-events: none; }
.face-frame img { width: 100%; height: 100%; border-radius: 50%; }
.face-frame.s36 { width: 36px; height: 36px; }
.face-frame.s64 { width: 64px; height: 64px; }
.face-frame.s72 { width: 72px; height: 72px; }

/* 下部ナビ 64px */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; margin: 0 auto; max-width: var(--app); height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255, 249, 238, .96); border-top: 1px solid rgba(21, 61, 74, .12); }
.bottom a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 56px; text-decoration: none; color: var(--sub); font-size: 11px; font-weight: 600; white-space: nowrap; position: relative; }
.bottom a .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .5; }
.bottom a.on { color: var(--ink); font-weight: 700; }
.bottom a.on .dot { background: var(--gold); opacity: 1; }
.bottom a.on::after { content: ""; position: absolute; bottom: 4px; width: 60px; height: 12px; background: url("/img/parts/tab-active-ornament.webp") center / 100% 100% no-repeat; }

/* 画面の切り替え */
.view { display: none; padding-top: 16px; }
body[data-view="loading"] .view[data-for="loading"], body[data-view="auth"] .view[data-for="auth"], body[data-view="today"] .view[data-for="today"],
body[data-view="diary"] .view[data-for="diary"], body[data-view="review"] .view[data-for="review"], body[data-view="settings"] .view[data-for="settings"] { display: block; }

/* 文字 */
.h1 { font-family: var(--font-hand); font-size: 26px; line-height: 1.55; font-weight: 400; margin: 8px 0 4px; }
.h3 { font-size: 17px; line-height: 1.6; font-weight: 700; margin: 0 0 8px; }
.h3.sec { margin: 28px 0 10px; padding-left: 10px; border-left: 2px solid rgba(169, 93, 100, .5); }
.links { margin: 24px 0 16px; line-height: 1.8; }
.lead { font-size: 15px; line-height: 1.85; margin: 0 0 16px; }
.help { color: var(--sub); font-size: 13px; line-height: 1.75; margin: 8px 0 0; }
.note { color: var(--sub); font-size: 13px; }
.date { font-size: 12px; color: var(--sub); }
.center { text-align: center; }
.kicker { font-family: var(--font-hand); font-size: 16px; line-height: 1.7; margin: 0 0 10px; }
.sui-line { font-family: var(--font-hand); font-size: 17px; line-height: 1.7; background: rgba(255, 249, 238, .9); border-left: 3px solid var(--gold); padding: 10px 14px; border-radius: 0 12px 12px 0; margin: 0 0 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.gap8 { gap: 8px; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--dawn); color: var(--ink); }

/* 通常面 (金縁なし) */
.surface { background: rgba(255, 249, 238, .95); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin: 0 0 20px; }
.surface .btn.secondary { margin-top: 8px; }
.surface.danger { background: var(--danger-bg); border-color: rgba(169, 93, 100, .25); }
.surface ul { margin: 4px 0 8px; padding-left: 20px; }
.ribbon { background: rgba(246, 213, 210, .75); border-radius: 22px; padding: 8px 16px; font-size: 13px; line-height: 1.6; text-align: center; margin: 0 0 12px; }

/* 札 (LP の部品。文字は .inner に) */
.plaque-title { position: relative; width: 196px; aspect-ratio: 3 / 2; margin: 0 auto 16px; background: url("/img/a/plaque-title.webp") center / 100% 100% no-repeat; }
.plaque-title .inner { position: absolute; inset: 32% 16% 21% 20%; display: flex; align-items: center; justify-content: center; font-family: var(--font-hand); font-size: 22px; line-height: 1.2; white-space: nowrap; }
.plaque-name { position: relative; display: inline-block; width: 112px; aspect-ratio: 4 / 1; background: url("/img/a/plaque-name.webp") center / 100% 100% no-repeat; flex: none; }
.plaque-name .inner { position: absolute; inset: 39% 22% 26% 18%; display: flex; align-items: center; justify-content: center; font-family: var(--font-hand); font-size: 13px; line-height: 1; white-space: nowrap; }

/* 雲の入力紙: 9 分割で伸ばす (角と雲の縁は絵、中は紙色) */
.cloud { border: 56px solid transparent; border-image: url("/img/a/plaque-input.webp") 34% 19% 34% 17% fill / 56px 66px 56px 60px round; padding: 0; margin: 0 -8px 16px; }
.cloud .kicker { margin: -16px 0 10px; padding: 0 8px; }
.cloud textarea { width: 100%; min-height: 140px; border: 1px solid #a9bcc1; border-radius: 12px; padding: 12px 16px; background: rgba(255, 255, 255, .72); resize: vertical; line-height: 1.75; }
.cloud .counter { text-align: right; font-size: 12px; color: var(--sub); margin: 6px 12px -16px 0; }
.cloud .counter.near { color: var(--ink); font-weight: 700; }
textarea:focus, input:focus { outline: none; border-color: var(--gold-dark); box-shadow: 0 0 0 3px rgba(215, 166, 58, .24); }
::placeholder { color: #90a4ab; }

/* 入力 */
label { display: block; font-size: 13px; color: var(--sub); margin: 0 0 4px; }
input[type="email"] { width: 100%; height: 48px; border: 1px solid #a9bcc1; border-radius: 12px; padding: 0 14px; background: #fff; }
.form .btn { margin-top: 12px; }

/* ボタン */
.btn:not([disabled]) { background: linear-gradient(180deg, #fff6d6, #f9dc8a); }
.btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 52px; border-radius: 26px; border: 1.5px solid var(--gold); background: linear-gradient(180deg, #ffe8a5, #f7cf68); color: var(--ink); font-size: 16px; font-weight: 700; cursor: pointer; text-decoration: none; box-shadow: 0 4px 0 rgba(155, 112, 27, .18); transition: transform .15s, box-shadow .15s; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(155, 112, 27, .18); }
.btn[disabled] { filter: saturate(.4); opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn.secondary { height: 44px; width: auto; min-width: 140px; padding: 0 20px; background: var(--cloud); border: 1px solid rgba(21, 61, 74, .28); border-radius: 12px; box-shadow: none; font-weight: 700; }
.link { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; cursor: pointer; font-size: 14px; }
.link.danger { color: var(--danger); }
.copy { margin-left: 8px; font-size: 12px; padding: 2px 10px; border-radius: 999px; border: 1px solid rgba(21, 61, 74, .28); background: #fff; cursor: pointer; }

/* サインインのボタン (Google は公式のボタン、Apple は黒のピル) */
.provider-btn { display: flex; justify-content: center; margin: 4px 0 12px; min-height: 44px; }
.btn.apple { height: 44px; background: #000; color: #fff; border: 1px solid #000; border-radius: 22px; box-shadow: none; font-weight: 600; margin: 0 0 12px; gap: 8px; }
.apple-mark { width: 16px; height: 16px; display: inline-block; background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'><path d='M16.4 12.7c0-2.5 2-3.6 2.1-3.7-1.2-1.7-3-1.9-3.6-2-1.5-.2-3 .9-3.8.9-.8 0-2-.9-3.3-.9-1.7 0-3.3 1-4.1 2.5-1.8 3.1-.5 7.7 1.3 10.2.9 1.2 1.9 2.6 3.2 2.6 1.3-.1 1.8-.8 3.3-.8s2 .8 3.3.8c1.4 0 2.2-1.3 3.1-2.5 1-1.4 1.4-2.8 1.4-2.9-.1 0-2.9-1.1-2.9-4.2zM13.9 5.4c.7-.8 1.2-2 1-3.1-1 0-2.2.7-2.9 1.5-.6.7-1.2 1.9-1 3 1.1.1 2.2-.6 2.9-1.4z'/></svg>") center / contain no-repeat; }
#signin-box .link { display: block; margin: 4px auto 0; font-size: 14px; }

/* スイの上半身 (四角い端を見せない: 楕円 + 下へフェード) */
.bust-window { position: relative; width: 252px; height: 300px; margin: 0 auto; overflow: hidden; border-radius: 50% 50% 42% 42% / 36% 36% 30% 30%; -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent 100%); mask-image: linear-gradient(180deg, #000 72%, transparent 100%); }
.bust-window .bust { width: 100%; height: auto; }
.bust-window.small { width: 148px; height: 206px; margin: 0 auto 8px; }
.bust-window.entry { margin-top: 8px; height: 300px; }
.bust-window.entry .bust { object-fit: cover; object-position: 50% 35%; height: 100%; width: 100%; }
body[data-view="auth"] .top { position: static; }
.deco-fish { position: absolute; right: 6px; top: 10px; width: 56px; z-index: 1; opacity: .9; }

/* カード (裏は Codex の絵、表は色 + 枠 + HTML の文字) */
.cards { display: flex; justify-content: center; gap: 12px; margin: 0 0 16px; }
.card { position: relative; width: 92px; aspect-ratio: 5 / 8; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 8px; transition: transform .18s; transform: translateY(3px); }
.cards .card:nth-child(2) { transform: translateY(0); }
.card .back, .card .front-face { position: absolute; inset: 0; border-radius: 8px; backface-visibility: hidden; transition: transform .6s; }
.card .back { background: url("/img/parts/card-back.webp") center / 100% 100% no-repeat; }
.card .front-face { transform: rotateY(180deg); background: var(--tone, #cfe3f5); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24% 10% 12%; text-align: center; }
.card .front-face .card-name { position: absolute; top: 6%; left: 22%; right: 22%; font-size: 13px; line-height: 1; z-index: 1; }
.card .front-face .card-key { position: relative; z-index: 1; }
.card .front-face::after { content: ""; position: absolute; inset: 0; background: url("/img/parts/card-front-frame.webp") center / 100% 100% no-repeat; pointer-events: none; }
.card .card-name { font-family: var(--font-hand); font-size: 18px; line-height: 1.2; }
.card .front-face .card-key { font-size: 12px; }
.result-card .front-face .card-name { font-size: 16px; }
.result-card .front-face .card-key { font-size: 14px; }
.card .card-key { font-size: 11px; line-height: 1.4; color: rgba(21, 61, 74, .8); }
.card.open .back { transform: rotateY(180deg); }
.card.open .front-face { transform: rotateY(0); }
.card.picked { transform: translateY(-6px); outline: 4px solid var(--gold); outline-offset: 0; }
.cards.has-pick .card:not(.picked) { opacity: .58; }
@media (hover: hover) { .card:hover { transform: translateY(-2px); } }
.card.chosen { width: 124px; margin: 32px auto 24px; cursor: default; transform: none; }
.card.front { cursor: default; transform: none; }
.card.front .back { display: none; }
.card.front .front-face { transform: none; }
.result-card { width: 108px; margin: 20px auto 8px; }
@media (prefers-reduced-motion: reduce) { .card .back, .card .front-face, .card { transition: none; } }

/* 読み中 */
.sui-wait { font-family: var(--font-hand); font-size: 17px; text-align: center; margin: 12px 0 8px; min-height: 2.4em; }
.deco-stars { width: 108px; margin: 0 auto; opacity: .65; }

/* 読みの手紙 (上・中・下の 3 枚) */
.letter { position: relative; margin: 24px 0 24px; padding: 0 20px; background: url("/img/parts/letter-middle.webp") center top / 100% auto repeat-y; filter: drop-shadow(0 10px 26px rgba(52, 77, 86, .12)); }
.letter::before, .letter::after { content: ""; display: block; width: 100%; }
.letter::before { aspect-ratio: 1200 / 240; background: url("/img/parts/letter-top.webp") center / 100% 100% no-repeat; margin: 0 -20px; width: calc(100% + 40px); }
.letter::after { aspect-ratio: 1200 / 260; background: url("/img/parts/letter-bottom.webp") center / 100% 100% no-repeat; margin: 0 -20px; width: calc(100% + 40px); }
.letter-head { display: flex; align-items: center; gap: 12px; margin: -30px 0 14px 0; }
.letter-head .plaque-name { margin-left: 8px; }
.reading { white-space: pre-wrap; font-size: 16px; line-height: 2; letter-spacing: .045em; margin: 0 0 12px; padding: 0 4px; }
.letter-foot { font-size: 13px; color: var(--sub); margin: 0 0 4px; }

.dream-detail { padding: 10px 16px; }
.dream-detail summary { cursor: pointer; min-height: 28px; font-weight: 700; }
.dream-detail p { white-space: pre-wrap; margin: 8px 0 0; color: var(--sub); font-size: 15px; }

/* 会話 */
#talk { margin-top: 24px; }
.talk-log { display: grid; gap: 14px; margin: 24px 0 12px; }
.bubble { display: flex; gap: 8px; align-items: flex-start; max-width: 92%; }
.bubble.user { justify-self: end; max-width: 84%; }
.bubble .body { padding: 10px 14px; font-size: 15px; line-height: 1.8; white-space: pre-wrap; border: 1px solid rgba(21, 61, 74, .12); }
.bubble.sui .body { background: var(--cloud); border-radius: 4px 16px 16px 16px; font-family: var(--font-hand); font-size: 16px; }
.bubble.user .body { background: #eef7fa; border: 1px solid rgba(21, 61, 74, .22); border-radius: 16px 4px 16px 16px; }
.talk-form { display: flex; gap: 8px; align-items: flex-end; }
.talk-form textarea { flex: 1; min-height: 96px; border: 1px solid #a9bcc1; border-radius: 12px; padding: 10px 12px; background: rgba(255, 255, 255, .8); resize: vertical; }
.talk-form .btn { min-width: 72px; width: 72px; height: 48px; }
.talk-form textarea { padding: 14px; line-height: 1.6; }
#talk-left { margin: 24px 0 12px; }
.talk-form { margin-bottom: 24px; }
.cloud-note { background: var(--cloud); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; text-align: center; font-family: var(--font-hand); }

/* 運営の札 (スイと分ける) */
.operator { position: relative; margin: 24px 0 0; padding: 18px; background: var(--cloud); border: 1px solid rgba(215, 166, 58, .55); border-radius: 14px; font-size: 14px; line-height: 1.8; }
.operator .from { display: block; font-size: 12px; font-weight: 700; color: var(--sub); margin-bottom: 4px; }
.operator p { margin: 0 0 6px; }
.operator .price { font-weight: 700; margin: 0 0 10px; }
.operator .btn.secondary { height: 42px; }

/* 日記 (月の足跡) */
.month-row { display: flex; align-items: center; justify-content: center; gap: 0; height: 48px; margin: 0 0 12px; }
.month-btn { width: 40px; height: 40px; border: 0; background: none; font-size: 24px; color: var(--ink); cursor: pointer; }
.month-select { border: 0; background: none; font-size: 16px; font-weight: 700; text-align: center; padding: 8px; }
.timeline { list-style: none; margin: 0; padding: 20px 18px 20px 38px; background: rgba(255, 249, 238, .92); border: 1px solid var(--line); border-radius: 16px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 24px; top: 20px; bottom: 20px; width: 1px; background: rgba(21, 61, 74, .35); }
.timeline li { position: relative; padding: 14px 0 14px 20px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.timeline li::before { content: ""; position: absolute; left: -18px; top: 24px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.timeline li:last-child { border-bottom: 0; }
.timeline .meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.timeline .meta .plaque-name { width: 92px; }
.timeline .meta .plaque-name .inner { font-size: 12px; }
.timeline .excerpt { font-size: 15px; line-height: 1.75; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.timeline li.open .excerpt { display: block; -webkit-line-clamp: unset; white-space: pre-wrap; }
.timeline .sub { font-size: 12px; color: var(--sub); margin-top: 4px; }
.empty { text-align: center; padding: 24px 0; }
.empty .face-frame { margin: 0 auto 8px; }
.empty p { margin: 0 0 12px; }
.intro { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; font-size: 15px; }

/* 設定 */
.plans { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin: 10px 0; }
.plan { border: 1px solid rgba(21, 61, 74, .28); border-radius: 14px; padding: 12px; background: #fff; text-align: center; cursor: pointer; }
.plan strong { display: block; font-size: 20px; }
.plan small { color: var(--sub); font-size: 12px; }
.fold { margin: 16px 0 16px; }
.fold summary { padding: 8px 0; }
.fold summary { cursor: pointer; font-size: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 8px 0; font-size: 14px; align-items: center; }
.kv dt { color: var(--sub); }
.kv dd { margin: 0; }
.kv code { font-family: ui-monospace, Menlo, monospace; user-select: all; }
.links a { color: var(--sub); }
.foot { text-align: center; color: var(--sub); font-size: 12px; padding: 16px 0 8px; }
.foot a { color: var(--sub); }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 9; max-width: 90vw; }

/* 小さなページ (login / billing) */
body.plain .narrow { max-width: 420px; margin: 10vh auto; padding: 0 16px; text-align: center; }
.face { width: 96px; height: 96px; border-radius: 50%; border: 3px solid var(--gold); margin: 0 auto 12px; }
.h { font-size: 20px; }
