:root {
  --bg: #0a1016;
  --panel: rgba(12, 19, 26, 0.88);
  --panel-soft: rgba(18, 27, 36, 0.76);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.2);
  --ink: #edf4f8;
  --muted: #9aabb8;
  --muted-2: #6f8493;
  --accent: #59e3c1;
  --accent-2: #ffb45c;
  --danger: #ff6b6b;
  --blue: #6ca8ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid rgba(89, 227, 193, 0.7);
  outline-offset: 2px;
}

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { position: relative; width: 100vw; height: 100vh; overflow: hidden; isolation: isolate; }

/* ---------- Office scene ---------- */
.office-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #cbb79b;
}

.office-floor {
  position: absolute;
  inset: -4% -3% -6%;
  width: 106%;
  height: 110%;
  object-fit: cover;
  object-position: center 44%;
  filter: saturate(1.08) contrast(1.04) brightness(1.02);
  user-select: none;
  -webkit-user-drag: none;
  transform: scale(1.02);
}

.scene-wash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(7, 13, 18, 0.42) 0%, rgba(7, 13, 18, 0.05) 22%, rgba(7, 13, 18, 0) 58%, rgba(7, 13, 18, 0.72) 100%),
    radial-gradient(ellipse at 50% 40%, transparent 42%, rgba(6, 12, 17, 0.3) 100%);
}

.light-strip {
  position: absolute;
  pointer-events: none;
  width: 28vw;
  height: 120vh;
  top: -30vh;
  background: linear-gradient(90deg, transparent, rgba(255, 244, 211, 0.12), transparent);
  transform: rotate(24deg);
  filter: blur(18px);
  opacity: 0.8;
}
.light-strip-a { left: 12%; }
.light-strip-b { left: 62%; opacity: 0.45; }

.zone-label {
  position: absolute;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: rgba(12, 18, 24, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.84);
  font-size: 10px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.zone-label span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.zone-boss { left: 15.5%; top: 13%; }
.zone-meeting { left: 43.5%; top: 12.5%; }
.zone-pantry { left: 76%; top: 13%; }
.zone-open { left: 44%; top: 78%; }

.agents-layer, .fx-layer { position: absolute; inset: 0; pointer-events: none; }
.agents-layer { z-index: 20; }
.fx-layer { z-index: 40; }

/* ---------- Agents ---------- */
.agent {
  position: absolute;
  width: 44px;
  height: 56px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  z-index: 20;
  transition: filter 0.25s ease;
}
.agent:hover { filter: brightness(1.12); z-index: 30; }
.agent::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  background: radial-gradient(circle, rgba(89, 227, 193, 0.22), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.agent.working::before, .agent.break::before { opacity: 1; }
.agent.working::before { background: radial-gradient(circle, rgba(89, 227, 193, 0.26), transparent 70%); }
.agent.break::before { background: radial-gradient(circle, rgba(255, 180, 92, 0.22), transparent 70%); }

.agent-shadow {
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 26px;
  height: 10px;
  border-radius: 50%;
  background: rgba(16, 12, 8, 0.34);
  filter: blur(3px);
  transform: translateX(-50%);
}

.agent-figure {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 43px;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(var(--s, 1));
  transform-origin: center center;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.2));
}

