/* LMTeam: light "glass" UI. Visual language borrowed from TiinyPaint (floating glass bar, translucent panels, ink buttons,
   pills) on a plain page background. System fonts only; no external resource; no inline style anywhere (strict CSP). */

:root {
  color-scheme: light;
  /* page and panels */
  --bg: #edf2f3;
  --glass: rgb(255 255 255 / 0.74);
  --glass-strong: rgb(255 255 255 / 0.92);
  --surface: #ffffff;
  --surface-2: #e6edef;
  --surface-3: #d9e3e6;
  --border: rgb(16 40 48 / 0.16);
  --line-strong: rgb(16 40 48 / 0.32);
  --hover: rgb(16 40 48 / 0.07);
  /* text (WCAG AA on --bg, --surface and --glass: text 15:1, muted 6.3:1) */
  --text: #11191c;
  --muted: #4a5a60;
  --ink: #11191c;
  --on-ink: #ffffff;
  /* accent: deep green for text and links, brighter green for dots and bars */
  --accent: #166534;
  --accent-hover: #14532d;
  --on-accent: #ffffff;
  --accent-soft: #dcf3e3;
  --active: #1a8f57;
  --danger: #b42318;
  --danger-soft: #fde7e4;
  --warn-soft: #fff1d6;
  --warn-text: #7a4a00;
  --focus: #0f6b35;
  --nick-l: 34%;
  --nick-s: 62%;
  --bubble-own: #dcf1e4;
  --code-bg: #e9f0f1;
  --shadow: 0 1px 2px rgb(16 40 48 / 0.06), 0 8px 24px rgb(16 40 48 / 0.07);
  --shadow-pop: 0 18px 50px rgb(16 40 48 / 0.22);
  --radius: 14px;
  --radius-sm: 10px;
  --blur: blur(18px) saturate(140%);
  --bar-h: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* presence, alerts */
  --p-online: #1a8f57; --p-idle: #c26a05; --p-offline: #d1322b;
  --alert-bg: #fff4dc; --alert-border: #e2b04a;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; }
html { scroll-padding-top: calc(var(--bar-h) + var(--phead-h, 0px) + 76px); } /* keyboard focus stays clear of the sticky bar and board header */
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 0.75em; }
code, pre { font-family: var(--mono); font-size: 0.9em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: var(--on-ink); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { top: 8px; }
.noscript { padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.loading { color: var(--muted); padding: 24px 16px; }

/* ---------- shell: floating glass top bar that attaches to the top edge once the page scrolls ---------- */
.shell { display: flex; flex-direction: column; min-height: 100dvh; }
.shell:has(#app.full) { height: 100dvh; min-height: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40; flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: var(--bar-h); margin: 10px 10px 0; padding: 0 12px;
  background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: margin 0.18s ease, border-radius 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
.topbar.stuck {
  margin-inline: 0; border-radius: 0 0 var(--radius) var(--radius); border-top-color: transparent; border-inline-color: transparent;
  background: var(--glass-strong); box-shadow: 0 6px 22px rgb(16 40 48 / 0.14);
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; letter-spacing: -0.01em; }
.brand:hover { color: var(--text); }
.brand-mark {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px;
  background: var(--ink); color: var(--on-ink); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em;
}
.nav { display: flex; align-items: center; gap: 4px; }
.nav-link { padding: 6px 11px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 550; }
.nav-link:hover { background: var(--hover); color: var(--text); }
.nav-link[aria-current="page"] { color: var(--on-ink); background: var(--ink); }
#app { flex: 1; min-width: 0; }
#app:focus { outline: none; }
#app.full { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ---------- pages ---------- */
.page { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
.page.narrow, .narrow { max-width: 560px; margin-inline: auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero { padding: 12px 0 20px; }
.hero h1 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); max-width: 22ch; }
.lead { color: var(--muted); max-width: 62ch; font-size: 1.02rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.card {
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card + .card, .created > .card, .created > .keybox { margin-top: 16px; }
.grid-2 > .card { margin-top: 0; }
.card h2 { margin-bottom: 0.7em; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.flow { margin-top: 12px; }
.flow > .card, .flow > .room-summary { margin-top: 12px; }
.facts { margin: 16px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.9rem; }
.note { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.room-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 600; font-size: 0.86rem; color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
input[type="text"], input[type="password"], input[type="search"], textarea, .input {
  font: inherit; color: var(--text); background: var(--glass-strong);
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; width: 100%;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.input-key { font-family: var(--mono); font-size: 1.3rem; letter-spacing: 0.25em; text-transform: uppercase; text-align: center; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.form-error:empty { display: none; }
.alert { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 8px 12px; margin: 0; font-weight: 500; }
.warn { background: var(--warn-soft); color: var(--warn-text); border-radius: 10px; padding: 8px 12px; font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: 8px 14px; border-radius: 10px; color: var(--text);
  background: rgb(255 255 255 / 0.78); border: 1px solid var(--border);
  transition: background-color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn-primary:hover { background: #2a373c; color: var(--on-ink); border-color: #2a373c; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 0.85rem; border-radius: 8px; }
.btn-icon { padding: 8px; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); filter: brightness(0.92); color: #fff; border-color: var(--danger); }
.btn-danger-ghost { color: var(--danger); background: transparent; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.seg { display: inline-flex; background: rgb(255 255 255 / 0.6); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg-btn { font: inherit; font-weight: 600; background: transparent; border: 0; color: var(--muted); padding: 5px 12px; border-radius: 7px; cursor: pointer; }
.seg-btn:hover { background: var(--hover); color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }

/* ---------- chips, badges, code ---------- */
.key-chip { font-family: var(--mono); font-weight: 700; letter-spacing: 0.12em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 1px 8px; }
.badge { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; border-radius: 999px; padding: 2px 8px; }
.badge-public { background: var(--accent-soft); color: var(--accent); }
.badge-private { background: var(--warn-soft); color: var(--warn-text); }
.keybox { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; background: var(--glass-strong); border: 2px solid var(--ink); border-radius: var(--radius); padding: 16px 18px; }
.keybox-label { color: var(--muted); font-weight: 600; width: 100%; font-size: 0.85rem; }
.keybox-value { font-family: var(--mono); font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 800; letter-spacing: 0.22em; }
.codeblock { position: relative; margin: 0 0 12px; }
.codeblock pre { margin: 0; padding: 12px 12px 40px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.codeblock-copy { position: absolute; right: 8px; bottom: 8px; }
.secret .secret-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.secret-value { font-family: var(--mono); background: var(--code-bg); border: 1px dashed var(--accent); border-radius: 10px; padding: 8px 12px; word-break: break-all; flex: 1; min-width: 0; }
.reveal:not(:empty) { margin-bottom: 12px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.table th, .table td { padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.sr-th { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.cell-actions { text-align: right; white-space: nowrap; }
.inline-form { margin-top: 16px; }
.room-list { list-style: none; margin: 0; padding: 0; }
.room-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.room-item:last-child { border-bottom: 0; }

/* ---------- room (chat): head, chat and side are three separate glass panels ---------- */
.room { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 10px; padding: 10px; }
.room-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none;
  padding: 8px 14px; background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.room-id { min-width: 0; }
.room-name { font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 0.85rem; color: var(--muted); }
.countdown.soon { color: var(--danger); font-weight: 700; }
.conn { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn-on::before { background: var(--p-online); }
.conn-off::before { background: var(--p-idle); }
.side-toggle { display: none; }

.room-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 10px; }
.chat {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--glass-strong); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.scroller { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 8px; overscroll-behavior: contain; }
.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.empty { text-align: center; padding: 32px 8px; }

.msg { display: flex; gap: 10px; padding: 6px 8px; border-radius: 10px; --h: 200; }
.msg:hover { background: var(--hover); }
.msg:not(.msg-cont):not(.msg-system) { margin-top: 8px; }
.msg-own { background: var(--bubble-own); }
.msg-own:hover { background: var(--bubble-own); filter: brightness(0.97); }
.avatar, .avatar-gap { width: 32px; flex: none; }
.avatar {
  height: 32px; display: grid; place-items: center; border-radius: 9px; font-weight: 700; text-transform: uppercase;
  color: hsl(var(--h) var(--nick-s) var(--nick-l)); background: hsl(var(--h) 55% 50% / 0.18);
}
.msg-body { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: center; gap: 6px; line-height: 1.2; margin-bottom: 2px; }
.nick { font-weight: 700; color: hsl(var(--h) var(--nick-s) var(--nick-l)); overflow-wrap: anywhere; }
.kind { display: inline-flex; color: var(--muted); }
.msg-time { color: var(--muted); font-size: 0.75rem; margin-left: auto; white-space: nowrap; }
.msg-head .msg-time { margin-left: 2px; }
.msg-system { justify-content: center; align-items: baseline; gap: 8px; padding: 2px 8px; margin-top: 4px; color: var(--muted); font-size: 0.85rem; font-style: italic; }
.msg-system:hover { background: transparent; }
.msg-system .msg-time { margin-left: 0; }
.msg.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }

.md { overflow-wrap: anywhere; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 0.5em; }
.md .md-h { margin: 0.7em 0 0.3em; font-size: 1rem; }
.md h3.md-h { font-size: 1.1rem; }
.md ul, .md ol { margin: 0 0 0.5em; padding-left: 1.4em; }
.md li > ul, .md li > ol { margin: 0.2em 0 0; }
.md blockquote { margin: 0 0 0.5em; padding: 2px 10px; border-left: 3px solid var(--active); color: var(--muted); }
.md code { background: var(--code-bg); border-radius: 5px; padding: 1px 5px; }
.md pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; overflow: auto; margin: 0 0 0.6em; }
.md pre code { background: none; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 0.8em 0; }
.md .md-table { overflow-x: auto; margin: 0 0 0.6em; }
.md table { border-collapse: collapse; font-size: 0.9em; }
.md th, .md td { border: 1px solid var(--border); padding: 3px 8px; }
.md th { background: var(--surface-2); }
.md .al-right { text-align: right; }
.md .al-center { text-align: center; }

.thumb { display: inline-block; margin-top: 4px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; line-height: 0; }
.thumb img { max-width: 260px; max-height: 180px; width: auto; height: auto; object-fit: cover; }
.chip { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-decoration: none; max-width: 100%; }
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-size { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

.pill {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 5;
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--ink); color: var(--on-ink); border: 0; border-radius: 999px; padding: 6px 14px; box-shadow: var(--shadow-pop);
}

.composer { position: relative; flex: none; padding: 8px 16px 12px; background: rgb(255 255 255 / 0.5); border-top: 1px solid var(--border); }
.composer-form { display: flex; align-items: flex-end; gap: 8px; }
.composer-input { resize: none; min-height: 40px; max-height: 180px; line-height: 1.4; }
.composer-err:empty, .composer-status:empty { display: none; }
.composer-err { color: var(--danger); font-weight: 500; margin-bottom: 6px; }
.composer-status { color: var(--muted); margin-bottom: 6px; font-size: 0.85rem; }
.composer-hint { margin-top: 6px; }
.btn-icon-text { height: 40px; }
.composer .btn-icon { height: 40px; }
.drop-overlay {
  position: absolute; inset: 8px; z-index: 6; display: grid; place-items: center;
  border: 3px dashed var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 88%, transparent);
  font-weight: 700; font-size: 1.1rem; pointer-events: none;
}
.ended { background: var(--warn-soft); color: var(--warn-text); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ended p { margin: 0; }

.side {
  min-height: 0; overflow-y: auto; background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px; display: flex; flex-direction: column; gap: 16px;
}
.side-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.search-form { display: flex; flex-direction: column; gap: 6px; }
.results { margin-top: 8px; }
.result-list, .participants { list-style: none; margin: 0; padding: 0; }
.result { --h: 200; border-bottom: 1px solid var(--border); }
.result-btn { display: block; width: 100%; text-align: left; font: inherit; color: var(--text); background: transparent; border: 0; padding: 6px 4px; cursor: pointer; border-radius: 8px; }
.result-btn:hover { background: var(--hover); }
.result-text { display: block; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.participant { --h: 200; display: flex; align-items: center; gap: 8px; padding: 5px 2px; }
.participant .nick { flex: 1; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--h) var(--nick-s) var(--nick-l)); flex: none; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .room { padding: 8px; gap: 8px; }
  .room-body { grid-template-columns: minmax(0, 1fr); position: relative; gap: 8px; }
  .side-toggle { display: inline-flex; }
  .side {
    position: absolute; inset: 0 0 0 auto; width: min(320px, 92%); z-index: 20;
    transform: translateX(100%); visibility: hidden; box-shadow: var(--shadow-pop); background: var(--glass-strong);
    transition: transform 0.2s ease, visibility 0.2s;
  }
  .room.side-open .side { transform: none; visibility: visible; }
  .room-head { padding: 6px 10px; }
  .scroller { padding: 8px 8px 4px; }
  .composer { padding: 6px 8px 10px; }
  .btn-icon-text span { display: none; }
  .thumb img { max-width: 100%; }
  .nav-link { padding: 6px 8px; }
  .brand-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ======================= projects ======================= */
.narrow-wide { max-width: 720px; margin-inline: auto; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.project-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); margin-top: 0 !important; }
.project-card:hover { border-color: var(--line-strong); background: var(--glass-strong); color: var(--text); }
.project-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.project-card-head h2 { margin: 0; overflow-wrap: anywhere; }
.project-desc { margin: 0; color: var(--muted); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.project-card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.counts { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.count { font-size: 0.75rem; font-weight: 600; border-radius: 999px; padding: 1px 8px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.count-doing { color: var(--warn-text); background: var(--warn-soft); border-color: transparent; }
.count-done { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.new-project { margin-bottom: 16px; max-width: 560px; }

.select { appearance: auto; padding: 6px 8px; }
select { font: inherit; color: var(--text); }
.input.select, select.input { background: var(--glass-strong); }
.seg-sm { margin-bottom: 0; }
.seg-sm .seg-btn { padding: 2px 10px; font-size: 0.85rem; }
.md-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.md-input { font-family: var(--mono); font-size: 0.9rem; resize: vertical; min-height: 6em; }
.md-preview { min-height: 6em; padding: 8px 10px; background: var(--glass-strong); border: 1px solid var(--border); border-radius: 10px; }
.label-like { font-weight: 600; font-size: 0.86rem; color: var(--muted); }

/* project shell and tabs: the project scrolls with the page (the Channels tab alone fills the viewport, see index.js) */
.project { min-height: 0; }
/* project header card: name, key and status on top, the tabs attached below as its lower band (the active tab's actions on the right) */
.project-head {
  position: sticky; top: var(--bar-h); z-index: 30; flex: none; --room-pad: 10px;
  background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  transition: margin 0.18s ease, border-radius 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
/* stuck under the top bar: full width, no gap, only margins/radii/borders/shadow change (the inner padding makes up for the margin) */
.project-head.stuck {
  margin-inline: calc(-1 * var(--room-pad)); border-radius: 0 0 var(--radius) var(--radius); border-top-color: transparent; border-inline-color: transparent;
  background: var(--glass-strong); box-shadow: 0 6px 22px rgb(16 40 48 / 0.14);
}
.project-head.stuck .project-head-top { padding-inline: calc(14px + var(--room-pad)); }
.project-head.stuck .tabrow { padding-inline: calc(8px + var(--room-pad)); }
.shell:has(.project-head.stuck) .topbar.stuck { border-radius: 0; box-shadow: none; }
.project-head .project-head-top { background: none; border: 0; border-radius: 0; box-shadow: none; }
.tabrow { display: flex; align-items: center; gap: 4px 12px; padding: 4px 8px; border-top: 1px solid var(--border); background: rgb(16 40 48 / 0.035); }
.tabs {
  display: flex; gap: 4px; flex: 1 1 auto; min-width: 0; overflow-x: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.tab-actions { display: flex; flex: none; align-items: center; justify-content: flex-end; gap: 8px; margin-left: auto; }
.tab-act { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.tab-act[hidden] { display: none; }
.tab-actions:not(:has(.tab-act:not([hidden]) > *)) { display: none; }
.tab { font: inherit; font-weight: 600; color: var(--muted); background: transparent; border: 0; border-radius: 10px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); background: var(--hover); }
.tab:focus-visible { outline-offset: -3px; } /* the tab bar clips what sticks out of it */
.tab[aria-selected="true"] { color: var(--on-ink); background: var(--ink); }
.project-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tab-panel { flex: 1; min-height: 0; }
.tab-panel[data-panel="canaux"] { overflow: hidden; display: flex; flex-direction: column; }
.tab-panel[data-panel="canaux"][hidden] { display: none; }
.tab-panel[data-panel="agents"], .tab-panel[data-panel="parametres"], .tab-panel[data-panel="reunions"] { padding: 4px 0 24px; }

/* ---------- board: swimlanes ---------- */
.board-toolbar:has(> .form-error:empty) { display: none; }
.board-wrap { width: 100%; max-width: 1600px; margin-inline: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 24px; }
.new-task { max-width: 760px; }
.board-area { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.has-detail .board-area { grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); }

.swim { --lane-cols: minmax(220px, 1.15fr) repeat(3, minmax(0, 1fr)); container-type: inline-size; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.lane-grid { display: grid; grid-template-columns: var(--lane-cols); }
/* header row: stays visible under the top bar */
.swim-head {
  position: sticky; top: calc(var(--bar-h) + var(--phead-h, 0px) + 8px); z-index: 20;
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.sh-cell { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; padding: 8px 12px; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.sh-cell + .sh-cell { border-left: 1px solid var(--border); }
.col-count { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; color: var(--text); font-weight: 700; letter-spacing: 0; }

.epic-group { display: flex; flex-direction: column; gap: 10px; }
.epic-body { display: flex; flex-direction: column; gap: 10px; }
.epic-head {
  display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; padding: 8px 12px;
  background: var(--glass-strong); border: 1px solid var(--border); border-left: 5px solid #7c4dcc; border-radius: 12px; box-shadow: var(--shadow);
}
.epic-head.selected { border-color: #7c4dcc; box-shadow: 0 0 0 2px #e4d8f8; }
.epic-head.epic-none { border-left-color: var(--line-strong); }
.epic-head.refused { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.epic-toggle { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; flex: none; }
.epic-toggle:hover { background: var(--hover); }
.epic-toggle .icon { transition: transform 0.15s; }
.epic-toggle[aria-expanded="false"] .icon { transform: rotate(-90deg); }
.epic-title { margin: 0; font-size: 1.05rem; flex: 1 1 14ch; min-width: 0; }
.epic-title .card-open { font-weight: 700; }
.epic-note { margin: 0; padding: 6px 4px; }
.prog { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
progress.bar { appearance: none; -webkit-appearance: none; width: 84px; height: 8px; border: 0; border-radius: 99px; overflow: hidden; background: var(--surface-3); vertical-align: middle; }
progress.bar::-webkit-progress-bar { background: var(--surface-3); border-radius: 99px; }
progress.bar::-webkit-progress-value { background: var(--active); border-radius: 99px; }
progress.bar::-moz-progress-bar { background: var(--active); border-radius: 99px; }

.us-row {
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0;
  transition: opacity 0.15s;
}
.us-details { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 12px 14px; border-right: 1px solid var(--border); box-shadow: inset 4px 0 0 #3b82d6; border-radius: var(--radius) 0 0 var(--radius); }
.us-details.selected { background: #eaf3ff; }
.us-details.refused { box-shadow: inset 4px 0 0 var(--danger), 0 0 0 3px var(--danger-soft); }
.us-details.us-loose { box-shadow: inset 4px 0 0 var(--line-strong); justify-content: center; }
.us-title-line { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.us-title-line .card-open { font-weight: 700; font-size: 0.95rem; }
.us-desc { margin: 0; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.us-desc:empty { display: none; }
.us-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.us-loose-title { margin: 0; font-weight: 650; color: var(--muted); }
.us-author { font-size: 0.78rem; color: var(--muted); }

.lane-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 76px; padding: 8px; }
.lane-cell + .lane-cell { border-left: 1px solid rgb(16 40 48 / 0.08); }
.lane-cell:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.cell-title { display: none; margin: 0; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.lane-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }

/* drag and drop: only the cells of the row the card comes from accept it */
.swim.drag-active .us-row:not(.drag-home) { opacity: 0.5; }
.swim.drag-active .us-row.drag-home .lane-cell { outline: 2px dashed var(--line-strong); outline-offset: -4px; border-radius: 10px; }
.lane-cell.drop-target { background: var(--accent-soft); outline-color: var(--accent); }

.task-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "open open" "badges badges" "who sel";
  align-items: center; gap: 4px 6px; padding: 7px 9px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: grab; flex: none;
  box-shadow: 0 1px 2px rgb(16 40 48 / 0.05);
}
.task-card:hover { border-color: var(--line-strong); }
.task-card.selected { border-color: var(--active); box-shadow: 0 0 0 2px var(--accent-soft); }
.task-card.dragging { opacity: 0.5; }
.task-card.is-blocked { border-left: 4px solid var(--danger); }
.task-card.refused { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); animation: lm-shake 0.4s; }
@keyframes lm-shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .task-card.refused { animation: none; } }
.card-open { grid-area: open; display: flex; gap: 6px; align-items: baseline; text-align: left; font: inherit; color: var(--text); background: transparent; border: 0; padding: 0; cursor: pointer; min-width: 0; }
.card-open:hover .task-title { text-decoration: underline; }
.task-id { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); flex: none; }
.task-title { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.task-badges { grid-area: badges; display: flex; flex-wrap: wrap; gap: 4px; }
.task-badges:empty { display: none; }
.task-who { grid-area: who; display: flex; align-items: center; gap: 4px; font-size: 0.78rem; color: var(--muted); min-width: 0; flex-wrap: wrap; }
.who { display: inline-flex; align-items: center; gap: 3px; min-width: 0; }
.who-name { overflow: hidden; text-overflow: ellipsis; max-width: 11ch; white-space: nowrap; }
.card-status { grid-area: sel; font: inherit; font-size: 0.78rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 2px 4px; max-width: 100%; }
.us-meta .card-status, .epic-head .card-status { grid-area: auto; }
.swim-empty { padding: 28px 12px; text-align: center; }

@container (max-width: 700px) {
  .lane-grid { display: block; }
  .swim-head { display: none; }
  .us-details { border-right: 0; border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
  .lane-cell { min-height: 0; padding: 8px 12px; }
  .lane-cell + .lane-cell { border-left: 0; border-top: 1px solid rgb(16 40 48 / 0.08); }
  .lane-cell:not(:has(.task-card)) { display: none; }
  .cell-title { display: block; }
  .swim.drag-active .us-row.drag-home .lane-cell { outline: 0; }
}

.task-detail {
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto; gap: 8px; padding: 12px;
  background: var(--glass-strong); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  position: sticky; top: calc(var(--bar-h) + var(--phead-h, 0px) + 8px); max-height: calc(100dvh - var(--bar-h) - var(--phead-h, 0px) - 20px);
}
.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px; }
.detail-title { font-size: 1.05rem; margin: 0; overflow-wrap: anywhere; flex: 1 1 12ch; }
.detail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.detail-desc { padding: 8px 10px; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--border); }
.detail-sub { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 8px 0 4px; }
.detail-chat .chat { height: 380px; border-radius: 10px; box-shadow: none; }
.del-host { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.confirm-msg { flex-basis: 100%; font-size: 0.9rem; color: var(--danger, inherit); }

/* channels */
.chan-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 10px; }
.chan-side { overflow-y: auto; background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.chan-group-title { margin: 8px 0 4px; }
.chan-list { list-style: none; margin: 0; padding: 0; }
.chan-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; font: inherit; color: var(--text); background: transparent; border: 0; border-radius: 9px; padding: 6px 8px; cursor: pointer; }
.chan-item:hover { background: var(--hover); }
.chan-item.active { background: var(--ink); color: var(--on-ink); font-weight: 700; }
.chan-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--active); flex: none; box-shadow: 0 0 0 2px var(--surface); }
.chan-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 10px; }
.chan-main > .chat { flex: 1; }
.chan-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); flex: none; position: relative; }
.chan-title { flex: 1; min-width: 0; }
.chan-title h2 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.chan-search summary { list-style: none; cursor: pointer; }
.chan-search-body { position: absolute; right: 12px; top: 100%; z-index: 8; width: min(340px, calc(100% - 24px)); max-height: 60vh; overflow: auto; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow-pop); }
.add-part { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 12px; background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); }
.add-part .select { width: auto; min-width: 12em; }
.participants-pick { border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; margin: 0; max-height: 160px; overflow: auto; }
.participants-pick legend { font-weight: 600; font-size: 0.88rem; padding: 0 4px; }
.check { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.chat-project .msg-system, .chat-task .msg-system { justify-content: flex-start; font-style: normal; background: var(--surface-2); border-left: 3px solid var(--active); border-radius: 8px; padding: 3px 10px; margin: 4px 0; }
.chat-project .msg-system .sys-text, .chat-task .msg-system .sys-text { flex: 1; }
.chat-project .msg-system .msg-time, .chat-task .msg-system .msg-time { margin-left: auto; }

/* agents */
.agents-layout { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.agent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.agent-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--glass); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; cursor: pointer; }
.agent-item:hover { border-color: var(--line-strong); background: var(--glass-strong); }
.agent-item.active { border-color: var(--ink); background: var(--glass-strong); box-shadow: 0 0 0 1px var(--ink); }
.agent-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.agent-role, .agent-seen { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presence { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); opacity: 0.5; }
.presence.on { background: var(--p-online); opacity: 1; }
.agent-profile { background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.profile-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0 0 12px; }
.profile-facts dt { color: var(--muted); font-weight: 600; }
.profile-facts dd { margin: 0; overflow-wrap: anywhere; }
.profile-notes { padding: 8px 10px; background: var(--glass-strong); border: 1px solid var(--border); border-radius: 10px; }

/* settings */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings .card + .card { margin-top: 0; }
.collab-list { list-style: none; margin: 0; padding: 0; }
.collab { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.nick-plain { font-weight: 600; overflow-wrap: anywhere; }
.token-state { margin: 0; }
.saved { color: var(--accent); font-weight: 600; }
.danger-zone { border-color: var(--danger); }

@media (max-width: 760px) {
  .project-head { --room-pad: 8px; }
  .project-head.stuck .project-head-top { padding-inline: calc(10px + var(--room-pad)); }
}
/* the Channels tab fills the viewport inside #app (its own scroll box): nothing to stick to */
#app.full .project-head { position: static; }
/* phone: only the top bar sticks; the project block scrolls away normally */
@media (max-width: 600px) {
  .project-head { position: static; }
  .swim-head, .task-detail { --phead-h: 0px; }
}
@media (max-width: 760px) {
  .tabrow { flex-wrap: wrap; }
  .tabs { flex: 1 1 100%; }
  .tab-actions { flex: 1 1 100%; margin-left: 0; justify-content: flex-start; }
  .tab-act { justify-content: flex-start; }
  .tab-panel[data-panel="agents"], .tab-panel[data-panel="parametres"], .tab-panel[data-panel="reunions"] { padding: 2px 0 16px; }
  .has-detail .board-area { grid-template-columns: minmax(0, 1fr); }
  /* the detail covers the board on a phone, under the top bar */
  .has-detail .task-detail { position: fixed; z-index: 30; inset: calc(var(--bar-h) + 8px) 8px 8px 8px; max-height: none; }
  .chan-layout { grid-template-columns: minmax(0, 1fr); position: relative; }
  .chan-side { position: absolute; inset: 0 auto 0 0; width: min(300px, 92%); z-index: 20; transform: translateX(-100%); visibility: hidden; box-shadow: var(--shadow-pop); background: var(--glass-strong); transition: transform 0.2s ease, visibility 0.2s; }
  .chan-layout.chan-open .chan-side { transform: none; visibility: visible; }
  .side-toggle { display: inline-flex; }
  .agents-layout, .settings-grid, .meetings-layout, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .alert-peek { display: none; }
  .detail-chat .chat { height: 320px; }
}

/* ---- presence, alerts, relations ---- */
.presence-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.presence-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.p-online .presence-dot { background: var(--p-online); }
.p-idle .presence-dot { background: var(--p-idle); }
.p-offline .presence-dot { background: var(--p-offline); }
.agent-main .presence-badge { margin-top: 1px; }

.ok-note { margin: 0; padding: 6px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-weight: 500; }
.ok-note:empty { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.side-head .side-title { margin: 0; }
.agents-side, .meetings-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.side-note:empty { display: none; }
.agent-row { display: flex; flex-direction: column; gap: 2px; }
.agent-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 4px 6px; }
.quick-status { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.quick-status:empty { display: none; }
.role-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.role-row .select { width: auto; min-width: 12em; max-width: 100%; }
.release-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.profile-body > .card { margin-top: 0; }
.prompt-fallback { font-family: var(--mono); font-size: 0.8rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.profile-body, .meeting-detail, .meetings-main { min-width: 0; }

/* alert banner */
.alert-banner { flex: none; background: var(--alert-bg); border: 1px solid var(--alert-border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); padding: 8px 14px; }
.alert-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.alert-count { white-space: nowrap; }
.alert-q { font-weight: 700; color: var(--danger); white-space: nowrap; }
.alert-peek { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-toggle { margin-left: auto; flex: none; }
.alert-list { list-style: none; margin: 8px 0 2px; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.alert-item { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--p-idle); border-radius: 10px; padding: 8px 10px; }
.alert-item.alert-question { border-left-color: var(--danger); }
.alert-line { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.alert-kind { font-weight: 700; }
.alert-body { margin: 4px 0 6px; overflow-wrap: anywhere; white-space: pre-wrap; }
.alert-answer { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; margin-bottom: 6px; }
.alert-answer textarea { flex: 1 1 220px; min-width: 0; }

/* badges, relations */
.badge { text-transform: none; letter-spacing: 0; font-size: 0.72rem; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.kind-badge.kind-epic { background: #ede4fb; color: #4b2a8f; border-color: #cdb9f2; }
.kind-badge.kind-us { background: #dcecff; color: #174c8f; border-color: #aecdf3; }
.kind-badge.kind-task { background: var(--surface-2); color: var(--muted); }
.badge-blocked { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.badge-ready { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.badge-wait { background: var(--warn-soft); color: var(--warn-text); border-color: var(--alert-border); }
.badge-turn { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.badge-queue, .badge-reopen { background: var(--warn-soft); color: var(--warn-text); border-color: var(--alert-border); }
.dep-pick { max-height: 160px; overflow: auto; }
.plain-list { margin: 0; padding-left: 1.1em; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgb(17 25 28 / 0.38); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(460px, 100%); margin: 0; background: var(--glass-strong); box-shadow: var(--shadow-pop); }

/* meetings */
.meetings-layout { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.meeting-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.meeting-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--glass); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; cursor: pointer; }
.meeting-item:hover { border-color: var(--line-strong); background: var(--glass-strong); }
.meeting-item.active { border-color: var(--ink); background: var(--glass-strong); box-shadow: 0 0 0 1px var(--ink); }
.meeting-topic { flex: 1 1 8ch; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.meeting-detail { background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.phase-line { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.phase-blind { background: var(--warn-soft); color: var(--warn-text); }
.phase-challenge { background: #dcecff; color: #174c8f; }
.phase-decision { background: var(--accent-soft); color: var(--accent); }
.phase-closed { background: var(--surface-3); color: var(--muted); }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); }
.participant-list, .transcript, .decision-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.participant { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--glass-strong); }
.tmsg { padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--glass-strong); overflow-wrap: anywhere; }
.tmsg-system { border-left: 3px solid var(--active); background: var(--surface-2); }
.tmsg-head { display: flex; gap: 6px; align-items: baseline; }
.decision { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--glass-strong); overflow-wrap: anywhere; }
.decision-text { margin: 4px 0; white-space: pre-wrap; }
.decision-log { margin: 0; }
.meeting-detail .card { margin-top: 0; }

@media (max-width: 760px) {
  .meetings-layout, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .meeting-detail { padding: 10px; }
}

/* ---------- language selector (top bar) ---------- */
.lang-select {
  flex: none; margin-left: 4px; max-width: 8.5em; padding: 5px 6px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--glass-strong); color: var(--text); font: inherit; font-size: 0.85rem;
}
.nav { min-width: 0; flex: 1 1 auto; justify-content: flex-end; }
@media (max-width: 520px) {
  .topbar { padding: 0 8px; gap: 4px; }
  .brand-name { display: none; }
  .nav { gap: 0; }
  .nav-link { padding: 6px 7px; font-size: 0.9rem; }
  .nav-home { display: none; } /* the brand already links home */
  .nav-account { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lang-select { max-width: 6.5em; margin-left: 2px; }
}

/* ---------- mentions, agent types, unread flags ---------- */
.composer-warn { display: none; gap: 6px; align-items: flex-start; background: var(--warn-soft); color: var(--warn-text); border-radius: 10px; padding: 6px 10px; margin-bottom: 6px; font-size: 0.88rem; font-weight: 500; }
.composer-warn.on { display: flex; }
.warn-ico { flex: none; }
.mention-list {
  position: absolute; left: 16px; right: 16px; bottom: calc(100% - 4px); z-index: 20; margin: 0; padding: 4px; list-style: none;
  max-height: min(40vh, 260px); overflow-y: auto; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop);
}
.mention-list[hidden] { display: none; }
.mention-opt { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; padding: 8px 10px; border-radius: 8px; cursor: pointer; min-height: 40px; }
.mention-opt:hover { background: var(--hover); }
.mention-opt[aria-selected="true"] { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
.mention-name { font-weight: 700; overflow-wrap: anywhere; }
.mention-meta { color: var(--muted); font-size: 0.82rem; }
@media (max-width: 760px) { .mention-list { left: 8px; right: 8px; } }
.mention { border-radius: 5px; padding: 0 3px; background: var(--accent-soft); color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.mention-role { border: 1px dashed var(--accent); }
.mention-all { border: 1px dotted var(--accent); }
.mention-self { background: var(--warn-soft); color: var(--warn-text); outline: 2px solid var(--warn-text); outline-offset: 0; font-weight: 800; }

.types-card .table-scroll, .table-scroll { overflow-x: auto; }
.types-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.types-table th, .types-table td { border-bottom: 1px solid var(--border); padding: 6px 6px; text-align: left; vertical-align: top; }
.types-table thead th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.types-table .input { padding: 4px 6px; min-width: 5em; }
.types-table .type-num { width: 7em; }
.types-table input[data-field=label] { min-width: 12em; }
.types-table .type-key code { overflow-wrap: anywhere; }
.settings > .types-card { margin-top: 16px; }
.types-table .type-actions { white-space: nowrap; }
.type-hint { display: block; }
.type-add { border-top: 1px solid var(--border); padding-top: 12px; }

.unread-flag { display: inline-block; margin-top: 2px; padding: 1px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-text); border: 1px solid var(--warn-text); font-size: 0.8rem; font-weight: 600; }
dd.unread-flag { display: block; border-radius: 8px; border-width: 1px; }
.participant-turn { white-space: nowrap; }

/* ---------- language picker (button + listbox with inline SVG flags) ---------- */
.lang-picker { position: relative; flex: none; margin-left: 4px; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 8px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); background: var(--glass-strong); color: var(--text); font: inherit; font-size: 0.85rem; font-weight: 600;
}
.lang-btn:hover, .lang-picker.open .lang-btn { background: var(--hover); }
.lang-picker .flag { width: 22px; height: 15px; flex: none; border-radius: 2px; box-shadow: 0 0 0 1px rgb(16 40 48 / 0.35); display: block; }
.lang-picker .icon { width: 16px; height: 16px; }
.lang-picker .lang-chev { width: 14px; height: 14px; }
.lang-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 80; min-width: 12em; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgb(16 40 48 / 0.2);
}
.lang-list[hidden] { display: none; }
.lang-list:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.lang-opt { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.lang-opt.active { background: var(--hover); }
.lang-opt[aria-selected="true"] { font-weight: 700; }
.lang-opt[aria-selected="true"]::after { content: "\2713"; margin-left: auto; padding-left: 8px; }
@media (max-width: 520px) {
  .lang-picker { margin-left: 2px; }
  .lang-btn { padding: 4px 6px; gap: 4px; }
  .lang-picker .lang-ico { display: none; }
}

/* ---------- short references (section 9.20) ---------- */
.ref-link { font: inherit; font-weight: 600; background: var(--accent-soft); color: var(--text); border: 0; border-radius: 5px; padding: 0 4px; cursor: pointer; text-decoration: underline dotted; overflow-wrap: anywhere; }
.ref-link:hover { text-decoration: underline; }
.ref-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ref-chip { display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; font-weight: 700; padding: 0 6px; border-radius: 5px; background: var(--accent-soft); color: var(--text); white-space: nowrap; }
.prj-chip { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--text); overflow-wrap: anywhere; }
.prj-chip[hidden] { display: none; }
.ref-path { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; color: var(--muted); overflow-wrap: anywhere; user-select: all; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); z-index: 60; overflow-wrap: anywhere; }
.toast-error { background: var(--danger, #b3261e); color: #fff; }
.move-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.move-row select { min-width: 0; max-width: 100%; }
.us-details .ref-chip, .epic-head .ref-chip, .task-card .ref-chip { margin-right: 4px; }
.ref-path-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0 0 8px; min-width: 0; }
.ref-path-row .ref-path { display: inline; }
@media (max-width: 760px) { .prj-chip { font-size: 0.78rem; } .toast { bottom: 12px; } .move-row select { flex: 1 1 100%; } }
