/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Body: full viewport, black background, no camera preview */
body {
  width: 100vw;
  height: 100vh;
  background: #000;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Main container: side-by-side layout on desktop, stacked on mobile */
#main-container {
  position: fixed;
  top: 60px; /* Below header */
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: row; /* Side-by-side on desktop */
  gap: 1rem;
  padding: 1rem;
  background: #000;
  overflow: hidden;
}

/* Skeleton container: takes remaining space */
#skeleton-container {
  flex: 1;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  min-width: 0; /* Allow flex shrink */
}

/* Canvas: fills container while maintaining aspect ratio */
#skeleton-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
}

/* Data panel: fixed width on desktop */
.data-panel {
  width: 280px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1.5rem;
  overflow-y: auto;
  flex-shrink: 0;
}

.data-panel-title {
  font-size: 18px;
  font-weight: 600;
  color: #10b981;
  margin-bottom: 1.5rem;
  text-align: center;
}

.data-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.data-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

.data-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.data-value {
  font-size: 16px;
  font-weight: 600;
  font-family: 'Courier New', monospace;
  color: #10b981;
}

/* Header bar: fixed at top */
#header-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.8);
  gap: 1rem;
  overflow: visible;
}

/* iOS controls moved to fullscreen overlay - see #ios-start-overlay below */

/* Status indicator */
#status-indicator {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Header actions */
#header-actions {
  display: flex;
  align-items: center;
  flex-grow: 1;
  justify-content: flex-end;
  margin-right: auto;
  margin-left: 1rem;
  gap: 0.5rem;
}

.header-link {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
  pointer-events: auto;
}

.header-link:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #10b981;
  color: #10b981;
}

.header-link:active {
  background: rgba(255, 255, 255, 0.2);
}

/* Header logout button */
.header-logout {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  cursor: pointer;
  font-family: inherit;
}

.header-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

/* Status dot */
.status-dot {
   width: 12px;
   height: 12px;
   border-radius: 4px;
   transition: background-color 0.3s ease;
 }

/* Status states */
.status-yellow {
  background: #fbbf24;
}

.status-green {
  background: #10b981;
}

.status-red {
  background: #ef4444;
}

/* Green pulsing animation */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.pulse {
  animation: pulse 2s infinite;
}

/* ── iOS Tap-to-Start Fullscreen Overlay ────────────────────────────── */

#ios-start-overlay {
  display: none; /* hidden by default; JS shows it on iOS only */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: #000;
  color: #fff;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#ios-start-overlay::before {
  content: '📷';
  font-size: 3rem;
  display: block;
  opacity: 0.9;
}

#ios-start-overlay .overlay-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}

#ios-start-overlay .overlay-subtitle {
  font-size: 1rem;
  opacity: 0.6;
  text-align: center;
  max-width: 280px;
  line-height: 1.4;
}

#ios-start-overlay #ios-start-button {
  margin-top: 0.5rem;
  padding: 1rem 2.5rem;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 12px;
  font-size: 1.125rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 52px;
  min-width: 200px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background 0.15s ease;
}

#ios-start-overlay #ios-start-button:active {
  transform: scale(0.97);
  background: #e5e5e5;
}

/* Remove old header-based iOS control styles */
#ios-controls {
  display: none !important;
}

/* Loading indicator for MediaPipe model download */
.loading-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.9);
  padding: 1.5rem 2rem;
  border-radius: 8px;
  font-size: 16px;
  color: #333;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-message {
  display: none;
  padding: 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 4px;
  color: #ef4444;
  font-size: 14px;
  text-align: center;
}

/* Recordings page styles */
.recordings-page {
  overflow: auto;
  background: #000;
  color: #fff;
  padding: 2rem 1rem;
}

.recordings-container {
  max-width: 900px;
  margin: 0 auto;
}

.recordings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.recordings-title {
  font-size: 28px;
  font-weight: 600;
  color: #10b981;
}

.recordings-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.nav-link {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  transition: all 0.2s ease;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.logout-link {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.logout-link:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
}

.info-message {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
}

.recordings-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  overflow: hidden;
}

.recordings-table thead {
  background: rgba(255, 255, 255, 0.05);
}

.recordings-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: #10b981;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.recordings-table td {
  padding: 0.875rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 14px;
}

.recordings-table tbody tr {
  transition: background-color 0.15s ease;
}

.recordings-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.filename-cell {
  font-family: 'Courier New', monospace;
  color: rgba(255, 255, 255, 0.9);
}

.size-cell,
.date-cell {
  color: rgba(255, 255, 255, 0.6);
}

.actions-cell {
  text-align: right;
}

.download-button {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #10b981;
  color: #000;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
  transition: background-color 0.2s ease;
  min-height: 32px;
  line-height: 1;
}

