/* Jarvis Virtual Office — warm, calm, readable. No external fonts or assets. */
:root {
  --bg: #f4ede1;
  --bg-2: #e9f1e4;
  --surface: #ffffff;
  --surface-2: #fbf8f3;
  --border: #e4d9c7;
  --text: #1f2933;
  --muted: #56606b;
  --navy: #2f4462;
  --navy-2: #22334b;
  --teal: #0f766e;
  --blue: #1d4ed8;
  --amber: #b45309;
  --red: #b91c1c;
  --green: #15803d;
  --focus: #1d4ed8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 6px 18px rgba(60, 40, 20, 0.08);
  --panel-w: 420px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

/* The hidden attribute must always win over component display rules. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: linear-gradient(160deg, var(--bg) 0%, #f7f1e7 45%, var(--bg-2) 100%);
  line-height: 1.45;
  font-size: 15px;
}

h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; margin-top: 14px; margin-bottom: 6px; }
p { margin: 6px 0; }

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--navy);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  text-decoration: none;
}
.skip-link:focus { top: 10px; }

.muted { color: var(--muted); }
.small-label { font-size: 0.82rem; color: var(--muted); margin-bottom: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand h1 { font-size: 1.12rem; color: var(--navy-2); }
.brand-sub { margin: 0; font-size: 0.8rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
}
button.chip { cursor: pointer; }
button.chip:hover { background: var(--surface-2); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: #9ca3af; flex: none; }
.conn-open .dot { background: #16a34a; }
.conn-connecting .dot, .conn-reconnecting .dot { background: #f59e0b; }
.conn-offline { border-color: #fca5a5; background: #fef2f2; }
.conn-offline .dot { background: #dc2626; }
.ai-off .dot { background: #9ca3af; }
.ai-on .dot { background: #16a34a; }
.ai-on { border-color: #86efac; }
.ai-working { border-color: #93c5fd; background: #eff6ff; }
.ai-working .dot { background: #2563eb; }
.ai-warn { border-color: #fcd34d; background: #fffbeb; }
.ai-warn .dot { background: #f59e0b; }
.ai-fail { border-color: #fca5a5; background: #fef2f2; }
.ai-fail .dot { background: #dc2626; }
.agent-idle .dot { background: #60a5fa; }
.agent-working .dot { background: #2563eb; }
.agent-waiting_input { border-color: #fcd34d; background: #fffbeb; }
.agent-waiting_input .dot { background: #f59e0b; }
.agent-failed { border-color: #fca5a5; background: #fef2f2; }
.agent-failed .dot { background: #dc2626; }
.chip-action { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  gap: 14px;
  padding: 14px 16px 16px;
  height: calc(100vh - 64px);
  min-height: 560px;
}

.office {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: radial-gradient(ellipse at 50% 40%, #fffaf2 0%, #f1e8da 70%, #e8decd 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.scene-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.65);
}
.tool {
  min-width: 36px;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.tool:hover { background: var(--surface-2); }
.tool[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }

.scene-wrap { position: relative; flex: 1; min-height: 0; }

#scene {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#scene.panning { cursor: grabbing; }
#scene text { font-family: "Segoe UI", system-ui, sans-serif; }

.scene-hint {
  position: absolute;
  right: 10px;
  bottom: 8px;
  margin: 0;
  max-width: calc(100% - 20px);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
  pointer-events: none;
}

.info-card {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: min(340px, calc(100% - 20px));
  max-height: calc(100% - 20px);
  overflow: auto;
  padding: 12px 40px 12px 14px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.info-card h2 { font-size: 1rem; color: var(--navy-2); }
.info-card p { font-size: 0.86rem; }
.icon-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.layout-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  font-size: 0.85rem;
}
.layout-bar p { margin: 0; flex: 1 1 260px; }

/* ---------- Panel ---------- */
.panel {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 2px;
}
.panel:focus { outline: none; }

.card, .view.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.view { display: flex; flex-direction: column; gap: 12px; }
.view[hidden] { display: none; }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: #efe6d8;
  border-radius: 12px;
}
.tabs[hidden] { display: none; }
.tabs [role="tab"] {
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font: inherit;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
}
.tabs [role="tab"][aria-selected="true"] { background: var(--surface); color: var(--navy-2); font-weight: 650; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.count-badge {
  display: inline-block;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e5e7eb;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

/* ---------- Forms ---------- */
label { display: block; margin-top: 10px; margin-bottom: 4px; font-size: 0.86rem; font-weight: 600; }
.req, .opt { font-weight: 500; font-size: 0.75rem; color: var(--muted); margin-left: 4px; }
.req { color: var(--red); }
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid #cdbfa8;
  border-radius: 10px;
  background: #fffdf9;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}
textarea { resize: vertical; min-height: 44px; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--red); background: #fff7f7; }
.help { font-size: 0.8rem; color: var(--muted); margin: 4px 0; }
.err { color: var(--red); font-size: 0.8rem; margin: 2px 0; min-height: 0; }
.err:empty { display: none; }
.field-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.field-meta .count { margin-left: auto; font-size: 0.75rem; color: var(--muted); padding-top: 2px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.form-error { color: var(--red); font-size: 0.85rem; margin: 8px 0 0; }
.form-error:empty { display: none; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.check-row label { margin: 0; }
.check-row input { width: 18px; height: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  border: 1px solid #cdbfa8;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #f3ede3; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 0.82rem; }
.btn.danger-outline { border-color: #f1a7a7; color: var(--red); background: #fff; }
.btn.danger-outline:hover { background: #fef2f2; }
.danger-text { color: var(--red); }
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 650;
  color: var(--navy-2);
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Task lists ---------- */
.task-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-item {
  border: 1px solid var(--border);
  border-left: 4px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
}
.task-item.status-running { border-left-color: #2563eb; background: #f5f8ff; }
.task-item.status-waiting_input { border-left-color: #f59e0b; background: #fffbeb; }
.task-item.status-done { border-left-color: #16a34a; }
.task-item.status-failed { border-left-color: #dc2626; background: #fff8f8; }
.task-item.status-cancelled { border-left-color: #9ca3af; }
.task-item.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.35); } to { box-shadow: 0 0 0 0 rgba(29, 78, 216, 0); } }
.task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.task-meta { font-size: 0.78rem; color: var(--muted); margin: 4px 0; overflow-wrap: anywhere; }
.task-wait { font-size: 0.82rem; color: #92400e; margin: 4px 0; overflow-wrap: anywhere; }
.task-error { font-size: 0.82rem; color: var(--red); margin: 4px 0; overflow-wrap: anywhere; }
.task-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.empty { color: var(--muted); font-size: 0.86rem; margin: 10px 0 0; }
.empty[hidden] { display: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 650;
  white-space: nowrap;
  border: 1px solid transparent;
}
.status-queued.badge, .badge.status-queued { background: #f3f4f6; color: #374151; border-color: #d1d5db; }
.badge.status-running { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.badge.status-waiting_input { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.badge.status-done { background: #dcfce7; color: #166534; border-color: #86efac; }
.badge.status-failed { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.badge.status-cancelled { background: #f3f4f6; color: #4b5563; border-color: #d1d5db; }
.badge.kind-local { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge.kind-ai { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; }
.badge.kind-test { background: #fdf4ff; color: #86198f; border-color: #f0abfc; }
.badge.kind-off { background: #f3f4f6; color: #4b5563; border-color: #d1d5db; }

.steps { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 0.8rem; }
.step { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); overflow-wrap: anywhere; }
.step-dot { width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; background: #d1d5db; flex: none; }
.step-done { color: var(--text); }
.step-done .step-dot { background: #16a34a; }
.step-active { color: #1e40af; font-weight: 650; }
.step-active .step-dot { background: #2563eb; animation: pulse-dot 1s ease-in-out infinite; }
.step-wait .step-dot { background: #f59e0b; }
.step-fail .step-dot { background: #dc2626; }
@keyframes pulse-dot { 50% { transform: scale(0.6); opacity: 0.6; } }

/* ---------- Detail ---------- */
.back-btn { align-self: flex-start; }
.detail-title { font-size: 1.1rem; overflow-wrap: anywhere; color: var(--navy-2); }
.detail-title:focus { outline: none; }
.detail-title:focus-visible { outline: 3px solid var(--focus); }
.detail-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.attempt-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip-btn {
  min-height: 30px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.chip-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 10px 0; font-size: 0.84rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.box { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-top: 10px; background: var(--surface-2); }
.box summary { cursor: pointer; font-weight: 600; font-size: 0.88rem; }
.box-error { background: #fef2f2; border-color: #fca5a5; color: #7f1d1d; overflow-wrap: anywhere; }
.box-wait { background: #fffbeb; border-color: #fcd34d; }
.box-ok { background: #f0fdf4; border-color: #86efac; }
.box-off { background: #f8fafc; border-color: #cbd5e1; }
.box-result { background: #fff; }
.ai-label { font-weight: 700; font-size: 1rem; margin: 0; }
.report, .snippet {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 8px 0;
  padding: 10px;
  border-radius: 10px;
  background: #fbfaf7;
  border: 1px solid var(--border);
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 0.8rem;
  max-height: 360px;
  overflow: auto;
}
.snippet { max-height: 160px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.stat { display: flex; flex-direction: column; align-items: center; padding: 6px; border-radius: 10px; background: #f3f7ff; border: 1px solid #dbe6ff; }
.stat-value { font-weight: 750; font-size: 1.05rem; color: var(--navy-2); }
.stat-label { font-size: 0.72rem; color: var(--muted); }
.result-actions, .detail-actions, .banner-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.log { list-style: none; margin: 8px 0 0; padding: 0; font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: 0.74rem; display: flex; flex-direction: column; gap: 2px; }
.log li { overflow-wrap: anywhere; }
.log time { color: var(--muted); }
.log-warn { color: #92400e; }
.log-error { color: var(--red); }

/* ---------- AI view ---------- */
.ai-stage-ready, .ai-stage-working { background: #f0fdf4; border-color: #86efac; }
.ai-stage-working { background: #eff6ff; border-color: #93c5fd; }
.ai-stage-failed, .ai-stage-service_down { background: #fef2f2; border-color: #fca5a5; }
.ai-stage-model_missing { background: #fffbeb; border-color: #fcd34d; }
.checklist { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 0.84rem; }
.check { display: flex; gap: 8px; align-items: flex-start; overflow-wrap: anywhere; }
.check-icon { width: 1.2em; flex: none; text-align: center; font-weight: 700; }
.check-ok .check-icon { color: var(--green); }
.check-fail { color: #7f1d1d; }
.check-fail .check-icon { color: var(--red); }
.check-off, .check-idle { color: var(--muted); }
.check-active { color: #1e40af; font-weight: 600; }
.check-active .check-icon { color: #2563eb; }
.provider-switch { margin: 10px 0 0; }
.provider-switch legend { font-weight: 600; font-size: 0.88rem; padding: 0 4px; }
.radio-row { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; font-size: 0.85rem; cursor: pointer; overflow-wrap: anywhere; }
.radio-row input { margin-top: 3px; flex: none; }
#ai-budget meter { display: block; width: 100%; height: 14px; margin: 6px 0; }
.ai-check { margin: 6px 0; font-size: 0.84rem; }
.ai-check p { margin: 3px 0; overflow-wrap: anywhere; }
.ok-text { color: var(--green); }
.warn-text { color: #92400e; }
.bullets { margin: 4px 0; padding-left: 20px; font-size: 0.85rem; }
.providers { list-style: none; padding: 0; margin: 4px 0; display: flex; flex-direction: column; gap: 8px; }
.provider { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface-2); font-size: 0.84rem; overflow-wrap: anywhere; }
.provider-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.provider p { margin: 3px 0; }

/* ---------- Banners, toast, dialog ---------- */
.alert-area:empty { display: none; }
.banner { border-radius: 12px; padding: 10px 12px; font-size: 0.86rem; overflow-wrap: anywhere; }
.banner p { margin: 0; }
.banner-error { background: #fef2f2; border: 1px solid #fca5a5; color: #7f1d1d; }
.banner-wait { background: #fffbeb; border: 1px solid #fcd34d; color: #78350f; }
.banner-warn { background: #fffbeb; border: 1px solid #fcd34d; color: #78350f; }
.page-banner { margin: 10px 16px 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--navy-2);
  color: #fff;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  overflow-wrap: anywhere;
}
.toast-error { background: #7f1d1d; }

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  max-width: min(460px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  color: var(--text);
}
dialog::backdrop { background: rgba(31, 41, 51, 0.45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------- Scene (SVG) ---------- */
#scene .focus-ring,
#scene .focus-ring-rect,
#scene .focus-ring-group polygon {
  visibility: hidden;
  fill: none;
  stroke: #1d4ed8;
  stroke-width: 2.5;
  stroke-linejoin: round;
  pointer-events: none;
}
#scene .selectable { cursor: pointer; }
#scene .selectable:focus { outline: none; }
#scene .selectable:hover > * > .focus-ring,
#scene .selectable:hover > .focus-ring { visibility: visible; stroke: rgba(29, 78, 216, 0.45); }
#scene .selectable:focus-visible .focus-ring,
#scene .selectable:focus-visible .focus-ring-rect,
#scene .selectable:focus-visible .focus-ring-group polygon {
  visibility: visible;
  stroke: #1d4ed8;
  stroke-width: 3;
}
#scene .selected .focus-ring,
#scene .selected .focus-ring-rect,
#scene .selected .focus-ring-group polygon {
  visibility: visible;
  stroke: #f59e0b;
  stroke-width: 3;
}
#scene.layout-mode .movable .focus-ring {
  visibility: visible;
  stroke: #0f766e;
  stroke-dasharray: 6 4;
  stroke-width: 2.2;
}
#scene.layout-mode .movable { cursor: grab; }
#scene .drag-valid { opacity: 0.85; }
#scene .drag-invalid { opacity: 0.6; }
#scene .drag-invalid .focus-ring { visibility: visible; stroke: #dc2626 !important; stroke-dasharray: none; }

/* Water */
#scene .wave { animation: wave-drift 6s ease-in-out infinite alternate; }
#scene .wave.w1 { animation-duration: 7.5s; animation-delay: -2.5s; }
#scene .wave.w2 { animation-duration: 9s; animation-delay: -5s; }
@keyframes wave-drift {
  from { transform: translate(-14px, -4px); opacity: 0.35; }
  to { transform: translate(14px, 5px); opacity: 0.85; }
}
#scene .sparkle { opacity: 0; animation: twinkle 3.2s ease-in-out infinite; }
#scene .sparkle.s1 { animation-delay: -1.1s; }
#scene .sparkle.s2 { animation-delay: -2.2s; }
@keyframes twinkle { 0%, 100% { opacity: 0; } 50% { opacity: 0.9; } }
#scene .steam path { animation: steam 3.4s ease-in-out infinite; }
#scene .steam .steam-b { animation-delay: -1.7s; }
@keyframes steam {
  0% { transform: translateY(2px); opacity: 0; }
  40% { opacity: 0.8; }
  100% { transform: translateY(-7px); opacity: 0; }
}

/* Monitor follows runner state */
#scene .monitor .screen { fill: #222b38; transition: fill 0.25s; }
#scene .monitor[data-state="working"] .screen { fill: #2f6fb0; }
#scene .monitor[data-state="waiting"] .screen { fill: #d99a2b; }
#scene .monitor[data-state="failed"] .screen { fill: #c2413a; }
#scene .monitor[data-state="done"] .screen { fill: #2f9e63; }
#scene .monitor .scr-working,
#scene .monitor .scr-waiting,
#scene .monitor .scr-failed,
#scene .monitor .scr-done,
#scene .monitor .scr-idle { display: none; }
#scene .monitor[data-state="working"] .scr-working,
#scene .monitor[data-state="waiting"] .scr-waiting,
#scene .monitor[data-state="failed"] .scr-failed,
#scene .monitor[data-state="done"] .scr-done,
#scene .monitor[data-state="idle"] .scr-idle { display: inline; }
#scene .monitor .code { fill: #cfe8ff; animation: code-blink 1.1s steps(2) infinite; }
#scene .monitor .code-1 { animation-delay: -0.3s; }
#scene .monitor .code-2 { animation-delay: -0.6s; }
#scene .monitor .code-3 { animation-delay: -0.9s; }
@keyframes code-blink { 50% { opacity: 0.35; } }
#scene .scr-glyph { fill: #ffffff; }

/* Jarvis */
#scene .agent .eye { fill: #5ef2ff; }
#scene .agent .eye-line { stroke: #5ef2ff; }
#scene .agent .eyes-happy,
#scene .agent .eyes-error { display: none; }
#scene .agent.mood-done .eyes-normal,
#scene .agent.mood-failed .eyes-normal { display: none; }
#scene .agent.mood-done .eyes-happy { display: inline; }
#scene .agent.mood-failed .eyes-error { display: inline; }
#scene .agent.mood-failed .eye-line { stroke: #ff6b6b; }
#scene .agent.mood-waiting .eye { fill: #ffc861; }
#scene .agent .antenna { fill: #43e0ff; }
#scene .agent.mood-working .antenna { fill: #60a5fa; animation: blink 1s ease-in-out infinite; }
#scene .agent.mood-waiting .antenna { fill: #f59e0b; animation: blink 0.8s ease-in-out infinite; }
#scene .agent.mood-failed .antenna { fill: #ef4444; }
#scene .agent.mood-done .antenna { fill: #34d399; }
@keyframes blink { 50% { opacity: 0.25; } }
#scene .agent.facing-front .view-back,
#scene .agent.facing-back .view-front { display: none; }
#scene .agent .legs-sit { display: none; }
#scene .agent.pose-sit .legs-sit { display: inline; }
#scene .agent.pose-sit .legs-stand { display: none; }
#scene .agent.pose-sit .agent-body { transform: translateY(7px); }
#scene .agent .leg { transform-box: fill-box; transform-origin: 50% 0%; }
#scene .agent .arm { transform-box: fill-box; transform-origin: 50% 10%; }
#scene .agent .head { transform-box: fill-box; transform-origin: 50% 100%; }
#scene .agent .torso { transform-box: fill-box; transform-origin: 50% 100%; }
#scene .agent.pose-walk .leg-a { animation: leg-swing 0.42s ease-in-out infinite alternate; }
#scene .agent.pose-walk .leg-b { animation: leg-swing 0.42s ease-in-out infinite alternate-reverse; }
#scene .agent.pose-walk .arm-a { animation: arm-swing 0.42s ease-in-out infinite alternate; }
#scene .agent.pose-walk .arm-b { animation: arm-swing 0.42s ease-in-out infinite alternate-reverse; }
#scene .agent.pose-walk .agent-body { animation: bob 0.21s ease-in-out infinite alternate; }
@keyframes leg-swing { from { transform: rotate(20deg); } to { transform: rotate(-20deg); } }
@keyframes arm-swing { from { transform: rotate(-16deg); } to { transform: rotate(16deg); } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-1.6px); } }
#scene .agent.pose-sit .arm { transform: rotate(-35deg); }
#scene .agent.typing .arm { animation: typing 0.22s ease-in-out infinite alternate; }
@keyframes typing { from { transform: rotate(-56deg); } to { transform: rotate(-68deg); } }
#scene .agent.pose-stand .torso,
#scene .agent.pose-sit.mood-idle .head { animation: breathe 3.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: translateY(-0.8px); } }
#scene .agent.mood-failed .head { transform: translateY(1.5px) rotate(7deg); animation: none; }
#scene .agent.mood-waiting .head { animation: wonder 2.4s ease-in-out infinite; }
@keyframes wonder { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }

#scene .agent-overlay { pointer-events: none; }
#scene .agent-overlay .bubble { display: none; }
#scene .agent-overlay.mood-working .bubble,
#scene .agent-overlay.mood-waiting .bubble,
#scene .agent-overlay.mood-failed .bubble,
#scene .agent-overlay.mood-done .bubble { display: inline; }
#scene .bubble-box { fill: #ffffff; stroke: #2563eb; stroke-width: 1.4; }
#scene .mood-waiting .bubble-box { fill: #fff4dc; stroke: #d97706; }
#scene .mood-failed .bubble-box { fill: #fee2e2; stroke: #dc2626; }
#scene .mood-done .bubble-box { fill: #dcfce7; stroke: #16a34a; }
#scene .bubble-tail { stroke-width: 1.2; }
#scene .bubble-text { fill: #1e3a8a; }
#scene .mood-waiting .bubble-text { fill: #92400e; }
#scene .mood-failed .bubble-text { fill: #991b1b; }
#scene .mood-done .bubble-text { fill: #166534; }
#scene .mood-waiting .bubble { transform-box: fill-box; transform-origin: 50% 100%; animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-3px); } }
#scene .agent-label-bg { fill: rgba(31, 43, 61, 0.8); }
#scene .agent-label { fill: #ffffff; letter-spacing: 0.02em; }

/* Paused or reduced motion: everything still, status stays visible */
#scene.paused *,
#scene.paused *::before { animation-play-state: paused !important; }
#scene.reduced *,
#scene.reduced *::before { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Login (VPS) ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 6px; }
.login-card h1 { font-size: 1.2rem; color: var(--navy-2); }
.login-card .btn { margin-top: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  :root { --panel-w: 360px; }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
    padding: 10px 12px 16px;
  }
  .office { height: auto; min-height: 0; }
  .scene-wrap { flex: none; aspect-ratio: 1.7; min-height: 210px; }
  .panel { overflow: visible; }
  .scene-hint { display: none; }
  .topbar { padding: 8px 12px; }
  .page-banner { margin: 8px 12px 0; }
}

@media (max-width: 480px) {
  body { font-size: 14px; }
  .brand-sub { display: none; }
  .chip { font-size: 0.76rem; padding: 3px 9px; }
  .tool { font-size: 0.82rem; padding: 4px 8px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .info-card { left: 6px; bottom: 6px; width: calc(100% - 12px); max-height: 55%; }
  .layout-bar { left: 6px; right: 6px; top: 6px; font-size: 0.8rem; }
}
