/* ストーリーチャット（自前版）テーマ：ダーク＋オレンジ→紫グラデ＋金 */
@font-face {
  font-family: "HakkouMincho";
  src: url("assets/hakkou.woff2") format("woff2");
  font-display: swap;
}
:root {
  --bg: #12101d;
  --bg2: #1a1729;
  --card: #221e36;
  --card2: #2a2545;
  --line: #38335a;
  --text: #f2eefc;
  --sub: #a49cc4;
  --gold: #d9b36c;
  --grad: linear-gradient(100deg, #ff9a5c, #c86dd7 60%, #8a5cf6);
  --danger: #e5536b;
  --nav-h: 64px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  line-height: 1.75;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; }
img { display: block; }
.font-headline { font-family: "Shippori Mincho", "HakkouMincho", "Hiragino Mincho ProN", Meiryo, serif; }

.screen { padding: 16px 16px calc(var(--nav-h) + 28px); max-width: 720px; margin: 0 auto; min-height: 100dvh; }
.screen.no-nav { padding-bottom: 24px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 6px 0 12px; position: sticky; top: 0; background: linear-gradient(var(--bg) 82%, transparent); z-index: 5; }
.topbar .title { font-size: 18px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { width: 42px; height: 42px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-size: 18px; flex: none; }
.iconbtn.danger { color: var(--danger); }

/* ヒーロー帯 */
.hero { position: relative; overflow: hidden; border-radius: 0 0 24px 24px; margin: -16px -16px 8px; padding: 64px 20px 52px; background: radial-gradient(120% 150% at 15% 0%, #4a2c1a 0%, transparent 55%), radial-gradient(120% 160% at 90% 10%, #352058 0%, transparent 55%), #16132a; }
.hero .stars { position: absolute; inset: 0; pointer-events: none; }
.hero .stars i { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #ffeec9; opacity: .7; animation: tw 2.8s ease-in-out infinite; }
@keyframes tw { 0%,100% { opacity: .15; } 50% { opacity: .85; } }
.hero .orn { display: flex; align-items: center; gap: 10px; }
.hero .orn .bar { height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); flex: 0 0 64px; }
.hero .orn .bar.r { background: linear-gradient(90deg, var(--gold), transparent); flex-basis: 24px; }
.hero .orn .dia { color: var(--gold); font-size: 12px; }

.section-title { font-size: 19px; font-weight: 700; margin: 26px 0 12px; display: flex; align-items: baseline; gap: 10px; }
.section-title .more { margin-left: auto; font-size: 13px; color: var(--sub); font-weight: 400; }
.fold-head { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 4px 0; }
.fold-head .cnt { color: var(--sub); font-size: 14px; }
.fold-head .chev { margin-left: auto; color: var(--sub); }

/* 棚 */
.shelf { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.shelf::-webkit-scrollbar { display: none; }
.shelf .cover { flex: 0 0 108px; width: 108px; }
.shelf .cover .img { width: 108px; height: 144px; border-radius: 14px; object-fit: cover; background: var(--card); }
.shelf .cover .ph { width: 108px; height: 144px; border-radius: 14px; }
.shelf .cover .nm { margin-top: 6px; font-size: 13px; line-height: 1.4; }
.shelf .cover .sub2 { font-size: 11px; color: var(--gold); line-height: 1.4; }
.shelf .cover .tag2 { font-size: 11px; color: var(--sub); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* リスト・グリッド */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid .cover .img, .grid .cover .ph { width: 100%; aspect-ratio: 3/4; height: auto; border-radius: 14px; object-fit: cover; background: var(--card); }
.grid .cover .nm { margin-top: 6px; font-size: 13px; line-height: 1.4; }
.grid .cover .sub2 { font-size: 11px; color: var(--gold); }
.grid .cover .tag2 { font-size: 11px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 16px; padding: 12px; width: 100%; text-align: left; }
.row + .row { margin-top: 10px; }
.row .avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex: none; }
.row .ph { width: 52px; height: 52px; border-radius: 50%; flex: none; }
.row .main { flex: 1; min-width: 0; }
.row .nm { font-weight: 600; }
.row .prev { color: var(--sub); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .time { color: var(--sub); font-size: 12px; flex: none; }
.pinmark { color: #b78ef7; font-size: 13px; }
.searchbar { display: flex; gap: 8px; margin: 8px 0 14px; }
.searchbar input { flex: 1; }
.chip { border: 1px solid var(--line); background: var(--bg2); color: var(--sub); border-radius: 999px; padding: 6px 14px; font-size: 13px; }
.chip.on { background: var(--grad); color: #fff; border: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; padding: 12px 22px; font-weight: 600; background: var(--card2); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 24px rgba(200, 109, 215, .35); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.bottombar { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 12px 0 calc(6px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }

/* フォーム */
.field { margin: 14px 0; }
.field label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--sub); margin-top: 4px; }
textarea.fixed-profile { height: 45vh; resize: none; }
input[type="range"] { padding: 0; border: none; background: transparent; }
input[type="color"] { padding: 2px; height: 42px; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; inset: 0; }
.switch .tr { position: absolute; inset: 0; background: var(--card2); border-radius: 999px; transition: .2s; pointer-events: none; }
.switch .tr::after { content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + .tr { background: #ff8a3d; }
.switch input:checked + .tr::after { left: 25px; }
.setrow { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 16px; padding: 14px; }
.setrow + .setrow { margin-top: 10px; }
.setrow .tx { flex: 1; }
.setrow .tx .t { font-weight: 600; }
.setrow .tx .d { color: var(--sub); font-size: 13px; }

/* 下部ナビ */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(22, 19, 40, .94); backdrop-filter: blur(10px); display: flex; z-index: 40; border-top: 1px solid rgba(255,255,255,.05); }
.tabbar.hide { display: none; }
.tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--sub); font-size: 11px; }
.tabbar .tab .ic { font-size: 20px; line-height: 1; }
.tabbar .tab.on { color: #ffb37a; }
.tabbar .fab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; color: var(--sub); font-size: 11px; padding-bottom: 6px; }
.tabbar .fab .ball { width: 52px; height: 52px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 26px; display: grid; place-items: center; margin-top: -26px; box-shadow: 0 8px 24px rgba(200, 109, 215, .45); }

/* チャット */
.chatwrap { display: flex; flex-direction: column; height: 100dvh; max-width: 720px; margin: 0 auto; }
.chathead { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: rgba(18,16,29,.92); backdrop-filter: blur(8px); z-index: 5; }
.chathead .avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.chathead .ph { width: 38px; height: 38px; border-radius: 50%; }
.chathead .nm { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatbody { flex: 1; overflow-y: auto; padding: 14px 14px 8px; overscroll-behavior: contain; }
.msg { margin: 10px 0; display: flex; gap: 8px; }
.msg .avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; margin-top: 2px; }
.msg .ph { width: 34px; height: 34px; border-radius: 50%; flex: none; margin-top: 2px; }
.msg .col { max-width: 82%; }
.msg .who { font-size: 12px; color: var(--sub); margin-bottom: 3px; }
.bubble { background: var(--card); border-radius: 4px 16px 16px 16px; padding: 9px 13px; white-space: pre-wrap; word-break: break-word; }
.msg.me { justify-content: flex-end; }
.msg.me .bubble { background: var(--grad); color: #fff; border-radius: 16px 4px 16px 16px; }
.msg.me .bubble .ast { opacity: .55; }
.narration { background: rgba(38, 33, 66, .55); border-radius: 14px; padding: 11px 14px; margin: 10px 0; line-height: 1.9; }
.typing { color: var(--sub); font-size: 13px; padding: 6px 2px; }
.tobottom { position: absolute; right: 16px; bottom: 86px; width: 40px; height: 40px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; box-shadow: 0 4px 16px rgba(0,0,0,.4); z-index: 6; }
.chatinput { position: relative; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(18,16,29,.95); }
.chatinput .rowin { display: flex; gap: 8px; align-items: flex-end; }
.chatinput textarea { flex: 1; max-height: 120px; border-radius: 18px; }
.sendbtn { width: 44px; height: 44px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 18px; flex: none; display: grid; place-items: center; }
.toolrow { display: flex; gap: 6px; margin-bottom: 6px; }
.toolrow .chip { padding: 4px 10px; font-size: 12px; }
.genver { display: flex; align-items: center; gap: 8px; color: var(--sub); font-size: 12px; margin: 2px 0 6px; }
.genver button { color: var(--sub); padding: 2px 6px; }

/* 詳細・カード */
.banner { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 18px; background: var(--card); }
.kv { background: var(--card); border-radius: 16px; padding: 14px; margin-top: 12px; }
.kv .k { color: var(--sub); font-size: 12px; }
.kv .v { white-space: pre-wrap; word-break: break-word; }
.secret-cat { color: var(--gold); font-size: 13px; margin-top: 10px; }
.modal-veil { position: fixed; inset: 0; background: rgba(5,4,12,.7); display: grid; place-items: end center; z-index: 60; }
.modal { background: var(--bg2); width: 100%; max-width: 720px; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 86dvh; overflow-y: auto; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 22px); background: var(--card2); color: var(--text); padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 80; box-shadow: 0 8px 28px rgba(0,0,0,.5); }
.empty { color: var(--sub); text-align: center; padding: 34px 10px; }
a { color: #cfa7ff; }
.small { font-size: 13px; color: var(--sub); }
.mt { margin-top: 14px; }
