:root {
  --bg-color: #070709;
  --node-bg: #1a1a2e;
  --accent: #5B4FE8;
  --accent-glow: rgba(91, 79, 232, 0.4);
  --text-primary: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.6);
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
  user-select: none;
}

body, html {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Canvas is background */
#universe-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* UI Overlay layer */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through to canvas by default */
}

/* Annotation Card */
.annotation-card {
  position: absolute;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  pointer-events: auto;
  transform-origin: center;
  /* Antigravity handles transform so NO css transitions here for transform */
  /* opacity might be CSS transitioned or Antigravity, we'll use Antigravity */
  opacity: 0;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

/* Fullscreen Overlay */
#fullscreen-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 7, 9, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
}
#fullscreen-container {
  display: flex;
  height: 100%;
  width: 100%;
  align-items: center;
  /* transform will be handled by Antigravity spring */
}
.fs-slide {
  flex: 0 0 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.fs-slide img {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  border-radius: 8px;
  object-fit: contain;
}
.fs-slide.virtual-slide {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.virtual-slide h1 {
  font-family: 'Inter', sans-serif;
  font-size: 4vw;
  font-weight: 700;
  margin-bottom: 2vh;
  background: linear-gradient(135deg, #ffffff, #EB533D);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.virtual-slide p {
  font-family: 'Inter', sans-serif;
  font-size: 1.5vw;
  font-weight: 300;
  color: var(--text-muted);
  max-width: 80%;
  line-height: 1.6;
}
#close-fullscreen {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  cursor: pointer;
}
#close-fullscreen:hover {
  background: rgba(255,255,255,0.2);
}

/* Admin Toggle */
#admin-toggle {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}
#admin-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}
#admin-toggle.hidden {
  display: none;
}

/* Global Plus Button */
.floating-plus-btn {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 100;
  pointer-events: auto;
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: rgba(235, 83, 61, 0.1);
  border: 1px solid rgba(235, 83, 61, 0.4);
  color: #EB533D;
  font-size: 28px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 15px rgba(235, 83, 61, 0.1);
}

.floating-plus-btn:hover {
  transform: scale(1.1) rotate(90deg);
  background: rgba(235, 83, 61, 0.2);
  border-color: #EB533D;
  box-shadow: 0 0 25px rgba(235, 83, 61, 0.4);
}

.floating-plus-btn:active {
  transform: scale(0.95);
}

/* ============================================
   Presence Panel (Collaboration)
   ============================================ */
#presence-panel {
  position: absolute;
  top: 20px;
  right: 80px;
  z-index: 100;
  pointer-events: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 20px;
  background: rgba(10, 10, 15, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  min-height: 36px;
  transition: opacity 0.3s ease;
}

#presence-panel:empty {
  opacity: 0;
  pointer-events: none;
}

.presence-avatar {
  width: 24px;
  height: 24px;
  border-radius: 12px;
  background: var(--avatar-color, #EB533D);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.7);
  cursor: default;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 0 8px var(--avatar-color, rgba(235, 83, 61, 0.4));
  position: relative;
}

.presence-avatar:hover {
  transform: scale(1.15);
}

.presence-avatar::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 15, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 400;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.presence-avatar:hover::after {
  opacity: 1;
}

/* Modal Dialogs */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.modal.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: rgba(15, 15, 25, 0.95);
  border: 1px solid rgba(235, 83, 61, 0.3);
  padding: 40px;
  border-radius: 12px;
  width: 400px;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5), 0 0 20px rgba(235, 83, 61, 0.1);
  text-align: center;
}

.modal-content h3 {
  color: #fff;
  margin-bottom: 20px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.modal-content input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 15px;
  border-radius: 6px;
  color: #fff;
  font-size: 16px;
  margin-bottom: 25px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.modal-content input:focus {
  border-color: #EB533D;
  box-shadow: 0 0 10px rgba(235, 83, 61, 0.3);
}

.modal-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.modal-actions .btn {
  padding: 10px 25px;
  min-width: 100px;
}

/* Admin Panel */
#admin-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  height: 100%;
  background: rgba(10, 10, 15, 0.95);
  border-left: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 0;
  /* initial state for Antigravity */
  transform: translateX(100%);
}

#admin-panel .admin-header {
  padding: 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#admin-panel .admin-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
