/* ============================================================
 * rinka-chat.css — りんかとおしゃべり v3（/chat/・2026-09-27 LINE風に作り直し）
 * 本体は assets/js/rinka-chat.js（会話のひきだしは rinka-chat-talk.js）。旧スタイル（fansite.css の .rinka-fs-chat*）とは別名（.rch-*）。
 * きせかえ 3種：.rch--line（既定・水色の背景＋みどりの ふきだし）／.rch--sakura（ピンク）／.rch--night（よる）
 * スマホ縦持ち最優先・横持ち／PCでも崩れない。UIの記号は SVG と共通アイコン（assets/img/chat/icons/）。絵文字は使わない。
 * ========================================================== */

.rch {
	/* LINE（既定） */
	--rc-bg: #9bb6de;
	--rc-bg2: #8faedb;
	--rc-top: #2f3b52;
	--rc-top-ink: #fff;
	--rc-top-sub: rgba(255, 255, 255, .72);
	--rc-me: #8de055;
	--rc-me-ink: #1b2a12;
	--rc-me-edge: #7fcf4a;
	--rc-you: #fff;
	--rc-you-ink: #222;
	--rc-meta: rgba(24, 36, 60, .72);
	--rc-sep-bg: rgba(40, 60, 100, .28);
	--rc-sep-ink: #fff;
	--rc-name: rgba(24, 36, 60, .82);
	--rc-bar: #fff;
	--rc-bar-line: #e6e9ef;
	--rc-field: #f1f3f6;
	--rc-ink: #2a2f3a;
	--rc-sub: #7a8394;
	--rc-accent: #06c755;
	--rc-accent-d: #04a647;
	--rc-chip: #fff;
	--rc-chip-ink: #2a2f3a;
	--rc-chip-line: #dde3ec;
	max-width: 640px;
	margin: 8px auto 28px;
	padding: 0 10px;
	color: var(--rc-ink);
	font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
	-webkit-tap-highlight-color: transparent;
}
.rch--sakura {
	--rc-bg: #fde4ee; --rc-bg2: #fbd6e5; --rc-top: #ff8fb4; --rc-top-ink: #fff; --rc-top-sub: rgba(255,255,255,.85);
	--rc-me: #ff8fb4; --rc-me-ink: #fff; --rc-me-edge: #f07aa2; --rc-you: #fff; --rc-you-ink: #5a3a46;
	--rc-meta: rgba(120, 70, 90, .75); --rc-sep-bg: rgba(210, 110, 150, .28); --rc-sep-ink: #fff; --rc-name: #9a5a74;
	--rc-accent: #ff6f9f; --rc-accent-d: #e2507f; --rc-chip-line: #f7cfdd; --rc-chip-ink: #5a3a46; --rc-ink: #5a3a46; --rc-sub: #9a7686;
}
.rch--night {
	--rc-bg: #1d2436; --rc-bg2: #182031; --rc-top: #121827; --rc-top-ink: #eef2fb; --rc-top-sub: rgba(238,242,251,.65);
	--rc-me: #3fbf6b; --rc-me-ink: #fff; --rc-me-edge: #34a95c; --rc-you: #2e374c; --rc-you-ink: #e8ecf5;
	--rc-meta: rgba(220, 228, 245, .6); --rc-sep-bg: rgba(255, 255, 255, .12); --rc-sep-ink: #dfe6f5; --rc-name: rgba(220,228,245,.75);
	--rc-bar: #151c2c; --rc-bar-line: #28324a; --rc-field: #222b40; --rc-ink: #e8ecf5; --rc-sub: #9aa6bf;
	--rc-accent: #3fbf6b; --rc-accent-d: #2f9c55; --rc-chip: #222b40; --rc-chip-ink: #e8ecf5; --rc-chip-line: #34405c;
}
.rch *, .rch *::before, .rch *::after { box-sizing: border-box; }
.rch-ico { width: 24px; height: 24px; flex: none; object-fit: contain; vertical-align: middle; }
.rch-ico--s { width: 18px; height: 18px; }
.rch-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.rch svg { display: block; }

