/* もろみ — 画面の骨組みと会話
 *
 *  色は必ず下の変数から取る（直書きしない）。明暗は html[data-theme] が差し替え、
 *  大部屋の色は JS が --accent を差し替える。濃淡は color-mix で地と混ぜて作るので、
 *  明暗や大部屋を切り替えても自動で釣り合う。
 */

:root {
  /* 蔵（暗いほう）。温かい墨色を3段重ねる */
  --bg-rail: #14110e;
  --bg-side: #1b1814;
  --bg-main: #221f1a;
  --bg-raise: #2a2620;
  --bg-float: #302b24;
  --bg-input: #2e2a23;
  --hover: rgba(255, 238, 208, .055);
  --active: rgba(255, 238, 208, .10);
  --line: rgba(255, 238, 208, .085);
  --line-strong: rgba(255, 238, 208, .16);
  --text: #ece5d8;
  --text-2: #b9ae9c;
  --text-3: #8a8071;
  --accent: #d8a657;
  --accent-ink: #1c1509;
  --danger: #e37563;
  --ok: #86c08a;
  --warn: #e0b45c;
  --shadow: 0 10px 34px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
  --name-mix: 100%;
  --ori-opacity: .42;
  --scrim: rgba(8, 6, 4, .62);

  --accent-wash: color-mix(in srgb, var(--accent) 13%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 26%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 88%, var(--text));

  --rail-w: 68px;
  --side-w: 252px;
  --aside-w: 248px;
  --top-h: 52px;
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
          "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

html[data-theme="light"] {
  /* 和紙（明るいほう） */
  --bg-rail: #e3dccd;
  --bg-side: #ece6da;
  --bg-main: #faf7f0;
  --bg-raise: #ffffff;
  --bg-float: #ffffff;
  --bg-input: #f1ece1;
  --hover: rgba(70, 50, 20, .06);
  --active: rgba(70, 50, 20, .11);
  --line: rgba(70, 50, 20, .12);
  --line-strong: rgba(70, 50, 20, .22);
  --text: #2a241b;
  --text-2: #655b4c;
  --text-3: #92887a;
  --accent-ink: #ffffff;
  --danger: #c2473a;
  --ok: #3f8a4a;
  --warn: #a8771a;
  --shadow: 0 10px 30px rgba(60, 40, 10, .16), 0 2px 6px rgba(60, 40, 10, .10);
  --name-mix: 58%;
  --ori-opacity: .55;
  --scrim: rgba(40, 30, 15, .38);
}

html { font-size: 15px; }
html[data-size="large"] { font-size: 17px; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-text); text-underline-offset: 2px; }
[hidden] { display: none !important; }
svg.ic { width: 1.25rem; height: 1.25rem; flex: none; stroke: currentColor; fill: none;
         stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ───────────── 骨組み ───────────── */

.app { display: grid; grid-template-columns: auto minmax(0, 1fr); height: 100dvh; }
.nav { display: flex; min-width: 0; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-main); }
.stage { flex: 1; display: flex; min-height: 0; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

/* ───────────── 大部屋の列（左端） ───────────── */

.rail {
  width: var(--rail-w); background: var(--bg-rail);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px 0 12px; overflow-y: auto; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-item { position: relative; width: 100%; display: flex; justify-content: center; }
.rail-tile {
  width: 46px; height: 46px; border-radius: 15px;
  display: grid; place-items: center;
  background: var(--bg-raise); color: var(--text-2);
  font-size: 1.3rem; font-weight: 600;
  transition: border-radius .16s, background .16s, color .16s, transform .1s;
}
.rail-tile:hover { background: var(--tile, var(--accent)); color: var(--accent-ink); border-radius: 12px; }
.rail-tile:active { transform: scale(.95); }
.rail-item.on .rail-tile { background: var(--tile, var(--accent)); color: var(--accent-ink); border-radius: 12px; }
/* 枡の縁。大部屋の色を細い線で持たせて、選ぶ前から色が分かるようにする */
.rail-tile.board { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tile) 55%, transparent); }
.rail-item.on .rail-tile.board, .rail-tile.board:hover { box-shadow: none; }
.rail-item::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 4px; height: 0;
  background: var(--text); border-radius: 0 4px 4px 0; transform: translateY(-50%);
  transition: height .16s;
}
.rail-item.unread::before { height: 8px; }
.rail-item:hover::before { height: 18px; }
.rail-item.on::before { height: 34px; }
.rail-home .rail-tile { color: var(--accent); font-size: 1.45rem; }
.rail-home.on .rail-tile, .rail-home .rail-tile:hover { color: var(--accent-ink); }
.rail-sep { width: 30px; height: 2px; border-radius: 2px; background: var(--line-strong); flex: none; }
.rail-badge {
  position: absolute; right: 7px; bottom: -3px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 0 0 3px var(--bg-rail); font-family: var(--font);
}
.rail-spacer { flex: 1; }
.rail-tool { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--text-3); }
.rail-tool:hover { background: var(--hover); color: var(--text); }