.agent .head {
  position: absolute;
  left: 7px;
  top: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50% 50% 46% 46%;
  background: var(--skin, #dfac85);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.08), inset 1px 1px 0 rgba(255, 255, 255, 0.24);
  z-index: 4;
}
.agent .hair {
  position: absolute;
  left: -1px;
  right: -1px;
  top: -2px;
  height: 12px;
  border-radius: 52% 52% 34% 34%;
  background: var(--hair, #2d2119);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}
.agent-figure[data-hair="bun"] .hair::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hair, #2d2119);
  transform: translateX(-50%);
}
.agent-figure[data-hair="long"] .hair { height: 18px; border-radius: 50% 50% 45% 45%; }
.agent-figure[data-hair="curly"] .hair {
  height: 14px;
  border-radius: 48% 48% 40% 40%;
  background-image: radial-gradient(circle at 20% 50%, var(--hair) 3px, transparent 4px), radial-gradient(circle at 50% 40%, var(--hair) 4px, transparent 5px), radial-gradient(circle at 80% 50%, var(--hair) 3px, transparent 4px);
}
.agent-figure[data-hair="cap"] .hair {
  height: 8px;
  border-radius: 50% 50% 20% 20%;
  background: var(--hair, #2d2119);
}
.agent-figure[data-hair="cap"] .hair::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 18px;
  height: 4px;
  border-radius: 50%;
  background: var(--hair, #2d2119);
  transform: translateX(-50%);
}

.agent .torso {
  position: absolute;
  left: 4px;
  top: 15px;
  width: 22px;
  height: 18px;
  clip-path: polygon(18% 0, 82% 0, 100% 100%, 0 100%);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 42%), var(--shirt, #4f7d9e);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.16);
  z-index: 3;
}
.agent .torso::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 1px;
  width: 5px;
  height: 7px;
  background: rgba(255, 255, 255, 0.5);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform: translateX(-50%);
  opacity: 0.75;
}
.agent .arm {
  position: absolute;
  top: 17px;
  width: 6px;
  height: 16px;
  border-radius: 5px;
  background: var(--shirt, #4f7d9e);
  z-index: 2;
}
.agent .arm::after {
  content: "";
  position: absolute;
  left: 1px;
  bottom: -2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--skin, #dfac85);
}
.agent .arm-l { left: 0; transform-origin: 50% 10%; transform: rotate(-8deg); }
.agent .arm-r { right: 0; transform-origin: 50% 10%; transform: rotate(8deg); }
.agent .leg {
  position: absolute;
  top: 31px;
  width: 8px;
  height: 12px;
  border-radius: 3px 3px 5px 5px;
  background: var(--pants, #2f3945);
  z-index: 1;
}
.agent .leg-l { left: 6px; }
.agent .leg-r { right: 6px; }

.agent.walking .agent-figure { animation: agentBob 0.52s ease-in-out infinite; }
.agent.walking .arm-l { animation: armLeft 0.52s ease-in-out infinite; }
.agent.walking .arm-r { animation: armRight 0.52s ease-in-out infinite; }
.agent.working .arm-l { animation: typeLeft 0.24s ease-in-out infinite alternate; }
.agent.working .arm-r { animation: typeRight 0.24s ease-in-out infinite alternate; }
.agent.working .head { animation: headNod 2.4s ease-in-out infinite; }
.agent.break .head { animation: sip 2.8s ease-in-out infinite; }

.agent-role {
  position: absolute;
  left: 50%;
  top: calc(100% - 1px);
  transform: translateX(-50%);
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(8, 14, 19, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
  font-size: 9px;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: 0.04em;
  backdrop-filter: blur(6px);
}

.agent-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translate(-50%, 5px) scale(0.96);
  max-width: 190px;
  padding: 6px 10px;
  border-radius: 10px 10px 10px 3px;
  background: rgba(10, 17, 23, 0.9);
  border: 1px solid rgba(89, 227, 193, 0.28);
  color: #e8f7f2;
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}
.agent.show-bubble .agent-bubble { opacity: 1; transform: translate(-50%, 0) scale(1); }
.agent.break .agent-bubble { border-color: rgba(255, 180, 92, 0.32); color: #fff0d9; }

.agent-progress {
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 32px;
  height: 3px;
  border-radius: 4px;
  background: rgba(6, 12, 17, 0.65);
  overflow: hidden;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.agent.working .agent-progress { opacity: 1; }
.agent-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #b8ffe9);
  transition: width 0.2s linear;
}

.spark {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: sparkFly 1.25s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes agentBob {
  0%, 100% { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(var(--s, 1)) translateY(0); }
  50% { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(var(--s, 1)) translateY(-3px); }
}
@keyframes armLeft { 0%,100% { transform: rotate(18deg); } 50% { transform: rotate(-24deg); } }
@keyframes armRight { 0%,100% { transform: rotate(-18deg); } 50% { transform: rotate(24deg); } }
@keyframes typeLeft { from { transform: rotate(-4deg) translateY(0); } to { transform: rotate(-13deg) translateY(1px); } }
@keyframes typeRight { from { transform: rotate(4deg) translateY(1px); } to { transform: rotate(13deg) translateY(0); } }
@keyframes headNod { 0%,100% { transform: translateY(0); } 50% { transform: translateY(1px); } }
@keyframes sip { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-2px) rotate(-5deg); } }
@keyframes sparkFly {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); }
}

/* ---------- Top bar ---------- */
.topbar {
  position: absolute;
  z-index: 50;
  top: 18px;
  left: 20px;
  right: 20px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 16px 0 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(11, 18, 25, 0.9), rgba(14, 23, 31, 0.76));
  backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 250px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(89, 227, 193, 0.22), rgba(108, 168, 255, 0.12));
  border: 1px solid rgba(89, 227, 193, 0.32);
  color: var(--accent);
  box-shadow: inset 0 0 16px rgba(89, 227, 193, 0.1);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-copy { display: flex; flex-direction: column; gap: 2px; }
.brand-copy strong { font-size: 15px; letter-spacing: 0.14em; }
.brand-copy small { color: var(--muted); font-size: 10px; letter-spacing: 0.08em; }

.top-stats { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.stat-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.stat-chip b { font-size: 14px; font-variant-numeric: tabular-nums; }
.stat-chip em { font-style: normal; color: var(--muted); font-size: 11px; }
.stat-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.stat-dot.live { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.stat-dot.idle { background: var(--accent-2); }
.stat-dot.task { background: var(--blue); }
.clock-chip b { letter-spacing: 0.06em; }

.boss-entry {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 15px;
  border-radius: 11px;
  border: 1px solid rgba(255, 180, 92, 0.42);
  background: linear-gradient(135deg, rgba(255, 180, 92, 0.16), rgba(255, 180, 92, 0.06));
  color: #ffd7a6;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: transform 0.2s ease, background 0.2s ease;
}
.boss-entry:hover { transform: translateY(-1px); background: rgba(255, 180, 92, 0.22); }
.boss-entry svg { width: 16px; height: 16px; }
.boss-entry.authorized { color: #b9f6e5; border-color: rgba(89, 227, 193, 0.42); background: rgba(89, 227, 193, 0.12); }

/* ---------- Mission card ---------- */
.mission-card {
  position: absolute;
  z-index: 45;
  left: 20px;
  top: 96px;
  width: 338px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(12, 20, 27, 0.9), rgba(10, 17, 23, 0.78));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.mission-head { display: flex; align-items: center; justify-content: space-between; }
.mission-label { color: var(--muted); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; }
.mission-state {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(108, 168, 255, 0.12);
  border: 1px solid rgba(108, 168, 255, 0.24);
  color: #a9ccff;
  font-size: 10px;
}
.mission-state.running { background: rgba(89, 227, 193, 0.12); border-color: rgba(89, 227, 193, 0.28); color: #9ff0da; }
.mission-state.done { background: rgba(255, 180, 92, 0.12); border-color: rgba(255, 180, 92, 0.28); color: #ffd7a6; }
.mission-card h2 { margin: 12px 0 7px; font-size: 17px; line-height: 1.35; font-weight: 650; }
.mission-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.mission-progress { height: 4px; margin: 15px 0 14px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.mission-progress i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), #a8f0ff); transition: width 0.4s ease; }
.mission-steps { display: flex; flex-direction: column; gap: 7px; max-height: 168px; overflow: auto; }
.empty-steps { color: var(--muted-2); font-size: 11px; padding: 8px 0; }
.step-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.045);
}
.step-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); flex: none; }
.step-row.active .step-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: dotPulse 1.4s infinite; }
.step-row.done .step-dot { background: var(--blue); }
.step-name { color: var(--muted); font-size: 10px; min-width: 46px; }
.step-task { flex: 1; color: #dce8ee; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-state { color: var(--muted-2); font-size: 10px; }
.step-row.active .step-state { color: var(--accent); }
.step-row.done .step-state { color: var(--blue); }
@keyframes dotPulse { 50% { opacity: 0.45; transform: scale(0.8); } }

.stage-hint {
  position: absolute;
  z-index: 45;
  right: 24px;
  top: 100px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(10, 17, 23, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: opacity 0.5s ease;
}
.stage-hint svg { width: 14px; height: 14px; color: var(--accent); }

/* ---------- Dock ---------- */
.dock {
  position: absolute;
  z-index: 50;
  left: 20px;
  right: 20px;
  bottom: 18px;
  height: 74px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(11, 18, 25, 0.91), rgba(14, 23, 31, 0.83));
  backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.dock-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  min-width: 205px;
  padding: 0 12px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.dock-btn:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.07); }
.dock-btn.primary { background: linear-gradient(135deg, rgba(89, 227, 193, 0.18), rgba(89, 227, 193, 0.06)); border-color: rgba(89, 227, 193, 0.3); }
.dock-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.07);
  color: var(--accent);
  flex: none;
}
.dock-btn:not(.primary) .dock-icon { color: var(--blue); }
.dock-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dock-text b { font-size: 13px; }
.dock-text small { color: var(--muted); font-size: 9px; white-space: nowrap; }
.dock-lock { width: 14px; height: 14px; color: var(--muted-2); margin-left: auto; }
.dock-btn.unlocked .dock-lock { color: var(--accent); }
.dock-spacer { flex: 1; }
.dock-status { display: flex; align-items: center; gap: 10px; padding-right: 8px; }
.dock-status div { display: flex; flex-direction: column; gap: 2px; }
.dock-status b { font-size: 12px; }
.dock-status small { color: var(--muted); font-size: 10px; }
.pulse-ring {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  position: relative;
}
.pulse-ring::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  animation: ringPulse 2s ease-out infinite;
}
@keyframes ringPulse { 0% { opacity: 0.8; transform: scale(0.6); } 100% { opacity: 0; transform: scale(1.4); } }