.download-button:hover {
  background: #0ea472;
}

.download-button:active {
  background: #0d9268;
}

.delete-button {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 32px;
  line-height: 1;
  margin-left: 0.5rem;
}

.delete-button:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
}

.delete-button:active {
  background: rgba(239, 68, 68, 0.35);
}

.recording-active {
  background: rgba(239, 68, 68, 0.08);
}

.recording-badge {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 3px;
  animation: rec-pulse 1.5s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.recording-status {
  color: #ef4444;
  font-size: 13px;
  font-style: italic;
}

.retry-button {
  background: none;
  border: none;
  color: #10b981;
  text-decoration: underline;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

.retry-button:hover {
  color: #0ea472;
}

/* ── Sortable Table Headers ────────────────────────────────────── */

.recordings-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

.recordings-table th.sortable:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sort-indicator {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  width: 12px;
}

.recordings-table th.sort-asc .sort-indicator,
.recordings-table th.sort-desc .sort-indicator {
  color: #10b981;
}

/* ── Checkbox Cells ─────────────────────────────────────────────── */

.checkbox-cell {
  width: 40px;
  text-align: center;
  padding: 0.5rem !important;
}

.checkbox-cell input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #10b981;
}

/* ── Row Selected State ─────────────────────────────────────────── */

.recordings-table tbody tr.row-selected {
  background: rgba(16, 185, 129, 0.08) !important;
}

/* ── Batch Action Bar ───────────────────────────────────────────── */

.batch-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #111;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 200;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
}

.selected-count {
  font-size: 14px;
  font-weight: 600;
  color: #10b981;
}

.batch-delete-button {
  padding: 0.5rem 1.25rem;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.2s ease;
  min-height: 36px;
}

.batch-delete-button:hover {
  background: #dc2626;
}

.batch-delete-button:active {
  background: #b91c1c;
}

.batch-clear-button {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  min-height: 36px;
}

.batch-clear-button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ── Actions column header ──────────────────────────────────────── */

.actions-cell-header {
  text-align: right;
}

/* Mobile responsive */
@media (max-width: 768px) {
  /* Main container: stack vertically on mobile */
  #main-container {
    flex-direction: column;
    top: 50px;
    padding: 0.5rem;
  }

  #skeleton-container {
    flex: 1;
    min-height: 50%; /* Skeleton takes top half */
  }

  .data-panel {
    width: 100%;
    max-height: 40%; /* Data panel takes bottom portion */
    padding: 1rem;
  }

  .data-panel-title {
    font-size: 16px;
    margin-bottom: 1rem;
  }

  .data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .data-item {
    padding: 0.5rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .data-label {
    font-size: 12px;
  }

  .data-value {
    font-size: 14px;
  }

  /* Recordings page mobile styles */
  .recordings-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .recordings-title {
    font-size: 24px;
  }

  .recordings-table {
    font-size: 13px;
  }

  .recordings-table th,
  .recordings-table td {
    padding: 0.75rem 0.5rem;
  }

  .filename-cell {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .download-button {
    padding: 0.4rem 0.75rem;
    font-size: 12px;
  }

  .header-link {
    font-size: 12px;
    padding: 0.4rem 0.6rem;
  }

  #header-actions {
    margin-left: 0.5rem;
  }

  /* Batch bar mobile */
  .batch-bar {
    padding: 0.625rem 1rem;
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  .batch-delete-button {
    font-size: 13px;
    padding: 0.4rem 1rem;
  }

  .batch-clear-button {
    font-size: 12px;
    padding: 0.4rem 0.75rem;
  }
}

/* ===== Admin Settings Page ===== */

.admin-page {
  overflow: auto; /* Allow scrolling unlike main app */
  background: #000;
  color: #fff;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(0, 0, 0, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-title {
  font-size: 24px;
  font-weight: 600;
  color: #10b981;
}

.admin-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.admin-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Tabs */
.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 2rem;
}

.admin-tab {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.admin-tab:hover {
  color: rgba(255, 255, 255, 0.8);
}

.admin-tab.active {
  color: #10b981;
  border-bottom-color: #10b981;
}

/* Tab content */
.admin-tab-content {
  min-height: 200px;
}

.tab-placeholder {
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  padding: 3rem;
}

/* Settings form elements */
.settings-section {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.settings-section-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 1rem;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
}

.settings-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.settings-input {
  width: 100px;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  text-align: center;
  font-family: 'Courier New', monospace;
}

.settings-input:focus {
  outline: none;
  border-color: #10b981;
  background: rgba(255, 255, 255, 0.15);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 26px;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: #10b981;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

.toast-success {
  background: rgba(16, 185, 129, 0.9);
  color: #000;
}

.toast-error {
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
}

/* Admin form buttons (shared across tabs) */
.admin-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  min-height: 36px;
}

.admin-btn-primary {
  background: #10b981;
  color: #000;
}

.admin-btn-primary:hover {
  background: #0ea472;
}

.admin-btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.admin-btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.admin-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.admin-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Item list (shared: pose list, routine list) */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.item-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  transition: border-color 0.2s ease;
}