/* ───────────── 部屋の一覧 ───────────── */

.side { width: var(--side-w); background: var(--bg-side); display: flex; flex-direction: column; min-height: 0; }
.side-head {
  height: var(--top-h); flex: none; padding: 0 14px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.side-head .t { min-width: 0; flex: 1; }
.side-head b { display: block; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-head small { display: block; color: var(--text-3); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: -1px; }
.side-head .dot { width: 9px; height: 9px; border-radius: 3px; background: var(--accent); flex: none; }
.side-list { flex: 1; overflow-y: auto; padding: 10px 8px 16px; }

.cat-head {
  display: flex; align-items: center; gap: 4px; width: 100%; text-align: left;
  padding: 14px 6px 4px; font-size: .74rem; font-weight: 700; color: var(--text-3); letter-spacing: .04em;
}
.cat-head:hover { color: var(--text-2); }
.cat-head svg.ic { width: .8rem; height: .8rem; stroke-width: 2.4; transition: transform .15s; }
.cat-head.folded svg.ic { transform: rotate(-90deg); }
.cat-head .accent-dot { width: 7px; height: 7px; border-radius: 2px; background: var(--c); }

.ch {
  position: relative; display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 7px 9px; margin: 1px 0; border-radius: var(--r-s);
  color: var(--text-3); min-height: 36px;
}
.ch svg.ic { width: 1.15rem; height: 1.15rem; opacity: .85; }
.ch .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .98rem; }
.ch:hover { background: var(--hover); color: var(--text-2); }
.ch.on { background: var(--active); color: var(--text); }
.ch.on svg.ic { color: var(--accent); opacity: 1; }
.ch.unread { color: var(--text); font-weight: 650; }
.ch.unread::before {
  content: ""; position: absolute; left: -8px; top: 50%; width: 4px; height: 8px;
  background: var(--text); border-radius: 0 4px 4px 0; transform: translateY(-50%);
}
.ch .pill {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 700; display: grid; place-items: center;
}
.ch .lock { width: .85rem; height: .85rem; opacity: .6; }
.ch .here { display: flex; }
.ch .here .av { width: 18px; height: 18px; font-size: .6rem; margin-left: -5px; box-shadow: 0 0 0 2px var(--bg-side); }
.ch .here .more { font-size: .68rem; color: var(--text-3); margin-left: 3px; }
.side-board { margin-top: 6px; }
.side-board:first-child { margin-top: 0; }

/* 自分の欄（一覧の下） */
.me {
  flex: none; display: flex; align-items: center; gap: 4px; padding: 8px 8px;
  background: color-mix(in srgb, var(--bg-rail) 55%, var(--bg-side));
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.me-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 4px 6px; border-radius: var(--r-s); text-align: left; }
.me-who:hover { background: var(--hover); }
.me-who .t { min-width: 0; line-height: 1.25; }
.me-who b { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-who small { display: block; font-size: .72rem; color: var(--text-3); }
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-s); display: grid; place-items: center;
  color: var(--text-2); flex: none; position: relative;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); background: var(--accent-wash); }
