/* team·bridge — night bridge / control room
   Dual accent encodes WHO: teal = agent/machine, amber = human. Never decoration. */

:root {
  --bg: #0C1618;
  --bg-deep: #081012;
  --surface: #122024;
  --surface-2: #182B2F;
  --ink: #E2EDEC;
  --muted: #7E979A;
  --line: #1F3438;
  --agent: #4FC6C0;
  --agent-dim: rgba(79, 198, 192, .14);
  --human: #E5A25A;
  --human-dim: rgba(229, 162, 90, .14);
  --wire: #2A4448;
  --good: #63C783;
  --good-dim: rgba(99, 199, 131, .14);
  --danger-dim: rgba(228, 114, 107, .13);
  --danger: #E4726B;

  --font-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --font-body: "Instrument Sans", "Helvetica Neue", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", "SF Mono", ui-monospace, monospace;

  --send-ink: #14100A;
}

/* theme: dark tokens live on bare :root above; OS-light applies only when the
   user has not forced dark; an explicit data-theme="light" wins everywhere. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F1F6F5;
    --bg-deep: #E4EDEC;
    --surface: #FFFFFF;
    --surface-2: #E9F1F0;
    --ink: #14282B;
    --muted: #5C7376;
    --line: #D3E1E0;
    --agent: #0F7F82;
    --human: #A9631C;
    --wire: #BFD3D2;
    --good: #2F8D52;
  --good-dim: rgba(47, 141, 82, .16);
  --danger-dim: rgba(194, 79, 68, .13);
    --good-dim: rgba(47, 141, 82, .16);
    --danger-dim: rgba(194, 79, 68, .13);
    --danger: #C24F44;
    --send-ink: #FFF8EF;
  }
}

:root[data-theme="light"] {
  --bg: #F1F6F5;
  --bg-deep: #E4EDEC;
  --surface: #FFFFFF;
  --surface-2: #E9F1F0;
  --ink: #14282B;
  --muted: #5C7376;
  --line: #D3E1E0;
  --agent: #0F7F82;
  --human: #A9631C;
  --wire: #BFD3D2;
  --good: #2F8D52;
  --danger: #C24F44;
  --send-ink: #FFF8EF;
}

/* ---------- reset / base ---------- */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--agent);
  outline-offset: 2px;
  border-radius: 2px;
}

::selection { background: var(--agent-dim); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; }

/* mono voice — the system speaks in mono */
.mono, .ts, .rail-label, .legend, .tabs, .field-label, .p-status, .p-role,
.seat-chip, .token-box, .sys-body, .day-sep, .tag-dm, .to-chip, .crew-n,
.card-meta, .reconnect, .rail-foot, .kv-key, .toast, .fc-size, .invite-meta,
.kcol-label, .kcol-n, .tk-time, .task-empty {
  font-family: var(--font-mono);
}

/* ---------- app frame ---------- */

.app {
  --rail-w: 212px;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  height: 100dvh;
}

body.view-project .app {
  grid-template-columns: var(--rail-w) minmax(0, 1fr) 288px;
}

/* split perspective: the kanban pane replaces the crew sidebar */
body.view-project.view-split .app {
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--split-w, 440px);
}

body.nav-collapsed .app { --rail-w: 52px; }

@media (prefers-reduced-motion: no-preference) {
  .app { transition: grid-template-columns .25s cubic-bezier(.33, 0, .2, 1); }
}

/* ---------- left rail ---------- */

.rail {
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 6px;
  min-height: 0;
}

.rail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--ink);
  padding: 2px 6px;
  white-space: nowrap;
}

.nav-toggle {
  flex: none;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
}

.nav-toggle:hover { color: var(--ink); border-color: var(--line); }

.wm-dot { color: var(--agent); }

.legend {
  display: flex;
  gap: 14px;
  font-size: 10.5px;
  color: var(--muted);
  padding: 2px 6px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.lg-item { display: inline-flex; align-items: center; gap: 6px; }
.lg-node { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.lg-agent { background: var(--agent); }
.lg-human { border: 2px solid var(--human); }

.rail-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  padding: 4px 6px;
}

.project-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }

.project-list a {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--muted);
  border-left: 2px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-list a:hover { color: var(--ink); background: var(--surface); }

.project-list a.active {
  color: var(--ink);
  background: var(--surface);
  border-left-color: var(--wire);
}

.project-list .pl-empty { font-size: 12px; color: var(--muted); padding: 6px 8px; }

