/* ═══════════════════════════════════════════════════════════════════
   xHuman ID · Personal Agent & Twin Matrix Sovereign Cockpit
   Visual style matches the dark obsidian & emerald neon Human ID design
   ═══════════════════════════════════════════════════════════════════ */

/* Panel sizing is shared with the ID card in flash-card-studio.css. */

.sovereign-panel h2,
.sovereign-panel h3,
.control-panel h2,
.control-panel h3,
.panel-heading h2 {
  font-family: var(--studio-font, Inter, system-ui, sans-serif);
}

.personal-agent-panel[hidden],
.personal-agent-panel:not(.active) {
  display: none !important;
}

.personal-agent-panel.active,
[data-active-tab="agent"] .personal-agent-panel:not([hidden]) {
  display: flex !important;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

/* ── Hero Agent Header Card ── */
.agent-hero-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  background: radial-gradient(circle at 10% 20%, rgba(202, 168, 99, 0.12), transparent 60%),
              linear-gradient(180deg, rgba(20, 24, 38, 0.85) 0%, rgba(12, 15, 26, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.agent-hero-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 140px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(202, 168, 99, 0.05));
  pointer-events: none;
}

.agent-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.agent-avatar-orb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.agent-avatar-orb svg {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.agent-status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #070911;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.agent-hero-details {
  flex: 1;
  min-width: 0;
}

.agent-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.agent-name-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-name-text {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #f0f6fc;
  letter-spacing: -0.01em;
}

.agent-badge-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.agent-pill.sbt {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
}

.agent-pill.erc {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
}

.agent-pill.online {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
}

/* ── 11-Slot Skill Matrix Cockpit ── */
.skills-matrix-cockpit {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skills-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 12px;
  color: #8b949e;
}

.skills-count-badge {
  color: #f1f5f9;
  font-weight: 700;
  font-family: ui-monospace, monospace;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.skill-slot-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(22, 27, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .skill-slot-chip:hover {
    background: rgba(28, 36, 58, 0.9);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
  }
}

.skill-slot-chip.equipped {
  background: rgba(24, 32, 54, 0.85);
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: none;
}

.skill-slot-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8b949e;
  flex-shrink: 0;
  transition: all 0.2s;
}

.skill-slot-chip.equipped .skill-slot-icon {
  background: rgba(202, 168, 99, 0.2);
  border-color: rgba(202, 168, 99, 0.45);
  color: #c4b5fd;
}

.skill-slot-info {
  flex: 1;
  min-width: 0;
}

.skill-slot-name {
  font-size: 12px;
  font-weight: 600;
  color: #e6edf3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-slot-type {
  font-size: 10px;
  color: #8b949e;
  margin-top: 2px;
}

.skill-toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  transition: all 0.2s;
}

.skill-slot-chip.equipped .skill-toggle-dot {
  background: #00e5ff;
  box-shadow: 0 0 6px #00e5ff;
}

