/* YH Talk — dark graphite with an ember accent. */
:root {
  --bg-rail: #121316;
  --bg-sidebar: #1a1b1f;
  --bg-chat: #222328;
  --bg-elev: #2b2d33;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.07);
  --text: #e9e7e3;
  --text-2: #a9a8a4;
  --text-3: #75746f;
  --accent: #ff7a45;
  --accent-ink: #1a1007;
  --danger: #ef4f4f;
  --online: #3fc77d;
  --idle: #f0b232;
  --dnd: #ef4f4f;
  --radius: 10px;
  --titlebar: 30px;
  font-family: 'Noto Sans Thai', 'Leelawadee UI', 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg-rail);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #root { height: 100%; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; background: none; border: 0; outline: none; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #0e0f11; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
.muted { color: var(--text-3); }

.app { height: 100%; display: flex; flex-direction: column; }
.workspace { flex: 1; display: flex; min-height: 0; }

/* Title bar — draggable region, buttons opt out */
.titlebar {
  height: var(--titlebar); flex: none; display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-rail); -webkit-app-region: drag; user-select: none;
}
.titlebar-brand { display: flex; align-items: center; gap: 8px; padding-left: 12px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.titlebar-brand.mac { padding-left: 78px; }
.brand-mark {
  font-size: 9px; font-weight: 800; letter-spacing: 0.04em; padding: 2px 4px; border-radius: 4px;
  background: var(--accent); color: var(--accent-ink);
}
.titlebar-controls { display: flex; height: 100%; -webkit-app-region: no-drag; }
.titlebar-controls button { width: 46px; height: 100%; display: grid; place-items: center; color: var(--text-2); }
.titlebar-controls button:hover { background: var(--bg-active); color: var(--text); }
.titlebar-controls .close:hover { background: var(--danger); color: #fff; }

/* Server rail */
.rail { width: 72px; flex: none; background: var(--bg-rail); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0; overflow-y: auto; }
.rail-item { position: relative; width: 100%; display: flex; justify-content: center; }
.rail-pill {
  position: absolute; left: 0; top: 50%; width: 4px; height: 0; border-radius: 0 4px 4px 0;
  background: var(--text); transform: translateY(-50%); transition: height 0.15s ease;
}
.rail-item.has-unread .rail-pill { height: 8px; }
.rail-item:hover .rail-pill { height: 20px; }
.rail-item.active .rail-pill { height: 40px; }
.rail-icon {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; background: var(--bg-elev); color: var(--text);
  transition: border-radius 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.rail-item:hover .rail-icon, .rail-item.active .rail-icon { border-radius: 16px; background: var(--server); color: #fff; }
.rail-add { color: var(--online); }
.rail-add:hover { border-radius: 16px; background: var(--online); color: #fff; }
.rail-sep { width: 32px; height: 2px; border-radius: 1px; background: var(--line); }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--danger); color: #fff;
}
.rail-badge { position: absolute; right: 10px; bottom: -2px; border: 3px solid var(--bg-rail); height: 22px; min-width: 22px; border-radius: 11px; }

/* Channel sidebar */
.sidebar { width: 240px; flex: none; background: var(--bg-sidebar); display: flex; flex-direction: column; border-top-left-radius: var(--radius); }
.sidebar-header {
  height: 48px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  font-weight: 700; border-bottom: 1px solid var(--line); text-align: left;
}
.sidebar-header:hover { background: var(--bg-hover); }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
.category h3 { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); padding: 16px 8px 4px; }
.channel {
  width: 100%; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px;
  color: var(--text-3); text-align: left; margin: 1px 0;
}
.channel:hover { background: var(--bg-hover); color: var(--text-2); }
.channel.active { background: var(--bg-active); color: var(--text); }
.channel.unread { color: var(--text); font-weight: 600; }
.channel-icon { flex: none; opacity: 0.8; }
.channel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-panel { height: 56px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 8px; background: #16171a; }
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; padding-left: 4px; }
.user-meta strong { font-size: 13px; }
.user-meta span { font-size: 11px; color: var(--text-3); }
.user-panel button { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--text-2); }
.user-panel button:hover { background: var(--bg-active); color: var(--text); }

/* Avatar */
.avatar { position: relative; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: rgba(0, 0, 0, 0.72); }
.presence { position: absolute; right: -2px; bottom: -2px; width: 34%; height: 34%; border-radius: 50%; border: 3px solid var(--bg-sidebar); }
.presence.online { background: var(--online); }
.presence.idle { background: var(--idle); }
.presence.dnd { background: var(--dnd); }
.presence.offline { background: var(--text-3); }
.message .presence { display: none; }

/* Chat */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-chat); }
.chat-header { height: 48px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.chat-header h2 { font-size: 15px; font-weight: 700; }
.chat-topic { font-size: 13px; color: var(--text-3); padding-left: 12px; margin-left: 4px; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-tools { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--text-2); }
.chat-tools button:hover, .chat-tools button.on { color: var(--text); }
.search { display: flex; align-items: center; gap: 4px; background: var(--bg-rail); border-radius: 6px; padding: 0 8px; height: 26px; width: 160px; color: var(--text-3); }
.search input { flex: 1; min-width: 0; font-size: 13px; }

.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; }
.channel-intro { padding: 16px 16px 8px; }
.intro-icon { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-elev); margin-bottom: 8px; }
.channel-intro h1 { font-size: 28px; font-weight: 800; }
.channel-intro p { color: var(--text-2); }
.day-divider { display: flex; align-items: center; margin: 20px 16px 8px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.day-divider::before, .day-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.day-divider span { padding: 0 8px; }
.message { display: flex; gap: 16px; padding: 2px 16px 2px 16px; margin-top: 16px; }
.message.cont { margin-top: 0; }
.message:hover { background: rgba(0, 0, 0, 0.08); }
.message-body { min-width: 0; flex: 1; }
.message-head { display: flex; align-items: baseline; gap: 8px; }
.message-head strong { font-size: 15px; }
.message-head time { font-size: 11px; color: var(--text-3); }
.message p { line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.message-hover-time { width: 40px; flex: none; font-size: 10px; color: transparent; text-align: right; padding-top: 4px; }
.message:hover .message-hover-time { color: var(--text-3); }
.tag { font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); }

.composer { margin: 0 16px 20px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border-radius: var(--radius); background: var(--bg-elev); min-height: 46px; }
.composer button { color: var(--text-2); display: grid; place-items: center; }
.composer button:hover { color: var(--text); }
.composer textarea { flex: 1; resize: none; padding: 12px 0; line-height: 1.4; max-height: 40vh; }
.composer textarea::placeholder { color: var(--text-3); }

/* Members */
.members { width: 240px; flex: none; background: var(--bg-sidebar); overflow-y: auto; padding: 8px; }
.members h3 { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); padding: 16px 8px 4px; }
.member { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 6px; font-size: 14px; font-weight: 500; }
.member:hover { background: var(--bg-hover); }
.member.off { opacity: 0.4; }