/* ---------- Toast & profile ---------- */
.toast-stack { position: fixed; z-index: 120; right: 22px; bottom: 106px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  min-width: 250px;
  max-width: 340px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(11, 19, 26, 0.94);
  border: 1px solid rgba(89, 227, 193, 0.26);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(12px);
  animation: toastIn 0.3s ease both;
}
.toast.warn { border-color: rgba(255, 180, 92, 0.3); }
.toast b { display: block; font-size: 12px; margin-bottom: 3px; }
.toast span { color: var(--muted); font-size: 11px; line-height: 1.5; }
@keyframes toastIn { from { opacity: 0; transform: translateX(18px) scale(0.96); } to { opacity: 1; transform: none; } }

.profile-pop {
  position: fixed;
  z-index: 80;
  width: 260px;
  padding: 15px;
  border-radius: 15px;
  background: rgba(12, 20, 27, 0.95);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  animation: popIn 0.2s ease both;
}
@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(0.97); } to { opacity: 1; transform: none; } }
.profile-head { display: flex; align-items: center; gap: 10px; }
.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--shirt, #4f7d9e);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.profile-info b { display: block; font-size: 13px; }
.profile-info small { color: var(--muted); font-size: 10px; }
.profile-status { margin: 12px 0 10px; padding: 9px 10px; border-radius: 9px; background: rgba(255, 255, 255, 0.045); font-size: 11px; line-height: 1.5; color: #d9e6ed; }
.profile-status span { color: var(--accent); }
.profile-model { color: var(--muted); font-size: 10px; margin-bottom: 10px; word-break: break-all; }
.profile-actions { display: flex; gap: 8px; }
.mini-btn {
  flex: 1;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  font-size: 10px;
}
.mini-btn.primary { border-color: rgba(89, 227, 193, 0.32); color: var(--accent); background: rgba(89, 227, 193, 0.1); }

/* ---------- Lock modal ---------- */
.modal-backdrop, .panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(4, 9, 13, 0.68);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.25s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.door-scene {
  position: relative;
  width: min(780px, 92vw);
  height: min(660px, 90vh);
  display: grid;
  place-items: center;
  perspective: 1200px;
}
.door-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.28), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.28)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 6px),
    linear-gradient(135deg, #232e37, #101820);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.45), 0 30px 80px rgba(0, 0, 0, 0.45);
  transition: transform 0.85s cubic-bezier(0.7, 0, 0.2, 1);
  z-index: 1;
}
.door-left { left: 0; transform-origin: left center; border-radius: 22px 0 0 22px; }
.door-right { right: 0; transform-origin: right center; border-radius: 0 22px 22px 0; }
.door-line { position: absolute; top: 12%; bottom: 12%; width: 1px; background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.12), transparent); }
.door-left .door-line { right: 10%; }
.door-right .door-line { left: 10%; }
.door-scene.opening .door-left { transform: translateX(-104%) rotateY(-22deg); }
.door-scene.opening .door-right { transform: translateX(104%) rotateY(22deg); }