/* ── Twin Matrix 256D Hex Grid ── */
.matrix-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.matrix-quadrant-tabs {
  display: flex;
  background: rgba(18, 22, 36, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
  overflow-x: auto;
}

.matrix-quad-btn {
  flex: 1;
  min-width: 80px;
  padding: 6px 10px;
  border-radius: 7px;
  background: transparent;
  border: 0;
  color: #8b949e;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  white-space: nowrap;
}

.matrix-quad-btn:hover {
  color: #f0f6fc;
}

.matrix-quad-btn.active {
  background: rgba(202, 168, 99, 0.2);
  color: #c4b5fd;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.matrix-hex-frame {
  background: rgba(10, 13, 22, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px;
  max-width: 440px;
  margin: 4px auto 0;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.7);
}

.matrix-hex-grid {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 2px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.matrix-hex-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.02);
  color: #373e47;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .matrix-hex-cell:hover {
    background: var(--studio-selected, #18372e) !important;
    color: var(--studio-accent, #65dfb4) !important;
    z-index: 5;
  }
}

.matrix-hex-cell.active {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.matrix-hex-cell.highlighted {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.matrix-hex-cell.selected {
  background: rgba(255, 255, 255, 0.85) !important;
  color: #090d16 !important;
  font-weight: 800;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* ── Dimension Inspector Card ── */
.dimension-inspector {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(20, 25, 40, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 440px;
  margin: 8px auto 0;
}

.dimension-badge-hex {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f1f5f9;
  font-family: ui-monospace, monospace;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dimension-info-content {
  flex: 1;
  min-width: 0;
}

.dimension-info-title {
  font-size: 13px;
  font-weight: 600;
  color: #f0f6fc;
}

.dimension-info-meta {
  font-size: 11px;
  color: #8b949e;
  margin-top: 3px;
}

/* ── Stats Row ── */
.matrix-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.matrix-stat-card {
  background: rgba(20, 25, 38, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 10px 12px;
}

.matrix-stat-label {
  font-size: 11px;
  color: #8b949e;
}

.matrix-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #f0f6fc;
  margin-top: 3px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.matrix-stat-value small {
  font-size: 11px;
  color: #6e7681;
  font-weight: 400;
}

.matrix-stat-value.green {
  color: #00e5ff;
}

/* ── OpenClaw Engine Tuning ── */
.engine-tuning-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.engine-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.engine-row label {
  font-size: 12px;
  font-weight: 600;
  color: #c9d1d9;
}

.engine-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.engine-slider-wrap input[type="range"] {
  flex: 1;
  accent-color: #caa863;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  cursor: pointer;
}

.engine-slider-value {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: #00e5ff;
  min-width: 32px;
  text-align: right;
}

.engine-textarea {
  width: 100%;
  box-sizing: border-box;
  background: rgba(10, 13, 22, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #e6edf3;
  font-size: 12px;
  line-height: 1.5;
  padding: 10px;
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
}

.engine-textarea:focus {
  outline: none;
  border-color: rgba(202, 168, 99, 0.6);
  box-shadow: 0 0 10px rgba(202, 168, 99, 0.25);
}

.engine-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.engine-toggle-label {
  font-size: 12px;
  color: #c9d1d9;
}

.engine-toggle-desc {
  font-size: 10px;
  color: #8b949e;
}

/* ── Channel Bridge Cards ── */
.channel-bridge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.channel-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: rgba(22, 27, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}

@media (hover: hover) and (pointer: fine) {
  .channel-card:hover {
    background: rgba(28, 36, 56, 0.85);
    border-color: rgba(202, 168, 99, 0.4);
    transform: translateY(-1px);
  }
}

.channel-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.channel-icon.tg {
  background: rgba(41, 182, 246, 0.15);
  color: #29b6f6;
  border: 1px solid rgba(41, 182, 246, 0.3);
}

.channel-icon.dc {
  background: rgba(88, 101, 242, 0.15);
  color: #5865f2;
  border: 1px solid rgba(88, 101, 242, 0.3);
}

.channel-name {
  font-size: 12px;
  font-weight: 600;
  color: #f0f6fc;
}

.channel-status {
  font-size: 10px;
  color: #00e5ff;
  margin-top: 2px;
}

@media (max-width: 600px) {
  .skills-grid {
    grid-template-columns: 1fr;
  }
  .channel-bridge-grid {
    grid-template-columns: 1fr;
  }
  .matrix-stats-row {
    grid-template-columns: 1fr;
  }
}

/* ── Telegram Mini App Style Agent Cockpit Slots ── */
.agent-cockpit-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.agent-slots-top {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.agent-cockpit-center {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 14px;
}

.agent-slots-flank {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-slot-box {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(14, 18, 30, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .agent-slot-box:hover {
    border-color: #caa863;
    color: #ffffff;
    transform: scale(1.08);
    box-shadow: 0 0 10px rgba(202, 168, 99, 0.3);
  }
}

.agent-slot-box.equipped {
  border-style: solid;
  border-color: rgba(202, 168, 99, 0.5);
  background: rgba(26, 32, 54, 0.85);
  color: #00e5ff;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.25);
}

.agent-slot-box .slot-mini-icon {
  font-size: 14px;
  color: #00e5ff;
}

.agent-slot-box .slot-empty-plus {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.25);
}

.agent-character-hub {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.agent-caption-sub {
  font-size: 11px;
  color: var(--muted);
}

.agent-slots-hint {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}

.agent-status-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 12px;
  padding: 0 4px;
}

.human-id-logo-mark.has-motion-gif,
.splash-emblem.has-motion-gif {
  animation: none !important;
  filter: none !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}

.dao-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50% !important;
  clip-path: circle(50% at center);
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  display: block;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════
   Floating Matrix Cube Agent Button & Dialogue Modal
   ═══════════════════════════════════════════════════════════════════ */
.floating-matrix-cube-btn {
  display: none !important;
}

[data-active-tab="twin"] .floating-matrix-cube-btn {
  position: fixed;
  right: 20px;
  bottom: 82px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(56, 189, 248, 0.4), rgba(30, 58, 138, 0.8) 65%, #070d1e 100%);
  border: 1.5px solid rgba(56, 189, 248, 0.55);
  box-shadow: 0 10px 28px rgba(14, 165, 233, 0.42), 0 0 20px rgba(56, 189, 248, 0.35), inset 0 2px 6px rgba(255, 255, 255, 0.4);
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 105;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  padding: 0;
  color: #ffffff;
  overflow: visible;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .floating-matrix-cube-btn:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 14px 34px rgba(14, 165, 233, 0.58), 0 0 28px rgba(56, 189, 248, 0.55), inset 0 2px 8px rgba(255, 255, 255, 0.6);
  }
}

.floating-matrix-cube-btn.is-dragging {
  cursor: grabbing !important;
  transition: none !important;
  transform: scale(1.12) !important;
  box-shadow: 0 18px 40px rgba(14, 165, 233, 0.7), 0 0 36px rgba(56, 189, 248, 0.75), inset 0 2px 8px rgba(255, 255, 255, 0.8) !important;
}

.floating-matrix-cube-btn:active:not(.is-dragging) {
  transform: scale(0.95);
}

.orb-canvas-container {
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.orb-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}

.orb-fallback-icon {
  position: relative;
  z-index: 2;
  opacity: 0.95;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.floating-matrix-orb-btn.has-orb-active .orb-fallback-icon {
  opacity: 0;
}

.cube-icon-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: floatCubeBreath 3.5s ease-in-out infinite;
}

@keyframes floatCubeBreath {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-2px) rotate(3deg); }
}

.cube-pulse-ring {
  position: absolute;
  inset: -4px;
  border-radius: 20px;
  border: 1.5px solid rgba(56, 189, 248, 0.5);
  opacity: 0.6;
  animation: pulseCubeRing 2.6s cubic-bezier(0.25, 1, 0.5, 1) infinite;
  pointer-events: none;
}

@keyframes pulseCubeRing {
  0% { transform: scale(0.95); opacity: 0.8; }
  70% { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* Floating Dialogue Modal */
.matrix-dialogue-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.matrix-dialogue-modal[hidden] {
  display: none !important;
}

.matrix-dialogue-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 29, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.matrix-dialogue-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 12px 16px;
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65), 0 0 32px rgba(56, 189, 248, 0.15);
  overflow: hidden;
  animation: slideUpDialogue 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

@keyframes slideUpDialogue {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.matrix-dialogue-sheet .conscious-chat-container {
  display: flex;
  flex-direction: column;
  padding: 16px;
  max-height: 80vh;
}

.matrix-dialogue-sheet .matrix-chat-stream {
  max-height: 380px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (min-width: 640px) {
  .matrix-dialogue-modal {
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0 24px 80px 0;
  }
  .matrix-dialogue-sheet {
    margin: 0;
    width: 420px;
  }
}

/* The Twin orb belongs to the Matrix sub-tab; on 人類驗證 it sat over the
   layer rows (Ming 09-17, H-11). */
[data-active-tab="twin"]:not([data-twin-subtab="matrix"]) .floating-matrix-cube-btn { display: none !important; }
