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

:root,
[data-theme="dark"] {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --accent: #f59e0b;
  --accent-dim: rgba(245, 158, 11, 0.15);
  --text: #e0e0e0;
  --text-dim: #777;
}

[data-theme="light"] {
  --bg: #f2f2f2;
  --surface: #ffffff;
  --surface2: #e8e8e8;
  --border: #d0d0d0;
  --accent: #d97706;
  --accent-dim: rgba(217, 119, 6, 0.1);
  --text: #1a1a1a;
  --text-dim: #666666;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

#title {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

h1 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#site-name {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

#app-version {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-family: 'Courier New', monospace;
  opacity: 0.6;
}

#download-btn {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

#download-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#download-btn.unavailable {
  opacity: 0.3;
  pointer-events: none;
}

#log-btn {
  font-size: 0.8rem;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

#log-btn:hover,
#log-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

#theme-btn {
  font-size: 1rem;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
}

#theme-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Log panel */

#log-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 0.25rem;
}

#log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#log-clear {
  font-size: 0.75rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  padding: 0.15rem 0.5rem;
  cursor: pointer;
}

#log-clear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#log-entries {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  padding: 0.6rem 0.85rem;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
}

.log-entry {
  display: grid;
  grid-template-columns: 5.5rem 4rem 1fr;
  gap: 0.5rem;
  padding: 0.1rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.log-time { color: var(--text-dim); }

.log-level { font-weight: 600; }
.log-level.INFO    { color: #6b9e6b; }
.log-level.WARNING { color: var(--accent); }
.log-level.ERROR   { color: #e06c6c; }

.log-msg { color: var(--text); word-break: break-word; white-space: pre-wrap; }

.log-empty {
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  padding: 0.75rem 0;
}

#controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  font-size: 0.875rem;
  cursor: pointer;
  outline: none;
}

select:focus {
  border-color: var(--accent);
}

#status {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 1.25rem auto;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Video */

#video-container {
  position: relative;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

#player {
  width: 100%;
  height: 100%;
  display: block;
}

#no-video,
#loading {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}

#no-video.visible,
#loading.visible {
  display: flex;
}

/* Demo banner */

#demo-banner {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  color: var(--accent);
  text-align: center;
  letter-spacing: 0.04em;
}

/* Timeline */

#timeline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem 0.5rem;
}

#timeline-bar {
  position: relative;
  height: 20px;
  background: var(--surface2);
  border-radius: 3px;
  cursor: pointer;
  margin-bottom: 0.35rem;
  overflow: visible;
}

.timeline-segment {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--accent);
  opacity: 0.75;
  border-radius: 2px;
  min-width: 3px;
  transition: opacity 0.15s;
}

.timeline-segment:hover {
  opacity: 1;
}

#timeline-cursor {
  position: absolute;
  top: -3px;
  width: 2px;
  height: calc(100% + 6px);
  background: #fff;
  border-radius: 1px;
  pointer-events: none;
  transform: translateX(-50%);
  z-index: 2;
  display: none;
}

#timeline-labels {
  position: relative;
  height: 14px;
}

.timeline-label {
  position: absolute;
  font-size: 0.68rem;
  color: var(--text-dim);
  transform: translateX(-50%);
  white-space: nowrap;
  user-select: none;
}

/* Clip list */

#clip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.clip-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.clip-item:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.clip-item.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.clip-time {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.clip-dur {
  color: var(--text-dim);
  font-size: 0.73rem;
}

.no-clips {
  color: var(--text-dim);
  font-size: 0.875rem;
  padding: 0.25rem;
}

/* Footer */

footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-dim);
}

#footer-credit a {
  color: var(--text-dim);
  text-decoration: none;
}

#footer-credit a:hover {
  color: var(--accent);
}

#footer-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Auth modal */

#auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#auth-modal[hidden] {
  display: none;
}

#auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem 2.25rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#auth-card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}

#auth-site-name {
  margin: 0 0 0.5rem;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#auth-password {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  outline: none;
  width: 100%;
}

#auth-password:focus {
  border-color: var(--accent);
}

#auth-form button {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 0.55rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

#auth-form button:hover {
  opacity: 0.85;
}

#auth-error {
  font-size: 0.8rem;
  color: #e06c6c;
  min-height: 1.2em;
  margin: 0;
}