.lock-card {
  position: relative;
  z-index: 3;
  width: min(380px, 88vw);
  padding: 26px 28px 22px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(18, 29, 38, 0.97), rgba(10, 17, 23, 0.97));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.door-scene.opening .lock-card { opacity: 0; transform: scale(0.92); }
.lock-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: var(--accent-2);
  background: rgba(255, 180, 92, 0.12);
  border: 1px solid rgba(255, 180, 92, 0.28);
}
.lock-icon svg { width: 24px; height: 24px; }
.eyebrow { color: var(--accent); font-size: 9px; letter-spacing: 0.24em; text-transform: uppercase; }
.lock-card .eyebrow { color: var(--accent-2); }
.lock-card h2 { margin: 6px 0 8px; font-size: 23px; letter-spacing: 0.04em; }
.lock-card p { margin: 0 0 18px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.pass-input-wrap { position: relative; height: 48px; margin-bottom: 14px; }
.pass-input-wrap input {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: transparent;
  font-size: 20px;
  letter-spacing: 0.8em;
  text-align: center;
  caret-color: var(--accent);
}
.pass-dashes { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 16px; pointer-events: none; }
.pass-dashes i { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.3); background: transparent; transition: all 0.15s ease; }
.pass-dashes i.filled { background: var(--accent-2); border-color: var(--accent-2); box-shadow: 0 0 12px rgba(255, 180, 92, 0.55); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.keypad button {
  height: 43px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.045);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s ease, transform 0.15s ease;
}
.keypad button:hover { background: rgba(255, 255, 255, 0.09); }
.keypad button:active { transform: scale(0.96); }
.keypad .key-fn { font-size: 11px; color: var(--muted); }
.unlock-btn {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(89, 227, 193, 0.42);
  background: linear-gradient(135deg, rgba(89, 227, 193, 0.22), rgba(89, 227, 193, 0.08));
  color: #c6ffee;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.unlock-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(89, 227, 193, 0.14); }
.lock-error { height: 16px; margin-top: 9px; color: var(--danger); font-size: 10px; opacity: 0; transition: opacity 0.2s ease; }
.lock-error.show { opacity: 1; }
.lock-card.shake { animation: shake 0.35s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-4px); } }
.lock-foot { margin-top: 4px; color: var(--muted-2); font-size: 9px; }
.modal-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 20, 27, 0.7);
  display: grid;
  place-items: center;
}

