:root {
  --bg-color: #0f172a;
  --sidebar-bg: rgba(15, 23, 42, 0.98);
  --card-bg: rgba(30, 41, 59, 0.6);
  --border-color: rgba(148, 163, 184, 0.15);

  --primary: #2dd4bf;
  --primary-hover: #14b8a6;
  --primary-glow: rgba(45, 212, 191, 0.3);

  --accent: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --danger: #ef4444;

  --radius: 12px;
  --font-family: 'Inter', sans-serif;
  --sidebar-width: 380px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background: radial-gradient(140% 120% at 10% 10%, rgba(61, 206, 211, 0.1), transparent 40%), radial-gradient(120% 120% at 90% 0%, rgba(59, 130, 246, 0.08), transparent 40%), var(--bg-color);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

input[type="date"], input[type="time"] {
  color-scheme: dark;
}

body.resizing { cursor: col-resize; user-select: none; }

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 100%;
  height: 100%;
  width: 100%;
}

.map-wrapper { position: relative; width: 100%; height: 100%; background: #020617; z-index: 1; }
#map { width: 100%; height: 100%; border-radius: 14px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.35); }
.map-tools {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 500;
  pointer-events: auto;
}
.map-btn {
  background: rgba(15,23,42,0.85);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(6px);
}
.map-btn:hover { border-color: rgba(255,255,255,0.18); transform: translateY(-1px); }
.map-btn:active { transform: translateY(0); }
.map-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(45,212,191,0.35); }

@media (max-width: 900px) {
  .app-layout { display: flex; flex-direction: column; overflow-y: auto; }
  body { overflow: auto; height: auto; min-height: 100vh; }
  .resizer { display: none !important; }

  .map-wrapper {
    min-height: 450px;
    height: 450px;
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
    z-index: 10;
  }

  .sidebar {
    height: auto;
    overflow: visible;
    flex: 1;
  }
}

.sidebar {
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 20;
  height: 100%;
  position: relative;
  min-width: 300px;
}

.resizer {
  position: absolute; right: -8px; top: 0; bottom: 0; width: 16px;
  cursor: col-resize; z-index: 100; transition: background 0.2s; display: flex; justify-content: center;
}
.resizer::after { content: ''; width: 2px; height: 100%; background: transparent; transition: background 0.2s; }
.resizer:hover::after, .sidebar:hover .resizer::after { background: var(--primary); opacity: 0.5; }

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: rgba(15, 23, 42, 0.4);
}

.brand { font-weight: 700; font-size: 20px; letter-spacing: -0.5px; color: var(--text-main); }
.brand span { color: var(--primary); }
.brand-container { display:flex; align-items:center; gap:10px; }
.login-box .brand-container { justify-content: center; align-items: center; gap: 18px; }
.login-brand { width: 100%; justify-content: center; }
.login-icon {width: 64px !important;height: 64px !important;stroke: var(--primary);stroke-width: 1px !important;margin-bottom: 32px;}
.login-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }

.sidebar-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.mode-tabs {
  display: flex;
  background: rgba(0,0,0,0.4);
  padding: 6px;
  border-radius: 14px;
  margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(45,212,191,0.35); }
.tab-btn.active {
  background: linear-gradient(135deg, rgba(45,212,191,0.12), rgba(59,130,246,0.18));
  color: var(--primary);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.06);
}

.viewer-frame {
  aspect-ratio: 16/9;
  background: radial-gradient(90% 120% at 30% 20%, rgba(45,212,191,0.1), rgba(59,130,246,0.08)), #020617;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 15px 50px rgba(0,0,0,0.45);
}

.viewer-frame img { width: 100%; height: 100%; object-fit: contain; z-index: 10; opacity: 0; transition: opacity 0.3s; display: none; }
.viewer-frame img.active { display: block; opacity: 1; }

.iframe-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: none;
  background: rgba(0,0,0,0.3);
  transition: all 0.3s;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.iframe-wrapper.active { display: flex; }
.iframe-wrapper:hover {
  background: rgba(0,0,0,0.5);
}
.iframe-wrapper:hover svg {
  transform: scale(1.1);
  transition: transform 0.2s;
}

.video-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  display: none;
}
.video-frame.active { display: block; }
.video-frame::-webkit-media-controls-timeline { background: rgba(255,255,255,0.05); }

.loading-spinner {
  position: absolute; width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.1); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 1s linear infinite; z-index: 5;
}
@keyframes spin { to { transform: rotate(360deg); } }

