/* みんなのチャット — 白とすりガラス、エメラルド→ブルーのグラデーションを1本の軸にする */
:root {
  --font: "Inter", "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

  --grad: linear-gradient(135deg, #10b981 0%, #0ea5e9 55%, #6366f1 100%);
  --grad-soft: linear-gradient(135deg, rgba(16,185,129,.14), rgba(14,165,233,.14) 55%, rgba(99,102,241,.14));
  --accent: #0ea5e9;
  --accent-strong: #0284c7;
  --accent-soft: rgba(14,165,233,.12);
  --emerald: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;

  --bg: #eef3f7;
  --mesh: radial-gradient(1200px 700px at 0% 0%, rgba(16,185,129,.18), transparent 60%),
          radial-gradient(900px 600px at 100% 10%, rgba(99,102,241,.16), transparent 60%),
          radial-gradient(900px 700px at 60% 110%, rgba(14,165,233,.16), transparent 60%);
  --glass: rgba(255,255,255,.62);
  --glass-strong: rgba(255,255,255,.95);
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eef2f7;
  --hover: rgba(15,23,42,.045);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: rgba(15,23,42,.08);
  --line-strong: rgba(15,23,42,.14);
  --mention-bg: rgba(245,158,11,.10);
  --mention-line: #f59e0b;
  --code-bg: rgba(15,23,42,.05);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 24px -8px rgba(15,23,42,.12);
  --shadow-lg: 0 24px 60px -12px rgba(15,23,42,.28);
  --glow: 0 8px 24px -6px rgba(14,165,233,.45);
  --radius: 14px;
  --radius-sm: 10px;
  --side-w: 272px;
  --panel-w: 400px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #070b14;
  --mesh: radial-gradient(1100px 700px at 0% 0%, rgba(16,185,129,.16), transparent 60%),
          radial-gradient(900px 600px at 100% 0%, rgba(99,102,241,.20), transparent 60%),
          radial-gradient(900px 700px at 60% 110%, rgba(14,165,233,.14), transparent 60%);
  --glass: rgba(15,22,38,.62);
  --glass-strong: rgba(17,25,42,.96);
  --surface: #0e1524;
  --surface-2: #121b2d;
  --surface-3: #18233a;
  --hover: rgba(255,255,255,.05);
  --text: #e8eef8;
  --text-2: #c6d0df;
  --muted: #8b98ad;
  --faint: #5f6d84;
  --line: rgba(255,255,255,.08);
  --line-strong: rgba(255,255,255,.14);
  --accent-soft: rgba(56,189,248,.16);
  --mention-bg: rgba(245,158,11,.12);
  --code-bg: rgba(255,255,255,.07);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -10px rgba(0,0,0,.6);
  --shadow-lg: 0 30px 80px -10px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image: var(--mesh);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
:root[data-theme="dark"] .body a, :root[data-theme="dark"] .page a:not(.btn) { color: #7dd3fc; }
::selection { background: rgba(14,165,233,.25); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* スクロールバー */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------- 部品 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px; line-height: 1.2;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { border: 0; color: #fff; background: var(--grad); box-shadow: var(--glow); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent-strong); background: var(--accent-soft); }
.icon-btn svg, .btn svg, .side-item svg { width: 18px; height: 18px; flex: none; }
.input {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px;
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }
.muted { color: var(--muted); }
.kbd {
  display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 6px; font: 600 11px/18px var(--font);
  text-align: center; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line-strong); border-bottom-width: 2px;
}
.segment { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-3); gap: 2px; }
.segment button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.segment button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(16px); }

.avatar {
  --size: 36px;
  position: relative; width: var(--size); height: var(--size); flex: none; border-radius: 30%;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: calc(var(--size) * .42);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.avatar.round { border-radius: 50%; }
.avatar .presence {
  position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--faint);
}
.avatar .presence.on { background: #22c55e; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; background: var(--grad); display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 16px; box-shadow: var(--glow); flex: none;
}

/* ---------- ゲスト入場・ログイン ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 420px; padding: 36px 32px 28px; border-radius: 22px;
  background: var(--glass-strong); backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 44px; height: 44px; border-radius: 14px; font-size: 21px; }
.auth h1 { margin: 0; font-size: 22px; letter-spacing: .01em; }
.auth .tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.auth h2 { font-size: 26px; line-height: 1.3; margin: 0 0 6px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth .lead { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.auth .btn.primary { width: 100%; padding: 12px; font-size: 15px; }
.auth-switch { margin-top: 16px; font-size: 13px; text-align: center; color: var(--muted); }
.auth-switch button { border: 0; background: none; color: var(--accent-strong); font-weight: 600; padding: 0; }
.color-dots { display: flex; gap: 8px; margin: 4px 0 18px; }
.color-dots span { width: 26px; height: 26px; border-radius: 50%; }

/* ---------- 全体の枠 ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr) auto; height: 100dvh; padding: 10px 10px 10px 0; gap: 10px; }
.side {
  display: flex; flex-direction: column; min-height: 0; padding: 4px 10px 10px;
  color: var(--text-2);
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 10px 8px 12px; border-radius: 12px; cursor: pointer; }
.side-head:hover { background: var(--hover); }
.side-head .ws-name { font-weight: 800; font-size: 15px; line-height: 1.25; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-head .ws-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.side-head .chev { margin-left: auto; color: var(--muted); }
.jump {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; margin: 2px 0 8px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--glass); color: var(--muted);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: 14px; text-align: left;
}
.jump:hover { border-color: var(--line-strong); color: var(--text); }
.jump .kbd { margin-left: auto; }
.jump svg { width: 16px; height: 16px; flex: none; }
.side-item .hash svg { width: 17px; height: 17px; vertical-align: -3px; }
.side-scroll { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.side-label {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 8px 4px;
  font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em;
}
.side-label button { opacity: 0; transition: opacity .15s; width: 24px; height: 24px; }
.side-label:hover button, .side-label button:focus-visible { opacity: 1; }
.side-item {
  position: relative; display: flex; align-items: center; gap: 9px; padding: 6px 8px; margin: 1px 0; border-radius: 10px;
  color: var(--text-2); font-size: 14.5px; text-decoration: none; cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.side-item:hover { background: var(--hover); text-decoration: none; }
.side-item .hash { width: 20px; text-align: center; color: var(--faint); font-weight: 600; flex: none; }
.side-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item.unread { color: var(--text); font-weight: 700; }
.side-item.unread .hash { color: var(--text); }
.side-item.active { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow); }
.side-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--grad);
}
.side-item.active .hash { color: var(--accent-strong); }
.side-item .badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--grad);
  color: #fff; font-size: 11.5px; font-weight: 800; display: grid; place-items: center; box-shadow: var(--glow);
}
.side-item .avatar { --size: 22px; font-size: 10px; }
.side-item .avatar .presence { width: 9px; height: 9px; right: -3px; bottom: -3px; }
.side-foot { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 2px; }
.me-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; }
.me-card:hover { background: var(--hover); }
.me-card .avatar { --size: 32px; }
.me-card b { display: block; font-size: 14px; color: var(--text); }
.me-card small { color: var(--muted); font-size: 12px; }

.main, .panel {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.panel { width: var(--panel-w); }
.head {
  display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 10px 14px 10px 20px; border-bottom: 1px solid var(--line);
  flex: none; background: linear-gradient(to bottom, var(--surface), var(--surface));
}
.head h2 { margin: 0; font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 8px; white-space: nowrap; min-width: 0; }
.head h2 .hash { color: var(--faint); }
.head .topic {
  color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1;
  padding: 4px 8px; border-radius: 8px; cursor: pointer; border: 0; background: none; text-align: left;
}
.head .topic:hover { background: var(--hover); }
.head .spacer { flex: 1; }
.head .actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.stack { display: flex; align-items: center; padding: 3px 8px 3px 4px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); gap: 6px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.stack:hover { background: var(--surface-2); }
.stack .avatars { display: flex; }
.stack .avatar { --size: 24px; border-radius: 50%; border: 2px solid var(--surface); margin-left: -6px; font-size: 10px; }
.stack .avatar:first-child { margin-left: 0; }
.search-box { position: relative; width: 220px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search-box .input { padding: 7px 10px 7px 32px; background: var(--surface-2); border-color: transparent; font-size: 13.5px; border-radius: 10px; }
.search-box .input:focus { background: var(--surface); }

/* ---------- 投稿の一覧 ---------- */
.messages { flex: 1; overflow-y: auto; min-height: 0; padding: 8px 0 12px; position: relative; overflow-anchor: none; }
.intro { padding: 36px 24px 16px; }
.intro .big { width: 56px; height: 56px; border-radius: 18px; background: var(--grad-soft); display: grid; place-items: center; font-size: 26px; font-weight: 800; color: var(--accent-strong); margin-bottom: 12px; }
.intro h3 { margin: 0 0 4px; font-size: 22px; }
.intro p { margin: 0; color: var(--muted); }
.more { text-align: center; padding: 8px; }
.day {
  position: sticky; top: 6px; z-index: 2; display: flex; justify-content: center; margin: 14px 0 6px; pointer-events: none;
}
.day span {
  pointer-events: auto; font-size: 12px; font-weight: 700; color: var(--text-2); padding: 4px 12px; border-radius: 99px;
  background: var(--glass-strong); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.unread-line { display: flex; align-items: center; gap: 10px; margin: 8px 20px; color: var(--danger); font-size: 12px; font-weight: 800; }
.unread-line::before, .unread-line::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .5; }

.msg { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 6px 20px; }
.msg:hover { background: var(--hover); }
.msg.cont { padding-top: 1px; padding-bottom: 1px; }
.msg.cont .gutter { visibility: hidden; font-size: 11px; color: var(--faint); text-align: right; padding-top: 3px; }
.msg.cont:hover .gutter { visibility: visible; }
.msg.mentioned { background: var(--mention-bg); box-shadow: inset 3px 0 0 var(--mention-line); }
.msg.highlight { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.msg.pending .body { opacity: .55; }
.msg.failed .body { color: var(--danger); }
.msg .avatar { --size: 40px; cursor: pointer; }
.meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.meta .name { font-weight: 800; font-size: 15px; cursor: pointer; border: 0; background: none; padding: 0; color: var(--text); }
.meta .name:hover { text-decoration: underline; }
.tag { font-size: 11px; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; }
.meta time { font-size: 12px; color: var(--faint); }
.body { color: var(--text); line-height: 1.6; overflow-wrap: anywhere; }
.body .edited { font-size: 12px; color: var(--faint); }
.body.deleted { color: var(--faint); font-style: italic; }
.body code { font-family: var(--mono); background: var(--code-bg); padding: 1px 5px; border-radius: 6px; font-size: .86em; color: #db2777; }
:root[data-theme="dark"] .body code { color: #f9a8d4; }
.body .pre { position: relative; margin: 6px 0; }
.body pre {
  margin: 0; font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px;
  border-radius: 12px; overflow-x: auto; font-size: 13px; line-height: 1.5;
}
.body .pre .copy-code { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s; }
.body .pre:hover .copy-code { opacity: 1; }
.body blockquote { border-left: 3px solid var(--line-strong); margin: 2px 0; padding: 0 0 0 10px; color: var(--text-2); }
.body ul { margin: 2px 0; padding-left: 20px; }
.mention-chip {
  background: var(--accent-soft); color: var(--accent-strong); border-radius: 6px; padding: 0 4px; font-weight: 700; cursor: pointer;
}
.mention-chip.me { background: rgba(245,158,11,.18); color: #b45309; }
:root[data-theme="dark"] .mention-chip { color: #7dd3fc; }
:root[data-theme="dark"] .mention-chip.me { color: #fbbf24; }
.status-line { font-size: 12px; margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.status-line .btn { padding: 2px 8px; font-size: 12px; }

.blocks { margin-top: 6px; border-left: 3px solid; border-image: var(--grad) 1; padding: 2px 0 2px 12px; display: grid; gap: 6px; }
.blocks h4 { margin: 2px 0; font-size: 15px; }
.blocks .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.blocks .context { font-size: 12px; color: var(--muted); }
.blocks hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; width: 100%; }
.blocks img { max-width: 360px; border-radius: 10px; }
.blocks .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.files .thumb { border: 0; padding: 0; background: none; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); cursor: zoom-in; }
.files .thumb img { display: block; max-width: 340px; max-height: 260px; object-fit: cover; }
.file-card {
  display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 320px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-decoration: none;
}
.file-card:hover { border-color: var(--line-strong); text-decoration: none; }
.file-card .ficon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800; background: var(--grad); flex: none; }
.file-card .fname { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card small { color: var(--muted); font-size: 12px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--text-2);
}
.reaction:hover { border-color: var(--line-strong); }
.reaction.mine { border-color: rgba(14,165,233,.5); background: var(--accent-soft); color: var(--accent-strong); }
.reaction.add { color: var(--muted); opacity: 0; }
.msg:hover .reaction.add { opacity: 1; }
.thread-link {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 4px 10px 4px 4px; border-radius: 10px;
  border: 1px solid transparent; background: none; color: var(--accent-strong); font-size: 13px; font-weight: 700;
}
.thread-link:hover { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-sm); }
.thread-link .avatar { --size: 22px; font-size: 10px; }
.thread-link small { color: var(--faint); font-weight: 500; }

.toolbar {
  position: absolute; right: 18px; top: -16px; z-index: 3; display: none; align-items: center; gap: 1px; padding: 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.msg:hover .toolbar, .toolbar.open { display: flex; }
.toolbar button { border: 0; background: none; height: 30px; min-width: 30px; padding: 0 5px; border-radius: 8px; font-size: 16px; color: var(--muted); display: grid; place-items: center; }
.toolbar button:hover { background: var(--hover); color: var(--text); }
.toolbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }

.edit-box textarea { width: 100%; border: 1px solid var(--accent); border-radius: 10px; padding: 9px 11px; resize: vertical; min-height: 64px; background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); outline: none; }
.edit-box .row { display: flex; gap: 6px; margin-top: 6px; align-items: center; font-size: 12px; color: var(--muted); }

.new-pill {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4; border: 0; color: #fff; background: var(--grad);
  padding: 7px 14px; border-radius: 99px; font-size: 13px; font-weight: 700; box-shadow: var(--glow); display: inline-flex; gap: 6px; align-items: center;
}
.list-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- 入力欄 ---------- */
.composer { padding: 0 16px 14px; flex: none; position: relative; }
.composer-box {
  border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within { border-color: rgba(14,165,233,.6); box-shadow: 0 0 0 4px var(--accent-soft); }
.composer .fmt { display: flex; align-items: center; gap: 1px; padding: 6px 8px 0; }
.composer .fmt .icon-btn { width: 28px; height: 28px; border-radius: 7px; }
.composer .fmt .icon-btn svg { width: 16px; height: 16px; }
.composer .fmt .sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.composer textarea {
  display: block; width: 100%; border: 0; resize: none; padding: 8px 14px 4px; max-height: 260px; min-height: 42px; outline: none; background: transparent; line-height: 1.55;
}
.composer textarea::placeholder { color: var(--faint); }
.composer-tools { display: flex; align-items: center; gap: 2px; padding: 4px 8px 8px; }
.composer-tools .hint { font-size: 12px; color: var(--faint); margin-left: auto; margin-right: 8px; }
.send {
  width: 36px; height: 34px; border: 0; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: var(--grad); box-shadow: var(--glow); transition: opacity .15s, filter .15s;
}
.send:disabled { background: var(--surface-3); color: var(--faint); box-shadow: none; cursor: default; }
.send svg { width: 18px; height: 18px; }
.pending-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px 0; }
.pfile { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 28px 6px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; max-width: 240px; }
.pfile img, .pfile .ficon { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; }
.pfile .ficon { display: grid; place-items: center; background: var(--grad); color: #fff; font-size: 10px; font-weight: 800; }
.pfile span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pfile .x { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--surface-3); color: var(--muted); font-size: 12px; display: grid; place-items: center; }
.pfile.loading { opacity: .6; }
.typing { height: 20px; font-size: 12px; color: var(--muted); padding: 3px 6px 0; display: flex; align-items: center; gap: 6px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.suggest {
  position: absolute; bottom: calc(100% - 6px); left: 16px; z-index: 6; min-width: 280px; max-width: 420px; max-height: 300px; overflow-y: auto;
  background: var(--glass-strong); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px;
}
.suggest .s-head { font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 8px 6px; }
.suggest .s-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.suggest .s-item.on { background: var(--accent-soft); }
.suggest .s-item .avatar { --size: 24px; font-size: 10px; }
.suggest .s-item .em { width: 24px; text-align: center; font-size: 18px; }
.suggest .s-item small { color: var(--muted); margin-left: auto; font-size: 12px; }
.drop-hint {
  position: absolute; inset: 8px; border-radius: 16px; background: var(--accent-soft); border: 2px dashed var(--accent);
  display: grid; place-items: center; font-weight: 800; color: var(--accent-strong); pointer-events: none; z-index: 10; font-size: 16px;
}

/* ---------- 右のパネル ---------- */
.panel .head h2 { font-size: 16px; }
.panel .messages .msg { padding-left: 16px; padding-right: 16px; }
.panel .composer { padding: 0 12px 12px; }
.thread-root { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 6px; }
.thread-count { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 700; padding: 4px 16px 8px; }
.thread-count::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.panel-body { flex: 1; overflow-y: auto; min-height: 0; padding: 12px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; }
.member-row:hover { background: var(--hover); }
.member-row b { font-size: 14px; }
.member-row small { color: var(--muted); font-size: 12px; display: block; }
.member-row .role { margin-left: auto; }
.result { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.result:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.result .sub { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; }
.result mark { background: rgba(245,158,11,.3); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- 小窓・メニュー・ポップ ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(2,6,23,.38); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: start center; padding: 10vh 16px 16px; }
.dialog {
  width: min(520px, 100%); max-height: 80vh; overflow: auto; border-radius: 20px; background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.dialog-body { padding: 22px 24px; }
.dialog h3 { margin: 0 0 14px; font-size: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting-row:first-of-type { border-top: 0; }
.setting-row b { font-size: 14px; display: block; }
.setting-row small { color: var(--muted); font-size: 12.5px; }
.switcher { padding: 0; }
.switcher-input { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.switcher-input svg { width: 20px; height: 20px; color: var(--muted); }
.switcher-input input { flex: 1; border: 0; background: transparent; font-size: 17px; outline: none; }
.switcher-list { padding: 8px; max-height: 50vh; overflow-y: auto; }
.switcher-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; cursor: pointer; font-size: 15px; }
.switcher-item.on { background: var(--accent-soft); }
.switcher-item .hash { width: 24px; text-align: center; color: var(--faint); font-weight: 700; }
.switcher-item .avatar { --size: 24px; font-size: 10px; }
.switcher-item small { margin-left: auto; color: var(--muted); font-size: 12px; }
.switcher-item .badge { margin-left: auto; background: var(--grad); color: #fff; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; }
.switcher-foot { display: flex; gap: 14px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.shortcuts { display: grid; grid-template-columns: 1fr auto; gap: 10px 20px; font-size: 14px; }
.shortcuts .keys { display: flex; gap: 4px; justify-content: flex-end; }
.menu, .pop {
  position: fixed; z-index: 50; min-width: 220px; padding: 6px; border-radius: 14px; background: var(--glass-strong);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--line); box-shadow: var(--shadow-lg); color: var(--text);
}
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 9px; font-size: 14px; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.menu .menu-label { font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 10px 2px; }
.emoji-pop { width: 340px; padding: 0; }
.emoji-pop .e-search { padding: 10px 10px 6px; }
.emoji-pop .e-search input { padding: 7px 10px; font-size: 14px; }
.emoji-pop .e-body { height: 260px; overflow-y: auto; padding: 0 8px 8px; }
.emoji-pop .e-cat { font-size: 11px; font-weight: 700; color: var(--muted); padding: 8px 4px 4px; position: sticky; top: 0; background: var(--glass-strong); }
.emoji-pop .e-grid { display: grid; grid-template-columns: repeat(8, 1fr); }
.emoji-pop .e-grid button { border: 0; background: none; font-size: 22px; height: 38px; border-radius: 9px; }
.emoji-pop .e-grid button:hover { background: var(--hover); transform: scale(1.12); }
.emoji-pop .e-foot { border-top: 1px solid var(--line); padding: 6px 10px; font-size: 12px; color: var(--muted); min-height: 30px; }
.profile-pop { width: 280px; padding: 0; overflow: hidden; }
.profile-pop .cover { height: 64px; background: var(--grad); }
.profile-pop .p-body { padding: 0 16px 16px; margin-top: -28px; }
.profile-pop .avatar { --size: 64px; border: 4px solid var(--surface); border-radius: 22px; font-size: 26px; }
.profile-pop h4 { margin: 8px 0 0; font-size: 18px; }
.profile-pop .p-sub { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; margin: 2px 0 12px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.online-dot.on { background: #22c55e; }
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; justify-items: center; }
.toast {
  display: flex; align-items: center; gap: 12px; background: #0f172a; color: #fff; padding: 10px 12px 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow-lg); animation: toast-in .2s ease-out;
}
:root[data-theme="dark"] .toast { background: #e8eef8; color: #0f172a; }
.toast button { border: 0; background: rgba(255,255,255,.14); color: inherit; font-weight: 700; padding: 5px 10px; border-radius: 8px; font-size: 13px; }
:root[data-theme="dark"] .toast button { background: rgba(15,23,42,.1); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(2,6,23,.86); display: grid; place-items: center; padding: 40px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: var(--shadow-lg); }
.lightbox .lb-bar { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; }
.lightbox .lb-bar .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #fff; }
.lightbox .lb-name { position: absolute; top: 20px; left: 20px; color: #fff; font-weight: 600; }
.side-backdrop { display: none; }

/* 画面に入ったときの動きは 1 回だけ（common-ui-motion）。動き終わったら印を外す */
.view-in { animation: view-in .28s cubic-bezier(.2,.7,.2,1) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
.pop-in { animation: pop-in .14s ease-out both; }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(.98); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- 連携・引っ越しの画面（既存） ---------- */
.page { flex: 1; overflow-y: auto; padding: 24px 32px 48px; }
.page h3 { margin: 32px 0 6px; font-size: 17px; }
.page h3:first-of-type { margin-top: 8px; }
.page .desc { color: var(--muted); font-size: 14px; margin: 0 0 14px; max-width: 760px; line-height: 1.75; }
.tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; padding: 4px; background: var(--surface-3); border-radius: 12px; width: fit-content; }
.tabs button { border: 0; background: none; padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 700; font-size: 14px; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; max-width: 880px; }
.form-row .input { width: auto; flex: 1; min-width: 160px; }
.form-row select.input { flex: 0 0 auto; }
.list { border: 1px solid var(--line); border-radius: var(--radius); max-width: 880px; background: var(--surface); overflow: hidden; }
.list-item { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 200px; }
.list-item .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.code-line { display: flex; gap: 6px; align-items: stretch; margin-top: 6px; max-width: 880px; }
.code-line code, pre.snippet {
  flex: 1; background: #0b1220; color: #d7e1ee; border-radius: 10px; padding: 9px 12px; font-size: 12.5px; overflow-x: auto; white-space: pre; display: block; font-family: var(--mono);
}
pre.snippet { margin: 6px 0 0; max-width: 880px; }
.secret-box { background: var(--grad-soft); border: 1px solid rgba(14,165,233,.25); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; max-width: 880px; }
.secret-box p { margin: 0 0 6px; font-size: 14px; }
.ok-dot { color: #22c55e; }
.ng-dot { color: var(--danger); }


/* 連携: アプリとつなぐ（OAuth）と、畳んだ開発者向け */
.connect-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; max-width: 880px; margin-bottom: 28px; }
.connect-card { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.connect-card b { font-size: 15px; }
.connect-card p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.connect-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px; flex: none; }
details.dev { max-width: 880px; border-top: 1px solid var(--line); padding-top: 14px; }
details.dev > summary { cursor: pointer; font-weight: 700; color: var(--muted); font-size: 14px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.dev > summary::before { content: "▸"; transition: transform .15s; }
details.dev[open] > summary::before { transform: rotate(90deg); }
details.dev > summary::-webkit-details-marker { display: none; }

/* はじめの画面: アプリの中のブラウザの案内・区切り・鍵が作れないとき */
.inapp { border: 1px solid rgba(245,158,11,.45); background: rgba(245,158,11,.10); border-radius: 14px; padding: 12px 14px; margin: 0 0 16px; font-size: 14px; }
.inapp p { margin: 4px 0 10px; color: var(--text-2); font-size: 13px; }
.inapp .btn { margin: 0 6px 6px 0; }
.or { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
details.fallback { margin-top: 14px; font-size: 13px; color: var(--muted); }
details.fallback summary { cursor: pointer; text-align: center; }
details.fallback p { margin: 8px 0; }
.setting-row .btn { white-space: nowrap; flex: none; }
.key-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.key-row:first-child { border-top: 0; }
.key-row small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- スマホ ---------- */
.mobile-only { display: none; }
@media (max-width: 1100px) {
  .app { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .panel { position: fixed; top: 10px; right: 10px; bottom: 10px; z-index: 20; box-shadow: var(--shadow-lg); }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 0; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 30; background: var(--glass-strong);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); transform: translateX(-102%); transition: transform .22s ease;
    padding-top: max(8px, env(safe-area-inset-top)); box-shadow: var(--shadow-lg);
  }
  .app.side-open .side { transform: none; }
  .app.side-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(2,6,23,.4); }
  .main { border-radius: 0; border: 0; box-shadow: none; }
  .panel { inset: 0; width: auto; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
  .head { padding: 8px 10px; min-height: 56px; padding-top: max(8px, env(safe-area-inset-top)); }
  .head .topic, .search-box, .stack .count { display: none; }
  .mobile-only { display: inline-grid; }
  .msg { padding-left: 12px; padding-right: 12px; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; }
  .msg .avatar { --size: 36px; }
  .toolbar { right: 8px; }
  .composer { padding: 0 8px max(8px, env(safe-area-inset-bottom)); }
  .composer .fmt { display: none; }
  .composer-tools .hint { display: none; }
  .composer-tools .spacer { flex: 1; }
  .page { padding: 16px; }
  .emoji-pop { width: min(340px, calc(100vw - 16px)); }
  .files .thumb img { max-width: 100%; }
}