#close-admin {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}
#close-admin:hover {
  color: #fff;
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.section {
  margin-bottom: 32px;
}
.section h3 {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-top: 0;
  margin-bottom: 16px;
}

.btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}
.btn:hover {
  background: rgba(255,255,255,0.1);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
}
.btn.primary:hover {
  background: #6C60F8;
}

ul#admin-pp-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
}
ul#admin-pp-list li {
  background: rgba(255,255,255,0.03);
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: grab;
  border: 1px solid transparent;
}
ul#admin-pp-list li:hover {
  border-color: var(--glass-border);
}

.pp-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.pp-summary strong { font-size: 14px; }
.pp-summary small { color: var(--text-muted); }

.pp-editor {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border);
}
.pp-editor.hidden { display: none; }

.pp-editor input, .pp-editor textarea {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
  font-family: inherit;
  font-size: 13px;
}
.pp-editor textarea { height: 60px; resize: none; }

.annotation-row {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}
.annotation-row input { margin-bottom: 0; }
.remove-a {
  background: rgba(255,0,0,0.1);
  border: 1px solid rgba(255,0,0,0.2);
  color: #ff4444;
  padding: 0 8px;
  border-radius: 4px;
  cursor: pointer;
}

.edit-annotations {
  margin-bottom: 12px;
}
.add-a {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
}

.edit-pp-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.delete-pp-btn {
  background: rgba(255,0,0,0.2);
  border: 1px solid rgba(255,0,0,0.3);
  color: #ff8888;
  font-size: 12px;
  padding: 6px;
  width: 100%;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.backlog-item {
  width: 100%;
  aspect-ratio: 16/9;
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  background-size: cover;
  background-position: center;
}
.backlog-item:hover {
  border-color: var(--accent);
}

/* Drag Ghost */
.drag-ghost {
  position: absolute;
  pointer-events: none;
  z-index: 9999;
  width: 120px;
  aspect-ratio: 16/9;
  background: rgba(255,255,255,0.1);
  border: 2px solid var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  border-radius: 4px;
  background-size: cover;
  transform: translate(-50%, -50%);
}

/* ============================================
   Board Switcher
   ============================================ */
.board-toggle-btn {
  position: absolute;
  bottom: 24px;
  left: 24px;
  z-index: 100;
  pointer-events: auto;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(10, 10, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.board-toggle-btn:hover {
  background: rgba(91, 79, 232, 0.15);
  border-color: rgba(91, 79, 232, 0.4);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 4px 25px rgba(91, 79, 232, 0.2);
}

.board-toggle-btn:active {
  transform: scale(0.95);
}

.board-panel {
  position: absolute;
  bottom: 80px;
  left: 24px;
  z-index: 100;
  pointer-events: auto;
  width: 320px;
  max-height: 60vh;
  background: rgba(10, 10, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.04) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: boardPanelSlideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.board-panel.hidden {
  display: none;
}

@keyframes boardPanelSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.board-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.board-panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.85);
}

.board-panel-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.board-panel-close:hover {
  color: #fff;
}

.board-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  max-height: 40vh;
}

.board-list::-webkit-scrollbar {
  width: 4px;
}

.board-list::-webkit-scrollbar-track {
  background: transparent;
}

.board-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.board-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.board-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}

.board-item.active {
  background: rgba(91, 79, 232, 0.12);
  border-color: rgba(91, 79, 232, 0.3);
}

.board-item-info {
  flex: 1;
  min-width: 0;
}

.board-item-name {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-item-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 2px;
}

.board-item-delete {
  background: none;
  border: none;
  color: rgba(255, 80, 80, 0.5);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0;
  transition: all 0.2s;
}

.board-item:hover .board-item-delete {
  opacity: 1;
}

.board-item-delete:hover {
  color: #ff5050;
  background: rgba(255, 80, 80, 0.1);
}

.board-panel-actions {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 8px;
}

.board-action-btn {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.board-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.board-action-btn.save:hover {
  background: rgba(91, 79, 232, 0.15);
  border-color: rgba(91, 79, 232, 0.4);
}

.board-action-btn.new:hover {
  background: rgba(235, 83, 61, 0.15);
  border-color: rgba(235, 83, 61, 0.4);
}

.board-empty-state {
  padding: 24px;
  text-align: center;
  color: rgba(255, 255, 255, 0.3);
  font-size: 13px;
}