.rail-foot {
  margin-top: auto;
  padding: 12px 6px 0;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-foot b { color: var(--ink); font-weight: 500; }

/* ---------- main column ---------- */

.main {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.col {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 0 20px;
}

/* ---------- dashboard ---------- */

.dash {
  width: 100%;
  max-width: 860px;
  padding: 36px 24px;
  overflow-y: auto;
}

.dash h1 { font-size: 26px; letter-spacing: -0.02em; }

.dash-sub { color: var(--muted); font-size: 13px; margin: 4px 0 26px; font-family: var(--font-mono); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 18px 14px;
  min-height: 128px;
  transition: border-color .15s ease;
}

.card:hover { border-color: var(--wire); }

.card h2 { font-size: 17px; margin-bottom: 6px; overflow-wrap: anywhere; }

.card-desc {
  color: var(--muted);
  font-size: 13.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.card-meta { margin-top: 12px; font-size: 11px; color: var(--muted); }

.card-new {
  background: none;
  border: 1px dashed var(--wire);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}

.card-new:hover { color: var(--ink); border-color: var(--muted); }

.dash-empty { color: var(--muted); font-size: 13px; font-family: var(--font-mono); padding: 24px 0; }

/* ---------- chat header ---------- */

.chat-head { padding: 22px 0 0; flex: none; }

.ch-top { display: flex; align-items: flex-start; gap: 12px; }

.ch-top h1 { font-size: 21px; letter-spacing: -0.02em; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

.ch-desc { color: var(--muted); font-size: 13px; margin-top: 2px; }

.crew-toggle {
  display: none;
  flex: none;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}

.tabs {
  display: flex;
  gap: 18px;
  margin-top: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.tabs button {
  padding: 8px 2px 9px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--ink); }

.reconnect {
  display: none;
  flex: none;
  font-size: 11px;
  color: var(--human);
  background: var(--human-dim);
  border-bottom: 1px solid var(--human);
  padding: 4px 12px;
}

.reconnect.show { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .reconnect.show { animation: pulse-bar 1.6s ease-in-out infinite; }
  @keyframes pulse-bar { 50% { opacity: .55; } }
}

.tab-body { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

/* ---------- timeline: the wire ---------- */

.chat-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding: 22px 0 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--wire) transparent;
}

.timeline {
  position: relative;
  padding-left: 44px;
  padding-top: 4px;
  padding-bottom: 4px;
}

/* the wire itself */
.timeline::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--wire);
}

.msg { position: relative; padding: 5px 0; }

/* typed nodes hang off the wire */
.msg .node {
  position: absolute;
  left: -44px;
  top: 11px;
  width: 28px;
  height: 12px;
}

/* connector stub, node → content */
.msg .node::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 5px;
  width: 20px;
  height: 2px;
  background: var(--wire);
}

.msg .node::before {
  content: "";
  position: absolute;
  z-index: 1;
}

/* agent: filled teal circle */
.msg.from-agent .node::before {
  left: 3px; top: 1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--agent);
  box-shadow: 0 0 0 3px var(--bg);
}

/* human: amber ring */
.msg.from-human .node::before {
  left: 3px; top: 1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--human);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--bg);
}

/* system: small rotated square sitting ON the wire, no stub */
.msg.sys .node::after { display: none; }
.msg.sys .node::before {
  left: 4px; top: 3px;
  width: 7px; height: 7px;
  transform: rotate(45deg);
  background: var(--bg);
  border: 1.5px solid var(--muted);
  box-shadow: 0 0 0 3px var(--bg);
}

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.msg-name { font-weight: 600; font-size: 13.5px; }
.msg-name.agent { color: var(--agent); }
.msg-name.human { color: var(--human); }

.ts { font-size: 11px; color: var(--muted); }

.tag-dm {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 5px;
  letter-spacing: 0.04em;
}

.msg-body {
  margin-top: 1px;
  font-size: 14.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
}

/* system rows: one quiet mono line */
.msg.sys { padding: 7px 0; }
.msg.sys .sys-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sys-body { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

/* day separator: a tick on the wire */
.day-sep {
  position: relative;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 16px 0 10px;
}

.day-sep::before {
  content: "";
  position: absolute;
  left: -35px;
  top: 22px;
  width: 10px;
  height: 2px;
  background: var(--muted);
}

.timeline-empty {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  padding: 28px 0;
}

/* file chip */
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  max-width: 100%;
}

.file-chip:hover { border-color: var(--wire); }

.fc-glyph { flex: none; color: var(--muted); display: flex; }
.fc-name { font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.fc-size { font-size: 11px; color: var(--muted); flex: none; }
.fc-dl { flex: none; color: var(--muted); font-size: 13px; }
.fc-caption { margin-top: 4px; font-size: 13.5px; color: var(--muted); }

/* page-load moment: wire draws in, messages stagger */
@media (prefers-reduced-motion: no-preference) {
  .timeline.enter::before {
    transform-origin: top center;
    animation: wire-in .6s cubic-bezier(.33, 0, .2, 1) both;
  }
  .timeline.enter .msg,
  .timeline.enter .day-sep {
    animation: msg-in .45s ease both;
    animation-delay: calc(120ms + var(--i, 0) * 40ms);
  }
  .msg.enter-one { animation: msg-in .3s ease both; }
  @keyframes wire-in { from { transform: scaleY(0); } }
  @keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* ---------- composer ---------- */

.composer {
  flex: none;
  border-top: 1px solid var(--line);
  padding: 12px 0 18px;
  position: relative;
}

.composer-row { display: flex; gap: 10px; align-items: flex-end; }

.to-chip {
  flex: none;
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  margin-bottom: 4px;
  white-space: nowrap;
}

.to-chip:hover { color: var(--ink); border-color: var(--wire); }
.to-chip b { font-weight: 500; color: var(--ink); }
.to-chip.dm b { color: var(--human); }
.to-chip.dm.dm-agent b { color: var(--agent); }

.menu {
  position: absolute;
  bottom: calc(100% - 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  min-width: 190px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
  z-index: 30;
}

.menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
}

.menu button:hover { background: var(--surface-2); }
.menu .m-node { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.menu .m-node.agent { background: var(--agent); }
.menu .m-node.human { border: 2px solid var(--human); }
.menu .m-node.all { background: var(--wire); }

#msg-input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 13px;
  resize: none;
  max-height: 140px;
  line-height: 1.45;
  color: var(--ink);
}

#msg-input::placeholder { color: var(--muted); }
#msg-input:focus { outline: none; border-color: var(--wire); }
#msg-input:focus-visible { outline: 2px solid var(--agent); outline-offset: 1px; }

/* sending is a human act — the button is amber */
.btn-send {
  flex: none;
  background: var(--human);
  color: var(--send-ink);
  font-weight: 600;
  font-size: 14px;
  border-radius: 9px;
  padding: 9px 18px;
}

.btn-send:hover { filter: brightness(1.07); }
.btn-send:disabled { opacity: .5; cursor: default; }

/* ---------- crew sidebar ---------- */

.crew {
  display: none;
  background: var(--bg-deep);
  border-left: 1px solid var(--line);
  flex-direction: column;
  min-height: 0;
}

body.view-project .crew { display: flex; }

.crew-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 24px 18px 12px;
}

.crew-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-family: var(--font-mono);
}