.live-badge {
  position: absolute; top: 12px; left: 12px;
  background: rgba(0,0,0,0.7); padding: 6px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 700; color: var(--text-main);
  z-index: 20; display: flex; align-items: center; gap: 8px;
  backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.1);
}
.status-dot { width: 8px; height: 8px; background: var(--text-muted); border-radius: 50%; transition: all 0.3s; }
.status-dot.live { background: #ef4444; box-shadow: 0 0 10px #ef4444; animation: pulse 2s infinite; }
.status-dot.loading { background: var(--primary); }
.status-dot.success { background: var(--primary); }
.status-dot.error { background: #f59e0b; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

.control-group {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.25));
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  transition: border-color 0.2s, transform 0.15s;
}
.control-group.hidden { display: none; }
.control-group:hover { border-color: rgba(255,255,255,0.12); transform: translateY(-1px); }
.control-group.collapsed { padding-bottom: 12px; }
.control-group.collapsed .control-body { display: none; }

.group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 700; margin-bottom: 4px;
  display: flex; justify-content: space-between; align-items: center;
}
.collapse-btn {
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,0.05);
  color: var(--text-main);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.collapse-btn:hover { border-color: rgba(255,255,255,0.15); background: rgba(255,255,255,0.08); }
.collapse-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(45,212,191,0.35); }

.custom-input {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  outline: none;
  transition: all 0.2s;
}
.custom-input:hover { border-color: rgba(255,255,255,0.2); }
.custom-input:focus { border-color: var(--primary); background: rgba(0,0,0,0.5); }
.custom-input:focus-visible { box-shadow: 0 0 0 2px rgba(45,212,191,0.3); outline: none; }
.custom-input + .custom-input { margin-top: 8px; }

.timeline-scroller { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent); }
.timeline-scroller::-webkit-scrollbar { display: none; }

.hour-chip {
  flex: 0 0 auto; min-width: 48px; height: 38px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); border-radius: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text-muted); transition: all 0.2s;
}
.hour-chip:hover { border-color: var(--text-muted); color: var(--text-main); }
.hour-chip.active { background: var(--primary); color: #0f172a; font-weight: 700; border-color: var(--primary); box-shadow: 0 0 15px var(--primary-glow); }

.slider-container {
  position: relative;
  padding: 10px 0;
}

.slider-track {
  position: relative;
  height: 24px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  border: 1px solid var(--border-color);
}

.slider-segment {
  width: 1px;
  height: 8px;
  background: rgba(255,255,255,0.1);
}
.slider-segment.major { height: 14px; background: rgba(255,255,255,0.3); }

input[type=range] {
  -webkit-appearance: none;
  position: absolute;
  top: 10px; left: 0;
  width: 100%;
  height: 24px;
  background: transparent;
  z-index: 2;
  cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 28px; width: 14px;
  background: var(--primary);
  border-radius: 3px;
  border: 1px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  margin-top: -2px;
}

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; }
.btn {
  border: none; padding: 14px; border-radius: 8px; font-weight: 600; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(45,212,191,0.35); }

.btn-primary { background: var(--primary); color: #0f172a; box-shadow: 0 4px 12px rgba(45, 212, 191, 0.2); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 6px 16px rgba(45, 212, 191, 0.3); }

.btn-secondary { background: rgba(255,255,255,0.05); color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: var(--text-muted); }
.btn-secondary:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(45,212,191,0.35); }
@media (hover: none) {
  .btn:hover, .ghost-btn:hover { transform: none; border-color: var(--border-color); }
}

.icon { width: 18px; height: 18px; stroke-width: 2.5; }
.help-link { font-size: 11px; color: var(--accent); text-decoration: none; margin-top: 6px; display: inline-block; border-bottom: 1px dashed var(--accent); cursor: pointer; }

.viewer-meta { display:flex; justify-content:space-between; align-items:center; margin-top:12px; gap: 12px; }
.viewer-meta-left { display:flex; flex-direction:column; width:100%; gap:6px; }
.status-text { font-size:12px; color:var(--text-muted); font-weight:500; }
.viewer-meta-right { display:flex; align-items:center; gap: 8px; white-space: nowrap; }
.url-preview { font-family:monospace; opacity:0.7; font-size:11px; color:var(--text-muted); max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-main);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-color);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.viewer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.ghost-btn:hover { color: var(--text-main); border-color: rgba(255,255,255,0.2); }

#loginScreen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 100% at 10% 20%, rgba(45,212,191,0.18), transparent 40%), radial-gradient(120% 120% at 90% 10%, rgba(59,130,246,0.12), transparent 50%);
  filter: blur(40px);
}

#loginScreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-box {
  background: var(--sidebar-bg);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 42px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.55);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: stretch;
}

.login-box::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.04);
  pointer-events: none;
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
  text-align: left;
}
.login-title span { color: var(--primary); }

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 26px;
  text-align: left;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 16px;
  outline: none;
  transition: all 0.2s;
}

.login-input:focus {
  border-color: var(--primary);
  background: rgba(0,0,0,0.5);
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #2dd4bf, #3b82f6);
  color: #0f172a;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 12px 30px rgba(59,130,246,0.35);
}

.login-btn:hover {
  background: linear-gradient(135deg, #3be3cf, #5a96ff);
  transform: translateY(-1px);
}

.login-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 12px;
  text-align: center;
  display: none;
}
