/* Agent Office — standalone, dependency-free UI. */
:root {
  --bg: #0b0f14;
  --panel: #121820;
  --panel-2: #18212c;
  --line: #2b3949;
  --text: #e6edf3;
  --muted: #93a1b1;
  --brand: #58a6ff;
  --brand-solid: #2f81f7;
  --backlog: #9aa8b8;
  --assigned: #e3b341;
  --progress: #58a6ff;
  --review: #bc8cff;
  --done: #56d364;
  --failed: #ff7b72;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { max-width: 100%; }
body {
  margin: 0;
  max-width: 100%;
  overflow-x: clip;
  min-height: 100vh;
  background: radial-gradient(1200px 500px at 15% -10%, #15263a 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 19px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 12px; }
.eyebrow { color: var(--muted); font: 700 10px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; }

.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 100;
  padding: 8px 12px; border-radius: 8px; background: var(--brand-solid); color: #fff;
}
.skip-link:focus { top: 12px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px 20px; padding: 12px clamp(12px, 2vw, 28px);
  background: rgba(11, 15, 20, .94); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 auto; }
.brand-copy { min-width: 0; }
.brand-copy p { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; }
.connection {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--muted); font: 12px/1.3 var(--mono); white-space: nowrap;
}
.connection::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.connection.live::before { background: var(--done); box-shadow: 0 0 0 3px rgba(86, 211, 100, .14); }
.connection.offline::before { background: var(--failed); box-shadow: 0 0 0 3px rgba(255, 123, 114, .14); }
.connection.live { color: #b7f0bd; }
.connection.offline { color: #ffc0bb; }

.tabs {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.tab {
  min-height: 34px; padding: 6px 11px; border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer;
}
.tab:hover { color: var(--text); border-color: var(--line); }
.tab[aria-selected="true"] { background: var(--brand-solid); border-color: var(--brand-solid); color: #fff; }
.tab:focus-visible, .btn:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.tab-note {
  display: inline-block; margin-left: 4px; padding: 1px 5px; border-radius: 4px;
  background: rgba(188, 140, 255, .16); color: var(--review); font: 700 9px/1.5 var(--mono);
}
.tab[aria-selected="true"] .tab-note { background: rgba(255, 255, 255, .2); color: #fff; }

.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 12px clamp(12px, 2vw, 28px) 0; padding: 10px 12px;
  border: 1px solid rgba(255, 123, 114, .45); border-radius: 10px;
  background: rgba(255, 123, 114, .09); color: #ffd6d2; overflow-wrap: anywhere;
}
.notice-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--failed); }
.notice .btn { margin-left: auto; }

main { max-width: 1500px; margin: 0 auto; padding: 16px clamp(12px, 2vw, 28px) 48px; }
.panel { display: grid; gap: 16px; min-width: 0; }
.panel[hidden], .notice[hidden], .detail[hidden], .backdrop[hidden], .toast[hidden] { display: none !important; }

.card {
  min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px;
  background: linear-gradient(180deg, rgba(27, 38, 51, .55), rgba(18, 24, 32, .95));
}
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.card-head p { margin-top: 4px; max-width: 70ch; }
.section-head { margin-bottom: 10px; }
.pill {
  display: inline-block; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel-2); color: var(--muted); font: 600 11px/1.4 var(--mono);
}
.btn {
  min-height: 32px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel-2); cursor: pointer; font-size: 12px; font-weight: 600;
}
.btn:hover:not(:disabled) { border-color: var(--brand); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn { padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); cursor: pointer; font-size: 12px; }
.empty { margin: 0; padding: 14px; border: 1px dashed var(--line); border-radius: 9px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

/* Flow view: reporting structure */
.org-root-wrap { display: flex; justify-content: center; }
.org-root {
  width: min(100%, 460px); padding: 12px 16px; border: 1px solid #3f5f86; border-radius: 10px;
  background: linear-gradient(180deg, #1c3554, #152033); text-align: center; min-width: 0;
}
.org-root strong { display: block; font-size: 14px; }
.org-root span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.org-tree { position: relative; padding-top: 24px; }
.org-tree::before {
  content: ""; position: absolute; left: 10%; right: 10%; top: 11px; height: 2px; background: var(--line);
}
.org-tree::after {
  content: ""; position: absolute; left: 50%; top: 0; width: 2px; height: 12px; background: var(--line);
}
.org-roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; min-width: 0; }
.role-card {
  position: relative; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-2);
}
.role-card::before { content: ""; position: absolute; left: 50%; top: -13px; width: 2px; height: 13px; background: var(--line); }
.role-card h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; text-transform: capitalize; overflow-wrap: anywhere; }
.role-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 2px; background: var(--muted); }
.role-card .role-meta { margin-top: 6px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.worker-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.worker-chip {
  padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px;
  background: #0f1620; color: #c8d6e5; font: 10px/1.5 var(--mono); overflow-wrap: anywhere;
}

/* Runs */
.runs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; min-width: 0; }
.run-card { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); }
.run-card .run-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.run-card code { font: 11px/1.4 var(--mono); color: #a5d6ff; overflow-wrap: anywhere; }
.run-card p { margin-top: 6px; font-size: 12px; overflow-wrap: anywhere; }

/* Status lanes and task cards */
.lanes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; align-items: start; min-width: 0; }
.lane { min-width: 0; max-height: 660px; overflow-y: auto; padding: 10px; border: 1px solid var(--line); border-top: 3px solid var(--lane-color, var(--muted)); border-radius: 10px; background: var(--panel); }
.lane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.lane-head h3 { font-size: 12px; overflow-wrap: anywhere; }
.lane-count { flex: 0 0 auto; min-width: 22px; padding: 1px 6px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font: 700 11px/1.5 var(--mono); text-align: center; }
.task-card { min-width: 0; margin-bottom: 8px; padding: 9px; border: 1px solid var(--line); border-left: 3px solid var(--lane-color, var(--muted)); border-radius: 8px; background: var(--panel-2); }
.task-open { display: block; width: 100%; min-width: 0; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.task-open:hover .task-title { color: var(--brand); text-decoration: underline; }
.task-title { font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.task-meta { margin-top: 5px; color: var(--muted); font: 10px/1.5 var(--mono); overflow-wrap: anywhere; }
.task-meta span { display: block; }
.task-actions, .detail-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.act { min-height: 27px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; background: #202b38; cursor: pointer; font: 700 10px/1.3 var(--mono); letter-spacing: .02em; }
.act.accept { color: #9ce6a5; border-color: rgba(86, 211, 100, .4); }
.act.reject { color: #ffaaa4; border-color: rgba(255, 123, 114, .4); }
.act.retry { color: #f1cc73; border-color: rgba(227, 179, 65, .4); }
.act:hover:not(:disabled) { background: #2b3949; }
.act:disabled { opacity: .32; cursor: not-allowed; }

/* Event feed */
.feed { margin: 0; padding: 0; list-style: none; min-width: 0; }
.feed li { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 4px 10px; padding: 8px 0; border-top: 1px solid var(--line); min-width: 0; }
.feed li:first-child { border-top: 0; }
.feed time { color: var(--muted); font: 10px/1.5 var(--mono); }
.feed .feed-body { min-width: 0; overflow-wrap: anywhere; }
.feed .kind { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px; background: #213044; color: #a5d6ff; font: 700 10px/1.6 var(--mono); }
.feed .msg-text { font-size: 12px; }
.feed .task-link { display: block; margin-top: 3px; padding: 0; border: 0; background: none; color: var(--muted); font: 11px/1.4 var(--mono); text-align: left; cursor: pointer; }
.feed .task-link:hover { color: var(--brand); text-decoration: underline; }
.feed.compact li { grid-template-columns: 72px minmax(0, 1fr); }

/* Office / game view */
.office-stage { width: 100%; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #0d131b; }
#office-svg { display: block; width: 100%; height: auto; }
.room-floor { fill: #141e2a; stroke: #34465c; stroke-width: 2; }
.room-grid { fill: url(#office-grid); opacity: .55; }
.room-label { fill: #d7e4f2; font: 700 15px var(--mono); letter-spacing: 1.5px; }
.room-sub { fill: #8094aa; font: 11px var(--mono); }
.furniture { stroke: #1a1210; stroke-width: 1; }
.desk { fill: #6b4f32; }
.desk-dark { fill: #4a3522; }
.screen { fill: #274b70; }
.paper { fill: #c9d6e5; }
.table { fill: #5a4530; }
.chair { fill: #35506b; }
.shelf { fill: #3d4b3a; }
.plant { fill: #3fb950; }
.sprite { cursor: pointer; transition: transform .55s cubic-bezier(.2, .75, .25, 1); }
#office-svg.no-transition .sprite { transition: none; }
.sprite figure, .sprite .figure { transform-box: fill-box; transform-origin: center bottom; }
.sprite.pop .figure { animation: sprite-step .42s steps(2, end) 1; }
@keyframes sprite-step { 0% { transform: translateY(0); } 50% { transform: translateY(-3px); } 100% { transform: translateY(0); } }
.sprite:focus-visible { outline: none; }
.sprite:focus-visible .sprite-hit { stroke: #fff; stroke-width: 3; }
.sprite-hit { fill: transparent; stroke: transparent; pointer-events: all; }
.bubble-box { fill: #e8eef6; stroke: #0b0f14; stroke-width: 1; }
.bubble-text { fill: #101820; font: 9px var(--mono); }
.sprite-name { fill: #f0f6fc; font: 700 9px var(--mono); paint-order: stroke; stroke: #0b0f14; stroke-width: 3px; }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; margin-top: 12px; min-width: 0; }
.legend-btn { display: block; width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); text-align: left; cursor: pointer; }
.legend-btn:hover { border-color: var(--brand); }
.legend-btn strong { display: block; font-size: 12px; overflow-wrap: anywhere; }
.legend-btn span { display: block; margin-top: 2px; color: var(--muted); font: 10px/1.5 var(--mono); overflow-wrap: anywhere; }

/* Task detail dialog */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(3, 6, 10, .72); }
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51;
  width: min(440px, 100%); padding: 18px; overflow-y: auto;
  border-left: 1px solid var(--line); background: var(--panel);
  box-shadow: -18px 0 40px rgba(0, 0, 0, .45); animation: detail-in .18s ease-out;
}
@keyframes detail-in { from { transform: translateX(18px); opacity: .6; } to { transform: none; opacity: 1; } }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.detail-head h2 { margin-top: 4px; font-size: 17px; overflow-wrap: anywhere; }
.detail-head p { margin-top: 4px; overflow-wrap: anywhere; }
.detail-fields { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 7px 10px; margin: 0 0 16px; }
.detail-fields dt { color: var(--muted); font: 700 10px/1.5 var(--mono); text-transform: uppercase; letter-spacing: .04em; }
.detail-fields dd { margin: 0; font-size: 12px; min-width: 0; overflow-wrap: anywhere; }
.detail-fields code { padding: 2px 5px; border-radius: 4px; background: #0e1723; color: #a5d6ff; font: 10px/1.6 var(--mono); overflow-wrap: anywhere; }
.detail-h3 { margin: 14px 0 4px; }
.detail-form { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.detail-form label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.detail-form input { width: 100%; min-height: 36px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--text); }
.detail-actions .act { min-height: 34px; padding: 7px 10px; font-size: 11px; }

.toast {
  position: fixed; right: 14px; bottom: 14px; z-index: 70; max-width: min(360px, calc(100vw - 28px));
  padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px;
  background: #1d2a38; color: var(--text); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); font-size: 12px; overflow-wrap: anywhere;
}
.noscript { margin: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }

@media (max-width: 1240px) {
  .lanes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lane { max-height: 420px; }
}
@media (max-width: 780px) {
  .lanes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feed li, .feed.compact li { grid-template-columns: 1fr; gap: 2px; }
  .card { padding: 12px; }
}
@media (max-width: 600px) {
  .topbar { align-items: flex-start; }
  .top-actions { width: 100%; justify-content: space-between; }
  .tabs { flex: 1 1 auto; }
  .tab { flex: 1 1 auto; padding: 6px 8px; font-size: 12px; }
  .lanes { grid-template-columns: minmax(0, 1fr); }
  .lane { max-height: 360px; }
  .org-tree::before { left: 8%; right: 8%; }
  .org-roles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runs { grid-template-columns: minmax(0, 1fr); }
  .detail-fields { grid-template-columns: 88px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