.crew-n { font-size: 11px; color: var(--muted); }

.crew-close {
  display: none;
  margin-left: auto;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
}

.crew-list { flex: 1 1 auto; overflow-y: auto; padding: 0 10px; min-height: 0; }

.p-tile {
  display: flex;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
}

.p-tile:hover { background: var(--surface); }
.p-tile.suspended { opacity: .45; }

.p-ava {
  flex: none;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.p-ava.agent { background: var(--agent-dim); border-radius: 8px; }

.p-ava.human {
  background: var(--human-dim);
  border-radius: 50%;
  color: var(--human);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

.p-info { min-width: 0; flex: 1; }

.p-name-row { display: flex; align-items: center; gap: 7px; }

.p-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-name.agent { color: var(--agent); }
.p-name.human { color: var(--human); }

.p-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--wire); flex: none; }
.p-dot.online { background: var(--good); }

@media (prefers-reduced-motion: no-preference) {
  .p-dot.online { animation: breathe 2.6s ease-in-out infinite; }
  @keyframes breathe {
    50% { box-shadow: 0 0 0 4px rgba(99, 199, 131, .16); opacity: .8; }
  }
}

.p-role { font-size: 11px; color: var(--muted); margin-top: 1px; }

.p-status {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.p-status:empty { display: none; }

.seat-chip {
  display: inline-block;
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--agent);
  background: var(--agent-dim);
  border-radius: 4px;
  padding: 1px 7px;
}

.crew-foot { flex: none; padding: 12px 16px 18px; }

.btn-invite {
  width: 100%;
  border: 1px dashed var(--wire);
  border-radius: 8px;
  padding: 9px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}

.btn-invite:hover { color: var(--ink); border-color: var(--muted); }

.crew-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 9, .55);
  z-index: 39;
}

/* ---------- ljudi tab ---------- */

.tab-scroll { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding: 22px 0 32px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }

table.people { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }

table.people th {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

table.people td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.people tr:last-child > td { border-bottom: 0; }

.pp-name { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.pp-name .p-ava { width: 26px; height: 26px; font-size: 12px; }
.pp-name.agent { color: var(--agent); }
.pp-name.human { color: var(--human); }

.pp-sec { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

.tag-out {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 3px;
  padding: 0 5px;
}

.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.btn-mini {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
  white-space: nowrap;
}

.btn-mini:hover { color: var(--ink); border-color: var(--wire); }
.btn-mini.danger:hover { color: var(--danger); border-color: var(--danger); }

.brief-editor td { background: var(--bg); }

.brief-form { display: flex; flex-direction: column; gap: 10px; padding: 6px 2px; }
.brief-form .bf-row { display: flex; gap: 10px; flex-wrap: wrap; }
.brief-form .bf-row > label { flex: 1 1 180px; }

.field-label {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 5px;
}

.brief-form input, .brief-form textarea,
.modal input[type="text"], .modal input[type="password"], .modal textarea, .modal select,
.login-card input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--ink);
}

.brief-form textarea, .modal textarea { resize: vertical; min-height: 110px; font-size: 14px; }

.brief-form input:focus, .brief-form textarea:focus,
.modal input:focus, .modal textarea:focus, .modal select:focus,
.login-card input:focus { outline: none; border-color: var(--wire); }

.brief-form input:focus-visible, .brief-form textarea:focus-visible,
.modal input:focus-visible, .modal textarea:focus-visible, .modal select:focus-visible,
.login-card input:focus-visible { outline: 2px solid var(--agent); outline-offset: 1px; }

/* ---------- zadaci tab: kanban ---------- */

.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.kcol {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
  transition: border-color .15s ease;
}

.kcol.drag-over { border-color: var(--wire); background: var(--surface-2); }

.kcol-head { display: flex; align-items: baseline; gap: 8px; padding: 0 2px; }

.kcol-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.kcol-n {
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 7px;
}

.task-add input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--ink);
}

.task-add input::placeholder { color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.task-add input:focus { outline: none; border-color: var(--wire); }
.task-add input:focus-visible { outline: 2px solid var(--agent); outline-offset: 1px; }

.kcol-cards { display: flex; flex-direction: column; gap: 8px; min-height: 24px; }

.task-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: grab;
}

.task-card:hover { border-color: var(--wire); }
.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: .45; }

.tk-title { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }

.tk-body {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.tk-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 18px; }

