/* Four columns like a chat client: server rail, channels, conversation, side panel. Columns become overlays on narrow screens. */
@font-face { font-family: "Noto Sans"; src: url("/fonts/NotoSans-Regular.ttf"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Sans"; src: url("/fonts/NotoSans-Bold.ttf"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Noto Sans Thai"; src: url("/fonts/NotoSansThai-Regular.ttf"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Sans Thai"; src: url("/fonts/NotoSansThai-Bold.ttf"); font-weight: 700; font-display: swap; }
:root {
  color-scheme: dark;
  --rail: #1e1f22; --side: #2b2d31; --main: #313338; --raised: #383a40; --hover: #2e3035; --active: #404249; --line: #26282c;
  --fg: #f2f3f5; --text: #dbdee1; --muted: #949ba4;
  --brand: #5865f2; --ok: #7fe7b3; --warn: #ffc56b; --bad: #f47b7b; --red: #da373c; --staff: #f6ad55;
  --sans: "Noto Sans", "Noto Sans Thai", "Segoe UI", system-ui, sans-serif;
}
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body { background: var(--rail); color: var(--text); font: 400 15px/1.45 var(--sans); overflow: hidden; }
button, select, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:focus-visible, textarea:focus-visible, input:focus-visible, label:focus-within { outline: 2px solid var(--brand); outline-offset: 1px; }
a { color: #00a8fc; }
.app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.notice { background: #4a1f1f; color: #ffd7d7; font-size: 13px; padding: 5px 12px; text-align: center; }
.cols { display: grid; grid-template-columns: 64px 236px minmax(0, 1fr) 300px; min-height: 0; }

.rail { background: var(--rail); padding: 10px 0; display: flex; flex-direction: column; align-items: center; }
.rail img { width: 46px; height: 46px; border-radius: 16px; background: var(--main); padding: 3px; }

.side { background: var(--side); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; min-width: 0; }
.srv { padding: 12px 14px; font-weight: 700; color: var(--fg); border-bottom: 1px solid var(--line); font-size: 14px; }
.list { overflow-y: auto; padding: 6px 8px 12px; }
.cat { font-size: 11px; font-weight: 700; color: var(--muted); padding: 14px 6px 3px; letter-spacing: .02em; }
.ch { width: 100%; display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 4px; color: var(--muted); text-align: left; }
.ch:hover { background: var(--hover); color: var(--text); }
.ch.on { background: var(--active); color: var(--fg); }
.ch.unread { color: var(--fg); font-weight: 700; }
.ch.thread { padding-left: 24px; font-size: 14px; }
.ch .pre { width: 16px; flex: none; text-align: center; opacity: .8; }
.ch .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch img { width: 20px; height: 20px; border-radius: 50%; background: var(--raised); flex: none; }
.badge { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 9px; padding: 0 6px; flex: none; font-variant-numeric: tabular-nums; }
.me { background: #232428; padding: 8px 10px; font-size: 13px; }
.me .row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.me img { width: 30px; height: 30px; border-radius: 50%; background: var(--raised); flex: none; }
.me-tx { flex: 1; min-width: 0; }
.me b { color: var(--fg); display: block; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { background: var(--main); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; min-width: 0; }
.top { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); min-width: 0; }
.top h1 { font-size: 15px; font-weight: 700; color: var(--fg); margin: 0; flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .topic { color: var(--muted); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn { padding: 4px 8px; border-radius: 4px; color: var(--muted); font-size: 13px; flex: none; }
.iconbtn:hover { background: var(--hover); color: var(--fg); }
.only-narrow, .only-right { display: none; }
.msgs { overflow-y: auto; padding: 14px 0 6px; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.more { align-self: center; color: var(--muted); font-size: 13px; padding: 4px 12px; border-radius: 4px; flex: none; }
.more:hover { background: var(--hover); color: var(--fg); }
.m { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 7px 16px; flex: none; }
.m:hover { background: var(--hover); }
.m.flash { background: #3a3f6e; transition: background 1.2s; }
.m .pic { width: 40px; height: 40px; border-radius: 50%; background: var(--raised); padding: 0; overflow: hidden; }
.m .pic img { width: 100%; height: 100%; display: block; }
.m .bd { min-width: 0; overflow-wrap: anywhere; }
.who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.who button { font-weight: 700; color: var(--fg); padding: 0; }
.who button:hover { text-decoration: underline; }
.who time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tag { font-size: 10px; font-weight: 700; border-radius: 3px; padding: 0 4px; background: var(--brand); color: #fff; }
.quote { display: block; width: 100%; text-align: left; font-size: 13px; color: var(--muted); border-left: 2px solid #4e5058; padding: 0 0 0 8px; margin: 1px 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txt { white-space: pre-wrap; }
.txt code { background: #1e1f22; padding: 0 4px; border-radius: 3px; font-size: 13px; }
.ment { background: #3c4270; color: #c9cdfb; padding: 0 3px; border-radius: 3px; }
.edited { color: var(--muted); font-size: 11px; }
.gone .txt { color: var(--muted); text-decoration: line-through; }
.del { margin-top: 3px; font-size: 12px; color: var(--bad); }
.m img.att { display: block; margin-top: 6px; border-radius: 8px; max-width: min(100%, 440px); max-height: 320px; }
.fileatt { display: inline-block; margin-top: 6px; background: var(--side); padding: 6px 10px; border-radius: 6px; }
.emb { margin-top: 4px; border-left: 4px solid #a78bfa; background: var(--side); padding: 8px 12px; border-radius: 4px; max-width: 520px; }
.emb b { color: var(--fg); display: block; }
.emb .ft { color: var(--muted); font-size: 12px; margin-top: 4px; }
.emb img { display: block; margin-top: 6px; max-width: 100%; border-radius: 4px; }
.dcbtn { display: inline-block; margin: 8px 6px 0 0; font-size: 13px; background: #4e5058; color: #fff; border-radius: 4px; padding: 3px 10px; }
.dcbtn.live { cursor: pointer; font-weight: 700; }
.dcbtn.live:hover { filter: brightness(1.15); }
.dcbtn.danger { background: var(--red); }
.card .acts button.danger { color: var(--bad); }
.sys { color: var(--muted); font-size: 13px; font-style: italic; }
.closed-note { align-self: center; padding: 8px 16px; flex: none; }
.rcts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.rct { font-size: 13px; background: var(--raised); border: 1px solid transparent; border-radius: 6px; padding: 0 6px; }
.rct.mine { background: #3c4270; border-color: var(--brand); }
.status { margin-top: 3px; font-size: 12px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.err { color: var(--bad); }
.status button { color: var(--fg); text-decoration: underline; font-size: 12px; padding: 0 0 0 6px; }
.bar { position: absolute; right: 12px; top: -10px; display: none; background: var(--main); border: 1px solid #1f2023; border-radius: 6px; padding: 2px; z-index: 2; flex-wrap: wrap; }
.m:hover .bar, .m:focus-within .bar { display: flex; }
.bar button { font-size: 12px; padding: 2px 7px; border-radius: 4px; color: var(--text); }
.bar button:hover { background: var(--active); }
.bar button.danger { color: var(--bad); }
.editbox { width: 100%; background: var(--raised); border-radius: 6px; padding: 6px 8px; margin-top: 4px; border: 0; resize: vertical; min-height: 60px; color: var(--fg); }
.editacts { display: flex; gap: 10px; font-size: 12px; margin-top: 2px; }
.editacts button { color: var(--ok); padding: 0; font-size: 12px; }
.center { margin: auto; padding: 24px; max-width: 440px; text-align: center; color: var(--muted); }
.center b { display: block; color: var(--fg); font-size: 17px; margin-bottom: 6px; }

.compose { padding: 0 14px 12px; display: grid; gap: 6px; min-width: 0; position: relative; }
.reply { display: flex; gap: 8px; justify-content: space-between; background: var(--side); border-radius: 6px 6px 0 0; padding: 5px 10px; font-size: 13px; color: var(--muted); min-width: 0; }
.reply span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest { position: absolute; left: 14px; right: 14px; bottom: 100%; background: var(--side); border-radius: 6px; padding: 4px; max-height: 220px; overflow-y: auto; box-shadow: 0 -4px 16px rgba(0,0,0,.35); z-index: 3; }
.box { background: var(--raised); border-radius: 8px; padding: 8px 10px; display: grid; gap: 6px; }
textarea#input { width: 100%; background: transparent; border: 0; outline: 0; resize: none; line-height: 1.45; min-height: 24px; max-height: 140px; color: var(--fg); padding: 0; }
textarea::placeholder { color: var(--muted); }
.ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.file { font-size: 13px; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.file:hover { color: var(--fg); background: var(--active); }
.file input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.send { margin-left: auto; background: var(--brand); color: #fff; font-weight: 700; font-size: 14px; border-radius: 4px; padding: 4px 16px; }
.send:disabled { opacity: .45; cursor: default; }
.picked { font-size: 12px; color: var(--ok); }

.right { background: var(--side); display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; min-width: 0; }
.rtabs { display: flex; border-bottom: 1px solid var(--line); }
.rtabs button { flex: 1; padding: 10px 4px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; }
.rtabs button.on { color: var(--fg); border-bottom-color: var(--brand); font-weight: 700; }
.rbody { overflow-y: auto; padding: 12px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.rbody h3 { margin: 0; font-size: 12px; color: var(--muted); font-weight: 700; }
.card { background: var(--main); border-radius: 6px; padding: 8px 10px; display: grid; gap: 4px; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.card small { color: var(--muted); font-size: 12px; }
.card .acts { display: flex; flex-wrap: wrap; gap: 10px; }
.card .acts button { color: var(--ok); font-size: 12px; padding: 0; }
.pill { font-size: 11px; font-weight: 700; }
.pill.open { color: var(--warn); }
.pill.closed { color: var(--muted); }
.person { display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px 6px; border-radius: 4px; text-align: left; min-width: 0; }
.person:hover, .person.on { background: var(--hover); }
.person img { width: 30px; height: 30px; border-radius: 50%; background: var(--raised); flex: none; }
.person span { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); font-size: 13px; }
input[type=search] { width: 100%; background: var(--rail); border: 0; border-radius: 4px; padding: 6px 8px; color: var(--fg); }
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 4; }

.login-page { display: grid; place-items: center; overflow: auto; padding: 16px; background: var(--rail); min-height: 100%; }
.login { background: var(--main); border-radius: 8px; padding: 28px; width: min(380px, 100%); display: grid; gap: 8px; }
.login h1 { margin: 6px 0 0; font-size: 22px; color: var(--fg); }
.login p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.login label { font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 6px; }
.login input { background: var(--rail); border: 0; border-radius: 4px; padding: 9px 10px; color: var(--fg); width: 100%; }
.login button { margin-top: 12px; background: var(--brand); color: #fff; font-weight: 700; border-radius: 4px; padding: 10px; }
.login button:disabled { opacity: .5; }
.err { color: var(--bad); font-size: 13px; }

@media (max-width: 1120px) {
  .cols { grid-template-columns: 64px 236px minmax(0, 1fr); }
  .right { display: none; position: fixed; top: 0; right: 0; bottom: 0; width: min(320px, 88vw); z-index: 5; padding-top: env(safe-area-inset-top, 0px); }
  .open-right .right { display: grid; }
  .open-right .scrim { display: block; }
  .only-right { display: inline-block; }
}
@media (max-width: 760px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .side { display: none; position: fixed; top: 0; left: 0; bottom: 0; width: min(290px, 86vw); z-index: 5; padding-top: env(safe-area-inset-top, 0px); }
  .open-side .side { display: grid; }
  .open-side .scrim { display: block; }
  .only-narrow { display: inline-block; }
  .top .topic { display: none; }
  .top h1 { flex: 1; max-width: none; }
}
@media (prefers-reduced-motion: reduce) { .m.flash { transition: none; } }
