:root {
  --bg: #0f1115;
  --panel: #151824;
  --muted: #9aa3b2;
  --text: #e9edf1;
  --accent: #4f8cff;
  --accent-2: #6dd3a6;
  --danger: #ff6b6b;
  --border: #24293a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .right { display: flex; align-items: center; gap: 8px; }
.topbar .brand { display: flex; flex-direction: column; gap: 2px; }
.topbar .watermark { position: static; right: auto; bottom: auto; z-index: auto; pointer-events: auto; cursor: pointer; opacity: 0.7; }

.file-input {
  position: relative;
  display: inline-block;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.file-input input { display: none; }
.secondary { background: transparent; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "player";
  gap: 0;
  min-height: calc(100% - 52px);
}

.player { grid-area: player; padding: 12px; }

video {
  width: 100%;
  max-height: 48vh;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.video-row { display: flex; gap: 12px; align-items: stretch; }
.video-row .video-wrap { flex: 1 1 0; }

.video-stage { position: relative; display: inline-block; overflow: hidden; }
.video-stage { touch-action: none; }
.video-stage .zoom-layer { position: relative; width: 100%; height: 100%; will-change: transform; }
.video-stage.dragging { cursor: grabbing; }
.video-stage .overlay { pointer-events: none; }
.video-stage.glow-red { box-shadow: 0 0 0 2px rgba(255,107,107,0.6), 0 0 14px rgba(255,107,107,0.35); border-radius: 10px; }
.video-stage.glow-green { box-shadow: 0 0 0 2px rgba(109,211,166,0.6), 0 0 14px rgba(109,211,166,0.35); border-radius: 10px; }
.video-stage.glow-red > video { border-color: var(--danger); }
.video-stage.glow-green > video { border-color: var(--accent-2); }
.video-stage .overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: screen; z-index: 2; }

.video-mini-controls { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.video-mini-controls input[type=range] { flex: 1 1 auto; min-width: 120px; }

.controls { margin-top: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.row { display: flex; gap: 8px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.row.steps button { flex: 1 1 auto; min-width: 60px; }
.row.scrub input[type=range] { width: 100%; }
.row.status { justify-content: space-between; }
.sep { color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
.row.shortcuts { line-height: 1.2; }

/* Export status under video */
.export-status {
  margin-top: 6px;
  color: var(--danger);
  font-weight: 600;
}

/* Elapsed timer above flags list */
.elapsed-timer {
  font-size: 20px;
  font-weight: 700;
  padding: 8px 12px;
}

/* Waveform */
.waveform-controls { justify-content: flex-end; }
.waveform { margin-top: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.waveform canvas { width: 100%; height: 80px; display: block; cursor: pointer; }
.waveform.glow-red { box-shadow: 0 0 0 2px rgba(255,107,107,0.6), 0 0 12px rgba(255,107,107,0.35); border-color: var(--danger); }
.waveform.glow-green { box-shadow: 0 0 0 2px rgba(109,211,166,0.6), 0 0 12px rgba(109,211,166,0.35); border-color: var(--accent-2); }

.watermark {
  position: fixed;
  right: 12px;
  bottom: 72px; /* keep above BuyMeACoffee widget */
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  pointer-events: none;
  z-index: 2147483647; /* ensure above third-party widgets */
}

button {
  background: #1b2030;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
button:hover:enabled { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

label.fps { display: inline-flex; align-items: center; gap: 6px; background: #1b2030; border: 1px solid var(--border); border-radius: 8px; padding: 2px 6px; }
label.fps input { width: 80px; color: var(--text); background: transparent; border: none; outline: none; }

.flagging { margin-top: 10px; }

.flags {
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.flags-header, .flags-footer { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; }
.presets { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.flags-body { overflow: auto; max-height: none; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; }
td.actions { text-align: right; }
td input.label-edit { width: 100%; background: transparent; color: var(--text); border: 1px dashed var(--border); border-radius: 6px; padding: 4px 6px; }

@media (min-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas: "player";
    gap: 12px;
  }
}

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal.hidden { display: none !important; }
.modal-dialog { width: min(92vw, 420px); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 12px; }
.icon-btn { background: transparent; border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 6px 8px; cursor: pointer; }
.qr-wrap { display: flex; align-items: center; justify-content: center; padding: 10px 0; }
.qr-wrap img { width: 240px; height: 240px; background: #fff; border-radius: 6px; border: 1px solid var(--border); }
.small { font-size: 12px; }
.settings-textarea { width: 100%; min-height: 120px; background: #0f1115; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.button-link { text-decoration: none; background: #1b2030; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: inline-block; }
.button-link:hover { border-color: var(--accent); }

/* Site footer — CustomWare credit (styled after FireTV / EX-PU) */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 22px 16px calc(72px + env(safe-area-inset-bottom)); /* clear the floating widget */
  margin-top: 16px;
}
.site-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-credit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: opacity 0.2s ease;
}
.footer-credit:hover { opacity: 0.85; }
.footer-credit .text-shimmer { font-size: 12px; letter-spacing: 0.02em; }
.footer-logo { height: 22px; width: auto; display: block; }
.site-footer-copy {
  max-width: 1100px;
  margin: 14px auto 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.site-footer-copy a { color: var(--muted); text-decoration: none; }
.site-footer-copy a:hover { color: var(--accent); }

/* Shimmer credit text (mirrors FireTV's .text-shimmer, tuned to app accent) */
.text-shimmer {
  background: linear-gradient(90deg, var(--muted) 0%, var(--accent) 25%, var(--muted) 50%, var(--accent) 75%, var(--muted) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  animation: shimmer 4s linear infinite;
}
@keyframes shimmer {
  to { background-position: 200% center; }
}
@media (prefers-reduced-motion: reduce) {
  .text-shimmer { animation: none; }
}