.tk-owner {
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  padding: 1px 7px;
  max-width: 55%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tk-owner.agent { color: var(--agent); background: var(--agent-dim); }
.tk-owner.human { color: var(--human); background: var(--human-dim); }

.tk-time { font-size: 10.5px; color: var(--muted); margin-left: auto; }

.tk-adv {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 9px;
}

.tk-adv:hover { color: var(--ink); border-color: var(--wire); }

.task-empty { font-size: 12px; color: var(--muted); padding: 4px 2px; }

/* ---------- postavke tab ---------- */

.settings { display: flex; flex-direction: column; gap: 18px; max-width: 640px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}

.panel h3 { font-size: 15px; margin-bottom: 12px; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv-key { font-size: 11px; color: var(--muted); padding-top: 2px; }
.kv-val { overflow-wrap: anywhere; }
.kv-val.mono { font-family: var(--font-mono); font-size: 12.5px; }

.invite-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.invite-row:last-child { border-bottom: 0; }
.invite-who { font-size: 13.5px; font-weight: 500; flex: 1 1 auto; min-width: 0; }
.invite-meta { font-size: 11px; color: var(--muted); }
.panel .p-empty { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  border-radius: 8px;
  padding: 9px 18px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface-2);
}

.btn:hover { border-color: var(--wire); }
.btn:disabled { opacity: .5; cursor: default; }

.btn-human { background: var(--human); border-color: var(--human); color: var(--send-ink); }
.btn-human:hover { filter: brightness(1.07); }

.btn-ghost { background: none; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.btn-ghost:hover { color: var(--ink); border-color: var(--wire); }

.btn-block { width: 100%; }

/* ---------- modal ---------- */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(4, 8, 9, .6);
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
}

.modal h3 { font-size: 18px; letter-spacing: -0.01em; }

.modal .m-step {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 3px 0 18px;
}

.modal .m-field { margin-bottom: 14px; }

.m-foot { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.m-foot .spacer { flex: 1; }
.modal .m-foot { margin-top: 20px; }

.type-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }

.type-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: left;
  background: var(--bg);
}

.type-card .tc-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.type-card .tc-node { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.type-card .tc-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-family: var(--font-mono); }

.type-card[data-kind="agent"] .tc-node { background: var(--agent); }
.type-card[data-kind="human"] .tc-node { border: 2px solid var(--human); }

.type-card.sel[data-kind="agent"] { border-color: var(--agent); background: var(--agent-dim); }
.type-card.sel[data-kind="agent"] .tc-name { color: var(--agent); }
.type-card.sel[data-kind="human"] { border-color: var(--human); background: var(--human-dim); }
.type-card.sel[data-kind="human"] .tc-name { color: var(--human); }

.token-box {
  background: var(--bg-deep);
  border: 1px solid var(--wire);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12.5px;
  overflow-x: auto;
  white-space: nowrap;
  color: var(--agent);
  margin: 12px 0 10px;
}

.m-hint { font-size: 12.5px; color: var(--muted); }
.m-err { font-size: 12.5px; color: var(--danger); font-family: var(--font-mono); margin-top: 10px; }

/* ---------- login overlay ---------- */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card { width: 100%; max-width: 320px; }

.login-mark { font-size: 26px; padding: 0; }

.login-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0 30px;
}

.login-card .field-label { margin-bottom: 6px; }
.login-card input { margin-bottom: 14px; font-family: var(--font-mono); letter-spacing: 0.08em; }

.login-err { font-family: var(--font-mono); font-size: 12px; color: var(--danger); margin: -6px 0 12px; }

.login-note { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 18px; }

/* ---------- drag overlay ---------- */

.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(8, 16, 18, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drag-box {
  border: 2px dashed var(--agent);
  border-radius: 14px;
  color: var(--agent);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 34px 44px;
  background: var(--agent-dim);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  padding: 9px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  max-width: min(90vw, 480px);
  overflow-wrap: anywhere;
}

.toast.err { color: var(--danger); border-color: var(--danger); }

/* ---------- lang + theme switch ---------- */

.lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 6px 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

.lang-switch button {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 2px 5px;
  border-radius: 4px;
}

.lang-switch button:hover { color: var(--ink); }
.lang-switch button.active { color: var(--ink); background: var(--surface); }
.lang-switch .ls-sep { color: var(--line); }

.lang-switch .theme-btn {
  margin-left: auto;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.lang-switch .theme-btn:hover { border-color: var(--line); }

.login-card .lang-switch { padding: 14px 0 0; }

/* ---------- mini markdown ---------- */

.md { white-space: normal; font-size: 13.5px; line-height: 1.55; color: var(--ink); overflow-wrap: anywhere; }
.md > * + * { margin-top: 8px; }
.md .md-h { font-family: var(--font-display); letter-spacing: -0.01em; margin-top: 14px; }
.md .md-h:first-child { margin-top: 0; }
.md h1.md-h { font-size: 17px; }
.md h2.md-h { font-size: 15px; }
.md h3.md-h { font-size: 13.5px; }
.md code.md-code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}
.md pre.md-pre {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre;
}
.md pre.md-pre code { font-family: inherit; }
.md blockquote.md-quote {
  border-left: 2px solid var(--wire);
  padding-left: 12px;
  color: var(--muted);
}
.md blockquote.md-quote > * + * { margin-top: 4px; }
.md ul.md-list, .md ol.md-list { padding-left: 20px; }
.md ul.md-list li, .md ol.md-list li { margin-top: 2px; }
.md hr.md-hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* ---------- inline file preview ---------- */

.fc-extra { margin-top: 6px; }

.fc-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
}

.fc-preview:hover { color: var(--ink); }
.fc-preview:disabled { opacity: .5; cursor: default; }

