/* Sync の見た目。配色は一旦 Slack に揃えた(2026-11-29 User)。ライト = 紫の左の帯と白い本文 / ダーク = Slack のダーク。
   切り替え = 既定は OS の設定・上の右のボタンで固定(data-theme・app.js)。 */
:root {
  --bg: #ffffff; --fg: #1d1c1d; --muted: #616061; --faint: #868686; --line: #dddddd; --hover: #f8f8f8; --row-hover: #f8f8f8;
  --top-bg: #350d36; --top-fg: #ffffff; --search-bg: #5d3c5e; --search-fg: #ffffff;
  --side-bg: #3f0e40; --side-fg: #cfc3cf; --side-strong: #ffffff; --side-hover: #350d36; --side-active: #1164a3; --side-line: #5d3c5e;
  --link: #1264a3; --mention-bg: #fef9ec; --mention-bar: #f2c744; --at-fg: #1264a3; --at-bg: #e8f5fa; --at-me-bg: #fdf3c8;
  --badge: #cd2553; --new: #e01e5a; --online: #2bac76; --send: #007a5a; --send-off: #dddddd;
  --react-bg: #f8f8f8; --react-line: #dddddd; --react-me-bg: #e8f5fa; --react-me-line: #1d9bd1;
  --code-bg: #f8f8f8; --code-fg: #e01e5a; --code-line: #dddddd; --quote: #dddddd;
  --shadow: 0 0 0 1px rgba(29,28,29,.13), 0 4px 12px rgba(0,0,0,.12); color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1d21; --fg: #d1d2d3; --muted: #ababad; --faint: #818385; --line: #35373b; --hover: #222529; --row-hover: #222529;
    --top-bg: #121016; --top-fg: #d1d2d3; --search-bg: #35373b; --search-fg: #d1d2d3;
    --side-bg: #19171d; --side-fg: #b9babd; --side-strong: #ffffff; --side-hover: #27242c; --side-active: #1164a3; --side-line: #35373b;
    --link: #1d9bd1; --mention-bg: #2d2a1f; --mention-bar: #f2c744; --at-fg: #1d9bd1; --at-bg: #1d9bd11a; --at-me-bg: #f2c74433;
    --react-bg: #222529; --react-line: #35373b; --react-me-bg: #1d9bd126; --react-me-line: #1d9bd1;
    --code-bg: #222529; --code-fg: #e8912d; --code-line: #35373b; --quote: #4a4d52; --send-off: #35373b;
    --shadow: 0 0 0 1px rgba(255,255,255,.08), 0 4px 12px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1d21; --fg: #d1d2d3; --muted: #ababad; --faint: #818385; --line: #35373b; --hover: #222529; --row-hover: #222529;
  --top-bg: #121016; --top-fg: #d1d2d3; --search-bg: #35373b; --search-fg: #d1d2d3;
  --side-bg: #19171d; --side-fg: #b9babd; --side-strong: #ffffff; --side-hover: #27242c; --side-active: #1164a3; --side-line: #35373b;
  --link: #1d9bd1; --mention-bg: #2d2a1f; --mention-bar: #f2c744; --at-fg: #1d9bd1; --at-bg: #1d9bd11a; --at-me-bg: #f2c74433;
  --react-bg: #222529; --react-line: #35373b; --react-me-bg: #1d9bd126; --react-me-line: #1d9bd1;
  --code-bg: #222529; --code-fg: #e8912d; --code-line: #35373b; --quote: #4a4d52; --send-off: #35373b;
  --shadow: 0 0 0 1px rgba(255,255,255,.08), 0 4px 12px rgba(0,0,0,.5); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 15px/1.46668 -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input, textarea { font: inherit; color: inherit; }

/* 名前を選ぶ */
.pick { position: fixed; inset: 0; display: grid; place-items: center; background: var(--side-bg); }
.pick-card { background: var(--bg); padding: 36px 40px; border-radius: 12px; min-width: 300px; text-align: center; box-shadow: var(--shadow); }
.pick-card h1 { margin: 0 0 4px; font-size: 28px; }
.pick-card p { margin: 0 0 18px; color: var(--muted); }
.pick-list { display: grid; gap: 8px; }
.pick-list button { padding: 11px; border: 1px solid var(--line); border-radius: 8px; font-weight: 700; }
.pick-list button:hover { background: var(--hover); }

/* 枠 */
.app { display: grid; grid-template-columns: 260px 1fr auto; grid-template-rows: 44px 1fr; height: 100dvh; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--top-bg); color: var(--top-fg); }
.search-wrap { flex: 1; display: flex; justify-content: center; }
.search { width: min(720px, 100%); height: 28px; border-radius: 6px; border: 0; padding: 0 12px; background: var(--search-bg); color: var(--search-fg); outline: 0; }
.search::placeholder { color: color-mix(in srgb, var(--search-fg) 70%, transparent); }
.search:focus { background: var(--bg); color: var(--fg); box-shadow: var(--shadow); }
.top-right { display: flex; align-items: center; gap: 6px; }
.top-btn { width: 28px; height: 28px; border-radius: 6px; color: var(--top-fg); font-size: 15px; }
.top-btn:hover { background: rgba(255,255,255,.15); }
.me-btn { height: 28px; padding: 0 10px; border-radius: 6px; color: var(--top-fg); font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.me-btn:hover { background: rgba(255,255,255,.15); }
.menu { display: none; }

/* 左の帯 */
.side { background: var(--side-bg); color: var(--side-fg); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--side-line); }
.ws-head { height: 50px; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--side-line); }
.ws-name { color: var(--side-strong); font-weight: 900; font-size: 18px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 10px 0; }
.sec { margin-bottom: 14px; }
.sec-head { display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 16px; color: var(--side-fg); font-size: 15px; text-align: left; }
.sec-head:hover { color: var(--side-strong); }
.caret { display: inline-block; width: 12px; font-size: 11px; transition: transform .1s; }
.sec.closed .caret { transform: rotate(-90deg); }
.sec.closed .sec-list .side-item:not(.active):not(.unread) { display: none; }
.side-item { display: flex; align-items: center; gap: 8px; width: calc(100% - 16px); margin: 0 8px; padding: 0 8px; height: 28px; border-radius: 6px; color: var(--side-fg); text-decoration: none; font-size: 15px; text-align: left; }
.side-item:hover { background: var(--side-hover); }
.side-item.active { background: var(--side-active); color: #fff; }
.side-item.unread { color: var(--side-strong); font-weight: 900; }
.side-item .ic { width: 18px; text-align: center; opacity: .85; }
.side-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .badge { background: var(--badge); color: #fff; border-radius: 9px; font-size: 12px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 6px; display: grid; place-items: center; }
.side-item.add { color: var(--side-fg); }
.mini-av { position: relative; width: 20px; height: 20px; border-radius: 4px; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; flex: none; }
.dot { position: absolute; right: -3px; bottom: -3px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--side-bg); background: var(--side-bg); box-shadow: inset 0 0 0 1.5px var(--side-fg); }
.dot.on { background: var(--online); box-shadow: none; }
.conn { padding: 8px 16px; font-size: 12px; color: var(--side-fg); border-top: 1px solid var(--side-line); }
.conn.ok::before { content: "● "; color: var(--online); }

/* 本文 */
.main, .thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.thread { width: 420px; border-left: 1px solid var(--line); }
.ch-head { display: flex; align-items: center; gap: 10px; padding: 0 16px 0 20px; height: 50px; border-bottom: 1px solid var(--line); flex: none; }
.ch-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.ch-title h2 { margin: 0; font-size: 18px; font-weight: 900; white-space: nowrap; }
.ch-topic { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50ch; text-align: left; }
.ch-topic:hover { color: var(--fg); }
.th-ch { color: var(--muted); font-size: 13px; }
.ch-members { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px 2px 4px; gap: 2px; font-size: 13px; color: var(--muted); }
.ch-members .mini-av { margin-right: -4px; border: 2px solid var(--bg); width: 24px; height: 24px; }
.ch-members span { margin-left: 8px; }
.icon-btn { width: 32px; height: 32px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--fg); }