.icon-btn .n.dot { min-width: 9px; width: 9px; height: 9px; padding: 0; right: 5px; top: 5px; background: var(--danger); }
.top .menu .n { background: var(--danger); color: #fff; }
.icon-btn .n {
  position: absolute; right: 1px; top: 1px; min-width: 15px; height: 15px; border-radius: 8px; padding: 0 4px;
  background: var(--accent); color: var(--accent-ink); font-size: .62rem; font-weight: 700; display: grid; place-items: center;
}

/* 顔 */
.av {
  width: 40px; height: 40px; border-radius: 50%; flex: none; position: relative;
  display: grid; place-items: center; font-weight: 700; font-size: 1rem;
  color: #1c1509; background: var(--c, var(--accent)); user-select: none;
}
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.av.s { width: 32px; height: 32px; font-size: .85rem; }
.av.xs { width: 18px; height: 18px; font-size: .6rem; }
.av.l { width: 76px; height: 76px; font-size: 2rem; }
.av .st {
  position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-3); box-shadow: 0 0 0 3px var(--ring, var(--bg-side));
}
.av .st.online { background: var(--ok); }

/* ───────────── 上の帯 ───────────── */

.top {
  height: var(--top-h); flex: none; display: flex; align-items: center; gap: 6px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: var(--bg-main); z-index: 2;
}
.top .menu { display: none; }
.top-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: none; max-width: 46%; }
.top-title svg.ic { color: var(--accent); }
.top-title b { font-size: 1.03rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-topic {
  flex: 1; min-width: 0; color: var(--text-3); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-left: 12px; margin-left: 6px; border-left: 1px solid var(--line-strong);
}
.top-spacer { flex: 1; }
.top-chip { font-size: .72rem; color: var(--text-3); border: 1px solid var(--line-strong); border-radius: 20px; padding: 1px 8px; flex: none; white-space: nowrap; }
.search {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 9px; border-radius: var(--r-s);
  background: var(--bg-input); color: var(--text-3); width: 170px; transition: width .18s; flex: none;
}
.search:focus-within { width: 250px; color: var(--text); box-shadow: 0 0 0 1.5px var(--accent-soft); }
.search svg.ic { width: 1rem; height: 1rem; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: .88rem; }
.search input::placeholder { color: var(--text-3); }

/* ───────────── 会話 ───────────── */

.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0 18px; overscroll-behavior: contain; }
.older { text-align: center; padding: 8px; }
.older button { font-size: .82rem; color: var(--text-2); padding: 6px 14px; border-radius: 20px; background: var(--hover); }
.older button:hover { background: var(--active); }