.file-preview {
  margin-top: 6px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  white-space: normal;
  scrollbar-width: thin;
  scrollbar-color: var(--wire) transparent;
}

.preview-pre {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
}

/* ---------- inline image preview + lightbox ---------- */

.msg-img-wrap { margin-top: 6px; }

.msg-img {
  display: block;
  max-height: 240px;
  max-width: 100%;
  width: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 8, 9, .85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: zoom-out;
}

.lb-close {
  position: absolute;
  top: 14px;
  right: 18px;
  color: #E2EDEC;
  font-size: 18px;
  line-height: 1;
  padding: 8px 10px;
  border-radius: 8px;
}

.lb-close:hover { color: #FFFFFF; }

@media (prefers-reduced-motion: no-preference) {
  .lightbox { animation: lb-in .18s ease both; }
  @keyframes lb-in { from { opacity: 0; } }
}

/* ---------- crew row blink ---------- */

@media (prefers-reduced-motion: no-preference) {
  .p-tile.blink-agent { animation: crew-blink-agent 1.2s ease-out 1; }
  .p-tile.blink-human { animation: crew-blink-human 1.2s ease-out 1; }
  @keyframes crew-blink-agent { from { background: var(--agent-dim); } to { background: transparent; } }
  @keyframes crew-blink-human { from { background: var(--human-dim); } to { background: transparent; } }
}

/* ---------- settings: description editor + danger zone ---------- */

.desc-ta {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  resize: vertical;
  min-height: 180px;
}

.desc-ta:focus { outline: none; border-color: var(--wire); }
.desc-ta:focus-visible { outline: 2px solid var(--agent); outline-offset: 1px; }

.save-ok { font-family: var(--font-mono); font-size: 12px; color: var(--good); align-self: center; }

.panel.danger-zone { border-color: var(--danger); }
.panel.danger-zone h3 { color: var(--danger); }

.dz-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.dz-row:first-of-type { border-top: 0; }
.dz-text { flex: 1 1 220px; min-width: 0; }
.dz-text b { font-size: 13.5px; font-weight: 600; }
.dz-text p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.btn-archive {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--agent);
  border: 1px solid var(--agent);
  border-radius: 8px;
  padding: 7px 14px;
  white-space: nowrap;
}

.btn-archive:hover { background: var(--agent-dim); }

.btn-danger-solid {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 7px 14px;
  white-space: nowrap;
}

.btn-danger-solid:hover:not(:disabled) { background: var(--danger); color: var(--bg); }
.btn-danger-solid:disabled { opacity: .45; cursor: default; }

.del-confirm {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
}

.del-confirm p { font-size: 13px; margin-bottom: 10px; }
.del-confirm .dc-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.del-confirm .field-label b { color: var(--danger); letter-spacing: normal; text-transform: none; }

.del-confirm input[type="text"] {
  width: 100%;
  max-width: 320px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--ink);
  font-family: var(--font-mono);
}

.del-confirm input[type="text"]:focus { outline: none; border-color: var(--danger); }
.del-confirm input[type="text"]:focus-visible { outline: 2px solid var(--danger); outline-offset: 1px; }

/* ---------- composer attach ---------- */

.attach-btn {
  flex: none;
  font-size: 14px;
  line-height: 1.2;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  margin-bottom: 4px;
}

.attach-btn:hover { color: var(--ink); border-color: var(--wire); }
.attach-btn:disabled { opacity: .6; cursor: default; }

/* ---------- perspective switch + split pane ---------- */

.persp-switch {
  margin-left: auto;
  align-self: center;
  display: flex;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  margin-bottom: 4px;
}

.persp-switch button {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 2px 9px;
  border-radius: 999px;
  border-bottom: 0;
  margin-bottom: 0;
}

.persp-switch button:hover { color: var(--ink); }
.persp-switch button.active { color: var(--ink); background: var(--surface); }

@media (max-width: 1199px) {
  .persp-switch { display: none; }
}

.split-pane { display: none; }

body.view-split .crew { display: none; }

body.view-split .split-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  position: relative;
  background: var(--bg-deep);
  border-left: 1px solid var(--line);
  padding: 0 16px;
}

.split-pane .tab-scroll { padding: 18px 0 24px; scrollbar-width: thin; scrollbar-color: var(--wire) transparent; }

.split-handle {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 5;
  touch-action: none;
}

.split-handle:hover, .split-handle.active { background: var(--agent-dim); }
.split-handle:focus-visible { outline: 2px solid var(--agent); outline-offset: 0; }

.kanban-stack { grid-template-columns: 1fr; }
.kanban-stack .tk-adv { display: inline-flex; }

/* compact presence strip (split mode) */

.presence-strip {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  flex: none;
  padding: 4px 6px;
  border-radius: 8px;
  max-width: 40%;
}

body.view-split .presence-strip { display: inline-flex; }
.presence-strip:hover { background: var(--surface); }

.ps-ava {
  position: relative;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.ps-ava.agent { background: var(--agent-dim); border-radius: 6px; }

.ps-ava.human {
  background: var(--human-dim);
  border-radius: 50%;
  color: var(--human);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
}

.ps-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--wire);
  border: 2px solid var(--bg);
}

.ps-dot.online { background: var(--good); }

.ps-seat { position: absolute; top: -7px; right: -6px; font-size: 9px; }

/* ---------- invite status dot ---------- */

.inv-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: baseline;
  background: var(--muted);
}

