/* 空間ごとのテンプレート。通常の画面と会話で同じ色を使う。 */
:root { --mine: #24493f; --button-fg: #08221d; --tab-bg: #151929; --theme-border: #33395c; --theme-wash: none; }
body[data-theme="peach"] {
  --bg: #fff7f2; --panel: #fffdfb; --panel2: #fbe9e2; --fg: #3c292b;
  --muted: #725960; --accent: #af3d61; --accent2: #a04d73; --danger: #aa2844;
  --mine: #f8dce4; --button-fg: #fff; --tab-bg: #fff7f2; --theme-border: #e8c9ca;
  --theme-wash: radial-gradient(circle at 92% 4%, #ffe1d5, transparent 46%);
  --radius: 24px;
}
body[data-theme="sky"] {
  --bg: #f3f9fc; --panel: #fff; --panel2: #e5f2fa; --fg: #193544;
  --muted: #536d7e; --accent: #126b9a; --accent2: #206b87; --danger: #ad3650;
  --mine: #d9eef8; --button-fg: #fff; --tab-bg: #f3f9fc; --theme-border: #c6dce8;
  --theme-wash: linear-gradient(160deg, #e1f3fb, #f3f9fc 50%);
  --radius: 12px;
}
body[data-theme="forest"] {
  --bg: #102820; --panel: #19392e; --panel2: #254839; --fg: #f0f7ea;
  --muted: #b9cbb9; --accent: #b4e2a1; --accent2: #e7d99b; --danger: #ffaaa6;
  --mine: #326444; --button-fg: #163321; --tab-bg: #143026; --theme-border: #537561;
  --theme-wash: radial-gradient(circle at 95% 0%, #204636, transparent 55%);
  --radius: 20px;
}
body[data-theme="lilac"] {
  --bg: #f9f5ff; --panel: #fff; --panel2: #eee5fa; --fg: #302844;
  --muted: #655a78; --accent: #7346aa; --accent2: #925bb6; --danger: #a63263;
  --mine: #e9d9f6; --button-fg: #fff; --tab-bg: #f9f5ff; --theme-border: #d9c7ed;
  --theme-wash: radial-gradient(circle at 90% 0%, #edddff, transparent 50%);
  --radius: 22px;
}
body[data-theme="sunny"] {
  --bg: #fff5a8; --panel: #fffcdb; --panel2: #ffec80; --fg: #3b2d17;
  --muted: #5e5020; --accent: #735200; --accent2: #6f4f12; --danger: #99262f;
  --mine: #ffdf40; --button-fg: #fff; --tab-bg: #fff29a; --theme-border: #d4b52a;
  --theme-wash: radial-gradient(circle at 88% 4%, #ffe95c, transparent 48%);
  --radius: 20px;
}
body[data-theme="autumn"] {
  --bg: #fff4d6; --panel: #fffaf0; --panel2: #fbe7be; --fg: #402b22;
  --muted: #71584a; --accent: #a52e24; --accent2: #9b511f; --danger: #a52e24;
  --mine: #f8d59e; --button-fg: #fff; --tab-bg: #fff1d4; --theme-border: #dbb989;
  --theme-wash: radial-gradient(circle at 90% 3%, #ffdba2, transparent 49%);
  --radius: 20px;
}
body[data-theme]:not([data-theme="classic"]) { background: var(--theme-wash), var(--bg); }
/* 背景の10枚だけを動かす。本文と操作面は手前に置く。 */
body[data-theme="autumn"] #app { position: relative; z-index: 1; }
#autumn-leaves { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
#autumn-leaves span {
  position: absolute; top: -48px; left: var(--leaf-x); width: var(--leaf-size); height: var(--leaf-size);
  background: var(--leaf-color); opacity: .52;
  clip-path: polygon(50% 0%, 58% 22%, 72% 12%, 69% 31%, 92% 29%, 77% 46%, 100% 57%, 71% 60%, 75% 78%, 56% 69%, 53% 100%, 47% 100%, 44% 69%, 25% 78%, 29% 60%, 0% 57%, 23% 46%, 8% 29%, 31% 31%, 28% 12%, 42% 22%);
  animation: autumn-fall var(--leaf-time) linear infinite; animation-delay: var(--leaf-delay);
  will-change: transform;
}
#autumn-leaves span:nth-child(5n+1) { --leaf-color: #b62c26; --leaf-size: 24px; --leaf-time: 18s; }
#autumn-leaves span:nth-child(5n+2) { --leaf-color: #d9552b; --leaf-size: 17px; --leaf-time: 23s; }
#autumn-leaves span:nth-child(5n+3) { --leaf-color: #9c3127; --leaf-size: 20px; --leaf-time: 20s; }
#autumn-leaves span:nth-child(5n+4) { --leaf-color: #db7733; --leaf-size: 15px; --leaf-time: 26s; }
#autumn-leaves span:nth-child(5n) { --leaf-color: #be4626; --leaf-size: 22px; --leaf-time: 22s; }
#autumn-leaves span:nth-child(10n+1) { --leaf-x: 4%; --leaf-delay: -3s; }
#autumn-leaves span:nth-child(10n+2) { --leaf-x: 16%; --leaf-delay: -15s; }
#autumn-leaves span:nth-child(10n+3) { --leaf-x: 28%; --leaf-delay: -8s; }
#autumn-leaves span:nth-child(10n+4) { --leaf-x: 38%; --leaf-delay: -19s; }
#autumn-leaves span:nth-child(10n+5) { --leaf-x: 49%; --leaf-delay: -11s; }
#autumn-leaves span:nth-child(10n+6) { --leaf-x: 59%; --leaf-delay: -1s; }
#autumn-leaves span:nth-child(10n+7) { --leaf-x: 70%; --leaf-delay: -17s; }
#autumn-leaves span:nth-child(10n+8) { --leaf-x: 79%; --leaf-delay: -6s; }
#autumn-leaves span:nth-child(10n+9) { --leaf-x: 87%; --leaf-delay: -13s; }
#autumn-leaves span:nth-child(10n) { --leaf-x: 95%; --leaf-delay: -22s; }
@keyframes autumn-fall {
  0% { transform: translate3d(-8px, -45px, 0) rotate(-35deg); }
  50% { transform: translate3d(28px, 53vh, 0) rotate(140deg); }
  100% { transform: translate3d(-17px, calc(100vh + 90px), 0) rotate(340deg); }
}
@media (prefers-reduced-motion: reduce) { #autumn-leaves span { animation: none; display: none; } }
body[data-theme]:not([data-theme="classic"]) .row,
body[data-theme]:not([data-theme="classic"]) .auth-card,
body[data-theme]:not([data-theme="classic"]) .daily-card { border-radius: var(--radius); }
body[data-theme]:not([data-theme="classic"]) .m-bubble { border-radius: var(--radius) var(--radius) var(--radius) 5px; }
body[data-theme]:not([data-theme="classic"]) .m-row.mine .m-bubble { background: var(--mine); border-radius: var(--radius) var(--radius) 5px var(--radius); }
body[data-theme]:not([data-theme="classic"]) .m-react.on { background: var(--mine); }
body[data-theme]:not([data-theme="classic"]) #tabbar { background: var(--tab-bg); border-color: var(--theme-border); }
body[data-theme]:not([data-theme="classic"]) button:not(.ghost):not(.link):not(.danger):not(.icon):not(.msg-item):not(.m-quote):not(.reply-main):not(.reply-x):not(.theme-choice):not(.stamp):not(.inp-btn):not(.ctitle):not(.jump-btn):not(.help-q):not(.off):not(.hangup):not(.m-more):not(.m-del) { color: var(--button-fg); }
body[data-theme]:not([data-theme="classic"]) .composer button.icon.send,
body[data-theme]:not([data-theme="classic"]) .easy-call,
body[data-theme]:not([data-theme="classic"]) .jump-badge,
body[data-theme]:not([data-theme="classic"]) .badge.unread { color: var(--button-fg); }
/* ひだまりの送信ボタンは茶色の --accent ではなく明るい黄色にする。 */
body[data-theme="sunny"]:not([data-theme="classic"]) .composer button.icon.send { background: #ffe500; color: #3b2d17; }
body[data-theme="sunny"]:not([data-theme="classic"]) .composer .inp-btn { color: #000; }
/* ひだまりでは濃い茶色の --accent が黒い線に見えるので、入力中の縁は送信ボタンと同系の黄色にする。(依頼#652) */
body[data-theme="sunny"]:not([data-theme="classic"]) textarea:focus,
body[data-theme="sunny"]:not([data-theme="classic"]) input:focus { border-color: #e0bc00; }
/* ひだまりでは入力行の部品を送信ボタンと同じ黄色に揃える。録音中の赤は残す。(依頼#654) */
body[data-theme="sunny"]:not([data-theme="classic"]) .composer textarea,
body[data-theme="sunny"]:not([data-theme="classic"]) .composer button.icon:not(.send):not(.on) { background: #ffe500; }
body[data-theme="sunny"]:not([data-theme="classic"]) .composer textarea::placeholder { color: #646464; opacity: 1; }

/* ひだまりの主ボタン等を明るい黄色の面+濃い文字にする。(依頼#663) */
body[data-theme="sunny"]:not([data-theme="classic"]) button:not(.ghost):not(.link):not(.danger):not(.icon):not(.msg-item):not(.m-quote):not(.reply-main):not(.reply-x):not(.theme-choice):not(.stamp):not(.inp-btn):not(.ctitle):not(.jump-btn):not(.help-q):not(.off):not(.hangup):not(.m-more):not(.m-del),
body[data-theme="sunny"]:not([data-theme="classic"]) .easy-call,
body[data-theme="sunny"]:not([data-theme="classic"]) .jump-badge,
body[data-theme="sunny"]:not([data-theme="classic"]) .badge.unread,
body[data-theme="sunny"]:not([data-theme="classic"]) .fx-opt.on,
body[data-theme="sunny"]:not([data-theme="classic"]) .ring-answer,
body[data-theme="sunny"]:not([data-theme="classic"]) .pwa-step .no { background: #ffe100; color: #3b2d17; border: 1px solid #8a7000; }
body[data-theme]:not([data-theme="classic"]) button.ghost { border-color: var(--theme-border); }
body[data-theme]:not([data-theme="classic"]) .jump-btn { background: var(--panel2); border-color: var(--theme-border); }
body[data-theme]:not([data-theme="classic"]) .m-time,
body[data-theme]:not([data-theme="classic"]) .m-del { color: var(--muted); }
body[data-theme]:not([data-theme="classic"]) .msg.ok { background: var(--panel2); color: var(--accent); }
body[data-theme]:not([data-theme="classic"]) .msg.err { background: var(--panel2); color: var(--danger); }
body[data-theme]:not([data-theme="classic"]) .frame { background: var(--panel2); }

.theme-dot { flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--theme-border); background: var(--accent); }
.theme-picker { max-width: 560px; margin: 0 auto; }
.theme-picker h2 { margin: 0; font-size: 1.2rem; }
.theme-picker p { color: var(--muted); font-size: .86rem; margin: 5px 0 14px; }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.theme-choice { display: flex; flex-direction: column; align-items: stretch; text-align: left; margin: 0; padding: 8px; min-width: 0; background: var(--panel2); color: var(--fg); border: 2px solid transparent; border-radius: 15px; }
.theme-choice[aria-pressed="true"] { border-color: var(--accent); }
.theme-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-choice-name { font-size: .87rem; font-weight: 700; margin-top: 5px; }
.theme-choice-note { font-size: .7rem; font-weight: 400; color: var(--muted); line-height: 1.3; }
.theme-sample { display: block; width: 100%; height: 62px; padding: 7px 9px; border-radius: 9px; background: #0f1220; overflow: hidden; }
.theme-sample-bar { display: block; width: 55%; height: 7px; border-radius: 6px; margin-bottom: 9px; background: #171b2e; }
.theme-sample-bubble { display: block; width: 48%; height: 12px; border-radius: 7px; margin-bottom: 5px; background: #171b2e; }
.theme-sample-bubble.mine { margin-left: auto; background: #24493f; }
.theme-sample[data-preview="peach"] { background: #fff7f2; }
.theme-sample[data-preview="peach"] .theme-sample-bar,
.theme-sample[data-preview="peach"] .theme-sample-bubble:not(.mine) { background: #fffdfb; }
.theme-sample[data-preview="peach"] .mine { background: #f8dce4; }
.theme-sample[data-preview="sky"] { background: #f3f9fc; }
.theme-sample[data-preview="sky"] .theme-sample-bar,
.theme-sample[data-preview="sky"] .theme-sample-bubble:not(.mine) { background: #fff; }
.theme-sample[data-preview="sky"] .mine { background: #d9eef8; }
.theme-sample[data-preview="forest"] { background: #102820; }
.theme-sample[data-preview="forest"] .theme-sample-bar,
.theme-sample[data-preview="forest"] .theme-sample-bubble:not(.mine) { background: #19392e; }
.theme-sample[data-preview="forest"] .mine { background: #326444; }
.theme-sample[data-preview="lilac"] { background: #f9f5ff; }
.theme-sample[data-preview="lilac"] .theme-sample-bar,
.theme-sample[data-preview="lilac"] .theme-sample-bubble:not(.mine) { background: #fff; }
.theme-sample[data-preview="lilac"] .mine { background: #e9d9f6; }
.theme-sample[data-preview="sunny"] { background: #fff5a8; }
.theme-sample[data-preview="sunny"] .theme-sample-bar,
.theme-sample[data-preview="sunny"] .theme-sample-bubble:not(.mine) { background: #fffcdb; }
.theme-sample[data-preview="sunny"] .mine { background: #ffdf40; }
.theme-sample[data-preview="autumn"] { background: #fff4d6; position: relative; }
.theme-sample[data-preview="autumn"] .theme-sample-bar,
.theme-sample[data-preview="autumn"] .theme-sample-bubble:not(.mine) { background: #fffaf0; }
.theme-sample[data-preview="autumn"] .mine { background: #f8d59e; }
.theme-sample[data-preview="autumn"]::after { content: '🍁'; position: absolute; right: 10px; top: 3px; font-size: 22px; transform: rotate(-20deg); }
.theme-dot[data-preview="sunny"] { background: #ffdc1f; }
.theme-dot[data-preview="autumn"] { background: #bc4128; }
.theme-actions { display: flex; gap: 10px; }
.theme-actions button { flex: 1; min-width: 0; font-size: .9rem; padding: 12px 8px; }
body.easy .theme-choice-name { font-size: 1rem; }
@media (max-width: 340px) { .theme-grid { gap: 6px; } .theme-choice-note { font-size: .64rem; } }
