@import url('https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@500;700&family=M+PLUS+Rounded+1c:wght@500;700&display=swap');

:root {
  --yellow: #F5E23F;
  --yellow-deep: #F3D200;
  --yellow-soft: #FDF6D6;
  --ink: #33302B;
  --ink-soft: #6B665C;
  --muted: #A8A296;
  --bubble: #FFFFFF;
  --bubble-border: #EDE9DD;
  --bg: #FFFDF4;
  --shadow: 0 2px 8px rgba(0, 0, 0, .06);
  --radius: 18px;
  --maxw: 760px;
  font-family: "Hiragino Maru Gothic ProN", "Zen Maru Gothic", "M PLUS Rounded 1c", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: var(--maxw); margin: 0 auto; background: var(--bg); position: relative; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: #fff; position: sticky; top: 0; z-index: 10; box-shadow: 0 1px 0 var(--bubble-border), var(--shadow); }
.brand { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: center; cursor: default; }
.brand-title { font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; }
.brand-logo { height: 30px; width: auto; display: block; }
.ic { display: inline-block; line-height: 0; }
.ic svg { display: block; width: 100%; height: 100%; }
.icon-btn { border: none; background: transparent; font-size: 1.3rem; cursor: pointer; color: var(--ink); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(0, 0, 0, .06); }
.back-btn { font-size: 2rem; line-height: 1; }

/* view */
.view { flex: 1; overflow-y: auto; padding: 16px 14px 24px; }
.view.sec-bg { background: var(--yellow); }
.crumb { font-size: .8rem; color: var(--muted); margin-bottom: 12px; }

/* home tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--bubble); border: 2px solid transparent; border-radius: var(--radius); padding: 18px 14px; cursor: pointer; text-align: center; transition: transform .08s, box-shadow .12s, border-color .12s; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, .1); border-color: var(--yellow-deep); }
.tile .tile-ic { width: 42px; height: 42px; color: var(--ink); }
.tile .label { font-weight: 700; }
.tile .count { font-size: .78rem; color: var(--muted); }
.tile.accent { background: var(--yellow); border-color: var(--yellow-deep); }
.home-section-title { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink-soft); margin: 22px 2px 12px; font-size: .95rem; }
.home-section-title:first-child { margin-top: 4px; }
.home-section-title .ic { width: 18px; height: 18px; }

/* コンテンツカード（トップページ：アイコン＋タイトル＋説明） */
.ccard-list { display: flex; flex-direction: column; gap: 12px; }
.ccard { display: flex; align-items: center; gap: 14px; width: 100%; background: #fff; border: none; border-radius: 18px; padding: 17px 16px; cursor: pointer; box-shadow: var(--shadow); font-family: inherit; text-align: left; transition: transform .08s; }
.ccard:hover { transform: translateY(-1px); }
.ccard .cc-ic { width: 34px; height: 34px; flex: none; color: var(--yellow-deep); display: grid; place-items: center; }
.ccard .cc-ic svg { width: 30px; height: 30px; }
.ccard .cc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ccard .cc-title { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.ccard .cc-desc { font-size: .8rem; color: var(--muted); line-height: 1.45; }
.ccard .chev { flex: none; color: var(--yellow-deep); font-size: 1.3rem; font-weight: 700; }

/* タイマー ウィジェット */
.timer-widget { background: #fff; border-radius: 18px; padding: 18px 16px; box-shadow: var(--shadow); margin-bottom: 14px; text-align: center; }
.tw-display { font-size: 2.6rem; font-weight: 800; color: var(--ink); letter-spacing: 1px; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.tw-presets { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.tw-preset { border: 2px solid var(--bubble-border); background: #fff; border-radius: 999px; padding: 7px 14px; font-family: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; color: var(--ink); }
.tw-preset.on { background: var(--yellow); border-color: var(--yellow-deep); }
.tw-actions { display: flex; gap: 10px; justify-content: center; }
.tw-note { font-size: .78rem; color: var(--muted); margin: 12px 0 0; }

/* category grid */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.cat-card { background: #fff; border: none; border-radius: 14px; padding: 15px 14px; cursor: pointer; font-weight: 700; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 8px; box-shadow: var(--shadow); color: var(--ink); transition: transform .08s; font-family: inherit; font-size: .95rem; }
.cat-card:hover { transform: translateY(-2px); }
.cat-card .cat-n { font-size: .72rem; color: var(--ink-soft); font-weight: 500; }
.cat-card .chev { font-size: 1.15rem; opacity: .6; }

/* カテゴリ選択（黄色背景に白いバー） */
.cat-list { display: flex; flex-direction: column; gap: 10px; }
.catrow { display: flex; align-items: center; gap: 12px; width: 100%; background: #fff; border: none; border-radius: 16px; padding: 16px; cursor: pointer; box-shadow: var(--shadow); font-family: inherit; transition: transform .08s; }
.catrow:hover { transform: translateY(-1px); }
.catrow .ci { width: 22px; height: 22px; color: var(--yellow-deep); flex: none; }
.catrow .cl { flex: 1; text-align: center; font-weight: 700; font-size: 1.02rem; color: var(--ink); }
.catrow .chev { flex: none; width: 22px; text-align: center; color: var(--yellow-deep); font-size: 1.3rem; font-weight: 700; }

/* content list (bubbles) */
.section-head { margin: 2px 2px 14px; font-weight: 700; font-size: 1.05rem; }
.list { display: flex; flex-direction: column; gap: 9px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--bubble); border: 2px solid var(--bubble-border); border-radius: var(--radius); padding: 11px 14px; cursor: pointer; transition: border-color .12s, background .12s; text-align: left; }
.item:hover { border-color: var(--yellow-deep); }
.item.is-playing { border-color: var(--yellow-deep); background: var(--yellow-soft); }
.item .play-ico { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--yellow); display: grid; place-items: center; color: var(--ink); }
.item .play-ico svg { width: 13px; height: 13px; margin-left: 1px; }
.item.is-playing .play-ico { background: var(--yellow-deep); }
.item .meta { flex: 1; min-width: 0; }
.item .title { font-weight: 500; word-break: break-word; line-height: 1.4; }
.item .sub { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.item .dur { font-size: .75rem; color: var(--muted); flex: none; }
.fav { flex: none; border: none; background: transparent; cursor: pointer; color: #D8D3C6; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.fav svg { width: 18px; height: 18px; }
.fav.on { color: var(--yellow-deep); }
.li-add { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--bubble-border); background: #fff; color: var(--ink-soft); font-size: 1rem; font-weight: 700; cursor: pointer; line-height: 1; padding: 0; }
.li-add:hover { border-color: var(--yellow-deep); color: var(--yellow-deep); }
.li-move { flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--bubble-border); background: #fff; color: var(--ink-soft); font-size: .7rem; cursor: pointer; line-height: 1; padding: 0; }
.li-move:hover { border-color: var(--yellow-deep); color: var(--yellow-deep); }

/* プレイリスト / 履歴 / リンクボタン */
.link-btn { margin-left: auto; background: none; border: none; color: var(--yellow-deep); font-family: inherit; font-weight: 700; font-size: .8rem; cursor: pointer; padding: 2px 4px; }
.pl-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.pl-toggle { flex: none; border: 2px solid var(--bubble-border); background: #fff; border-radius: 999px; padding: 7px 14px; font-family: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; color: var(--ink-soft); white-space: nowrap; }
.pl-toggle.on { background: var(--yellow); border-color: var(--yellow-deep); color: var(--ink); }
.pl-actions .pl-play { display: inline-flex; width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px; }
.addto-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.addto-row { width: 100%; justify-content: flex-start; text-align: left; }
.fav:hover { background: rgba(0, 0, 0, .05); }
.item.missing { opacity: .5; }

/* toolbar */
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.search { flex: 1; min-width: 160px; border: 2px solid var(--bubble-border); border-radius: 999px; padding: 9px 16px; font-size: .95rem; font-family: inherit; background: #fff; color: var(--ink); }
.search:focus { outline: none; border-color: var(--yellow-deep); }

/* 下部ツールバー（よびかけ・あいづち・なまえ／音量） */
.toolbar-bottom { background: #fff; border-top: 2px solid var(--bubble-border); padding: 9px 12px calc(11px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.tb-chips { display: flex; gap: 8px; overflow-x: auto; }
.tb-chip { flex: none; border: 2px solid var(--bubble-border); background: #fff; border-radius: 999px; padding: 7px 16px; font-family: inherit; font-weight: 700; font-size: .88rem; cursor: pointer; color: var(--ink); white-space: nowrap; }
.tb-chip:hover { border-color: var(--yellow-deep); }
.tb-free { background: var(--ink); color: #fff; border-color: var(--ink); }
.tb-free:hover { border-color: var(--ink); opacity: .9; }
.tb-volume { display: flex; align-items: center; gap: 8px; }
.tb-volicon { width: 18px; height: 18px; color: var(--ink-soft); flex: none; }
.tb-volume input { flex: 1; accent-color: var(--yellow-deep); }

/* ショートカット編集モーダル */
.sc-modal { max-width: 420px; }
.sc-list { max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.sc-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 2px solid var(--bubble-border); border-radius: 12px; cursor: pointer; }
.sc-row .sc-check { width: 18px; height: 18px; accent-color: var(--yellow-deep); flex: none; }
.sc-prev { flex: none; width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--yellow); cursor: pointer; font-size: .75rem; color: var(--ink); }
.sc-name { flex: 1; font-size: .92rem; }
.sc-label { flex: 1; min-width: 0; border: 2px solid var(--bubble-border); border-radius: 8px; padding: 6px 10px; font-family: inherit; font-size: .95rem; }
.sc-label:focus { outline: none; border-color: var(--yellow-deep); }

/* じゆうにしゃべる モーダル */
.compose-modal { max-width: 440px; }
.compose-area { width: 100%; border: 2px solid var(--bubble-border); border-radius: 12px; padding: 11px 13px; font-family: inherit; font-size: 1rem; line-height: 1.5; resize: vertical; color: var(--ink); box-sizing: border-box; }
.compose-area:focus { outline: none; border-color: var(--yellow-deep); }
.compose-status { min-height: 20px; margin: 10px 2px 4px; font-size: .85rem; color: var(--ink-soft); }
.compose-status.loading::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 7px; border: 2px solid var(--yellow-deep); border-top-color: transparent; border-radius: 50%; vertical-align: -2px; animation: spin .7s linear infinite; }
.compose-status.err { color: #C0392B; }
.compose-status code, .modal-note code { background: var(--yellow-soft); border-radius: 5px; padding: 1px 5px; font-size: .82em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* なまえ 登録／管理モーダル */
.name-modal { max-width: 440px; }
.name-input-row { display: flex; gap: 8px; align-items: center; }
.name-input { width: 100%; box-sizing: border-box; border: 2px solid var(--bubble-border); border-radius: 12px; padding: 11px 14px; font-family: inherit; font-size: 1.05rem; color: var(--ink); }
.name-input:focus { outline: none; border-color: var(--yellow-deep); }
.name-input-row .btn { flex: none; }
.name-status { min-height: 20px; margin: 10px 2px 6px; font-size: .85rem; color: var(--ink-soft); }
.name-status.loading::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 7px; border: 2px solid var(--yellow-deep); border-top-color: transparent; border-radius: 50%; vertical-align: -2px; animation: spin .7s linear infinite; }
.name-status.err { color: #C0392B; }
.name-cands { display: flex; flex-direction: column; gap: 6px; }
.name-cands:not(:empty) { margin-top: 4px; }
.name-cand, .name-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid var(--bubble-border); border-radius: 12px; cursor: pointer; }
.name-cand .nc-radio { width: 18px; height: 18px; accent-color: var(--yellow-deep); flex: none; }
.nc-prev { flex: none; width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--yellow); cursor: pointer; font-size: .75rem; color: var(--ink); }
.nc-label { flex: 1; font-size: 1rem; }
.name-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.name-del { flex: none; width: 28px; height: 28px; border-radius: 50%; border: none; background: transparent; color: var(--muted); font-size: .9rem; cursor: pointer; }
.name-del:hover { color: #C0392B; }
.btn-add { width: 100%; background: var(--yellow-soft); color: var(--ink); border: 2px dashed var(--yellow-deep); margin-bottom: 4px; }
.ccard-list + .btn-add { margin-top: 12px; } /* ホームのプレイリスト一覧と「＋つくる」の間隔 */

/* ホームのタブ（コンテンツ / プレイリスト / おきにいり / りれき） */
.home-tabs { display: flex; gap: 8px; margin: 2px 0 14px; overflow-x: auto; padding-bottom: 2px; }
.home-tab { flex: none; border: none; background: #fff; border-radius: 999px; padding: 8px 18px; font-family: inherit; font-weight: 700; font-size: .95rem; color: var(--ink-soft); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow); }
.home-tab.on { background: var(--ink); color: #fff; }

/* chat / quiz */
.chat { display: flex; flex-direction: column; gap: 12px; padding-bottom: 10px; }
.bubble { max-width: 82%; padding: 12px 16px; border-radius: 18px; line-height: 1.5; box-shadow: var(--shadow); animation: pop .18s ease; }
.bubble.pechat { align-self: flex-start; background: #fff; border: 2px solid var(--bubble-border); border-bottom-left-radius: 5px; }
.bubble.child { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 5px; }
.bubble.system { align-self: center; background: transparent; box-shadow: none; color: var(--muted); font-size: .82rem; padding: 2px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.choices { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 4px; justify-content: center; }
.choice { background: var(--ink); color: #fff; border: none; border-radius: 999px; padding: 12px 22px; font-size: 1rem; font-weight: 700; cursor: pointer; font-family: inherit; transition: transform .08s, opacity .12s; }
.choice:hover { transform: translateY(-2px); }
.choice.sub { background: #fff; color: var(--ink); border: 2px solid var(--bubble-border); }
.choice:disabled { opacity: .4; cursor: default; transform: none; }
.topic-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
/* おしゃべり 話題カード（縦長・グリッド専用） */
.topic-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 104px; background: #fff; border: none; border-radius: 14px; padding: 14px; cursor: pointer; text-align: left; box-shadow: var(--shadow); color: var(--ink); font-family: inherit; transition: transform .08s; }
.topic-card:hover { transform: translateY(-2px); }
.topic-card .tp-label { font-weight: 700; font-size: .95rem; line-height: 1.4; word-break: break-word; }
.topic-card .tp-genre { margin-top: auto; font-size: .72rem; font-weight: 500; color: var(--ink-soft); background: var(--yellow-soft); border-radius: 999px; padding: 3px 10px; }
.chat-tools { display: flex; gap: 8px; justify-content: center; margin-top: 4px; flex-wrap: wrap; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 20px; padding: 22px; max-width: 380px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
.modal h2 { margin: 0 0 8px; }
.modal-note { font-size: .8rem; color: var(--muted); margin: 0 0 16px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-size: .85rem; font-weight: 700; color: var(--ink-soft); }
.field input, .field select { border: 2px solid var(--bubble-border); border-radius: 10px; padding: 10px 12px; font-size: 1rem; font-family: inherit; background: #fff; color: var(--ink); }
.field input:focus, .field select:focus { outline: none; border-color: var(--yellow-deep); }
.seg { display: flex; gap: 6px; margin-top: 2px; }
.seg button { flex: 1; border: 2px solid var(--bubble-border); background: #fff; border-radius: 10px; padding: 10px 4px; font-family: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; color: var(--ink-soft); }
.seg button.on { background: var(--yellow); border-color: var(--yellow-deep); color: var(--ink); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.btn { border: none; border-radius: 999px; padding: 10px 20px; font-weight: 700; cursor: pointer; font-family: inherit; font-size: .95rem; }
.btn-primary { background: var(--yellow); color: var(--ink); }
.btn-ghost { background: #f0ede4; color: var(--ink-soft); }

.error { padding: 30px; text-align: center; color: #c0392b; line-height: 1.6; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
