:root {
  --bg: #f5f5f7; --panel: #ffffff; --panel-2: #fafafb; --rail: #ebebef; --line: #e3e3e8;
  --text: #1f1f24; --muted: #6b6b76; --accent: #5b5fc7; --accent-2: #4f52b2; --accent-soft: #e8e9fa; --accent-text: #4f52b2; --on-accent: #ffffff;
  --ok: #237b4b; --ok-soft: #e3f3ea; --bad: #c4314b; --bad-soft: #fbe7ea; --warn: #b26a00;
  --mention: #fff4ce; --shadow: 0 6px 24px rgba(0,0,0,.12); --radius: 8px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1b1b1f; --panel: #242429; --panel-2: #2a2a30; --rail: #151518; --line: #35353c;
  --text: #ececf1; --muted: #a0a0ab; --accent: #7f85f5; --accent-2: #9298ff; --accent-soft: #2f3052; --accent-text: #9da2ff; --on-accent: #141418;
  --ok: #6ccb94; --ok-soft: #1f3a2b; --bad: #ef6e83; --bad-soft: #43242b; --warn: #f0b04a;
  --mention: #4a4220; --shadow: 0 6px 24px rgba(0,0,0,.5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1b1f; --panel: #242429; --panel-2: #2a2a30; --rail: #151518; --line: #35353c;
    --text: #ececf1; --muted: #a0a0ab; --accent: #7f85f5; --accent-2: #9298ff; --accent-soft: #2f3052; --accent-text: #9da2ff; --on-accent: #141418;
    --ok: #6ccb94; --ok-soft: #1f3a2b; --bad: #ef6e83; --bad-soft: #43242b; --warn: #f0b04a;
    --mention: #4a4220; --shadow: 0 6px 24px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 1rem/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.8571rem; }
.error { color: var(--bad); min-height: 1.2em; font-size: 0.9286rem; }

/* buttons & inputs */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { padding: 3px 8px; font-size: 0.8571rem; }
.btn.wide { width: 100%; padding: 9px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 5px; color: var(--muted); }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.link { border: 0; background: none; color: var(--accent-text); cursor: pointer; padding: 0; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
label { display: block; font-size: 0.9286rem; color: var(--muted); margin: 0 0 12px; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.check input { width: auto; }

/* auth */
.auth { height: 100%; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, var(--accent-soft), var(--bg)); }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); padding: 28px; border-radius: 12px; box-shadow: var(--shadow); }
.auth-card .link { display: block; margin: 14px auto 0; }
.downloads { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; }
.downloads .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.downloads a.btn { text-decoration: none; color: var(--text); }
.brand-lg { font-size: 1.5714rem; font-weight: 700; display: flex; gap: 10px; align-items: center; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 1.0714rem; }
.brand-lg .logo { width: 36px; height: 36px; font-size: 1.3571rem; }