/* ---------- Control panel ---------- */
.panel-backdrop { z-index: 95; }
.control-panel {
  width: min(1080px, 94vw);
  height: min(760px, 92vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(155deg, rgba(15, 24, 32, 0.98), rgba(9, 15, 21, 0.98));
  box-shadow: 0 40px 110px rgba(0, 0, 0, 0.62);
  animation: panelIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.panel-head h2 { margin: 4px 0 0; font-size: 21px; letter-spacing: 0.03em; }
.panel-head-right { display: flex; align-items: center; gap: 10px; }
.auth-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: rgba(89, 227, 193, 0.1); border: 1px solid rgba(89, 227, 193, 0.24); color: #a9f1dd; font-size: 10px; }
.auth-pill svg { width: 13px; height: 13px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.04); display: grid; place-items: center; }
.panel-tabs { display: flex; gap: 4px; padding: 12px 20px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 15px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.tab svg { width: 15px; height: 15px; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); background: linear-gradient(180deg, transparent, rgba(89, 227, 193, 0.06)); }
.panel-body { flex: 1; min-height: 0; overflow: auto; }
.tab-page { display: none; }
.tab-page.active { display: block; }
#tabTask.active { display: grid; grid-template-columns: 1.08fr 0.92fr; gap: 20px; padding: 22px; }
#tabConfig.active, #tabLog.active { padding: 22px; }

.task-compose, .flow-preview, .config-form, .role-list, .log-list {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}
.task-compose { padding: 18px; }
.task-compose > label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 9px; }
.task-compose textarea {
  width: 100%;
  height: 138px;
  resize: none;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(4, 9, 13, 0.45);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.7;
}
.task-compose textarea::placeholder { color: var(--muted-2); }
.task-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.field select, .config-form select, .config-form input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: #101a23;
  color: var(--ink);
  font-size: 11px;
}
.templates { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.templates span { color: var(--muted); font-size: 10px; margin-right: 3px; }
.templates button {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd9e2;
  font-size: 10px;
}
.templates button:hover { border-color: rgba(89, 227, 193, 0.3); color: var(--accent); }
.submit-task {
  width: 100%;
  height: 44px;
  border-radius: 11px;
  border: 1px solid rgba(89, 227, 193, 0.4);
  background: linear-gradient(135deg, rgba(89, 227, 193, 0.24), rgba(89, 227, 193, 0.08));
  color: #c9ffee;
  font-size: 12px;
  font-weight: 650;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.submit-task:hover { box-shadow: 0 10px 26px rgba(89, 227, 193, 0.14); }
.flow-preview { padding: 18px; }
.flow-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.flow-title svg { color: var(--blue); width: 16px; height: 16px; }
.flow-preview p { color: var(--muted); font-size: 11px; line-height: 1.7; margin: 10px 0 16px; }
.flow-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-height: 58px; }
.flow-idle { color: var(--muted-2); font-size: 11px; }
.flow-node { padding: 7px 10px; border-radius: 9px; border: 1px solid rgba(108, 168, 255, 0.25); background: rgba(108, 168, 255, 0.08); font-size: 10px; color: #c7dcff; }
.flow-arrow { color: var(--muted-2); font-size: 11px; }
.flow-note { margin-top: 18px; padding: 10px 12px; border-radius: 9px; background: rgba(255, 180, 92, 0.06); border: 1px solid rgba(255, 180, 92, 0.14); color: #d5b98f; font-size: 10px; line-height: 1.6; }

.config-layout { display: grid; grid-template-columns: 250px 1fr; gap: 18px; }
.role-list { padding: 10px; max-height: 490px; overflow: auto; }
.role-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
}
.role-item:hover { background: rgba(255, 255, 255, 0.04); }
.role-item.active { border-color: rgba(89, 227, 193, 0.28); background: rgba(89, 227, 193, 0.08); }
.role-badge { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--shirt, #4f7d9e); color: #fff; font-size: 11px; font-weight: 700; flex: none; }
.role-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.role-meta b { font-size: 11px; }
.role-meta small { color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-indicator { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); margin-left: auto; }
.role-indicator.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.config-form { padding: 18px; }
.config-empty { color: var(--muted-2); font-size: 11px; text-align: center; padding: 80px 0; }
.config-title { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.config-title .role-badge { width: 38px; height: 38px; font-size: 13px; }
.config-title b { display: block; font-size: 14px; }
.config-title small { color: var(--muted); font-size: 10px; }
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.config-grid .full { grid-column: 1 / -1; }
.config-grid label { display: block; color: var(--muted); font-size: 10px; margin-bottom: 6px; }
.config-actions { display: flex; gap: 9px; margin-top: 18px; }
.save-btn, .ghost-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.save-btn { border-color: rgba(89, 227, 193, 0.3); background: rgba(89, 227, 193, 0.12); color: #baf6e5; }
.ghost-btn:hover { background: rgba(255, 255, 255, 0.09); }
.config-warning { margin-top: 14px; display: flex; align-items: flex-start; gap: 8px; padding: 11px 13px; border-radius: 10px; background: rgba(255, 180, 92, 0.06); border: 1px solid rgba(255, 180, 92, 0.14); color: #d8bd95; font-size: 10px; line-height: 1.6; }
.config-warning svg { flex: none; width: 14px; height: 14px; margin-top: 1px; }

.log-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.log-toolbar div { display: flex; align-items: baseline; gap: 10px; }
.log-toolbar b { font-size: 13px; }
.log-toolbar span { color: var(--muted); font-size: 10px; }
.log-list { padding: 10px; max-height: 520px; overflow: auto; min-height: 200px; }
.log-row { display: grid; grid-template-columns: 66px 74px 1fr; gap: 10px; align-items: start; padding: 9px 10px; border-radius: 9px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); font-size: 11px; }
.log-row:hover { background: rgba(255, 255, 255, 0.03); }
.log-time { color: var(--muted-2); font-variant-numeric: tabular-nums; }
.log-role { color: var(--accent); }
.log-row.boss .log-role { color: var(--accent-2); }
.log-row.system .log-role { color: var(--blue); }
.log-text { color: #d4e1e9; line-height: 1.5; }
.log-empty { color: var(--muted-2); font-size: 11px; text-align: center; padding: 70px 0; }
.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 10px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .brand { min-width: 205px; }
  .top-stats .stat-chip:nth-child(3) { display: none; }
  .dock-btn { min-width: 175px; }
  .dock-text small { display: none; }
}

@media (max-width: 900px) {
  .topbar { top: 10px; left: 10px; right: 10px; height: 58px; }
  .brand-copy small { display: none; }
  .top-stats .stat-chip:nth-child(2), .top-stats .stat-chip:nth-child(4) { display: none; }
  .mission-card { left: 10px; top: 78px; width: 290px; padding: 14px; }
  .stage-hint { display: none; }
  .dock { left: 10px; right: 10px; bottom: 10px; height: 66px; }
  .dock-btn { min-width: 0; height: 48px; padding: 0 10px; }
  .dock-text { display: none; }
  .dock-lock { display: none; }
  .dock-status { display: none; }
  #tabTask.active { grid-template-columns: 1fr; }
  .config-layout { grid-template-columns: 190px 1fr; }
}

@media (max-width: 620px) {
  .top-stats { display: none; }
  .boss-entry { margin-left: auto; }
  .mission-card { width: calc(100vw - 20px); top: 78px; }
  .mission-steps { max-height: 92px; }
  .control-panel { width: 100vw; height: 100vh; border-radius: 0; }
  .config-layout { grid-template-columns: 1fr; }
  .role-list { max-height: 170px; }
  .config-grid { grid-template-columns: 1fr; }
  .log-row { grid-template-columns: 58px 62px 1fr; gap: 6px; font-size: 10px; }
  .door-scene { width: 100vw; height: 100vh; }
  .dock-btn { flex: 1; justify-content: center; }
}