.list { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
.day { position: relative; text-align: center; margin: 16px 0 8px; }
.day::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.day span { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 24px; padding: 3px 14px; font-size: 13px; font-weight: 700; }
.new-line { display: flex; align-items: center; gap: 8px; color: var(--new); font-size: 12px; font-weight: 700; margin: 4px 0; padding-right: 20px; }
.new-line::before { content: ""; flex: 1; border-top: 1px solid var(--new); }
.empty { color: var(--muted); padding: 24px 20px; }
.intro { padding: 24px 20px 8px; }
.intro h3 { margin: 0 0 4px; font-size: 22px; font-weight: 900; }
.intro p { margin: 0; color: var(--muted); }

.msg { position: relative; display: grid; grid-template-columns: 36px 1fr; column-gap: 8px; padding: 8px 20px; }
.msg.cont { padding-top: 2px; padding-bottom: 2px; }
.msg:hover, .msg.menu-open { background: var(--row-hover); }
.msg.mention { background: var(--mention-bg); box-shadow: inset 2px 0 0 var(--mention-bar); }
.msg.flash { animation: flash 2s ease-out; }
@keyframes flash { from { background: var(--at-me-bg); } to { background: transparent; } }
.avatar { width: 36px; height: 36px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 15px; margin-top: 2px; }
.gutter-time { visibility: hidden; color: var(--faint); font-size: 12px; text-align: right; line-height: 22px; white-space: nowrap; }
.msg.cont:hover .gutter-time { visibility: visible; }
.meta { display: flex; gap: 8px; align-items: baseline; }
.meta b { font-weight: 900; }
.meta time { color: var(--faint); font-size: 12px; }
.meta time:hover { text-decoration: underline; cursor: pointer; }
.body { overflow-wrap: anywhere; }
.body p { margin: 0; white-space: pre-wrap; }
.edited { color: var(--faint); font-size: 13px; }
.deleted { color: var(--faint); font-style: italic; }
.body a { color: var(--link); text-decoration: none; }
.body a:hover { text-decoration: underline; }
.body .at { color: var(--at-fg); background: var(--at-bg); border-radius: 3px; padding: 0 2px; font-weight: 500; }
.body .at.me { background: var(--at-me-bg); color: var(--fg); }
.body code { font: 12px/1.5 Monaco, Menlo, Consolas, monospace; color: var(--code-fg); background: var(--code-bg); border: 1px solid var(--code-line); border-radius: 3px; padding: 1px 3px; }
.body pre { font: 12px/1.5 Monaco, Menlo, Consolas, monospace; background: var(--code-bg); border: 1px solid var(--code-line); border-radius: 4px; padding: 8px; margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.body blockquote { margin: 2px 0; padding-left: 12px; border-left: 4px solid var(--quote); }
.body ul, .body ol { margin: 2px 0; padding-left: 24px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.files a { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; color: var(--fg); text-decoration: none; font-size: 13px; background: var(--bg); }
.files a:hover { background: var(--hover); }
.files img { max-width: 360px; max-height: 240px; border-radius: 8px; display: block; border: 1px solid var(--line); }
.files a.img { padding: 0; border: 0; }

.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react { display: flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 12px; background: var(--react-bg); border: 1px solid var(--react-line); font-size: 12px; font-weight: 700; color: var(--muted); }
.react .e { font-size: 15px; }
.react.me { background: var(--react-me-bg); border-color: var(--react-me-line); color: var(--react-me-line); }
.react:hover { border-color: var(--muted); }
.react.add { opacity: 0; font-size: 14px; }
.msg:hover .react.add { opacity: 1; }

.thread-sum { display: flex; align-items: center; gap: 6px; margin-top: 4px; padding: 4px 6px 4px 4px; border-radius: 6px; border: 1px solid transparent; font-size: 13px; max-width: 420px; text-align: left; }
.thread-sum:hover { background: var(--bg); border-color: var(--line); }
.thread-sum .mini-av { width: 24px; height: 24px; }
.thread-sum b { color: var(--link); }
.thread-sum .when { color: var(--faint); }

/* 投稿の上に出る操作 */
.actions { position: absolute; right: 18px; top: -16px; display: none; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 2px; z-index: 5; }
.msg:hover .actions, .msg.menu-open .actions { display: flex; }
.actions button { width: 32px; height: 32px; border-radius: 4px; font-size: 16px; color: var(--muted); display: grid; place-items: center; }
.actions button:hover { background: var(--hover); color: var(--fg); }
.actions .sep { width: 1px; background: var(--line); margin: 4px 2px; }

.edit-box { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin-top: 4px; }
.edit-box textarea { width: 100%; border: 0; outline: 0; resize: none; background: transparent; padding: 8px 10px; min-height: 40px; }
.edit-box .row { display: flex; justify-content: flex-end; gap: 8px; padding: 6px 8px; }
.btn { height: 28px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.btn.primary { background: var(--send); color: #fff; border-color: var(--send); }

/* 入力欄 */
.compose { position: relative; padding: 0 20px 20px; flex: none; }
.compose-box { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.compose-box:focus-within { border-color: var(--muted); box-shadow: 0 0 0 1px var(--muted); }
.fmt { display: flex; align-items: center; gap: 2px; padding: 4px 6px 0; }
.fmt button, .tools button, .tools label { width: 28px; height: 28px; border-radius: 4px; color: var(--muted); font-size: 14px; display: grid; place-items: center; cursor: pointer; }
.fmt button:hover, .tools button:hover, .tools label:hover { background: var(--hover); color: var(--fg); }
.fmt .b { font-weight: 900; } .fmt .i { font-style: italic; font-family: Georgia, serif; } .fmt .s { text-decoration: line-through; }
.fmt .sep, .tools .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.compose textarea { display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; padding: 6px 12px; max-height: 300px; min-height: 22px; }
.tools { display: flex; align-items: center; gap: 2px; padding: 0 6px 6px; }
.tools .grow { flex: 1; }
.tools .send { width: 32px; height: 28px; border-radius: 4px; background: var(--send-off); color: var(--faint); font-size: 15px; }
.tools .send.ready { background: var(--send); color: #fff; }
.att { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.att span { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.att span button { color: var(--muted); }
.typing { height: 18px; padding: 2px 4px 0; font-size: 12px; color: var(--muted); }
.suggest { position: absolute; bottom: calc(100% - 14px); left: 20px; z-index: 30; background: var(--bg); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; min-width: 220px; padding: 4px 0; }
.suggest button { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; padding: 4px 14px; }
.suggest button.on { background: var(--side-active); color: #fff; }

/* スレッド */
.th-count { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; padding: 4px 20px; }
.th-count::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* 検索 */
.search-view .msg { cursor: pointer; }
.hit-ch { padding: 0 20px; font-size: 12px; color: var(--muted); font-weight: 700; margin-top: 8px; }
.search-head { padding: 8px 20px; font-weight: 900; font-size: 18px; }

/* 切り替え(⌘K)と絵文字 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: start center; padding-top: 12vh; z-index: 50; }
.modal-card { width: min(560px, 92vw); background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.sw-input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 16px 20px; font-size: 18px; background: transparent; outline: 0; }
.sw-list { max-height: 50vh; overflow-y: auto; padding: 6px 0; }
.sw-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 20px; text-align: left; }
.sw-list button.on { background: var(--side-active); color: #fff; }
.emoji-pop { position: fixed; z-index: 60; background: var(--bg); border-radius: 10px; box-shadow: var(--shadow); padding: 8px; display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; }
.emoji-pop button { width: 34px; height: 34px; border-radius: 6px; font-size: 20px; }
.emoji-pop button:hover { background: var(--hover); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-size: 13px; z-index: 70; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; top: 44px; bottom: 0; left: 0; width: 82%; max-width: 320px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .app.side-open .side { transform: none; }
  .menu { display: grid; place-items: center; }
  .thread { position: fixed; inset: 44px 0 0 0; width: auto; z-index: 45; border: 0; }
  .compose { padding: 0 10px max(10px, env(safe-area-inset-bottom)); }
  .msg { padding-left: 12px; padding-right: 12px; }
  .ch-members, .ch-topic { display: none; }
  .actions { right: 8px; }
}