/* layout */
.shell { display: grid; grid-template-columns: 68px 280px 1fr; grid-template-rows: 48px 1fr; height: 100%; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 12px; background: var(--accent); color: var(--on-accent); -webkit-app-region: drag; }
.topbar > * { -webkit-app-region: no-drag; }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 700; width: 320px; }
.brand .logo { background: var(--on-accent); color: var(--accent); }
.search { flex: 1; max-width: 560px; }
.search { position: relative; }
.search input { background: color-mix(in srgb, var(--on-accent) 16%, transparent); border: 0; color: var(--on-accent); padding-right: 64px; }
.search input:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--on-accent) 45%, transparent); }
.search input::placeholder { color: color-mix(in srgb, var(--on-accent) 75%, transparent); }
.top-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: #ffb4b4; }
.conn.on { background: #8ff0b0; }
.avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; }
.rail { background: var(--rail); display: flex; flex-direction: column; align-items: stretch; padding: 6px 0; border-right: 1px solid var(--line); }
.rail button { position: relative; border: 0; background: none; cursor: pointer; padding: 8px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 0.7857rem; border-left: 3px solid transparent; }
.rail button i { font-style: normal; font-size: 1.3571rem; filter: grayscale(.6); }
.rail button:hover { color: var(--text); }
.rail button.active { color: var(--accent-text); border-left-color: var(--accent); font-weight: 600; }
.rail button.active i { filter: none; }
.rail-spacer { flex: 1; }
.badge { position: absolute; top: 4px; right: 12px; background: var(--bad); color: #fff; font-size: 0.7143rem; min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; padding: 0 4px; font-style: normal; }
.sidebar { background: var(--panel-2); border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.main { background: var(--panel); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }

/* sidebar */
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; font-weight: 700; font-size: 1.2143rem; }
.side-list { padding: 0 6px 12px; }
.side-group { margin-top: 6px; }
.side-group > .gh { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-weight: 600; cursor: pointer; border-radius: 6px; }
.side-group > .gh:hover { background: var(--line); }
.side-group > .gh .caret { color: var(--muted); font-size: 0.7143rem; width: 10px; }
.side-group > .gh .more { margin-left: auto; visibility: hidden; }
.side-group > .gh:hover .more { visibility: visible; }
.item { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 26px; border-radius: 6px; cursor: pointer; color: var(--text); }
.item.flat { padding-left: 8px; }
.item:hover { background: var(--line); }
.item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.item.unread { font-weight: 700; }
.item .meta { margin-left: auto; font-size: 0.7857rem; color: var(--muted); }
.item .count { margin-left: auto; background: var(--bad); color: #fff; border-radius: 9px; font-size: 0.7857rem; padding: 0 6px; font-weight: 600; }
.item .sub { font-size: 0.8571rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.item .grow { min-width: 0; flex: 1; }
.item .grow > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-tile { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 0.8571rem; flex-shrink: 0; }

/* avatar */
.av { position: relative; display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 600; flex-shrink: 0; width: 32px; height: 32px; font-size: 0.8571rem; }
.av.sm { width: 24px; height: 24px; font-size: 0.7143rem; }
.av.lg { width: 56px; height: 56px; font-size: 1.4286rem; }
.av .dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--panel-2); background: #9a9aa3; }
.av .dot.on { background: #31a24c; }
.av.bot { border-radius: 8px; }

/* main header & tabs */
.mhead { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); min-height: 56px; }
.mhead h2 { font-size: 1.1429rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mhead .desc { color: var(--muted); font-size: 0.8571rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mhead .actions { margin-left: auto; display: flex; gap: 6px; }
.tabs { display: flex; gap: 2px; margin-left: 12px; }
.tabs button { border: 0; background: none; padding: 16px 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -11px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.scroll { flex: 1; overflow-y: auto; }
.pad { padding: 18px 22px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 2.8571rem; }
.empty h3 { color: var(--text); margin: 8px 0 4px; }

/* messages */
.msgs { flex: 1; overflow-y: auto; padding: 12px 22px 20px; background: var(--bg); }
.thread { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; }
.dm-list .msg { background: transparent; }
.msg { display: flex; gap: 10px; padding: 10px 14px; position: relative; }
.msg:hover { background: var(--panel-2); }
.msg.cont { padding-top: 2px; }
.msg.cont .av { visibility: hidden; height: 0; }
.msg .body { min-width: 0; flex: 1; }
.msg .who { display: flex; gap: 8px; align-items: baseline; }
.msg .who b { font-weight: 600; }
.msg .who .t { color: var(--muted); font-size: 0.7857rem; }
.msg .text { white-space: pre-wrap; word-wrap: break-word; }
.msg .text code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-family: ui-monospace, Consolas, monospace; font-size: 0.8929rem; }
.msg .text pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px; overflow-x: auto; font-family: ui-monospace, Consolas, monospace; font-size: 0.8929rem; margin: 4px 0; }
.mention { background: var(--accent-soft); color: var(--accent-text); border-radius: 4px; padding: 0 2px; font-weight: 600; }
.mention.me { background: var(--mention); color: inherit; }
.msg .tools { position: absolute; right: 10px; top: -12px; display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 2px; }
.msg:hover .tools { display: flex; }
.reacts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.react { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 0 7px; cursor: pointer; font-size: 0.8571rem; }
.react.mine { border-color: var(--accent); background: var(--accent-soft); }
.replies { border-top: 1px solid var(--line); }
.replies .msg { padding-left: 56px; }
.replies .msg .av { width: 24px; height: 24px; font-size: 0.7143rem; }
.reply-bar { display: flex; gap: 8px; align-items: center; padding: 6px 14px 8px 56px; border-top: 1px solid var(--line); }
.reply-bar .link { font-size: 0.9286rem; }
.reply-box { padding: 8px 14px 10px 56px; border-top: 1px solid var(--line); }
.day-sep { text-align: center; color: var(--muted); font-size: 0.8571rem; margin: 16px 0 4px; }
.typing { height: 18px; font-size: 0.8571rem; color: var(--muted); padding: 0 22px; background: var(--bg); }
.wf-tag { font-size: 0.7857rem; background: var(--accent-soft); color: var(--accent-text); border-radius: 4px; padding: 0 5px; }

.attach { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.file-chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; background: var(--panel); cursor: pointer; max-width: 320px; }
.file-chip:hover { border-color: var(--accent); }
.file-chip .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* composer */
.composer { padding: 10px 22px 16px; background: var(--bg); }
.composer .box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.composer .box:focus-within { border-color: var(--accent); border-bottom: 2px solid var(--accent); }
.composer textarea { border: 0; box-shadow: none !important; resize: none; min-height: 40px; max-height: 200px; background: transparent; }
.composer .bar { display: flex; align-items: center; gap: 4px; padding: 2px 6px 6px; }
.composer .bar .send { margin-left: auto; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px 0; }
.pending-files .file-chip { cursor: default; font-size: 0.8571rem; padding: 3px 8px; }
.new-post-btn { margin: 0 22px 16px; }
.mention-pop { position: absolute; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); max-height: 200px; overflow-y: auto; z-index: 50; min-width: 220px; }
.mention-pop div { padding: 6px 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.mention-pop div.sel, .mention-pop div:hover { background: var(--accent-soft); }

/* approval card */
.card { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; padding: 10px 12px; margin-top: 6px; background: var(--panel); max-width: 520px; }
.card.approved { border-left-color: var(--ok); }
.card.rejected { border-left-color: var(--bad); }
.card h4 { margin: 0 0 4px; }
.card .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.pill { display: inline-block; font-size: 0.7857rem; font-weight: 600; padding: 1px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); }
.pill.ok, .pill.success, .pill.approved { background: var(--ok-soft); color: var(--ok); }
.pill.bad, .pill.failed, .pill.rejected { background: var(--bad-soft); color: var(--bad); }
.pill.gray { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

/* files */
.fbar { display: flex; gap: 8px; align-items: center; padding: 10px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.crumbs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-weight: 600; }
.crumbs button { border: 0; background: none; cursor: pointer; padding: 2px 4px; border-radius: 4px; color: var(--accent-text); font-weight: 600; }
.crumbs button:last-child { color: var(--text); }
.crumbs span { color: var(--muted); }
.fbar .right { margin-left: auto; display: flex; gap: 6px; }
table.files { width: 100%; border-collapse: collapse; }
table.files th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8571rem; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
table.files td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.files tr:hover td { background: var(--panel-2); }
table.files td.name { cursor: pointer; }
.name-in { display: flex; align-items: center; gap: 10px; min-width: 0; }
table.files td.acts { text-align: right; white-space: nowrap; }
table.files tr td.acts .icon-btn { opacity: .45; }
table.files tr:hover td.acts .icon-btn, table.files td.acts .icon-btn:focus-visible { opacity: 1; }
@media (hover: none) { table.files tr td.acts .icon-btn { opacity: 1; } }
.dropzone { outline: 2px dashed var(--accent); outline-offset: -8px; background: var(--accent-soft) !important; }
.progress { height: 3px; background: var(--accent); transition: width .2s; }

/* workflows */
.wf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.wf-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--panel); cursor: pointer; }
.wf-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.wf-card h4 { margin: 6px 0 4px; }
.wf-card .ic { font-size: 1.5714rem; }
.builder { max-width: 760px; }
.step { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 14px 16px 4px; position: relative; }
.step.trig { border-left: 4px solid var(--warn); }
.step.act { border-left: 4px solid var(--accent); }
.step-h { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 10px; }
.step-h .rm { margin-left: auto; }
.arrow { text-align: center; color: var(--muted); padding: 4px 0; font-size: 1.2857rem; line-height: 1; }
.days { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.days button { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 2px 10px; cursor: pointer; font-size: 0.8571rem; }
.days button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chips .pill { display: inline-flex; gap: 4px; align-items: center; }
.vars { font-size: 0.8571rem; color: var(--muted); margin: -6px 0 12px; }
.vars code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; cursor: pointer; }
.runs { width: 100%; border-collapse: collapse; }
.runs td, .runs th { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; font-size: 0.9286rem; }
.runs th { color: var(--muted); font-weight: 600; font-size: 0.8571rem; }
.steps-list { margin: 0; padding-left: 16px; }
.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 10px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
.section { margin-bottom: 26px; }
.section h3 { margin: 0 0 10px; font-size: 1.0714rem; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; align-items: center; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--panel); }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.member-row:last-child { border: 0; }
.member-row .grow { flex: 1; }