.inv-dot.active { background: var(--good); }
.inv-dot.consumed { background: var(--human); }
.inv-dot.expired { background: var(--muted); }

/* ---------- task delete (done column) ---------- */

.task-card { position: relative; }
.task-card .tk-title { padding-right: 18px; }

.tk-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  font-size: 12px;
  line-height: 1;
  border-radius: 5px;
  opacity: 0;
}

.task-card:hover .tk-del,
.task-card:focus-within .tk-del,
.tk-del:focus-visible { opacity: 1; }

.tk-del:hover { background: var(--surface-2); }

@media (hover: none), (max-width: 899px) {
  .tk-del { opacity: 1; }
}

.tk-del-confirm {
  position: absolute;
  top: 3px;
  right: 3px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--danger);
  z-index: 2;
}

.tk-del-confirm button {
  font-size: 11px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--muted);
}

.tk-del-confirm .tdc-yes { color: var(--danger); }
.tk-del-confirm button:hover { background: var(--surface-2); }

/* ---------- work log (sudionici tab) ---------- */

.worklog-row td { background: var(--bg); }

.worklog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 2px;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--wire) transparent;
}

.wl-entry { border-left: 2px solid var(--line); padding-left: 10px; }
.wl-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }

.wl-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 5px;
}

.wl-tag.agent { color: var(--agent); border-color: var(--agent); }
.wl-tag.human { color: var(--human); border-color: var(--human); }

.wl-summary { font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }

.wl-more {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  padding: 2px 0;
  margin-top: 2px;
}

.wl-more:hover { color: var(--ink); }

.wl-details {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px 10px;
  margin-top: 4px;
}

/* ---------- collapsed rail ---------- */

.pl-init { display: none; }

.rf-mini {
  display: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--human-dim);
  color: var(--human);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  align-items: center;
  justify-content: center;
}

@media (min-width: 900px) {
  body.nav-collapsed .rail { padding: 20px 8px; }
  body.nav-collapsed .rail-top { flex-direction: column; align-items: center; gap: 8px; }
  body.nav-collapsed .wordmark { font-size: 0; padding: 2px; }
  body.nav-collapsed .wordmark .wm-dot { font-size: 20px; line-height: 1; }
  body.nav-collapsed .legend,
  body.nav-collapsed .rail-label,
  body.nav-collapsed .lang-switch { display: none; }
  body.nav-collapsed .project-list { align-items: center; gap: 6px; }
  body.nav-collapsed .project-list a {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
  }
  body.nav-collapsed .project-list a.active { border-color: var(--wire); }
  body.nav-collapsed .pl-full { display: none; }
  body.nav-collapsed .pl-init { display: block; font-family: var(--font-mono); font-size: 13px; }
  body.nav-collapsed .rail-foot {
    border-top: 0;
    padding: 12px 0 0;
    overflow: visible;
    display: flex;
    justify-content: center;
  }
  body.nav-collapsed .rf-full { display: none; }
  body.nav-collapsed .rf-mini { display: flex; }
}

/* ---------- responsive ---------- */

@media (max-width: 899px) {
  .app, body.view-project .app {
    display: flex;
    flex-direction: column;
  }

  .rail {
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    flex: none;
  }

  .legend, .rail-label, .rail-foot { display: none; }
  .wordmark { font-size: 16px; padding: 0; flex: none; }

  .rail .lang-switch { margin-left: auto; padding: 0; flex: none; flex-wrap: nowrap; }
  .rail .lang-switch .theme-btn { margin-left: 4px; }

  .project-list { flex-direction: row; gap: 4px; overflow-y: visible; }
  .project-list a { border-left: 0; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; padding: 4px 8px; font-size: 12.5px; }
  .project-list a.active { border-left: 0; border-bottom-color: var(--wire); }

  .main { flex: 1 1 auto; }
  .col { padding: 0 14px; }
  .chat-head { padding-top: 14px; }
  .crew-toggle { display: inline-block; }

  /* crew becomes an overlay sheet */
  .crew, body.view-project .crew {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 86vw);
    z-index: 40;
    border-left: 1px solid var(--line);
    transform: translateX(102%);
  }

  .crew.open { transform: none; }

  @media (prefers-reduced-motion: no-preference) {
    .crew { transition: transform .25s cubic-bezier(.33, 0, .2, 1); }
  }

  .crew-close { display: block; }

  .composer-row { flex-wrap: wrap; }
  .to-chip { order: 1; }
  .attach-btn { order: 1; }
  #msg-input { order: 2; flex-basis: 100%; }
  .btn-send { order: 3; margin-left: auto; }

  .nav-toggle { display: none; }

  .type-cards { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv-key { padding-top: 8px; }

  /* kanban: columns stack, dnd yields to the advance button */
  .kanban { grid-template-columns: 1fr; }
  .task-card { cursor: default; }
  .task-card:active { cursor: default; }
  .tk-adv { display: inline-flex; }
}

/* ---------- chat channels ---------- */

.chan-row {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 0 0;
}

.chan-row:empty { padding: 0; }

.chan-chip {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chan-chip:hover { color: var(--ink); border-color: var(--wire); }

.chan-chip.active {
  color: var(--agent);
  background: var(--agent-dim);
  border-color: transparent;
}

.chan-chip .ch-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--human);
  flex: none;
}

.chan-chip.chan-plus { padding: 3px 9px; }

.chan-add input {
  font-family: var(--font-mono);
  font-size: 11.5px;
  width: 150px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  color: var(--ink);
}

