:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-raised: #cfe2f3;
  --line: #a9c8e0;
  --ink: #000000;
  --muted: #4c5b6b;
  --accent: #1155cc;
  --accent-rgb: 17, 85, 204;
  --accent-ink: #ffffff;
  --error: #c5221f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
}

h1, h2, h3 {
  font-family: "Big Shoulders Display", "Segoe UI", sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
}

code, .mono, .timecode {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

.hidden { display: none !important; }

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---- shell layout ---- */

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.bin {
  width: 272px;
  flex-shrink: 0;
  background: var(--panel-raised);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.bin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bin-brand h1 {
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
  flex-shrink: 0;
}

.new-capture {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 4px;
  padding: 11px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.new-capture:hover { filter: brightness(1.08); }

.bin-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.bin-label {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 10px;
}

.bin-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.bin-empty { margin-top: 4px; }

.bin-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 7px 8px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}

.bin-item:hover, .bin-item.active {
  background: var(--panel);
  border-color: var(--line);
}

.bin-item.active {
  border-color: var(--accent);
}

.bin-thumb {
  width: 40px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 2px;
  background: var(--bg) center/cover no-repeat;
  border: 1px solid var(--line);
  position: relative;
}

.bin-thumb.empty {
  background-image: repeating-linear-gradient(
    45deg, var(--line) 0 4px, transparent 4px 8px
  );
}

.bin-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.bin-meta .bin-time {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bin-meta .bin-status {
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.status-dot.live {
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

.bin-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.bin-account .hint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  flex-shrink: 0;
}

.link-btn:hover { color: var(--ink); }

/* ---- stage ---- */

.stage {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 80px;
  max-width: 940px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.panel-title {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.count {
  color: var(--muted);
  font-weight: 400;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.panel-header-row .panel-title { margin-bottom: 0; }

.button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}

.button.secondary:hover { background: var(--panel-raised); }

.button.small {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.video-preview {
  width: 100%;
  max-height: 480px;
  border-radius: 4px;
  background: #000;
  display: block;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  min-height: 38px;
}

.rec-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rec-row p {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb, 0), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 4px;
  padding: 10px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}

.button:hover { filter: brightness(1.08); }

.error p { color: var(--error); }

/* ---- loader gate (dropzone) ---- */

.loader-gate {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  background: var(--panel-raised);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.loader-gate:hover, .loader-gate.dragover {
  border-color: var(--accent);
  background: #e3edf8;
}

.upload-icon {
  color: var(--accent);
  margin-bottom: 10px;
}

.loader-gate .gate-title {
  font-family: "Big Shoulders Display", sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  margin: 0 0 6px;
}

.loader-gate p.hint { margin: 0; }

.gate-formats { margin-top: 6px !important; }

.browse-link {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
}

/* ---- transcript ---- */

.transcript {
  white-space: pre-wrap;
  line-height: 1.6;
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--ink);
}

/* ---- contact sheet ---- */

.contact-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.frame-cell {
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 6px;
}

.sprocket {
  height: 6px;
  border-radius: 1px;
  background-color: var(--line);
  background-image: repeating-linear-gradient(
    to right, var(--panel-raised) 0 4px, transparent 4px 9px
  );
  margin-bottom: 6px;
}

.sprocket.bottom { margin-bottom: 0; margin-top: 6px; }

.frame-cell img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  border-radius: 1px;
}

.frame-cell .timecode {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
}

/* ---- auth pages ---- */

.auth-wrap {
  max-width: 380px;
  margin: 0 auto;
  padding: 96px 24px 48px;
}

.auth-wrap .bin-brand {
  margin-bottom: 8px;
}

.auth-wrap .subtitle {
  color: var(--muted);
  margin: 0 0 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-form input {
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
}

.auth-form input:focus-visible {
  border-color: var(--accent);
}

.error-text { color: var(--error); }

/* ---- responsive ---- */

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }

  .bin {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
  }

  .bin-brand { flex-shrink: 0; }
  .new-capture { flex-shrink: 0; }

  .bin-section {
    order: 3;
    width: 100%;
    flex: none;
  }

  .bin-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .bin-item { flex-shrink: 0; width: 200px; }

  .bin-account {
    order: 2;
    margin-left: auto;
    border-top: none;
    padding-top: 0;
  }

  .stage { padding: 24px 20px 60px; }
}
