:root { --bg:#f5f7f7; --panel:#fff; --line:#dfe6e6; --ink:#1c2b2b; --muted:#667a7a; --accent:#0e7c86; --accent-ink:#fff; --owner:#e3f3f4; --warn:#b4541a; --bad:#a32828; --ok:#2e8b57; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: -apple-system, "Segoe UI", "Heebo", "Arial Hebrew", Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: default; }
[hidden] { display: none !important; }

.login { max-width: 320px; margin: 18vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; gap: 10px; }
.login h1 { margin: 0 0 6px; font-size: 20px; }
.login input { font: inherit; padding: 9px; border: 1px solid var(--line); border-radius: 8px; }
.error { color: var(--bad); min-height: 1.4em; margin: 0; }

.app { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.conn { font-size: 12px; color: var(--muted); }
.conn.off { color: var(--bad); font-weight: 600; }
.tabs { margin-inline-start: auto; display: none; gap: 6px; }
.tabs button { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 5px 12px; }
.tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.cols { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px 1fr; }
.room { border-inline-end: 1px solid var(--line); overflow-y: auto; padding: 12px; }
.cards { display: grid; gap: 10px; }
.card { text-align: start; width: 100%; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; grid-template-columns: 44px 1fr; gap: 4px 10px; align-items: center; }
.card.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(14,124,134,.15); }
.avatar { grid-row: span 2; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.avatar { overflow: hidden; } .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.card .role { color: var(--muted); font-weight: 400; font-size: 13px; }
.card .status { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #b6c2c2; flex: none; }
.dot.working { background: var(--ok); animation: pulse 1.2s infinite; }
.dot.up { background: var(--ok); }
.outside { margin-top: 10px; }
.card.external { background: transparent; border-style: dashed; }
.card .note { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.dot.waiting { background: var(--warn); }
.unseen { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); margin-inline-start: auto; }
.card .activity { grid-column: 1 / -1; font-size: 12px; color: var(--muted); direction: ltr; text-align: end; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 1.3em; }
@keyframes pulse { 50% { opacity: .35; } }

.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.approvals { max-height: 42vh; flex: none; overflow-y: auto; }
.approval { margin: 10px 14px 0; background: #fff8ee; border: 1px solid #edd3ae; border-radius: 12px; padding: 12px; }
.approval h4 { margin: 0 0 4px; font-size: 14px; }
.approval .summary { white-space: pre-wrap; font-size: 14px; margin: 0 0 10px; }
.approval .actions { display: flex; gap: 8px; }
.step-note { white-space: pre-wrap; font-size: 13px; margin: 0 0 10px; padding: 8px 10px; background: #fff; border: 1px dashed #edd3ae; border-radius: 8px; }
.chain { margin: 10px 14px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.chain h4 { margin: 0 0 6px; font-size: 14px; }
.step { border-top: 1px solid var(--line); padding: 6px 0; font-size: 14px; }
.step summary { cursor: pointer; display: flex; align-items: center; gap: 8px; list-style: none; }
.step summary::-webkit-details-marker { display: none; }
.step .pos { width: 22px; height: 22px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 12px; flex: none; }
.step .step-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-text { white-space: pre-wrap; margin: 6px 30px 8px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.step .actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 30px 4px; } .step .actions:empty { display: none; }
.step .actions button { padding: 5px 11px; font-size: 13px; }
.step .actions input { flex: 1; min-width: 160px; font: inherit; font-size: 13px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; }
.step.locked, .step.rejected, .step.done { opacity: .75; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.ready, .badge.uri_turn { background: #fdebd2; color: var(--warn); font-weight: 700; }
.badge.running { background: #dff3e7; color: var(--ok); } .badge.done { color: var(--ok); } .badge.rejected { color: var(--bad); }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.spacer { flex: 1; }
.messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { flex: none; max-width: min(760px, 92%); padding: 9px 13px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg.owner { align-self: flex-start; background: var(--owner); border-color: #c9e4e6; white-space: pre-wrap; }
.msg.agent { align-self: flex-end; }
.msg.system, .msg.error { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: 13px; text-align: center; white-space: pre-wrap; }
.msg.error { color: var(--bad); }
.msg .tag { display: block; font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.msg.handoff_summary { border-color: #edd3ae; background: #fffaf2; }
.msg.live { border-style: dashed; white-space: pre-wrap; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin-bottom: 0; }
.msg h3 { margin: 4px 0 6px; font-size: 15px; }
.msg ul, .msg ol { margin: 0 0 8px; padding-inline-start: 22px; }
.msg pre { direction: ltr; text-align: left; background: #f1f5f5; padding: 8px; border-radius: 8px; overflow-x: auto; margin: 0 0 8px; }
.msg code { direction: ltr; unicode-bidi: isolate; background: #f1f5f5; padding: 0 4px; border-radius: 4px; font-size: 13px; }
.msg pre code { background: none; padding: 0; }
.msg .host { color: var(--muted); font-size: 12px; direction: ltr; unicode-bidi: isolate; }
.empty { color: var(--muted); text-align: center; margin: auto; }
.composer { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { flex: 1; font: inherit; resize: none; padding: 9px; border: 1px solid var(--line); border-radius: 10px; }

@media (max-width: 760px) {
  .tabs { display: flex; }
  .cols { grid-template-columns: 1fr; }
  .cols[data-tab="room"] .chat, .cols[data-tab="chat"] .room { display: none; }
  .room { border: 0; }
}

.files { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.files .file { display: flex; justify-content: space-between; gap: 12px; text-align: start; background: var(--panel); color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-weight: 400; }
.files .file .name { overflow-wrap: anywhere; }
.files .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.file-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; position: sticky; top: -14px; background: var(--bg, #fff); padding: 6px 0; }
.file-body { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; overflow-wrap: anywhere; }
.file-body pre { white-space: pre-wrap; font-size: 13px; }
.msg table, .file-body table { border-collapse: collapse; margin: 6px 0; font-size: 14px; display: block; overflow-x: auto; }
.msg td, .msg th, .file-body td, .file-body th { border: 1px solid var(--line); padding: 3px 7px; vertical-align: top; }
.file-head .path { direction: ltr; unicode-bidi: isolate; overflow-wrap: anywhere; }
