/* Agents office — interface. Ivory surfaces, deep navy ink, champagne-gold hairlines. */
@font-face { font-family: "Tajawal"; font-weight: 400; font-display: swap; src: url(/fonts/tajawal-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Tajawal"; font-weight: 400; font-display: swap; src: url(/fonts/tajawal-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Tajawal"; font-weight: 500; font-display: swap; src: url(/fonts/tajawal-arabic-500-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Tajawal"; font-weight: 500; font-display: swap; src: url(/fonts/tajawal-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Tajawal"; font-weight: 700; font-display: swap; src: url(/fonts/tajawal-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Tajawal"; font-weight: 700; font-display: swap; src: url(/fonts/tajawal-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Tajawal"; font-weight: 800; font-display: swap; src: url(/fonts/tajawal-arabic-800-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Tajawal"; font-weight: 800; font-display: swap; src: url(/fonts/tajawal-latin-800-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --ivory: #faf7f1;
  --surface: #ffffff;
  --surface-2: #f7f4ed;
  --bg: #fbfaf7;
  --line: #e8e2d5;
  --line-strong: #d9d0bd;
  --text: #141b2b;
  --muted: #6a7184;
  --ink: #101828;
  --navy: #16223b;
  --gold: #b08a45;
  --gold-soft: #efe4cc;
  --running: #2563d8;
  --done: #178a5c;
  --attention: #c27a0a;
  --error: #c8324f;
  --off: #9aa1b0;
  --shadow: 0 18px 50px rgba(22, 30, 52, .14), 0 2px 8px rgba(22, 30, 52, .06);
  --shadow-soft: 0 6px 20px rgba(22, 30, 52, .08);
  --body: "Tajawal", "Segoe UI", Tahoma, system-ui, sans-serif;
  --display: "Tajawal", "Segoe UI", Tahoma, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 90% at 50% 0%, #fdfcf9 0%, #f1ede3 55%, #e3dccb 100%);
  color: var(--text);
  font-family: var(--body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease; }
button:disabled { opacity: .45; cursor: default; }
button:not(:disabled):active { transform: translateY(1px); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.ghost, .primary, .yes, .no { border-radius: 10px; padding: 6px 14px; min-height: 36px; font-weight: 500; font-size: 13.5px; }
.ghost { background: var(--surface); border: 1px solid var(--line-strong); color: var(--text); }
.ghost:hover:not(:disabled) { border-color: var(--gold); box-shadow: var(--shadow-soft); }
.primary {
  position: relative; border: 1px solid #0c1424; color: #fff; font-weight: 700;
  background: linear-gradient(180deg, #22304f 0%, var(--navy) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 4px 14px rgba(22, 34, 59, .28);
}
.primary:hover:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 8px 22px rgba(22, 34, 59, .34); }
.primary.has-count::after {
  content: attr(data-count); position: absolute; top: -8px; inset-inline-end: -8px;
  min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: var(--gold); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; box-shadow: 0 0 0 2px var(--surface);
}
.yes { background: var(--done); border: 1px solid var(--done); color: #fff; font-weight: 700; }
.no { background: var(--surface); border: 1px solid var(--error); color: var(--error); font-weight: 700; }

/* Top bar: a floating sheet */
.topbar {
  position: fixed; inset: 12px 12px auto 12px; z-index: 20;
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, .9); border-radius: 18px; box-shadow: var(--shadow);
  padding: 10px 16px; margin-top: env(safe-area-inset-top);
}
.topbar::after { content: ""; position: absolute; inset: auto 18px 0 18px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: .55; }
.topbar-row { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; margin-inline-end: auto; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--gold-soft); font-family: var(--display); font-weight: 700; font-size: 18px;
  background: linear-gradient(145deg, #23314f, #0f1728); box-shadow: inset 0 0 0 1px rgba(176, 138, 69, .7), 0 4px 12px rgba(16, 24, 40, .3);
}
.topbar h1 { font-family: var(--display); font-size: 21px; font-weight: 700; margin: 0; letter-spacing: 0; color: var(--ink); line-height: 1.2; }
.updated { color: var(--muted); font-size: 12px; }
.alerts { display: flex; gap: 8px; overflow-x: auto; padding-top: 8px; scrollbar-width: none; }
.alerts:empty { display: none; }
.alert-chip {
  flex: none; max-width: 78vw; display: flex; align-items: center; gap: 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 5px 13px; font-size: 13px; white-space: nowrap;
}
.alert-chip span { overflow: hidden; text-overflow: ellipsis; }
.alert-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.alert-chip.urgent { border-color: #e9b3bf; background: #fdf1f3; color: #8f1f37; }
.alert-chip.urgent::before { background: var(--error); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* Scene, labels, view buttons */
.scene { position: fixed; inset: 0; touch-action: none; }
.scene canvas { display: block; }
.scene::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 100% at 50% 45%, transparent 55%, rgba(60, 48, 22, .16) 100%); }
.views {
  position: fixed; inset: auto 0 max(14px, env(safe-area-inset-bottom)) 0; z-index: 10;
  display: flex; gap: 6px; justify-content: safe center; overflow-x: auto; padding: 4px 14px; scrollbar-width: none;
}
.views button {
  flex: none; border: 1px solid rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .8); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--text); border-radius: 999px; padding: 7px 16px; font-size: 13px; font-weight: 500; min-height: 38px; box-shadow: var(--shadow-soft);
}
.views button:hover { border-color: var(--gold); }
.views button.on { background: linear-gradient(180deg, #22304f, var(--navy)); border-color: #0c1424; color: #fff; box-shadow: inset 0 0 0 1px rgba(176, 138, 69, .55), 0 6px 18px rgba(22, 34, 59, .3); }
.tag {
  direction: rtl; pointer-events: auto; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 7px; white-space: nowrap; position: relative;
  background: rgba(255, 255, 255, .93); border: 1px solid rgba(255, 255, 255, .95); border-radius: 999px; color: var(--ink);
  padding: 4px 12px; font-size: 12px; line-height: 1.5; box-shadow: 0 6px 18px rgba(22, 30, 52, .2), 0 0 0 1px rgba(176, 138, 69, .22);
}
.tag b { font-size: 13px; font-weight: 700; color: var(--ink); }
/* Over a person: the name only. The job shows on hover and in the side panel; the room's wall names the department. */
.tag span { display: none; }
.tag i { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; box-shadow: 0 0 0 3px rgba(154, 161, 176, .22); }
.tag.running i { background: var(--running); box-shadow: 0 0 0 3px rgba(37, 99, 216, .22); animation: pulse 1s infinite; }
.tag.done i { background: var(--done); box-shadow: 0 0 0 3px rgba(23, 138, 92, .2); }
.tag.attention i { background: var(--attention); box-shadow: 0 0 0 3px rgba(194, 122, 10, .22); }
.tag.error i { background: var(--error); box-shadow: 0 0 0 3px rgba(200, 50, 79, .22); }
.tag.disabled { opacity: .72; }
.tag.alerted { box-shadow: 0 6px 18px rgba(22, 30, 52, .2), 0 0 0 1.5px var(--error); }
.tag.alerted::after {
  content: attr(data-count); position: absolute; top: -9px; inset-inline-start: -7px;
  min-width: 19px; height: 19px; border-radius: 10px; padding: 0 4px; text-align: center;
  background: var(--error); color: #fff; font-size: 11px; font-weight: 700; line-height: 19px; box-shadow: 0 0 0 2px #fff;
}
.room-sign {
  direction: rtl; pointer-events: none; white-space: nowrap; font-family: var(--display); font-weight: 800; font-size: 14.5px; color: #fff;
  background: linear-gradient(180deg, #24334f, var(--navy)); border: 1px solid rgba(201, 163, 90, .85); border-radius: 10px; padding: 4px 14px;
  box-shadow: 0 8px 20px rgba(16, 24, 40, .35), inset 0 1px 0 rgba(255, 255, 255, .12); letter-spacing: 0;
}
.tag.session-tag { padding: 2px 9px; background: rgba(240, 244, 251, .92); box-shadow: 0 4px 12px rgba(22, 30, 52, .16); }
.tag.session-tag b { font-size: 11.5px; font-weight: 500; }
/* A session is a dot; its name shows when the pointer is on it or when it waits for the owner. */
.tag.session-tag span { display: none; }
.tag.session-tag { padding: 4px; gap: 0; }
.tag.session-tag b { display: none; }
.tag.session-tag:hover, .tag.session-tag.alerted { padding: 2px 9px; gap: 7px; z-index: 5; }
.tag.session-tag:hover b, .tag.session-tag.alerted b { display: inline; }
.reach { margin: 8px 0 0; padding-inline-start: 18px; font-size: 12.5px; line-height: 1.9; color: var(--muted); }
.tag.ready i { background: #5b8def; box-shadow: 0 0 0 3px rgba(91, 141, 239, .2); }
.room-label {
  direction: rtl; pointer-events: none; white-space: nowrap; font-family: var(--display);
  color: rgba(20, 27, 43, .72); font-size: 13px; font-weight: 700; text-shadow: 0 1px 6px rgba(255, 255, 255, .95);
}
.legend {
  position: fixed; inset: auto 14px 64px auto; z-index: 9; direction: rtl;
  background: rgba(255, 255, 255, .86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, .95); border-radius: 16px; box-shadow: var(--shadow-soft); padding: 10px 14px; font-size: 12.5px;
}
.legend ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 9px; color: var(--text); white-space: nowrap; }
.legend i { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--off); box-shadow: 0 0 0 3px rgba(154, 161, 176, .2); }
.legend i.running { background: var(--running); box-shadow: 0 0 0 3px rgba(37, 99, 216, .2); animation: pulse 1s infinite; }
.legend i.done { background: var(--done); box-shadow: 0 0 0 3px rgba(23, 138, 92, .2); }
.legend i.attention { background: var(--attention); box-shadow: 0 0 0 3px rgba(194, 122, 10, .2); }
.legend i.error { background: var(--error); box-shadow: 0 0 0 3px rgba(200, 50, 79, .2); }
.legend i.ready { background: #5b8def; box-shadow: 0 0 0 3px rgba(91, 141, 239, .2); }
.legend b.count { min-width: 18px; height: 18px; border-radius: 9px; background: var(--error); color: #fff; font-size: 11px; text-align: center; line-height: 18px; margin-inline: -4px; }
.legend b.mini { width: 10px; height: 16px; border-radius: 6px; background: #9fb0cc; }
.legend-toggle { background: transparent; border: 0; padding: 0; font-weight: 700; font-size: 13px; color: var(--ink); cursor: default; }
.toast {
  position: fixed; inset: auto auto 70px 50%; transform: translateX(-50%); z-index: 40; margin: 0;
  background: var(--navy); color: #fff; border: 1px solid rgba(176, 138, 69, .6); border-radius: 12px;
  padding: 9px 18px; font-size: 13.5px; box-shadow: var(--shadow); max-width: 90vw;
}
.toast[hidden] { display: none; }

/* Night: the page's backdrop follows the office */
body.night { background: radial-gradient(120% 90% at 50% 0%, #2a3350 0%, #161d31 55%, #0c111f 100%); }
body.night .scene::after { background: radial-gradient(120% 100% at 50% 45%, transparent 50%, rgba(4, 8, 20, .45) 100%); }
.org-node.lead .org-card { border-color: var(--gold); background: linear-gradient(180deg, #fffdf7, #fff); }

/* The org chart: the team as a tree */
.org { position: fixed; inset: 0; z-index: 8; overflow: auto; padding: 96px 20px 40px; background: radial-gradient(120% 90% at 50% 0%, #fdfcf9 0%, #f1ede3 55%, #e3dccb 100%); }
.org[hidden] { display: none; }
.org-mode .views, .org-mode .legend { display: none; }
.org-top { display: grid; justify-items: center; gap: 26px; margin-bottom: 30px; position: relative; }
.org-top::after { content: ""; position: absolute; top: 58px; bottom: -30px; left: 50%; width: 2px; background: var(--gold-soft); z-index: 0; }
.org-top > * { position: relative; z-index: 1; }
.org-owner { display: grid; justify-items: center; padding: 10px 26px; border-radius: 14px; color: #fff; background: linear-gradient(180deg, #24334f, var(--navy)); box-shadow: inset 0 0 0 1px rgba(201, 163, 90, .8), var(--shadow-soft); }
.org-owner b { font-size: 17px; } .org-owner small { opacity: .75; font-size: 12px; }
.org-depts { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; max-width: 1180px; margin: 0 auto; align-items: start; border-top: 2px solid var(--gold-soft); padding-top: 22px; }
.org-dept { display: grid; gap: 10px; background: rgba(255, 255, 255, .7); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: var(--shadow-soft); position: relative; }
.org-dept::before { content: ""; position: absolute; top: -24px; left: 50%; width: 2px; height: 24px; background: var(--gold-soft); }
.org-dept h3 { margin: 0 0 2px; font-size: 15.5px; font-weight: 800; color: var(--ink); text-align: center; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.org-node p { margin: 4px 6px 0; color: var(--muted); font-size: 11.5px; }
.org-card { width: 100%; display: flex; align-items: center; gap: 10px; text-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 9px 12px; color: var(--text); position: relative; }
.org-card:hover { border-color: var(--gold); box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.org-card.big { min-width: 250px; padding: 12px 16px; box-shadow: var(--shadow-soft); }
.org-avatar { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; }
.org-who { flex: 1; min-width: 0; display: grid; line-height: 1.4; }
.org-who b { font-size: 14.5px; } .org-who small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-card i { width: 11px; height: 11px; border-radius: 50%; background: var(--off); flex: none; box-shadow: 0 0 0 3px rgba(154, 161, 176, .2); }
.org-card.running i { background: var(--running); box-shadow: 0 0 0 3px rgba(37, 99, 216, .2); animation: pulse 1s infinite; }
.org-card.done i { background: var(--done); box-shadow: 0 0 0 3px rgba(23, 138, 92, .2); }
.org-card.attention i { background: var(--attention); box-shadow: 0 0 0 3px rgba(194, 122, 10, .22); }
.org-card.error i { background: var(--error); box-shadow: 0 0 0 3px rgba(200, 50, 79, .22); }
.org-card.ready i { background: #5b8def; box-shadow: 0 0 0 3px rgba(91, 141, 239, .2); }
.org-card.disabled { opacity: .7; }
.org-card em { position: absolute; top: -8px; inset-inline-start: -6px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px; background: var(--error); color: #fff; font-size: 11.5px; font-style: normal; font-weight: 700; line-height: 20px; text-align: center; box-shadow: 0 0 0 2px #fff; }

.org-hire { justify-self: stretch; border-style: dashed; color: var(--muted); }
.field small { color: var(--muted); font-size: 11.5px; }
.editor.small { min-height: 220px; margin-top: 0; }
.perm { color: var(--error); font-weight: 700; font-size: 12px; }
.setting > span { font-size: 13px; }
.setting .ghost, .setting .no { grid-column: 1 / -1; justify-self: start; }

/* Panel: a floating sheet at the side; a bottom sheet on phones */
.panel {
  position: fixed; z-index: 30; inset: 12px auto 12px 12px; width: min(500px, calc(100vw - 24px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); border: 1px solid rgba(255, 255, 255, .9); border-radius: 22px; box-shadow: var(--shadow);
  animation: slide-in .22s ease;
}
@keyframes slide-in { from { opacity: 0; transform: translateX(-14px); } }
.panel[hidden] { display: none; }
.panel-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px; color: #fff; position: relative;
  background: linear-gradient(135deg, #1d2a47 0%, #0f1728 100%);
}
.panel-head::after { content: ""; position: absolute; inset: auto 0 0 0; height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 22px; color: #fff; background: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35), 0 6px 14px rgba(0, 0, 0, .3);
}
.panel-head > div { flex: 1; min-width: 0; }
.panel-head h2 { margin: 0 0 2px; font-family: var(--display); font-size: 20px; font-weight: 700; }
.panel-meta { margin: 0; color: rgba(255, 255, 255, .72); font-size: 12.5px; line-height: 1.6; }
.panel-head .ghost { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .22); color: #fff; min-width: 36px; padding: 6px 0; }
.panel-head .ghost:hover { border-color: var(--gold); box-shadow: none; }
.panel-scroll { overflow-y: auto; overflow-x: hidden; flex: 1; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.panel-top { padding: 14px 18px 0; display: grid; gap: 12px; }
.panel-top:empty { display: none; }
.panel-top > *, .panel-top section > *, .chat-wrap > *, .chat > *, .stack > * { min-width: 0; }
.panel-top { grid-template-columns: minmax(0, 1fr); }
.panel-top section { display: grid; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.panel-top section:last-child { border-bottom: 0; }
.panel-top h3 { margin: 4px 0 0; font-family: var(--display); font-size: 15.5px; font-weight: 700; color: var(--ink); }
.panel-top .empty, .usage, .hint-line { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.75; }
.usage { font-size: 13.5px; color: var(--text); }
.stack { display: grid; gap: 10px; }

/* Cards */
.agent-row, .decision, .panel-alert, .note-row, .session, .file, .setting, .lead, .gate, .notebook {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(22, 30, 52, .04);
}
.lead { margin: 0; font-size: 14px; line-height: 1.85; padding: 12px 14px; border-inline-start: 3px solid var(--gold); }
.gate { display: grid; gap: 10px; justify-items: start; padding: 12px 14px; border-color: var(--gold); background: #fdf9ef; font-size: 13.5px; line-height: 1.7; }
.gate p { margin: 0; }
p.gate { color: #8f1f37; border-color: #e9b3bf; background: #fdf1f3; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.controls select, .controls input[type=number], .decision input, .note textarea, .setting select, .field select, .field input, .composer textarea, .chat-input textarea, .file-bar input, .editor {
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 11px; min-height: 38px; line-height: 1.6;
}
.controls input[type=number] { width: 104px; direction: ltr; }
select:hover, input:hover, textarea:hover { border-color: var(--gold); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: 13.5px; }
.switch input { width: 19px; height: 19px; accent-color: var(--navy); }
.note { display: grid; gap: 8px; justify-items: start; }
.note textarea { width: 100%; resize: vertical; }
.agent-row { display: grid; gap: 10px; padding: 12px 14px; }
.agent-name { font-size: 13.5px; line-height: 1.6; }
.agent-name b { font-family: var(--display); font-size: 15px; }
.agent-name span { color: var(--muted); }
.agent-name small { display: block; color: var(--muted); font-size: 12px; }
.decision, .panel-alert { display: grid; gap: 8px; padding: 12px 14px; font-size: 13.5px; line-height: 1.7; }
.decision { border-color: var(--gold); background: linear-gradient(180deg, #fffdf7, #fff); box-shadow: 0 6px 18px rgba(176, 138, 69, .12); }
.decision.answered { border-color: var(--line); background: var(--surface); box-shadow: none; opacity: .9; }
.decision span, .panel-alert span { color: var(--muted); font-size: 12.5px; }
.decision em { font-style: normal; color: var(--done); font-weight: 700; }
.decision input { width: 100%; }
.panel-alert.urgent { border-color: #e9b3bf; background: #fdf1f3; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-alert a, .report a, .bubble a { color: var(--running); }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; position: sticky; top: 0; z-index: 2; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.tabs button { flex: 1 0 auto; background: transparent; border: 0; border-radius: 9px; color: var(--muted); padding: 7px 12px; font-size: 13.5px; font-weight: 500; }
.tabs button:hover { color: var(--text); }
.tabs button.on { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-soft), inset 0 -2px 0 var(--gold); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; background: var(--surface); }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 9px 6px; font-size: 13.5px; font-weight: 500; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button.on { background: var(--navy); color: #fff; font-weight: 700; }
.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field[hidden] { display: none; }
.field select, .field input { width: 100%; }
.settings { display: grid; gap: 10px; }
.setting { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 6px 10px; padding: 12px 14px; font-size: 13.5px; }
.setting b { font-weight: 700; }
.setting small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; line-height: 1.6; }
.setting button { justify-self: start; }
.change { display: grid; gap: 2px; padding: 6px 12px; border-inline-start: 2px solid var(--line-strong); font-size: 13px; line-height: 1.6; }
.change.mine { border-inline-start-color: var(--gold); }
.change strong { font-weight: 500; }
.change span { color: var(--muted); font-size: 12px; }

/* Chat with an agent or a session */
.chat-wrap { display: grid; gap: 10px; }
.chat { display: grid; gap: 9px; }
.bubble { max-width: 90%; padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.bubble p { margin: 0; white-space: pre-wrap; }
.bubble span { display: block; font-size: 11px; opacity: .65; margin-top: 2px; }
.bubble b { display: block; font-size: 12px; color: var(--gold); font-weight: 700; }
.bubble.me { justify-self: start; color: #fff; border-end-start-radius: 5px; background: linear-gradient(180deg, #24334f, var(--navy)); box-shadow: 0 4px 12px rgba(22, 34, 59, .22); }
.bubble.me b { color: var(--gold-soft); }
.hint-line[hidden] { display: none; }
.bubble.me.lead { background: linear-gradient(180deg, #8a2c56, #6b1f42); }
.bubble.me.lead b { color: #ffd9e6; }
.bubble.them { justify-self: end; background: var(--surface); border: 1px solid var(--line); border-end-end-radius: 5px; box-shadow: 0 1px 2px rgba(22, 30, 52, .05); }
.bubble.them ul, .bubble.them ol { padding-inline-start: 20px; margin: 4px 0; }
.bubble.them p { margin: 0 0 4px; }
.bubble.them h1, .bubble.them h2, .bubble.them h3 { font-size: 14.5px; margin: 8px 0 2px; }
.bubble.them table { border-collapse: collapse; font-size: 12.5px; display: block; overflow-x: auto; }
.bubble.them td { border: 1px solid var(--line); padding: 3px 6px; }
.bubble.them code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; direction: ltr; unicode-bidi: isolate; }
.bubble.waiting p { color: var(--muted); animation: pulse 1.4s infinite; }
.steps { margin: 0; justify-self: center; max-width: 100%; color: var(--muted); font-size: 11.5px; direction: ltr; unicode-bidi: plaintext; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface-2); border-radius: 999px; padding: 2px 12px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: 0; background: linear-gradient(180deg, transparent, var(--bg) 30%); padding: 14px 0 12px; }
.chat-input textarea { flex: 1; resize: none; border-radius: 14px; }
.steps.note { background: var(--gold-soft); color: var(--ink); direction: rtl; unicode-bidi: normal; }
.gate textarea { width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 11px; line-height: 1.6; }
.gate[hidden], .chat-input[hidden] { display: none; }
.session-state { font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 10px; }
.session-state.running { color: var(--running); border-color: var(--running); animation: pulse 1.2s infinite; }
.session-state.error { color: var(--error); border-color: var(--error); }

/* Notes, sessions, files, notebook */
.composer { display: grid; gap: 8px; }
.composer textarea { resize: vertical; width: 100%; }
.composer [hidden] { display: none; }
.note-row { display: flex; gap: 8px; align-items: center; padding: 10px 12px; font-size: 13.5px; line-height: 1.6; }
.note-row > div { flex: 1; min-width: 0; }
.note-row strong { display: block; font-weight: 700; overflow-wrap: anywhere; }
.note-row span { color: var(--muted); font-size: 12px; }
.note-row.reminder { border-inline-start: 3px solid var(--attention); }
.note-row.todo { border-inline-start: 3px solid var(--done); }
.note-row.finished { opacity: .6; }
.note-row.finished strong { text-decoration: line-through; }
.tick { min-width: 36px; padding: 4px 0; }
.session { display: grid; gap: 4px; padding: 11px 14px; font-size: 13.5px; line-height: 1.65; text-align: start; width: 100%; color: var(--text); }
button.session:hover, .file:hover { border-color: var(--gold); box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.session.waiting { border-inline-start: 3px solid var(--attention); }
.session strong { font-weight: 700; }
.session span { color: var(--muted); font-size: 12px; }
.session p { margin: 0; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
a.file { text-decoration: none; }
.file { display: flex; justify-content: space-between; gap: 10px; align-items: center; text-align: start; width: 100%; padding: 10px 14px; color: var(--text); font-size: 13.5px; }
.file strong { direction: ltr; unicode-bidi: isolate; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.file span { color: var(--muted); font-size: 12px; flex: none; }
.file-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line); z-index: 1; }
.file-bar strong { margin-inline-end: auto; font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.file-bar input { flex: 1; min-width: 160px; }
.editor { width: 100%; min-height: 52vh; margin-top: 10px; padding: 14px; line-height: 1.85; font-size: 14px; resize: vertical; }
.notebook { line-height: 1.85; overflow-wrap: anywhere; font-size: 13.5px; padding: 8px 14px; }
.notebook ul { padding-inline-start: 20px; margin: 6px 0; }
.notebook h1, .notebook h2, .notebook h3 { font-size: 14px; margin: 10px 0 4px; }

.report-image { width: 100%; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow-soft); margin: 10px 0 4px; display: block; }
.record { margin-top: 10px; max-width: 240px; }
.record select { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 6px 10px; min-height: 36px; }

/* Reports */
.report { padding: 6px 18px 36px; font-size: 14.5px; line-height: 1.9; overflow-wrap: anywhere; }
.report:empty { display: none; }
.report h1 { font-family: var(--display); font-size: 20px; margin: 14px 0 6px; }
.report h2 { font-family: var(--display); font-size: 17px; margin: 24px 0 6px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.report h3 { font-size: 14.5px; color: var(--gold); margin: 16px 0 4px; }
.report code { background: var(--surface-2); border: 1px solid var(--line); padding: 0 5px; border-radius: 6px; font-size: 12.5px; direction: ltr; unicode-bidi: isolate; }
.report ul, .report ol { padding-inline-start: 22px; }
.report li { margin: 3px 0; }
.report blockquote { margin: 6px 0; padding: 4px 14px; border-inline-start: 3px solid var(--gold-soft); color: var(--muted); background: var(--surface); border-radius: 0 10px 10px 0; }
.report table { border-collapse: collapse; width: 100%; font-size: 13px; display: block; overflow-x: auto; background: var(--surface); border-radius: 12px; }
.report th, .report td { border: 1px solid var(--line); padding: 6px 9px; text-align: start; overflow-wrap: normal; word-break: normal; min-width: 84px; }
.report tr:first-child td { background: var(--surface-2); font-weight: 700; }
.report td code { overflow-wrap: anywhere; }
.report .empty { color: var(--muted); }

@media (max-width: 700px) {
  .topbar { inset: 8px 8px auto 8px; padding: 8px 12px; border-radius: 16px; }
  .topbar h1 { font-size: 18px; }
  .updated { display: none; }
  .org { padding: 84px 12px 30px; }
  .org-dept::before { display: none; }
  .org-depts { border-top: 0; padding-top: 0; }
  .panel { inset: auto 0 0 0; width: auto; height: 82vh; border-radius: 22px 22px 0 0; animation-name: slide-up; }
  @keyframes slide-up { from { opacity: 0; transform: translateY(18px); } }
  /* Phones: name only beside the status dot, so the labels do not pile up. */
  .tag { padding: 3px 9px; }
  .tag span { display: none; }
  .room-label { font-size: 10.5px; }
  /* Phones: the legend is a button that opens. */
  .legend { inset: auto 10px 62px auto; padding: 7px 12px; }
  .legend ul { display: none; }
  .legend.open ul { display: grid; }
  .legend-toggle { cursor: pointer; }
  .tag.session-tag { padding: 4px; gap: 0; }
.tag.session-tag b { display: none; }
.tag.session-tag:hover, .tag.session-tag.alerted { padding: 2px 9px; gap: 7px; z-index: 5; }
.tag.session-tag:hover b, .tag.session-tag.alerted b { display: inline; }
  .tabs button { padding: 7px 10px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Login */
.login { display: grid; place-items: center; overflow: auto; }
.login-card {
  width: min(360px, 90vw); background: var(--surface); border: 1px solid rgba(255, 255, 255, .9); border-radius: 22px; padding: 30px; display: grid; gap: 12px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.login-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--navy), var(--gold), var(--navy)); }
.login-card h1 { margin: 6px 0 8px; font-family: var(--display); font-size: 26px; text-align: center; color: var(--ink); }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input { padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); direction: ltr; }
.login-card button { margin-top: 6px; padding: 11px; border-radius: 12px; border: 1px solid #0c1424; color: #fff; font-weight: 700; background: linear-gradient(180deg, #22304f, var(--navy)); box-shadow: 0 6px 18px rgba(22, 34, 59, .3); }
.login-card button:hover { filter: brightness(1.12); }
.login-error { color: var(--error); min-height: 1.4em; margin: 0; font-size: 13px; }
.file > div { display: grid; gap: 2px; min-width: 0; }

.sheet { display: block; width: 100%; border-radius: 10px; margin: 8px 0; border: 1px solid var(--line-strong); }
.transcript { font-size: 13.5px; line-height: 1.9; white-space: pre-wrap; color: var(--text); }
.file.failed { border-inline-start: 3px solid var(--error); }
.stack input[type=file] { font: inherit; font-size: 13px; }