@media (max-width: 1100px) { .members { display: none; } }

/* ── shared bits ─────────────────────────────────────────── */
.red { color: var(--danger); }
.ok { color: var(--online); }
.warn { color: var(--idle); }
.bad { color: var(--danger); }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12px; color: var(--text-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.ghost { color: var(--text-2); }
.btn.ghost:hover { color: var(--text); text-decoration: underline; }
.btn.wide { width: 100%; margin-top: 12px; }
.live { font-size: 10px; font-weight: 800; letter-spacing: 0.04em; padding: 1px 5px; border-radius: 4px; background: var(--danger); color: #fff; }
button.avatar.clickable { border: 0; cursor: pointer; }
.avatar.speaking { box-shadow: 0 0 0 2px var(--bg-sidebar), 0 0 0 4px var(--online); }
.author { font-weight: 700; font-size: 15px; }
.author:hover { text-decoration: underline; }
.member { width: 100%; text-align: left; }

/* ── sidebar voice ───────────────────────────────────────── */
.voice-roster { list-style: none; padding: 2px 0 6px 30px; }
.roster-row { width: 100%; display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; color: var(--text-2); font-size: 13px; text-align: left; }
.roster-row:hover { background: var(--bg-hover); color: var(--text); }
.roster-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.voice-panel { flex: none; padding: 10px 8px 8px; background: #16171a; border-bottom: 1px solid var(--line); }
.voice-panel-row { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.voice-panel-info { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; line-height: 1.25; }
.voice-panel-info strong { font-size: 13px; }
.voice-panel-info span { font-size: 12px; color: var(--text-3); }
.voice-panel-info:hover span { text-decoration: underline; }
.voice-panel .hang { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--text-2); }
.voice-panel .hang:hover { background: var(--bg-active); color: var(--danger); }
.share-btn { margin-top: 8px; width: 100%; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; background: var(--bg-elev); }
.share-btn:hover { background: #33353c; }
.share-btn.on { background: rgba(239, 79, 79, 0.18); color: #ff9a9a; }

.user-panel .user-chip { width: auto; height: 44px; flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 4px; margin-left: -4px; border-radius: 6px; text-align: left; }
.user-panel .user-chip:hover { background: var(--bg-active); }
.user-panel > button:not(.user-chip) { flex: none; }
.user-panel button.off { color: var(--danger); }
.user-panel button.off:hover { background: rgba(239, 79, 79, 0.14); color: var(--danger); }

/* ── call view ───────────────────────────────────────────── */
.call { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #0f1012; }
.call-header { background: var(--bg-chat); }
.call-error { margin: 12px 16px 0; padding: 8px 12px; border-radius: 8px; background: rgba(240, 178, 50, 0.12); color: var(--idle); font-size: 13px; }
.call-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.call-empty h1 { font-size: 24px; }
.call-empty p { color: var(--text-2); margin-bottom: 8px; }
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; background: #0f1012; }
.stage-grid { flex: 1; min-height: 0; display: grid; gap: 10px; padding: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); grid-auto-rows: minmax(160px, 1fr); align-content: center; }
.stage-grid.n1 { grid-template-columns: minmax(260px, 720px); justify-content: center; }
.tile {
  position: relative; border-radius: 12px; overflow: hidden; display: grid; place-items: center; min-height: 160px;
  background: color-mix(in srgb, var(--tile, #444) 22%, #1d1e22); outline: 2px solid transparent; outline-offset: -2px; transition: outline-color 0.12s;
}
.tile.speaking { outline-color: var(--online); }
.tile.screen { background: #000; cursor: zoom-in; }
.tile.small { min-height: 0; height: 96px; width: 150px; flex: none; }
.tile .avatar.speaking { box-shadow: none; }
.tile-name {
  position: absolute; left: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 6px; max-width: calc(100% - 16px);
  padding: 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden;
}
.video-wrap { position: absolute; inset: 0; }
.video-wrap video { width: 100%; height: 100%; display: block; background: #000; }
.video-wrap.cover video { object-fit: cover; }
.video-wrap.contain video { object-fit: contain; }
.video-stats { position: absolute; right: 8px; top: 8px; padding: 2px 6px; border-radius: 4px; background: rgba(0, 0, 0, 0.6); font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.stage-focus { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px 12px 0; }
.focus-video { position: relative; flex: 1; min-height: 0; border-radius: 12px; overflow: hidden; background: #000; }
.focus-tools { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.focus-video:hover .focus-tools { opacity: 1; }
.focus-tools button { height: 32px; min-width: 32px; padding: 0 10px; border-radius: 6px; background: rgba(0, 0, 0, 0.65); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.focus-tools button:hover { background: rgba(0, 0, 0, 0.85); }
.stage-strip { flex: none; display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; justify-content: center; }
.stage:fullscreen .stage-strip, .stage:fullscreen .call-controls { display: none; }
.stage:fullscreen .stage-focus { padding: 0; }
.stage:fullscreen .focus-video { border-radius: 0; }
.call-controls { flex: none; display: flex; justify-content: center; gap: 12px; padding: 14px 0 18px; }
.round { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: #2b2d33; }
.round:hover { background: #363840; }
.round.off { background: rgba(239, 79, 79, 0.2); color: #ff8080; }
.round.live-on { background: var(--accent); color: var(--accent-ink); }
.round.hang { background: var(--danger); color: #fff; }
.round.hang:hover { filter: brightness(1.1); }

/* ── modal / share picker ────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.7); display: grid; place-items: center; padding: 24px; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; border-radius: 14px; background: var(--bg-chat); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5); }
.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; }
.modal > header h2 { font-size: 20px; }
.modal > header button { color: var(--text-2); }
.modal > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; background: var(--bg-sidebar); border-radius: 0 0 14px 14px; }
.pad { padding: 8px 20px; }
.tabs { display: flex; gap: 6px; padding: 4px 20px 10px; }
.tabs button { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.tabs button.on { background: var(--bg-active); color: var(--text); }
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 0 20px 8px; overflow-y: auto; min-height: 140px; max-height: 300px; }
.source { display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 10px; background: var(--bg-elev); outline: 2px solid transparent; text-align: left; }
.source:hover { background: #33353c; }
.source.on { outline-color: var(--accent); }
.source > img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border-radius: 6px; }
.source > span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-icon { width: 16px; height: 16px; flex: none; }
.quality { padding: 8px 20px 14px; }
.quality h3 { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.preset-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.preset-row button { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 10px; background: var(--bg-elev); text-align: left; outline: 2px solid transparent; }
.preset-row button.on { outline-color: var(--accent); }
.preset-row strong { font-size: 13px; }
.preset-row span { font-size: 11px; color: var(--text-3); }
.hint { margin-top: 10px; font-size: 12px; color: var(--text-3); line-height: 1.5; }
.hint b { color: var(--text-2); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ── profile card ────────────────────────────────────────── */
.profile-card { position: fixed; z-index: 60; width: 300px; border-radius: 14px; background: #18191c; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55); overflow: hidden; }
.profile-banner { height: 70px; }
.profile-close { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, 0.45); }
.profile-avatar { position: absolute; top: 26px; left: 14px; padding: 5px; border-radius: 50%; background: #18191c; }
.profile-avatar .presence { border-color: #18191c; }
.profile-body { margin: 52px 12px 12px; padding: 12px; border-radius: 10px; background: #111214; }
.profile-name { display: flex; align-items: center; gap: 8px; }
.profile-name h2 { font-size: 20px; }
.profile-sub { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); margin-top: 2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.online { background: var(--online); }
.dot.idle { background: var(--idle); }
.dot.dnd { background: var(--dnd); }
.dot.offline { background: var(--text-3); }
.profile-voice { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 8px; border-radius: 8px; background: rgba(63, 199, 125, 0.1); color: var(--online); font-size: 13px; font-weight: 600; }
.profile-body section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.profile-body h3 { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }
.profile-body p { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.profile-edit { display: flex; flex-direction: column; gap: 10px; }
.profile-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.profile-edit input, .profile-edit textarea { padding: 8px 10px; border-radius: 6px; background: #1e1f23; font-size: 14px; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text); resize: none; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 22px; height: 22px; border-radius: 50%; outline: 2px solid transparent; outline-offset: 2px; }
.swatches button.on { outline-color: var(--text); }
.profile-actions { display: flex; justify-content: flex-end; gap: 6px; }