/* modal, menu, toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal.wide { max-width: 640px; }
.modal h3 { margin: 0; padding: 18px 20px 6px; }
.modal .mbody { padding: 10px 20px; }
.modal .mfoot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 20px 18px; }
.menu { position: fixed; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; z-index: 120; min-width: 180px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; cursor: pointer; border-radius: 5px; }
.menu button:hover { background: var(--panel-2); }
.menu button.danger { color: var(--bad); }
.menu .emojis { display: flex; gap: 2px; padding: 2px; }
.menu .emojis button { width: auto; font-size: 1.2857rem; padding: 4px 6px; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--text); color: var(--panel); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; font-size: 0.9286rem; }
.toast.err { background: var(--bad); color: #fff; }
.user-pick { max-height: 300px; overflow-y: auto; margin-top: 8px; }
.user-pick .item { padding-left: 8px; }

.back-btn { display: none !important; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 56px 220px 1fr; }
  .brand { width: auto; }
  .brand span:last-child { display: none; }
  .kv { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .shell { grid-template-columns: 56px 1fr; }
  .shell.has-main .sidebar { display: none; }
  .shell:not(.has-main) .main { display: none; }
  .rail button span { display: none; }
  .tabs button { padding: 16px 6px 14px; }
  .msgs, .composer { padding-left: 10px; padding-right: 10px; }
  .back-btn { display: inline-block !important; }
}

/* ---------- avatars with photos & presence ---------- */
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.av.xs { width: 20px; height: 20px; font-size: 0.6rem; }
.av.xs .dot { width: 8px; height: 8px; }
.av.xl { width: 88px; height: 88px; font-size: 2rem; }
.av.xl .dot { width: 18px; height: 18px; border-width: 3px; }
.av .dot { z-index: 1; }
.av .dot.busy, .pdot.busy { background: #d13438; }
.av .dot.dnd, .pdot.dnd { background: #d13438; box-shadow: inset 0 0 0 2px #d13438, inset 0 0 0 3.5px #fff; }
.av .dot.away, .pdot.away { background: #f8b500; }
.pdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #9a9aa3; flex-shrink: 0; }
.pdot.on { background: #31a24c; }
.profile-top { display: flex; gap: 18px; align-items: center; margin-bottom: 22px; }
.row-gap { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.presence-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.presence-opt { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); border-radius: 20px; padding: 6px 14px; cursor: pointer; }
.presence-opt.sel { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 14px; padding: 2px 10px; cursor: pointer; font-size: 0.857rem; }
.chip:hover { border-color: var(--accent); }
.status-presets { margin: -6px 0 14px; }

/* ---------- appearance settings ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--panel); padding: 7px 14px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.sel { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer; background: var(--c); position: relative; margin: 0; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.swatch.sel { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--c); }
.swatch.custom { display: grid; place-items: center; overflow: hidden; }
.swatch.custom input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; padding: 0; border: 0; }
.swatch.sel.custom { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }
.appearance-preview { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.compact .msg { padding-top: 4px; padding-bottom: 4px; }
.compact .thread { margin: 6px 0; }
.compact .item { padding-top: 3px; padding-bottom: 3px; }
.compact .reply-bar { padding-top: 2px; padding-bottom: 4px; }
.compact .mhead { min-height: 48px; padding-top: 6px; padding-bottom: 6px; }

/* ---------- messages: thumbnails, jump button, Drive links ---------- */
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.thumb { border: 1px solid var(--line); border-radius: 8px; padding: 0; overflow: hidden; cursor: zoom-in; background: var(--panel-2); min-width: 80px; min-height: 60px; }
.thumb img { display: block; max-width: min(320px, 60vw); max-height: 240px; object-fit: cover; opacity: 0; transition: opacity .2s; }
.thumb img.loaded { opacity: 1; }
.thumb-missing { display: inline-block; padding: 18px 12px; color: var(--muted); font-size: 0.857rem; }
.msgs-wrap { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.jump { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 18px; padding: 6px 14px; cursor: pointer; box-shadow: var(--shadow); font-size: 0.857rem; z-index: 5; }
.jump.new { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
a.glink { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 6px; padding: 0 6px; text-decoration: none; font-weight: 600; }
a.glink:hover { border-color: var(--accent); }
.composer .hint { margin-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip.uploading { background: linear-gradient(90deg, var(--accent-soft) var(--p), var(--panel) var(--p)); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast-action { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }

/* ---------- files: previews, progress, filter ---------- */
.preview-bg { background: rgba(0,0,0,.6); }
.preview { background: var(--panel); border-radius: 10px; width: min(1100px, 100%); height: min(88vh, 900px); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.preview-head { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.preview-body { flex: 1; display: grid; place-items: center; overflow: auto; background: var(--bg); min-height: 0; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.preview-text { width: 100%; height: 100%; margin: 0; padding: 16px; overflow: auto; white-space: pre-wrap; font: 0.9rem/1.5 ui-monospace, Consolas, monospace; background: var(--panel); place-self: stretch; }
.ellipsis { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nowrap { white-space: nowrap; }
.row-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; background: var(--panel-2); }
table.files td.name { max-width: 0; width: 55%; }
.fb-filter { width: 170px; padding: 4px 8px; }
.upload-row { display: flex; align-items: center; gap: 10px; padding: 6px 22px; border-bottom: 1px solid var(--line); font-size: 0.857rem; }
.upload-row .ellipsis { flex: 0 1 260px; }
.upload-row .bar, .meter { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.upload-row .bar div, .meter div { height: 100%; background: var(--accent); transition: width .2s; }
.meter { margin-top: 8px; }

/* ---------- quick switcher & shortcuts ---------- */
.kbd-hint { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; border-radius: 5px; padding: 2px 7px; font-size: 0.75rem; cursor: pointer; background: color-mix(in srgb, var(--on-accent) 20%, transparent); color: var(--on-accent); }
.switcher-bg { align-items: start; padding-top: 12vh; }
.switcher { background: var(--panel); border-radius: 12px; width: min(560px, 100%); box-shadow: var(--shadow); overflow: hidden; }
.switcher input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 16px; font-size: 1.07rem; box-shadow: none !important; }
.sw-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.sw-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.sw-item .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-item.sel { background: var(--accent-soft); }
.sw-kind { font-size: 0.75rem; color: var(--muted); }
.sw-foot { padding: 8px 14px; border-top: 1px solid var(--line); }
kbd { display: inline-block; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font: 0.8rem ui-monospace, Consolas, monospace; background: var(--panel-2); }
table.shortcuts { border-collapse: collapse; width: 100%; }
table.shortcuts td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.shortcuts td:first-child { white-space: nowrap; width: 1%; padding-right: 18px; }

/* keyboard focus is always visible */
button:focus-visible, a:focus-visible, [data-act]:focus-visible, .swatch:focus-within { outline: 2px solid var(--accent-text); outline-offset: 2px; }
@media (max-width: 640px) { .hide-sm { display: none; } .kbd-hint { display: none; } .composer .hint { display: none; } .search input { padding-right: 9px; } }
.appearance-preview .pill { align-self: center; }