.chan-add input::placeholder { color: var(--muted); }
.chan-add input:focus { outline: none; border-color: var(--wire); }
.chan-add input:focus-visible { outline: 2px solid var(--agent); outline-offset: 1px; }

/* ---------- plan tab: WBS + gantt ---------- */

.plan-wrap { display: flex; flex-direction: column; gap: 12px; }

.plan-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.plan-add { display: flex; gap: 8px; flex: 1 1 auto; min-width: 0; max-width: 560px; }

.plan-add select {
  flex: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
}

.plan-add input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--ink);
}

.plan-add input::placeholder { color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.plan-add input:focus, .plan-add select:focus { outline: none; border-color: var(--wire); }
.plan-add input:focus-visible, .plan-add select:focus-visible { outline: 2px solid var(--agent); outline-offset: 1px; }

.plan-zoom {
  margin-left: auto;
  display: flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.plan-zoom button {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 11px;
  color: var(--muted);
}

.plan-zoom button + button { border-left: 1px solid var(--line); }
.plan-zoom button:hover { color: var(--ink); }
.plan-zoom button.active { background: var(--surface-2); color: var(--ink); }

.plan-empty { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); padding: 14px 2px; }

.plan-board {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--wire) transparent;
}

.plan-sheet { position: relative; min-width: 100%; }

.plan-hdr, .pl-row { display: flex; align-items: stretch; }

.plan-hdr { height: 34px; border-bottom: 1px solid var(--line); }

.pl-wbs {
  flex: none;
  width: 644px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px 44px 116px 58px 58px 28px;
  align-items: center;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 3;
}

.pl-wbs.menu-open { z-index: 30; }

.plan-hdr .pl-th {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
}

.pl-row { height: 34px; border-bottom: 1px solid var(--line); }
.plan-body .pl-row:last-of-type { border-bottom: 0; }
.pl-row:hover .pl-wbs { background: var(--surface-2); }

.pl-c {
  min-width: 0;
  height: 100%;
  padding: 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

.pl-tgl {
  width: 18px;
  height: 18px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--muted);
  border-radius: 4px;
}

.pl-tgl:hover { color: var(--ink); background: var(--surface-2); }
.pl-tgl-sp { width: 18px; flex: none; }

.pl-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 4px;
  flex: none;
}

.pl-badge.goal { color: var(--ink); border-color: var(--wire); }
.pl-badge.ms { border: 0; padding: 0; font-size: 10px; }

.pl-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.pl-row.is-goal .pl-title { font-weight: 600; }
.pl-row.dropped .pl-title { text-decoration: line-through; color: var(--muted); }

.pl-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 7px;
  white-space: nowrap;
}

.pl-pill.active { color: var(--agent); border-color: var(--agent); background: var(--agent-dim); }
.pl-pill.done { color: var(--good); border-color: var(--good); }
.pl-pill.dropped { text-decoration: line-through; }

.pl-prog, .pl-date { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; }

.pl-who .tk-owner { max-width: 100%; }

.pl-team {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-actions { position: relative; justify-content: flex-end; padding-right: 4px; }

.pl-kebab {
  width: 22px;
  height: 22px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  border-radius: 5px;
}

.pl-kebab:hover { color: var(--ink); background: var(--surface-2); }

.pl-menu {
  bottom: auto;
  top: calc(100% + 2px);
  left: auto;
  right: 2px;
  min-width: 174px;
  z-index: 40;
}

.plm-warn {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--danger);
  padding: 6px 8px 2px;
  max-width: 210px;
}

.plm-row { display: flex; gap: 6px; padding: 5px; }

.plm-child { padding: 4px; }

.plm-child input {
  width: 200px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12.5px;
  color: var(--ink);
}

.plm-child input:focus { outline: none; border-color: var(--wire); }
.plm-child input:focus-visible { outline: 2px solid var(--agent); outline-offset: 1px; }

/* gantt side */

.plan-body { position: relative; }

.plan-grid { position: absolute; top: 0; bottom: 0; z-index: 0; pointer-events: none; }
.plan-grid .pg-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); opacity: .6; }
.plan-grid .pg-today { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--human); opacity: .85; }

.pl-axis { flex: none; position: relative; overflow: hidden; }

.pl-axis .ax-lab {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted);
  padding-left: 4px;
  white-space: nowrap;
}

.pl-axis .ax-today { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--human); }

.pl-cell-gantt { flex: none; position: relative; z-index: 1; }

.pl-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.pl-bar .pl-fill { position: absolute; top: 0; bottom: 0; left: 0; }
.pl-fill.planned { background: var(--muted); opacity: .75; }
.pl-fill.active { background: var(--agent); }
.pl-fill.done { background: var(--good); }
.pl-fill.dropped { background: var(--muted); opacity: .4; }
.pl-row.dropped .pl-bar { opacity: .45; }

.pl-dia {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--muted);
  border-radius: 1px;
}

.pl-dia.active { background: var(--agent); }
.pl-dia.done { background: var(--good); }
.pl-row.dropped .pl-dia { opacity: .45; }

#plan-deps-svg { position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none; }

/* inline detail editor */

.pl-detail { border-bottom: 1px solid var(--line); background: var(--bg); }

.pl-detail-inner {
  position: sticky;
  left: 0;
  max-width: 680px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pld-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; }
.pld-grid .pld-wide { grid-column: 1 / -1; }

.pl-detail input[type="text"], .pl-detail input[type="date"], .pl-detail input[type="number"],
.pl-detail select, .pl-detail textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--ink);
}