.rch-app {
	position: relative;
	display: flex; flex-direction: column;
	background: var(--rc-bg);
	border-radius: 22px;
	overflow: hidden;
	box-shadow: 0 14px 34px -16px rgba(30, 50, 90, .45), 0 0 0 1px rgba(0, 0, 0, .06);
	height: min(84vh, 780px); min-height: 480px;
}
@supports (height: 100dvh) { .rch-app { height: min(84dvh, 780px); } }

/* ---------- 上のバー（LINEのトークルーム） ---------- */
.rch-top { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 4px; background: var(--rc-top); color: var(--rc-top-ink); flex: none; }
.rch-top__back { flex: none; width: 44px; height: 44px; display: grid; place-items: center; color: inherit; border-radius: 50%; text-decoration: none; }
.rch-top__back svg { width: 24px; height: 24px; }
.rch-top__back:hover { color: inherit; background: rgba(255,255,255,.1); }
.rch-top__face { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: #ffecf4; flex: none; transition: transform .25s ease; }
.rch-top__who { flex: 1; min-width: 0; }
.rch-top__name { margin: 0; font-weight: 800; font-size: 1.02rem; line-height: 1.2; color: inherit; }
.rch-top__st { margin: 1px 0 0; font-size: .7rem; color: var(--rc-top-sub); display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rch-dot { width: 7px; height: 7px; border-radius: 50%; background: #3be07a; flex: none; }
.rch-top__btn { appearance: none; border: 0; background: transparent; color: inherit; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex: none; padding: 0; }
.rch-top__btn svg { width: 23px; height: 23px; }
.rch-top__btn:hover, .rch-top__btn[aria-expanded="true"] { background: rgba(255, 255, 255, .14); }

/* アナウンス（なかよし度） */
.rch-bond { display: flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: .72rem; color: var(--rc-sub); background: var(--rc-bar); border-bottom: 1px solid var(--rc-bar-line); white-space: nowrap; flex: none; }
.rch-bond b { color: var(--rc-ink); }
.rch-bond__bar { flex: 1; height: 5px; border-radius: 999px; background: var(--rc-bar-line); overflow: hidden; min-width: 30px; }
.rch-bond__bar > span { display: block; height: 100%; background: linear-gradient(90deg, #ffc1d6, #ff7fa8); border-radius: 999px; }
.rch-bond__days { font-weight: 700; }

/* ---------- メモちょう（LINEのノート） ---------- */
.rch-memo { padding: 10px 14px; background: #fffaf0; color: #5a3a46; border-bottom: 1px solid #f3e1b8; max-height: 45%; overflow-y: auto; font-size: .82rem; flex: none; }
.rch-memo[hidden] { display: none; }
.rch-memo__t { margin: 2px 0 6px; font-weight: 900; display: flex; align-items: center; gap: 4px; }
.rch-memo__list, .rch-memo__topics { list-style: none; margin: 0 0 8px; padding: 0; }
.rch-memo__list li { padding: 4px 0; border-bottom: 1px dashed #f0dcc0; line-height: 1.5; display: grid; grid-template-columns: 8.5em 1fr; gap: 6px; align-items: baseline; }
.rch-memo__list b { color: #9a6a1c; font-size: .74rem; }
.rch-memo__topics li { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; padding: 4px 0; border-bottom: 1px dashed #f0dcc0; }
.rch-memo__topics time { grid-row: 1 / 3; color: #9a7686; font-weight: 800; font-size: .74rem; }
.rch-memo__topics span { color: #9a7686; font-size: .74rem; }
.rch-memo__n { margin: 0; font-size: .7rem; color: #9a7686; }

/* ---------- トーク ---------- */
.rch-log {
	flex: 1; min-height: 0; overflow-y: auto; padding: 10px 10px 12px; overscroll-behavior: contain;
	background: linear-gradient(180deg, var(--rc-bg), var(--rc-bg2));
	display: flex; flex-direction: column; gap: 2px;
	-webkit-overflow-scrolling: touch;
}
.rch-sep { text-align: center; margin: 10px 0 6px; }
.rch-sep span { display: inline-block; background: var(--rc-sep-bg); color: var(--rc-sep-ink); font-size: .68rem; font-weight: 700; border-radius: 999px; padding: 3px 12px; }
.rch-more { align-self: center; appearance: none; font: inherit; border: 0; background: var(--rc-sep-bg); color: var(--rc-sep-ink); border-radius: 999px; padding: 8px 16px; font-size: .74rem; font-weight: 700; cursor: pointer; min-height: 36px; margin-bottom: 6px; }

.rch-row { display: flex; align-items: flex-start; gap: 7px; max-width: 100%; margin-top: 2px; animation: rch-in .22s ease-out; }
.rch-row.is-first { margin-top: 10px; }
.rch-row--u { justify-content: flex-end; align-items: flex-end; }
.rch-av { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; background: #ffecf4; }
.rch-av--gap { display: block; visibility: hidden; height: 1px; }
.rch-col { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: calc(100% - 45px); }
.rch-name { font-size: .7rem; color: var(--rc-name); margin: 0 0 3px 4px; font-weight: 700; }
.rch-line { display: flex; align-items: flex-end; gap: 5px; max-width: 100%; }

.rch-bub {
	position: relative; max-width: min(78vw, 400px); padding: 8px 12px; border-radius: 18px;
	font-size: .93rem; line-height: 1.6; word-break: break-word; white-space: pre-wrap; overflow-wrap: anywhere;
}
.rch-row--r .rch-bub { background: var(--rc-you); color: var(--rc-you-ink); }
.rch-row--u .rch-bub { background: var(--rc-me); color: var(--rc-me-ink); max-width: min(72vw, 380px); }
/* しっぽ（グループの1つめだけ） */
.rch-row--r.is-first .rch-bub::before,
.rch-row--u.is-first .rch-bub::after {
	content: ""; position: absolute; top: 9px; width: 12px; height: 12px;
}
.rch-row--r.is-first .rch-bub::before { left: -5px; background: var(--rc-you); clip-path: polygon(100% 0, 0 0, 100% 100%); border-top-left-radius: 3px; }
.rch-row--u.is-first .rch-bub::after { right: -5px; background: var(--rc-me); clip-path: polygon(0 0, 100% 0, 0 100%); border-top-right-radius: 3px; }
.rch-bub--topic { background: #fffaf0 !important; color: #5a3a46 !important; box-shadow: inset 0 0 0 2px #f3d58a; }
.rch-row--r.is-first .rch-bub--topic::before { background: #fffaf0; }
.rch-bub__tag { display: flex; align-items: center; gap: 4px; font-size: .68rem; font-weight: 900; color: #9a6a1c; margin-bottom: 2px; }

.rch-meta { display: flex; flex-direction: column; align-items: flex-end; font-size: .6rem; color: var(--rc-meta); line-height: 1.3; flex: none; padding-bottom: 1px; }
.rch-row--r .rch-meta { align-items: flex-start; }
.rch-read { font-weight: 700; }

/* スタンプ（ふきだし無しで大きく） */
.rch-stamp { position: relative; width: 132px; display: flex; flex-direction: column; align-items: center; }
.rch-stamp img { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; background: radial-gradient(circle at 50% 40%, #fff, #ffe6f0); box-shadow: 0 0 0 4px #fff, 0 6px 14px -6px rgba(0,0,0,.35); }
.rch-stamp__t {
	margin-top: -16px; position: relative; padding: 3px 12px; border-radius: 999px; font-size: .92rem; font-weight: 900; letter-spacing: .02em;
	background: #fff; color: #ff5f95; box-shadow: 0 2px 0 rgba(0,0,0,.12); transform: rotate(-4deg); white-space: nowrap;
}
.rch-stamp--thanks .rch-stamp__t, .rch-stamp--ok .rch-stamp__t { color: #20a656; }
.rch-stamp--gn .rch-stamp__t, .rch-stamp--otsu .rch-stamp__t { color: #5a73c8; }
.rch-stamp--what .rch-stamp__t, .rch-stamp--hmm .rch-stamp__t { color: #e0892b; transform: rotate(3deg); }
.rch-stamp--secret .rch-stamp__t { color: #8a5ad6; }
.rch-stamp--love .rch-stamp__t, .rch-stamp--shy .rch-stamp__t, .rch-stamp--hug .rch-stamp__t { color: #ff4f86; transform: rotate(3deg); }
.rch-row.is-stamp .rch-stamp { animation: rch-stamp-pop .42s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes rch-stamp-pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }

@keyframes rch-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.rch-typing .rch-bub { display: flex; gap: 4px; align-items: center; min-height: 36px; }
.rch-typing i { width: 7px; height: 7px; border-radius: 50%; background: #aab3c2; animation: rch-dot 1s infinite ease-in-out; }
.rch-typing i:nth-child(2) { animation-delay: .15s; }
.rch-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes rch-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }

/* ---------- チップ ---------- */
.rch-chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; background: var(--rc-bar); border-top: 1px solid var(--rc-bar-line); scrollbar-width: none; flex: none; }
.rch-chips::-webkit-scrollbar { display: none; }
.rch-chip { appearance: none; font: inherit; flex: none; display: flex; align-items: center; gap: 4px; border: 1.5px solid var(--rc-chip-line); background: var(--rc-chip); color: var(--rc-chip-ink); border-radius: 999px; padding: 6px 13px 6px 10px; font-size: .8rem; font-weight: 700; cursor: pointer; min-height: 40px; white-space: nowrap; }
.rch-chip:active { transform: translateY(1px); }
.rch-chips.is-game .rch-chip { border-color: var(--rc-accent); color: var(--rc-accent-d); font-weight: 900; padding: 6px 16px; }
.rch--night .rch-chips.is-game .rch-chip { color: #8ff0b2; }

/* ---------- 入力 ---------- */
.rch-form { display: flex; align-items: center; gap: 6px; padding: 7px 8px 9px; background: var(--rc-bar); border-top: 1px solid var(--rc-bar-line); flex: none; }
.rch-tool { appearance: none; border: 0; background: transparent; color: var(--rc-sub); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex: none; padding: 0; }
.rch-tool svg { width: 25px; height: 25px; }
.rch-tool[aria-expanded="true"] { color: var(--rc-accent); }
.rch-field { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; background: var(--rc-field); border-radius: 22px; }
.rch-input { flex: 1; min-width: 0; font: inherit; font-size: 16px; border: 0; background: transparent; padding: 10px 4px 10px 16px; color: var(--rc-ink); min-height: 44px; }
/* テーマ（Cocoon）の input の枠・背景を消す */
.rch .rch-field .rch-input { border: 0 !important; box-shadow: none !important; background: transparent !important; border-radius: 0; margin: 0; height: auto; outline: none; }
.rch-input::placeholder { color: var(--rc-sub); }
.rch-input:focus { outline: none; }
.rch-field:focus-within { box-shadow: 0 0 0 2px var(--rc-accent); }
.rch-tool--in { width: 40px; height: 40px; }
.rch-send { appearance: none; border: 0; width: 44px; height: 44px; border-radius: 50%; background: transparent; color: var(--rc-sub); display: grid; place-items: center; cursor: pointer; flex: none; position: relative; transition: color .15s, background .15s, transform .15s; }
.rch-send svg { width: 24px; height: 24px; margin-left: 2px; }
.rch.is-typing .rch-send { background: var(--rc-accent); color: #fff; }
.rch-send:active { transform: scale(.92); }
.rch-chip:focus-visible, .rch-send:focus-visible, .rch-tool:focus-visible, .rch-top__btn:focus-visible, .rch-top__back:focus-visible, .rch-more:focus-visible, .rch-stamp-pick:focus-visible, .rch-menu__b:focus-visible { outline: 3px solid #8fc3ff; outline-offset: 2px; }

/* ---------- 下から出るパネル（スタンプ／あそびメニュー） ---------- */
.rch-panel { background: var(--rc-bar); border-top: 1px solid var(--rc-bar-line); padding: 8px 10px 12px; max-height: 42%; overflow-y: auto; flex: none; animation: rch-panel-in .2s ease-out; }
.rch-panel[hidden] { display: none; }
@keyframes rch-panel-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.rch-panel__t { margin: 0 0 8px; font-size: .74rem; font-weight: 800; color: var(--rc-sub); }
.rch-stamps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rch-stamp-pick { appearance: none; border: 0; background: transparent; padding: 4px 0 6px; border-radius: 14px; cursor: pointer; display: grid; place-items: center; min-height: 44px; }
.rch-stamp-pick:hover, .rch-stamp-pick:active { background: rgba(127, 140, 160, .12); }
.rch-stamp-pick .rch-stamp { width: 100%; }
.rch-stamp-pick .rch-stamp img { width: 58px; height: 58px; box-shadow: 0 0 0 3px #fff, 0 3px 8px -4px rgba(0,0,0,.35); }
.rch-stamp-pick .rch-stamp__t { font-size: .64rem; margin-top: -9px; padding: 1px 7px; }
.rch-menu { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rch-menu__b { appearance: none; font: inherit; border: 1.5px solid var(--rc-chip-line); background: var(--rc-chip); color: var(--rc-chip-ink); border-radius: 16px; min-height: 52px; padding: 6px 4px; font-size: .78rem; font-weight: 800; cursor: pointer; line-height: 1.3; }
.rch-menu__b:active { transform: translateY(1px); }

.rch-note { margin: 0; padding: 6px 12px 9px; font-size: .64rem; color: var(--rc-sub); text-align: center; line-height: 1.5; background: var(--rc-bar); flex: none; }
.rch.is-panel .rch-note { display: none; }

/* ---------- スマホ ---------- */
@media (max-width: 520px) {
	.rch { padding: 0 4px; margin-top: 4px; }
	.rch-app { border-radius: 18px; height: min(82vh, 760px); }
	@supports (height: 100dvh) { .rch-app { height: calc(100dvh - 150px); min-height: 460px; } }
	.rch-stamps { grid-template-columns: repeat(4, 1fr); }
	.rch-menu { grid-template-columns: repeat(3, 1fr); }
	.rch-note { display: none; }
}
@media (orientation: landscape) and (max-height: 520px) {
	.rch-app { height: calc(100vh - 24px); min-height: 300px; }
	.rch-note, .rch-bond { display: none; }
	.rch-top { padding-top: 4px; padding-bottom: 4px; }
}
@media (min-width: 900px) {
	.rch-app { height: min(78vh, 800px); }
}
@media (prefers-reduced-motion: reduce) {
	.rch-row, .rch-typing i, .rch-panel, .rch-row.is-stamp .rch-stamp { animation: none !important; }
}

/* ふきだしの中のリンク（手紙・ニュースを ひらく） */
.rch-link {
	display: flex; align-items: center; justify-content: space-between; gap: 6px;
	margin: 8px -4px -2px; padding: 9px 12px; min-height: 44px; border-radius: 12px;
	background: rgba(6, 199, 85, .1); color: var(--rc-accent-d); font-size: .82rem; font-weight: 800; text-decoration: none; white-space: normal;
}
.rch-link:hover { background: rgba(6, 199, 85, .18); color: var(--rc-accent-d); }
.rch-link svg { width: 18px; height: 18px; flex: none; }
.rch--sakura .rch-link { background: rgba(255, 111, 159, .12); }
.rch--night .rch-link { background: rgba(63, 191, 107, .16); color: #8ff0b2; }
.rch-link:focus-visible { outline: 3px solid #8fc3ff; outline-offset: 2px; }