.day { display: flex; align-items: center; gap: 12px; margin: 18px 16px 6px; color: var(--text-3); font-size: .74rem; font-weight: 600; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.newline { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px 16px; color: var(--danger); font-size: .72rem; font-weight: 700; }
.newline::before { content: ""; flex: 1; height: 1px; background: var(--danger); opacity: .6; }
.newline span { background: var(--danger); color: #fff; padding: 0 7px; border-radius: 9px 0 0 9px; line-height: 1.5; }

.msg {
  position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 14px;
  padding: 2px 44px 2px 16px;
}
.msg.head { margin-top: 14px; padding-top: 3px; }
.msg:hover, .msg.picked { background: var(--hover); }
.msg.mention { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--accent); }
.msg.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 35% { background: var(--accent-soft); } 100% { background: transparent; } }
.msg-gutter { grid-column: 1; text-align: right; }
.msg-gutter .av { cursor: pointer; margin-top: 2px; }
.msg-gutter time { display: block; font-size: .66rem; color: var(--text-3); opacity: 0; line-height: 1.75rem; font-variant-numeric: tabular-nums; }
.msg:hover .msg-gutter time { opacity: 1; }
.msg-main { grid-column: 2; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; line-height: 1.35; }
.msg-head .name {
  font-weight: 650; cursor: pointer;
  color: color-mix(in srgb, var(--c, var(--text)) var(--name-mix), #1a1206);
}
.msg-head .name:hover { text-decoration: underline; }
.msg-head time { font-size: .72rem; color: var(--text-3); }
.role-badge {
  font-size: .66rem; font-weight: 700; padding: 0 6px; border-radius: 4px; line-height: 1.55;
  background: var(--accent-wash); color: var(--accent-text); align-self: center;
}
.role-badge.staff { background: color-mix(in srgb, #6f9fc4 20%, transparent); color: color-mix(in srgb, #6f9fc4 75%, var(--text)); }
.role-badge.teacher { background: color-mix(in srgb, #b294bb 20%, transparent); color: color-mix(in srgb, #b294bb 75%, var(--text)); }
.stage-chip { font-size: .66rem; color: var(--text-3); border: 1px solid var(--line-strong); border-radius: 20px; padding: 0 7px; align-self: center; }
.stage-chip.hakko { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.stage-chip.jukusei { color: var(--accent-text); border-color: var(--accent-soft); }

.body { font-size: 1rem; line-height: 1.62; overflow-wrap: anywhere; white-space: pre-wrap; }
.body.jumbo { font-size: 2.4rem; line-height: 1.25; }
.body a { word-break: break-all; }
.body code { font-family: var(--font-mono); font-size: .86em; background: var(--bg-input); padding: .1em .35em; border-radius: 4px; }
.body pre { margin: 4px 0; padding: 9px 12px; border-radius: var(--r-s); background: var(--bg-side); border: 1px solid var(--line); overflow-x: auto; white-space: pre; }
.body pre code { background: none; padding: 0; }
.body blockquote { margin: 2px 0; padding-left: 10px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.body .at { background: var(--accent-wash); color: var(--accent-text); border-radius: 4px; padding: 0 3px; font-weight: 600; cursor: pointer; }
.body .at.self { background: var(--accent-soft); }
.body mark, .hit mark { background: var(--accent-soft); color: inherit; border-radius: 3px; }
.edited { font-size: .68rem; color: var(--text-3); margin-left: 5px; white-space: nowrap; }

/* 返信の参照（親から下りてくる線で結ぶ） */
.ref {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; min-width: 0;
  margin: 0 0 3px 19px; padding-left: 28px; position: relative;
  font-size: .82rem; color: var(--text-3); cursor: pointer; white-space: nowrap;
}
.ref::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 22px; height: 12px;
  border: 2px solid var(--line-strong); border-right: 0; border-bottom: 0; border-radius: 7px 0 0 0;
}
.ref:hover { color: var(--text-2); }
.ref .rn { font-weight: 650; color: color-mix(in srgb, var(--c, var(--text-2)) var(--name-mix), #1a1206); flex: none; }
.ref .rx { overflow: hidden; text-overflow: ellipsis; }

/* 写真 */
.photos { display: grid; gap: 4px; margin: 6px 0 2px; max-width: 460px; border-radius: var(--r-m); overflow: hidden; }
.photos.n1 { grid-template-columns: 1fr; max-width: 360px; }
.photos.n2 { grid-template-columns: 1fr 1fr; }
.photos.n3, .photos.nm { grid-template-columns: 1fr 1fr 1fr; }
.photos button { display: block; aspect-ratio: 1; background: var(--bg-side); overflow: hidden; position: relative; }
.photos.n1 button { aspect-ratio: auto; max-height: 340px; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos.n1 img { height: auto; max-height: 340px; object-fit: contain; object-position: left; background: none; }
.photos .broken { display: grid; place-items: center; min-height: 70px; padding: 0 14px; color: var(--text-3); font-size: .78rem; }
.photos .rest { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; font-size: 1.3rem; font-weight: 700; }

/* 反応 */
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0 2px; }
.react {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px; border-radius: 13px;
  background: var(--bg-raise); border: 1px solid var(--line); font-size: .82rem; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.react:hover { border-color: var(--line-strong); }
.react.mine { background: var(--accent-wash); border-color: var(--accent-soft); color: var(--accent-text); font-weight: 650; }
.react .e { font-size: 1rem; line-height: 1; }
.react.add { color: var(--text-3); padding: 0 7px; opacity: 0; }
.react.add svg.ic { width: 1rem; height: 1rem; }
.msg:hover .react.add, .msg.picked .react.add { opacity: 1; }

/* 投稿の道具（かざすと右上に出る） */
.tools {
  position: absolute; right: 12px; top: -14px; display: none; z-index: 3;
  background: var(--bg-float); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow); padding: 2px;
}
.msg:hover .tools, .msg.picked .tools { display: flex; }
.tools button { width: 32px; height: 32px; border-radius: var(--r-s); display: grid; place-items: center; color: var(--text-2); font-size: 1.05rem; }
.tools button:hover { background: var(--hover); color: var(--text); }
.tools svg.ic { width: 1.1rem; height: 1.1rem; }
/* 触る画面では「かざす」が無いので、押せる印を最初から出しておく */
.more-touch { display: none; position: absolute; right: 6px; top: 2px; width: 34px; height: 34px; border-radius: 50%; color: var(--text-3); place-items: center; }

/* 澱（反応が無いまま古びた投稿）。一行に畳んで沈める */
.msg.ori { opacity: var(--ori-opacity); cursor: pointer; margin-top: 2px; padding-top: 2px; padding-bottom: 2px; }
.msg.ori:hover { opacity: .85; }
.msg.ori .oneline { grid-column: 1 / -1; display: flex; gap: 8px; align-items: baseline; font-size: .86rem; min-width: 0; padding-left: 54px; }
.msg.ori .oneline b { flex: none; font-weight: 600; }
.msg.ori .oneline span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.msg.ori .oneline i { font-style: normal; font-size: .7rem; color: var(--text-3); flex: none; }
.msg.hakko .msg-gutter .av { box-shadow: 0 0 0 2px var(--bg-main), 0 0 0 4px color-mix(in srgb, var(--warn) 60%, transparent); }

/* 書き直し */
.editbox { margin: 3px 0 6px; }
.editbox textarea {
  width: 100%; resize: none; border: 0; outline: none; border-radius: var(--r-m); background: var(--bg-input);
  padding: 9px 12px; line-height: 1.55; box-shadow: 0 0 0 1.5px var(--accent-soft); display: block;
}
.editbox small { color: var(--text-3); font-size: .74rem; }
.editbox small button { color: var(--accent-text); font-weight: 600; }
.editbox small button:hover { text-decoration: underline; }

/* 下へ戻る */
.jump {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 4;
  display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 20px;
  background: var(--accent); color: var(--accent-ink); font-size: .84rem; font-weight: 700; box-shadow: var(--shadow);
}
.jump svg.ic { width: 1rem; height: 1rem; stroke-width: 2.4; }

/* ───────────── 書き込み欄 ───────────── */

.composer-wrap { flex: none; padding: 0 14px calc(6px + env(safe-area-inset-bottom)); position: relative; }
.replybar, .pending {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: .84rem; color: var(--text-2);
  background: var(--bg-raise); border-radius: var(--r-m) var(--r-m) 0 0; border-bottom: 1px solid var(--line);
}
.replybar b { color: var(--text); }
.replybar .x { margin-left: auto; }
.replybar .rx { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--text-3); }
.pending { gap: 8px; overflow-x: auto; padding: 10px 12px; }
.pending .pp { position: relative; flex: none; }
.pending img { width: 68px; height: 68px; object-fit: cover; border-radius: var(--r-s); display: block; }
.pending .pp button { position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; display: grid; place-items: center; }
.pending .pp button svg.ic { width: .8rem; height: .8rem; stroke-width: 2.6; }
.pending .busy { width: 68px; height: 68px; border-radius: var(--r-s); background: var(--hover); display: grid; place-items: center; color: var(--text-3); font-size: .72rem; }
.composer {
  display: flex; align-items: flex-end; gap: 2px; background: var(--bg-input); border-radius: var(--r-m);
  padding: 5px 6px; transition: box-shadow .15s;
}
.composer.stacked { border-radius: 0 0 var(--r-m) var(--r-m); }
.composer:focus-within { box-shadow: 0 0 0 1.5px var(--accent-soft); }
.composer textarea {
  flex: 1; min-width: 0; border: 0; outline: none; resize: none; background: none;
  padding: 8px 6px; line-height: 1.5; max-height: 40vh; font-size: 1rem;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer .icon-btn { width: 38px; height: 38px; border-radius: 50%; }
.composer .send { background: var(--accent); color: var(--accent-ink); }
.composer .send:hover { background: var(--accent); filter: brightness(1.08); color: var(--accent-ink); }
.composer .send:disabled { background: none; color: var(--text-3); cursor: default; filter: none; }
.typing { height: 20px; font-size: .76rem; color: var(--text-3); padding: 2px 6px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.typing b { color: var(--text-2); }
.typing .dots { display: inline-flex; gap: 3px; margin-right: 6px; vertical-align: middle; }
.typing .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-2); animation: bub 1.2s infinite; }
.typing .dots i:nth-child(2) { animation-delay: .15s; }
.typing .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bub { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-3px); opacity: 1; } }
.locked {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-m);
  background: var(--bg-input); color: var(--text-3); font-size: .9rem; margin-bottom: 20px;
}
.dropping .content::after {
  content: "ここに写真を置く"; position: absolute; inset: 10px; z-index: 9; display: grid; place-items: center;
  border: 2px dashed var(--accent); border-radius: var(--r-l); background: color-mix(in srgb, var(--bg-main) 86%, transparent);
  color: var(--accent-text); font-weight: 700; font-size: 1.1rem; pointer-events: none;
}

/* ───────────── 右：メンバー／検索 ───────────── */

.aside { width: var(--aside-w); flex: none; background: var(--bg-side); overflow-y: auto; padding: 14px 8px 20px; border-left: 1px solid var(--line); }
.aside.closed { display: none; }
.aside h3 { margin: 14px 8px 4px; font-size: .73rem; color: var(--text-3); font-weight: 700; letter-spacing: .04em; }
.aside h3:first-child { margin-top: 0; }
.mem { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 5px 8px; border-radius: var(--r-s); }
.mem:hover { background: var(--hover); }
.mem .av { --ring: var(--bg-side); }
.mem .t { min-width: 0; line-height: 1.25; }
.mem b { display: block; font-weight: 600; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: color-mix(in srgb, var(--c, var(--text)) var(--name-mix), #1a1206); }
.mem small { display: block; font-size: .71rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mem.off { opacity: .5; }
.mem.off:hover { opacity: 1; }
.aside-head { display: flex; align-items: center; gap: 6px; padding: 0 4px 8px 8px; }
.aside-head b { flex: 1; font-size: .92rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aside .search { width: auto; margin: 0 4px 10px; }
.aside .search:focus-within { width: auto; }
.hit { display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: var(--r-m); background: var(--bg-raise); margin: 0 0 6px; border: 1px solid transparent; }
.hit:hover { border-color: var(--accent-soft); }
.hit .w { display: flex; gap: 6px; align-items: baseline; font-size: .74rem; color: var(--text-3); }
.hit .w b { color: var(--text-2); font-size: .82rem; }
.hit .w .chn { margin-left: auto; color: var(--accent-text); white-space: nowrap; }
.hit p { margin: 3px 0 0; font-size: .86rem; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.empty { color: var(--text-3); font-size: .88rem; padding: 18px 10px; text-align: center; }

/* ───────────── 浮くもの（吹き出し・窓・下から出る板） ───────────── */

.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 39; }
#layer { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
#layer > * { pointer-events: auto; }
.pop {
  position: fixed; background: var(--bg-float); border: 1px solid var(--line); border-radius: var(--r-l);
  box-shadow: var(--shadow); max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto;
  animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.veil { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.veil.clear { background: transparent; }
.modal {
  width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--bg-float);
  border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow); animation: pop .14s ease-out;
}
.modal.wide { width: min(640px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 6px 18px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 1.12rem; }
.modal-body { padding: 6px 18px 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; background: color-mix(in srgb, var(--bg-side) 60%, transparent); border-radius: 0 0 var(--r-l) var(--r-l); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg-float); border-radius: var(--r-l) var(--r-l) 0 0;
  box-shadow: var(--shadow); padding: 8px 10px calc(14px + env(safe-area-inset-bottom)); max-height: 82dvh; overflow: auto;
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.sheet::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 2px auto 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: var(--r-s); font-weight: 650; font-size: .9rem; background: var(--hover); color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--active); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg.ic { width: 1rem; height: 1rem; }

.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: .76rem; font-weight: 700; color: var(--text-2); margin-bottom: 5px; }
.input, .field input[type="text"], .field input[type="email"], .field input[type="url"], .field textarea, .field select {
  width: 100%; border: 0; outline: none; border-radius: var(--r-s); background: var(--bg-input); padding: 9px 11px;
  font-size: 1rem; color: var(--text);
}
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { box-shadow: 0 0 0 1.5px var(--accent-soft); }
.hint { font-size: .78rem; color: var(--text-3); margin: 4px 0 0; }

.menu-list { padding: 6px; min-width: 210px; }
.menu-list button, .menu-list a {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border-radius: var(--r-s);
  color: var(--text-2); font-size: .92rem; text-decoration: none;
}
.menu-list button:hover, .menu-list a:hover { background: var(--hover); color: var(--text); }
.menu-list button.danger { color: var(--danger); }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.quick { display: flex; gap: 4px; padding: 6px 6px 2px; justify-content: space-between; }
.quick button { flex: 1; height: 42px; border-radius: var(--r-m); background: var(--hover); font-size: 1.35rem; }
.quick button:hover { background: var(--active); }

/* 絵文字 */
.emoji { width: 328px; max-width: 100%; padding: 8px; }
.emoji h4 { margin: 8px 4px 3px; font-size: .72rem; color: var(--text-3); }
.emoji h4:first-child { margin-top: 2px; }
.emoji .g { display: grid; grid-template-columns: repeat(8, 1fr); gap: 1px; }
.emoji .g button { aspect-ratio: 1; border-radius: var(--r-s); font-size: 1.4rem; line-height: 1; }
.emoji .g button:hover { background: var(--active); }
.sheet .emoji { width: auto; }

/* 人の札 */
.card { width: 290px; max-width: 100%; }
.card .band { height: 58px; background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 40%, var(--bg-float))); border-radius: var(--r-l) var(--r-l) 0 0; }
.card .av { margin: -38px 0 0 16px; --ring: var(--bg-float); box-shadow: 0 0 0 5px var(--bg-float); }
.card .in { padding: 8px 16px 16px; }
.card h3 { margin: 4px 0 2px; font-size: 1.15rem; }
.card p { margin: 0 0 10px; color: var(--text-2); font-size: .84rem; }
.card .row { display: flex; gap: 8px; }

/* ピン・リンク集 */
.plist { width: 380px; max-width: 100%; padding: 6px; }
.plist h3 { margin: 6px 8px 8px; font-size: .95rem; display: flex; align-items: center; gap: 6px; }
.pin-item { padding: 9px 10px; border-radius: var(--r-m); background: var(--bg-raise); margin-bottom: 6px; cursor: pointer; border: 1px solid transparent; position: relative; }
.pin-item:hover { border-color: var(--accent-soft); }
.pin-item .w { display: flex; gap: 6px; align-items: baseline; font-size: .76rem; color: var(--text-3); padding-right: 30px; }
.pin-item .w b { color: var(--text); font-size: .86rem; }
.pin-item p { margin: 3px 0 0; font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; white-space: pre-wrap; }
.pin-item .x { position: absolute; right: 4px; top: 4px; width: 28px; height: 28px; }
.links { width: 330px; max-width: 100%; padding: 10px; }
.links h3 { margin: 2px 4px 10px; font-size: .95rem; }
.links .g { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.links a {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 4px; border-radius: var(--r-m);
  background: var(--bg-raise); color: var(--text); text-decoration: none; font-size: .78rem; text-align: center; line-height: 1.3;
}
.links a:hover { background: var(--active); }
.links a .e { font-size: 1.6rem; line-height: 1.1; }

/* 部屋へ飛ぶ（⌘K） */
.switch { width: min(520px, 100%); align-self: start; margin-top: 12vh; }
.switch input { width: 100%; border: 0; outline: none; background: none; padding: 16px 18px; font-size: 1.1rem; border-bottom: 1px solid var(--line); }
.switch .rows { max-height: 46vh; overflow: auto; padding: 6px; }
.switch .row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border-radius: var(--r-s); color: var(--text-2); }
.switch .row.sel, .switch .row:hover { background: var(--active); color: var(--text); }
.switch .row small { margin-left: auto; color: var(--text-3); font-size: .76rem; }

/* 写真を大きく見る */
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .9); display: grid; place-items: center; animation: fade .12s; }
.lightbox img { max-width: 96vw; max-height: 90dvh; object-fit: contain; border-radius: 4px; }
.lightbox button { position: absolute; width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center; }
.lightbox .x { right: 14px; top: calc(14px + env(safe-area-inset-top)); }
.lightbox .p { left: 14px; top: 50%; margin-top: -23px; }
.lightbox .n { right: 14px; top: 50%; margin-top: -23px; }
.lightbox .c { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; color: #fff; font-size: .85rem; opacity: .8; }

/* お知らせ（下に出る短い帯） */
.toasts { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { background: var(--bg-float); color: var(--text); border: 1px solid var(--line-strong); box-shadow: var(--shadow); padding: 9px 16px; border-radius: 22px; font-size: .88rem; animation: pop .16s ease-out; }
.toast.err { border-color: var(--danger); }

/* ───────────── 入口 ───────────── */

.gate {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; overflow: auto;
  background:
    radial-gradient(900px 500px at 18% 8%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(700px 500px at 88% 92%, color-mix(in srgb, #6f9fc4 12%, transparent), transparent 70%),
    var(--bg-rail);
}
.gate-card { width: min(410px, 100%); background: var(--bg-main); border: 1px solid var(--line); border-radius: 22px; padding: 30px 26px 24px; box-shadow: var(--shadow); }
.gate-mark {
  width: 62px; height: 62px; border-radius: 19px; display: grid; place-items: center; margin: 0 auto 12px;
  background: var(--accent); color: var(--accent-ink); font-size: 2rem; font-weight: 700;
}
.gate h1 { margin: 0; text-align: center; font-size: 1.7rem; letter-spacing: .12em; }
.gate .motto { text-align: center; color: var(--text-3); font-size: .82rem; margin: 2px 0 20px; }
.gate .lead { color: var(--text-2); font-size: .92rem; margin: 0 0 12px; line-height: 1.7; }
.gate .btn { width: 100%; min-height: 44px; font-size: 1rem; margin-top: 6px; }
.gate .swatches { display: flex; gap: 8px; margin: 4px 0 8px; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px transparent; }
.swatches button.on { box-shadow: 0 0 0 2px var(--bg-main), 0 0 0 4px var(--c); }

/* ───────────── 狭い画面 ───────────── */

@media (max-width: 1080px) {
  .aside { position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; width: min(86vw, 300px); box-shadow: var(--shadow); transform: translateX(105%); transition: transform .2s ease; display: block !important; padding-top: calc(14px + env(safe-area-inset-top)); }
  .aside.open { transform: none; }
}
@media (max-width: 820px) {
  html { font-size: 16px; }
  html[data-size="large"] { font-size: 18px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; width: min(88vw, 340px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .nav.open { transform: none; }
  .nav .side { flex: 1; width: auto; min-width: 0; }
  .rail { padding-top: calc(10px + env(safe-area-inset-top)); }
  .side-head { margin-top: env(safe-area-inset-top); }
  .top { padding: 0 6px; padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top)); }
  .top .menu { display: grid; }
  .top-topic, .top .search, .top-chip { display: none; }
  .top-title { max-width: none; flex: 1; }
  .msg { padding: 2px 40px 2px 12px; column-gap: 11px; }
  .day { margin-left: 12px; margin-right: 12px; }
  .composer-wrap { padding-left: 8px; padding-right: 8px; }
  .typing { height: 16px; font-size: .7rem; }
  .ch { min-height: 42px; }
  .jump { bottom: 88px; }
}
@media (hover: none) {
  .tools { display: none !important; }
  .msg:not(.ori) .more-touch { display: grid; }
  .msg:not(.head) .more-touch { top: -4px; opacity: .6; }
  .react.add { opacity: 1; }
  .msg:hover { background: none; }
  .msg.picked { background: var(--hover); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
