* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0a0a0f; color: #e0e0e0; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }

/* Nav */
nav { background: #12121e; padding: 0 12px; display: flex; align-items: center; gap: 8px; height: 56px; border-bottom: 1px solid #1e1e2e; position: sticky; top: 0; z-index: 50; }
nav h1 { font-size: 16px; font-weight: 700; color: #e94560; letter-spacing: 0.5px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
nav h1::before { content: '\01F98A'; font-size: 18px; }
.hamburger { display: none; background: none; border: none; color: #6b6b80; font-size: 22px; padding: 4px 6px; cursor: pointer; border-radius: 6px; flex-shrink: 0; }
.hamburger:hover { color: #e0e0e0; background: #1e1e2e; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a { color: #6b6b80; text-decoration: none; font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 6px; transition: all 0.15s; white-space: nowrap; }
.nav-links a:hover { color: #e0e0e0; background: #1e1e2e; }
.nav-links a.active { color: #e94560; background: rgba(233,69,96,0.1); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.nav-status { font-size: 12px; color: #6b6b80; display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.green { background: #4ecdc4; box-shadow: 0 0 5px rgba(78,205,196,0.5); }
.dot.red { background: #e94560; box-shadow: 0 0 5px rgba(233,69,96,0.5); }
.nav-backdrop { display: none; }

/* Status bar */
.status-bar { background: #12121e; border-bottom: 1px solid #1e1e2e; padding: 6px 12px; display: flex; align-items: center; gap: 8px; font-size: 11px; color: #6b6b80; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.status-bar::-webkit-scrollbar { display: none; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot.alive { background: #4ecdc4; box-shadow: 0 0 6px rgba(78,205,196,0.5); }
.status-dot.dead { background: #e94560; box-shadow: 0 0 6px rgba(233,69,96,0.5); }
.sep { color: #2e2e42; font-size: 10px; }
.status-spacer { flex: 1; min-width: 8px; }
.badge-sm { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #1e1e2e; flex-shrink: 0; }
.stat-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main */
main { padding: 16px; max-width: 1400px; margin: 0 auto; }

/* Dashboard stats */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.stat-card { background: #12121e; border: 1px solid #1e1e2e; border-radius: 10px; padding: 12px; }
.stat-card .stat-value { font-size: 20px; font-weight: 700; color: #fff; }
.stat-card .stat-label { font-size: 10px; color: #505060; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.filter-group { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.filter-group::-webkit-scrollbar { display: none; }
.filter-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 20px; font-size: 11px; font-weight: 600; text-decoration: none; color: #6b6b80; background: #12121e; border: 1px solid #1e1e2e; transition: all 0.15s; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.filter-btn:active { transform: scale(0.96); }
.filter-btn.active { color: #fff; background: #e94560; border-color: #e94560; }
.filter-btn.badge.fox { color: #e94560; }
.filter-btn.badge.fox.active { color: #fff; background: #e94560; border-color: #e94560; }
.filter-btn.badge.cat { color: #f5a623; }
.filter-btn.badge.cat.active { color: #fff; background: #f5a623; border-color: #f5a623; }
.filter-btn.badge.dog { color: #4ecdc4; }
.filter-btn.badge.dog.active { color: #fff; background: #4ecdc4; border-color: #4ecdc4; }

/* Clip grid */
.clip-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.clip-card { background: #12121e; border: 1px solid #1e1e2e; border-radius: 10px; overflow: hidden; transition: border-color 0.15s; position: relative; }
.clip-card:active { border-color: #2e2e42; }
.clip-preview { position: relative; background: #000; aspect-ratio: 16/9; overflow: hidden; }
.clip-preview video, .clip-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-preview .play-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.25); opacity: 0; transition: opacity 0.2s; cursor: pointer; }
.clip-preview:hover .play-overlay { opacity: 1; }
@media (hover: none) {
  .clip-preview .play-overlay { opacity: 1; background: rgba(0,0,0,0.15); }
}
.clip-preview .play-overlay svg { width: 40px; height: 40px; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5)); }

/* Seek bar */
.seek-bar { position: absolute; bottom: 0; left: 0; right: 0; display: none; align-items: center; gap: 6px; padding: 3px 8px; background: linear-gradient(transparent, rgba(0,0,0,0.6)); cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none; z-index: 2; }
.seek-bar.active { display: flex; }
.seek-track { flex: 1; height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px; overflow: hidden; }
.seek-fill { height: 100%; width: 0; background: #e94560; border-radius: 2px; transition: width 0.1s linear; }
.seek-time { font-size: 10px; color: rgba(255,255,255,0.7); font-variant-numeric: tabular-nums; min-width: 65px; text-align: right; }
.seek-sep { color: rgba(255,255,255,0.35); }
.clip-info { padding: 10px 12px; }
.clip-info-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; min-width: 0; }
.clip-info .filename { font-size: 11px; color: #6b6b80; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.clip-info-bottom { display: flex; align-items: center; justify-content: space-between; }
.clip-info-bottom .size { font-size: 11px; color: #505060; }

/* Delete button - always visible on touch devices */
.delete-btn { margin-left: auto; flex-shrink: 0; opacity: 0.5; }
@media (hover: hover) {
  .delete-btn { opacity: 0; }
  .clip-card:hover .delete-btn { opacity: 1; }
}

/* Badge */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 20px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.badge.fox { background: rgba(233,69,96,0.2); color: #e94560; }
.badge.cat { background: rgba(245,166,35,0.2); color: #f5a623; }
.badge.dog { background: rgba(78,205,196,0.2); color: #4ecdc4; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; text-decoration: none; font-size: 12px; font-weight: 500; background: #1e1e2e; color: #c0c0d0; border: 1px solid #2e2e42; cursor: pointer; transition: all 0.15s; touch-action: manipulation; }
.btn:active { transform: scale(0.96); }
.btn.primary { background: #e94560; border-color: #e94560; color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 11px; }
.btn.danger { background: rgba(233,69,96,0.15); border-color: rgba(233,69,96,0.3); color: #e94560; }
.btn-icon { padding: 6px; min-width: 32px; min-height: 32px; justify-content: center; background: none; border: none; color: #505060; cursor: pointer; font-size: 13px; border-radius: 4px; transition: all 0.15s; touch-action: manipulation; }
.btn-icon:active { background: rgba(233,69,96,0.1); }
.btn-icon.danger { color: #505060; }
.btn-icon.danger:active { color: #e94560; background: rgba(233,69,96,0.1); }

/* Download link */
.download-link { text-decoration: none; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; }
.page-info { font-size: 12px; color: #505060; white-space: nowrap; }

/* Empty state */
.empty { text-align: center; padding: 48px 24px; color: #505060; }
.empty svg { margin-bottom: 12px; opacity: 0.3; }
.empty p { font-size: 14px; }
.empty .sub { font-size: 12px; margin-top: 6px; color: #3a3a4a; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #1a1a28; border: 1px solid #2e2e42; border-radius: 12px; padding: 24px; max-width: 400px; width: 100%; }
.modal h3 { font-size: 16px; margin-bottom: 8px; }
.modal p { font-size: 13px; word-break: break-all; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.modal .modal-actions .btn { min-width: 80px; justify-content: center; }
.modal .sub { color: #6b6b80; }

/* Zone editor */
.zone-editor { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.canvas-wrap { background: #0a0a0f; border-radius: 10px; overflow: hidden; border: 1px solid #1e1e2e; min-height: 300px; position: relative; }
.canvas-wrap .snapshot-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #505060; font-size: 13px; }
.canvas-wrap .snapshot-loading .spinner { width: 32px; height: 32px; border: 3px solid #1e1e2e; border-top-color: #e94560; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#zoneCanvas { width: 100%; display: block; cursor: crosshair; }
.zone-controls { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.zone-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.zone-item { background: #12121e; border: 1px solid #1e1e2e; border-radius: 8px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.zone-item .color-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.zone-item .zone-name { flex: 1; font-size: 13px; font-weight: 500; }
.zone-item .zone-name .hint { font-size: 11px; color: #505060; font-weight: 400; }
.zone-item .zone-remove { background: none; border: none; color: #505060; cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 4px; }
.zone-actions { display: flex; gap: 8px; }
.zone-actions .btn { flex: 1; justify-content: center; }
.help { color: #505060; font-size: 12px; line-height: 1.5; }
.help kbd { background: #1e1e2e; padding: 1px 6px; border-radius: 3px; font-size: 11px; border: 1px solid #2e2e42; }

/* Tooltip */
[data-tooltip] { position: relative; }
@media (hover: hover) {
  [data-tooltip]:hover::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: #1e1e2e; color: #c0c0d0; padding: 4px 10px; border-radius: 4px; font-size: 11px; white-space: nowrap; border: 1px solid #2e2e42; pointer-events: none; z-index: 10; }
}

/* Tablet+ */
@media (min-width: 600px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .clip-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .zone-editor { flex-direction: row; }
  .zone-controls { width: 280px; flex-shrink: 0; }
  .canvas-wrap { min-height: 400px; flex: 1; }
}

@media (min-width: 1024px) {
  .clip-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  main { padding: 24px; }
  nav { padding: 0 24px; gap: 32px; }
  .status-bar { padding: 8px 24px; }
  .stats { gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 24px; }
}

/* Mobile nav overlay */
@media (max-width: 599px) {
  .hamburger { display: block; }
  .nav-links { position: fixed; top: 56px; left: 0; right: 60%; bottom: 0; background: #12121e; flex-direction: column; align-items: stretch; padding: 8px; gap: 2px; transform: translateX(-100%); transition: transform 0.2s ease; z-index: 60; border-right: 1px solid #1e1e2e; }
  .nav-links.open { transform: translateX(0); }
  .nav-links a { padding: 12px 16px; font-size: 15px; border-radius: 8px; }
  .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 55; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
  .nav-backdrop.open { opacity: 1; pointer-events: auto; }
  .nav-label { display: none; }
  .filter-group { gap: 6px; }
  .filter-btn { font-size: 10px; padding: 4px 10px; }
}
