/* kidsAI：あかるい ひるの そら色を ベースに、アプリは 大きな タイルで ならべる。おはなし工房は 紙の絵本を ひらく レイアウト。
   子ども向けの画面は 1 テーマ（明るい色）に固定。保護者向けは 落ち着いた 文字組み。 */
@font-face { font-family: "Zen Maru Gothic"; font-weight: 500; font-display: swap; src: url(/fonts/zen-maru-gothic-kana-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Zen Maru Gothic"; font-weight: 700; font-display: swap; src: url(/fonts/zen-maru-gothic-kana-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Kiwi Maru"; font-weight: 500; font-display: swap; src: url(/fonts/kiwi-maru-kana-500-normal.woff2) format("woff2"); }

:root {
  color-scheme: light;
  --sky: #dff1fb;
  --sky-2: #c3e4f6;
  --paper: #fffdf7;
  --ink: #26354a;
  --muted: #6d7a8c;
  --sun: #ffc93c;
  --sun-ink: #4a3300;
  --coral: #ff8a65;
  --leaf: #4fae6a;
  --line: #e8e0cc;
  --danger: #c8412e;
  --kid: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic", sans-serif;
  --display: "Kiwi Maru", "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic", sans-serif;
  --adult: system-ui, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, var(--sky) 0%, var(--sky-2) 100%) fixed;
  background-color: var(--sky);
  color: var(--ink);
  font-family: var(--kid);
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
#app {
  min-height: 100%;
  display: flex; flex-direction: column;
  max-width: 860px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(10px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
}
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---------- ヘッダー・フッター */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px 0; cursor: pointer; font-family: var(--display); font-size: 20px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: block; }
.bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.brand-name { font-family: var(--adult); font-weight: 800; letter-spacing: .01em; font-size: 22px; }
.app-chip { max-width: 13em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 700; background: var(--paper); border-radius: 999px; padding: 4px 12px; box-shadow: inset 0 0 0 2px var(--line); }
.who { font-size: 15px; color: var(--muted); white-space: nowrap; }
.bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.mini-btn { font: 600 13px var(--adult); color: var(--ink); background: var(--paper); border: 0; border-radius: 999px; padding: 7px 12px; cursor: pointer; box-shadow: inset 0 0 0 2px var(--line); white-space: nowrap; }
.mini-btn:hover { box-shadow: inset 0 0 0 2px #cfc3a5; }

/* ---------- アプリ一覧 */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.app-tile .pic { aspect-ratio: 16 / 10; }
.app-tile:disabled { cursor: default; transform: none; }
.app-tile:disabled .pic { filter: grayscale(.55); opacity: .7; }
.badge { align-self: flex-start; margin: -2px 6px 4px; font-size: 14px; font-weight: 700; background: #fff6d6; color: var(--sun-ink); border-radius: 999px; padding: 4px 12px; }
.badge.off { background: #eef1f5; color: var(--muted); }
.app-rows { display: flex; flex-direction: column; }
.app-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid #eee6d2; }
.app-row:first-child { border-top: 0; }
.app-row-name { display: flex; flex-direction: column; min-width: 0; }
.adult .btn.switch { min-width: 76px; }
.adult .btn.switch[aria-checked="true"] { background: var(--leaf); color: #fff; }
main { flex: 1; outline: none; }
[data-stage="test"] .foot-note { color: var(--danger); font-weight: 600; }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 22px 0 4px; font-family: var(--adult); font-size: 13px; color: var(--muted); }
.link-btn { background: none; border: 0; padding: 8px 0; text-decoration: underline; cursor: pointer; font-family: var(--adult); font-size: 14px; color: var(--ink); }

/* ---------- 子ども向けの大きなボタンとカード */
.kid-title { font-family: var(--display); font-weight: 500; font-size: clamp(24px, 5vw, 34px); margin: 4px 0 18px; text-wrap: balance; }
.kid-sub { font-size: 18px; color: var(--muted); margin: -8px 0 18px; }
.big-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.big {
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
  background: var(--paper); border: 0; border-radius: 22px; padding: 14px; cursor: pointer; text-align: left;
  box-shadow: 0 4px 0 var(--line), 0 10px 24px rgba(38, 53, 74, .12);
  transition: transform .15s;
}
.big:hover { transform: translateY(-3px); }
.big:active { transform: translateY(1px); }
.big .pic { aspect-ratio: 16 / 10; border-radius: 14px; overflow: hidden; background: var(--sky); }
.big .pic svg { width: 100%; height: 100%; display: block; }
.big .label { font-size: 24px; font-weight: 700; padding: 0 6px 4px; }
.big .note { font-size: 15px; color: var(--muted); padding: 0 6px 4px; margin-top: -8px; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 620px) { .cards { grid-template-columns: 1fr; } }
.cards .big .label { font-size: 22px; }

.pill-btn {
  font-weight: 700; font-size: 18px; border: 0; border-radius: 999px; padding: 14px 24px; cursor: pointer;
  background: var(--paper); box-shadow: inset 0 0 0 3px var(--line);
}
.pill-btn.primary { background: var(--sun); color: var(--sun-ink); box-shadow: inset 0 -4px 0 #e8a800; }
.pill-btn:disabled { opacity: .4; cursor: default; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.back { margin-bottom: 14px; }

/* ---------- 絵本 */
.book { background: var(--paper); border-radius: 14px 14px 18px 18px; overflow: hidden; box-shadow: 0 2px 0 var(--line), 0 6px 0 #ddd2b6, 0 16px 34px rgba(38, 53, 74, .18); }
.art { aspect-ratio: 16 / 10; width: 100%; max-width: 100%; background: var(--sky); }
.art svg { width: 100%; height: 100%; display: block; }
.text { padding: 20px clamp(18px, 4vw, 34px) 16px; display: flex; flex-direction: column; gap: 14px; min-height: 9em; }
.text p { margin: 0; font-size: clamp(20px, 3.8vw, 25px); line-height: 1.9; letter-spacing: .04em; }
.text .title { font-family: var(--display); font-size: clamp(26px, 5vw, 34px); line-height: 1.5; }
.text .credit { font-size: 15px; color: var(--muted); }
.question { font-family: var(--display); color: #2e6b9a; }
.choices { display: flex; gap: 12px; flex-wrap: wrap; }
.choice { flex: 1 1 220px; font-weight: 700; font-size: 19px; background: #fff; border: 3px solid var(--line); border-radius: 16px; padding: 16px; cursor: pointer; text-align: left; transition: transform .15s, border-color .15s; }
.choice:hover { transform: translateY(-2px); border-color: var(--sun); }
.chosen { font-size: 16px; color: var(--muted); }
.chosen b { color: var(--ink); }
.pageno { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--adult); }
.controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dots span { width: 9px; height: 9px; border-radius: 50%; background: rgba(38, 53, 74, .18); }
.dots span.on { background: var(--coral); }
.thinking { display: flex; align-items: center; gap: 14px; font-size: 20px; color: var(--muted); }
.thinking .dot3 span { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--sun); margin: 0 3px; animation: hop 1s ease-in-out infinite; }
.thinking .dot3 span:nth-child(2) { animation-delay: .15s; }
.thinking .dot3 span:nth-child(3) { animation-delay: .3s; }
.end-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- 作成中 */
.loading { display: grid; place-items: center; gap: 18px; padding: 30px 0; text-align: center; }
.loading .pic { width: min(360px, 80vw); aspect-ratio: 16 / 10; border-radius: 20px; overflow: hidden; animation: hop 1.2s ease-in-out infinite; }
.loading .pic svg { width: 100%; height: 100%; display: block; }
.loading p { font-size: 22px; margin: 0; }

/* ---------- 本棚 */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.shelf .big .label { font-size: 18px; }
.empty { background: var(--paper); border-radius: var(--radius); padding: 26px; font-size: 19px; line-height: 1.8; }

/* ---------- 保護者向け */
.adult { font-family: var(--adult); font-weight: 400; line-height: 1.75; }
.adult h1 { font-size: 22px; margin: 4px 0 14px; }
.adult h2 { font-size: 17px; margin: 0 0 8px; }
.panel { background: var(--paper); border-radius: var(--radius); padding: 20px clamp(16px, 4vw, 26px); box-shadow: 0 2px 0 var(--line); }
.panels { display: flex; flex-direction: column; gap: 14px; }
.adult p { margin: 0 0 10px; max-width: 65ch; }
.adult ul { margin: 0 0 10px; padding-left: 1.3em; max-width: 65ch; }
.adult .btn { font-family: var(--adult); font-size: 16px; font-weight: 600; border: 0; border-radius: 10px; padding: 12px 18px; cursor: pointer; background: #eef2f6; color: var(--ink); }
.adult .btn.primary { background: var(--ink); color: #fff; }
.adult .btn.danger { background: var(--danger); color: #fff; }
.adult .btn:disabled { opacity: .45; cursor: default; }
.adult label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 16px; cursor: pointer; }
.adult label.check input { width: 22px; height: 22px; margin-top: 3px; flex: none; }
.adult input[type="text"], .adult input[type="password"], .adult input[inputmode] { font: 600 20px var(--adult); padding: 10px 12px; border: 2px solid #cfd8e3; border-radius: 10px; width: 100%; max-width: 320px; letter-spacing: .08em; }
.code { font: 700 clamp(22px, 6vw, 30px) ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: .12em; background: #f3f6f9; border-radius: 10px; padding: 12px 16px; display: inline-block; user-select: all; }
.err { color: var(--danger); font-weight: 600; }
.meta { color: var(--muted); font-size: 14px; }
.stat { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; gap: 4px; padding: 4px; background: #eef2f6; border-radius: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.seg button { font: 600 15px var(--adult); border: 0; background: transparent; padding: 9px 14px; border-radius: 9px; cursor: pointer; color: var(--ink); }
.seg button[aria-checked="true"] { background: #fff; box-shadow: 0 1px 3px rgba(38, 53, 74, .18); }
.adult input.nick-in { font-family: var(--kid); font-weight: 700; font-size: 22px; letter-spacing: .06em; }
.nick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .nick-grid { grid-template-columns: 1fr; } }
.nick { font-family: var(--kid); font-size: 20px; font-weight: 700; padding: 14px 10px; border-radius: 14px; border: 3px solid var(--line); background: #fff; cursor: pointer; }
.nick[aria-pressed="true"] { border-color: var(--sun); background: #fff6d6; }
.ages { display: flex; gap: 10px; flex-wrap: wrap; }
.age { font-family: var(--kid); font-size: 18px; font-weight: 700; padding: 12px 18px; border-radius: 999px; border: 3px solid var(--line); background: #fff; cursor: pointer; }
.age[aria-pressed="true"] { border-color: var(--sun); background: #fff6d6; }
.age:disabled { opacity: .45; cursor: default; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-family: var(--adult); font-size: 15px; z-index: 20; max-width: calc(100% - 32px); }
.noscript { padding: 24px; font-family: var(--adult); }

/* ---------- 絵の中のうごき */
.twinkle { animation: tw 2.4s ease-in-out infinite; }
.float, .drift { animation: fl 3.2s ease-in-out infinite; }
.flit { animation: flit 2.6s ease-in-out infinite; }
.rise { animation: rise 5s linear infinite; }
.glow { animation: tw 2.6s ease-in-out infinite; }
.sway { animation: sway 3.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes tw { 50% { opacity: .35; } }
@keyframes fl { 50% { transform: translateY(-8px); } }
@keyframes flit { 50% { transform: translate(14px, -10px); } }
@keyframes rise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-120px); opacity: 0; } }
@keyframes sway { 50% { transform: rotate(6deg); } }
@keyframes hop { 50% { transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) {
  .twinkle, .float, .drift, .flit, .rise, .glow, .sway, .loading .pic, .thinking .dot3 span { animation: none; }
  .big, .choice { transition: none; }
}

/* ---------- プライバシーポリシー・利用規約・運営者情報 */
a.brand { color: inherit; text-decoration: none; }
.adult a { color: #1f6aa5; }
.legal .panel { max-width: 760px; }
.legal h1 { font-size: 24px; }
.legal h2 { font-size: 18px; margin: 26px 0 8px; padding-top: 14px; border-top: 1px solid #eee6d2; }
.legal ol { margin: 0 0 10px; padding-left: 1.5em; max-width: 65ch; }
.legal li { margin-bottom: 4px; }
.data-table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: 15px; }
.data-table th, .data-table td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid #eee6d2; }
.data-table thead th { background: #f3f6f9; font-weight: 600; }
.data-table thead + tbody td:first-child { width: 8.5em; min-width: 6em; font-weight: 600; }
.data-table tbody th { width: 9em; font-weight: 600; white-space: nowrap; }
@media (max-width: 520px) { .data-table tbody th { white-space: normal; width: 6.5em; } }
.legal-links { display: flex; gap: 14px; flex-wrap: wrap; }
.legal-links a { color: var(--ink); font-family: var(--adult); font-size: 13px; }

/* ---------- フォニックスえいごであそぼう */
.ph-latin { font-family: "Andika", "Century Gothic", "Avenir Next", "Nunito", "Segoe UI", system-ui, sans-serif; }
.ph-menu .ph-pic { display: flex; align-items: center; justify-content: center; gap: 10px; background: #e6f4e8; font-size: clamp(34px, 7vw, 52px); }
.ph-pic-letters { font-family: "Andika", "Century Gothic", "Avenir Next", system-ui, sans-serif; font-weight: 700; color: #2f6b45; letter-spacing: .04em; }
.ph-pic-muu svg { width: 100%; height: 100%; display: block; }
.ph-talk { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.ph-avatar { flex: none; width: 72px; height: 72px; border-radius: 18px; overflow: hidden; box-shadow: 0 2px 0 var(--line); }
.ph-avatar img { width: 100%; height: 100%; display: block; }
.ph-bubble { flex: 1; min-width: 0; background: var(--paper); border-radius: 4px 20px 20px 20px; padding: 14px 18px; box-shadow: 0 2px 0 var(--line), 0 8px 18px rgba(38, 53, 74, .08); display: flex; flex-direction: column; gap: 8px; }
.ph-say { margin: 0; font-size: clamp(19px, 3.6vw, 23px); line-height: 1.7; letter-spacing: .03em; }
.ph-inline-letter { font-family: "Andika", "Century Gothic", "Avenir Next", system-ui, sans-serif; font-size: 1.4em; color: #2f6b45; }
.ph-stars { margin: 4px 0 0; font-size: 34px; letter-spacing: .1em; }
.ph-progress { margin: 0 0 8px; font-family: var(--adult); color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.ph-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.ph-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px 12px; background: #fff; border: 4px solid var(--line); border-radius: 20px; cursor: pointer; transition: transform .15s, border-color .15s; }
.ph-card:hover { transform: translateY(-2px); border-color: var(--sun); }
.ph-card.ok { border-color: var(--leaf); background: #eaf7ec; transform: scale(1.04); }
.ph-card.ng { animation: shake .4s; }
.ph-card:disabled { cursor: default; }
.ph-emoji { font-size: clamp(48px, 12vw, 76px); line-height: 1.1; }
.ph-word { font-family: "Andika", "Century Gothic", "Avenir Next", system-ui, sans-serif; font-size: 20px; font-weight: 700; color: var(--ink); }
.ph-fb { min-height: 1.8em; margin: 14px 0 6px; font-size: 22px; font-weight: 700; color: #2f6b45; text-align: center; }
.ph-letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px; margin-top: 18px; }
.ph-letter { aspect-ratio: 1; font-family: "Andika", "Century Gothic", "Avenir Next", system-ui, sans-serif; font-size: 34px; font-weight: 700; color: #2f6b45; background: #fff; border: 3px solid var(--line); border-radius: 16px; cursor: pointer; }
.ph-letter:nth-child(4n+2) { color: #b06a00; } .ph-letter:nth-child(4n+3) { color: #2e6b9a; } .ph-letter:nth-child(4n) { color: #c94f6a; }
.ph-letter.on { border-color: var(--sun); background: #fff6d6; }
.ph-focus { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; background: var(--paper); border-radius: 22px; padding: 18px 22px; box-shadow: 0 4px 0 var(--line); }
.ph-focus .pill-btn { grid-column: 1 / -1; justify-self: start; }
.ph-big-letter { font-family: "Andika", "Century Gothic", "Avenir Next", system-ui, sans-serif; font-size: clamp(84px, 20vw, 130px); font-weight: 700; line-height: 1; color: #2f6b45; display: flex; align-items: baseline; gap: 10px; }
.ph-upper { font-size: .45em; color: var(--muted); }
.ph-focus-word { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.ph-tiles { display: flex; justify-content: center; gap: 12px; margin: 10px 0 16px; }
.ph-tile { width: clamp(70px, 20vw, 100px); aspect-ratio: 1; font-family: "Andika", "Century Gothic", "Avenir Next", system-ui, sans-serif; font-size: clamp(44px, 12vw, 64px); font-weight: 700; color: var(--ink); background: #fff; border: 4px solid var(--line); border-radius: 18px; cursor: pointer; transition: transform .15s, background .15s; }
.ph-tile.on { background: #fff6d6; border-color: var(--sun); transform: translateY(-4px); }
.ph-center { justify-content: center; text-align: center; margin: 6px 0 4px; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (max-width: 420px) { .ph-avatar { width: 56px; height: 56px; } .ph-choices { gap: 8px; } .ph-card { padding: 12px 4px 10px; } .ph-word { font-size: 17px; } }
@media (prefers-reduced-motion: reduce) { .ph-card, .ph-tile { transition: none; } .ph-card.ng { animation: none; } }

/* ---------- フォニックス音声の聞き比べ */
.check-rows { display: flex; flex-direction: column; }
.check-row { display: grid; grid-template-columns: 9em 1fr; gap: 6px 14px; padding: 12px 0; border-top: 1px solid #eee6d2; align-items: center; }
.check-letter { display: flex; flex-direction: column; grid-row: span 2; }
.check-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.check-btns .btn { padding: 8px 12px; font-size: 15px; }
.check-pick { display: flex; gap: 14px; flex-wrap: wrap; font-size: 15px; }
.check-pick input { width: 18px; height: 18px; vertical-align: -3px; }
.legal textarea { width: 100%; font: 15px ui-monospace, Menlo, Consolas, monospace; padding: 10px; border: 2px solid #cfd8e3; border-radius: 10px; }
@media (max-width: 520px) { .check-row { grid-template-columns: 1fr; } .check-letter { grid-row: auto; flex-direction: row; align-items: center; gap: 12px; } }