.item-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

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

.item-card-name {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.25rem;
}

.item-card-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-card-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: 1rem;
}

/* Form panel (used for create/edit forms) */
.form-panel {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-panel-title {
  font-size: 18px;
  font-weight: 600;
  color: #10b981;
  margin-bottom: 1.5rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-row label {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
}

.form-row input,
.form-row textarea,
.form-row select {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  outline: none;
  border-color: #10b981;
  background: rgba(255, 255, 255, 0.15);
}

.form-row textarea {
  resize: vertical;
  min-height: 60px;
}

.form-row select {
  cursor: pointer;
}

.form-row select option {
  background: #222;
  color: #fff;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* Angle inputs grid (for pose form) */
.angle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.angle-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.angle-input-group label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.angle-input-group input {
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #10b981;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  text-align: center;
  width: 100%;
}

.angle-input-group input:focus {
  outline: none;
  border-color: #10b981;
}

/* Confirm dialog overlay */
.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.confirm-dialog {
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
}

.confirm-dialog-title {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 1rem;
}

.confirm-dialog-message {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Step builder (for routine form) */
.step-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.step-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

.step-number {
  font-size: 14px;
  font-weight: 600;
  color: #10b981;
  min-width: 24px;
}

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

.step-pose-name {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

.step-details {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.step-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.step-btn {
  padding: 0.25rem 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}

.step-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Mobile responsive for admin page */
@media (max-width: 768px) {
  .admin-header {
    padding: 1rem;
  }

  .admin-title {
    font-size: 20px;
  }

  .admin-container {
    padding: 1rem 0.75rem;
  }

  .admin-tab {
    padding: 0.6rem 1rem;
    font-size: 14px;
  }

  .angle-grid {
    grid-template-columns: 1fr;
  }

  .item-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .item-card-actions {
    margin-left: 0;
    width: 100%;
  }

  .item-card-actions .admin-btn {
    flex: 1;
  }
}

/* ===== Segment Page - Color Legend Panel ===== */

/* Segment canvas container - takes remaining space */
#segment-container {
  flex: 1;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  min-width: 0; /* Allow flex shrink */
}

/* Segment canvas fills container */
#segment-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
}

/* Color legend panel styling - uses existing .data-panel base */
#color-legend {
  /* Additional styling specific to color legend */
}

/* Legend item color swatch */
.legend-color-swatch {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-right: 0.75rem;
  flex-shrink: 0;
}

/* Legend item container */
.legend-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

/* Legend label text */
.legend-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  flex: 1;
}

/* Legend color value (hex) */
.legend-value {
  font-size: 14px;
  font-weight: 600;
  font-family: 'Courier New', monospace;
  text-transform: lowercase;
}

/* Mobile responsive for segment page */
@media (max-width: 768px) {
  #segment-container {
    flex: 1;
    min-height: 50%; /* Segment canvas takes top half */
  }

  #color-legend {
    width: 100%;
    max-height: 40%;
    padding: 1rem;
  }
}

/* Color dashboard specific styles */
.scrollbar-hide {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;     /* Firefox */
}

.scrollbar-hide::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* Grid widget styles */
.grid-stack-item-content {
  background: white;
  border-radius: 0.375rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.grid-stack-item .ui-resizable-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 1rem;
  height: 1rem;
  cursor: se-resize;
  background: linear-gradient(135deg, transparent 50%, #6b7280 50%);
}

/* Filter interface styles */
#filter-bar-container input[type="range"] {
  height: 0.5rem;
  background: #e5e7eb;
  border-radius: 0.5rem;
  appearance: none;
  cursor: pointer;
}

#filter-bar-container input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  height: 1rem;
  width: 1rem;
  border-radius: 9999px;
  background: #3b82f6;
  cursor: pointer;
}

#filter-bar-container input[type="range"]::-moz-range-thumb {
  height: 1rem;
  width: 1rem;
  border-radius: 9999px;
  background: #3b82f6;
  cursor: pointer;
  border: 0;
}

#drilldown-panel {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#drilldown-panel.hidden {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

/* Chart point hover effects */
.chart-point-hover {
  cursor: pointer;
  transition: transform 0.1s ease;
}

.chart-point-hover:hover {
  transform: scale(1.2);
}

/* ===== Viewer Page Body ===== */

.viewer-page {
  overflow: auto;
  background: #000;
  color: #fff;
  min-height: 100vh;
}