.pl-detail input[type="date"] { font-family: var(--font-mono); font-size: 12px; color-scheme: dark; }
.pl-detail textarea { resize: vertical; min-height: 64px; }

.pl-detail input:focus, .pl-detail select:focus, .pl-detail textarea:focus { outline: none; border-color: var(--wire); }
.pl-detail input:focus-visible, .pl-detail select:focus-visible, .pl-detail textarea:focus-visible {
  outline: 2px solid var(--agent);
  outline-offset: 1px;
}

.pld-prog { display: flex; gap: 10px; align-items: center; }
.pld-prog input[type="range"] { flex: 1 1 auto; min-width: 0; accent-color: var(--agent); padding: 0; }
.pld-prog input[type="number"] { width: 64px; flex: none; font-family: var(--font-mono); font-size: 12px; }

.pld-deps {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 150px;
  overflow-y: auto;
}

.pld-deps legend {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  padding: 0 4px;
}

.pld-dep { display: flex; gap: 8px; align-items: center; font-size: 12.5px; min-width: 0; }
.pld-dep input { accent-color: var(--agent); flex: none; }
.pld-dep span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* quick title edit */

.plq {
  width: 100%;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--wire);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 12.5px;
  color: var(--ink);
}

.plq:focus { outline: none; border-color: var(--agent); }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .pl-detail input[type="date"] { color-scheme: light; }
}

:root[data-theme="light"] .pl-detail input[type="date"] { color-scheme: light; }

@media (max-width: 899px) {
  .pl-detail-inner { max-width: calc(100vw - 44px); }
}

/* the plan board earns the full width of the main column */
.col.col-wide { max-width: 1560px; }

/* linkified URLs in messages */
.msg-link {
  color: var(--agent);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.msg-link:hover { text-decoration-color: var(--agent); opacity: .85; }

/* plan: view/zoom switcher group */
.plan-switchers { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.plan-switchers .plan-zoom { margin-left: 0; }

/* plan: priority markers */
.pl-prio { font-family: var(--font-mono); font-size: 11px; font-weight: 500; flex: none; }
.pl-prio.hi { color: var(--human); }
.pl-prio.crit { color: var(--danger); }

.pl-badge.bug { color: var(--danger); border-color: var(--danger); }

/* ---------- plan: matrix view ---------- */

.mx-board {
  overflow: auto;
  max-height: calc(100dvh - 230px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--wire) transparent;
}

table.mx { border-collapse: separate; border-spacing: 0; min-width: 100%; }

table.mx th, table.mx td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

table.mx tr > *:last-child { border-right: 0; }
table.mx tbody tr:last-child > * { border-bottom: 0; }

table.mx thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  white-space: nowrap;
}

table.mx thead .mx-corner { left: 0; z-index: 3; position: sticky; }

.mx-colh .tk-owner, .mx-colh .pl-team { max-width: 180px; display: inline-block; vertical-align: middle; }

.mx-un {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

table.mx .mx-rowh {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  min-width: 170px;
  max-width: 240px;
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.mx .mx-rowh.sub { padding-left: 26px; font-weight: 500; }
table.mx .mx-rowh.dropped { text-decoration: line-through; color: var(--muted); }

td.mx-cell { min-width: 168px; max-width: 260px; }

.mx-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 250px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11.5px;
  text-align: left;
  margin: 2px 0;
  color: var(--ink);
}

.mx-chip:hover { border-color: var(--wire); }

.mx-chip .mxc-t {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 28ch;
}

.mx-chip .mxc-p {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted);
  margin-left: auto;
  flex: none;
}

.mx-chip.st-active { background: var(--agent-dim); border-color: transparent; }
.mx-chip.st-done { background: var(--good-dim); border-color: transparent; }
.mx-chip.st-dropped { color: var(--muted); text-decoration: line-through; opacity: .75; }
.mx-chip.is-bug { background: var(--danger-dim); border-color: transparent; }

.mx-detail { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.mx-detail .pl-detail { border-bottom: 0; }

/* ---------- settings: github ---------- */

.gh-expl { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }

.gh-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.gh-row:last-child { border-bottom: 0; }

.gh-info { flex: 1 1 auto; min-width: 0; }
.gh-name { font-family: var(--font-mono); font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }

.gh-chan {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 7px;
  margin-left: 8px;
}

.gh-url { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); overflow-wrap: anywhere; }

.gh-confirm { display: inline-flex; align-items: center; gap: 6px; }
.gh-q { font-family: var(--font-mono); font-size: 11px; color: var(--danger); }

.gh-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.gh-form input, .gh-form select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
}

.gh-form input { flex: 1 1 160px; min-width: 0; }
.gh-form input::placeholder { color: var(--muted); }
.gh-form input:focus, .gh-form select:focus { outline: none; border-color: var(--wire); }
.gh-form input:focus-visible, .gh-form select:focus-visible { outline: 2px solid var(--agent); outline-offset: 1px; }

.gh-result { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }

.gh-once { font-family: var(--font-mono); font-size: 11px; color: var(--human); }

.gh-tokenrow { display: flex; gap: 8px; align-items: stretch; margin-bottom: 4px; }
.gh-tokenrow .token-box { flex: 1 1 auto; min-width: 0; margin: 0; }
.gh-tokenrow .btn-mini { flex: none; align-self: center; }

/* telegram origin tag */
.via-tag {
  font-family: "Spline Sans Mono", monospace;
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 8px;
  white-space: nowrap;
}
