/* Accurate brand palette. Dark-first (navy + yellow); light override under [data-theme="light"]. */
:root {
  --bg: #001335;          /* deep navy backdrop */
  --surface: #002360;     /* Accurate Blue — header, cards, panels */
  --surface-2: #093a7d;   /* lighter navy — inputs, hover, marker bar */
  --text: #eef3fc;
  --muted: #a2a7c6;       /* Accurate Blue Grey */
  --border: #1c3f7e;
  --accent: #fff100;      /* Accurate Yellow — actions, timecodes */
  --accent-text: #002360; /* navy text on yellow */
  --link: #6db3ee;
  --radius: 12px;
  --ok: #2fbf71;          /* approved */
  --warn: #ffcf00;        /* in review (Accurate Dark Yellow) */
  --danger: #ff5d5d;      /* needs changes */
}

:root[data-theme="light"] {
  --bg: #eef1f8;
  --surface: #ffffff;
  --surface-2: #e6ebf5;
  --text: #002360;        /* Accurate Blue text */
  --muted: #5b6486;
  --border: #cdd6ea;
  --accent: #ffcf00;      /* dark yellow reads better on white */
  --accent-text: #002360;
  --link: #0064a2;        /* Accurate Light Blue */
}

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

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header h1 { font-size: 1.1rem; margin: 0; }

/* Brand lockup: Accurate logo on a white chip + app wordmark */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-chip {
  background: #fff;
  border-radius: 9px;
  padding: 5px 9px;
  display: inline-flex;
  line-height: 0;
}
.brand-chip img { height: 30px; width: auto; display: block; }
.brand-name {
  font-size: 1.05rem; font-weight: 700; letter-spacing: 0.3px;
  color: var(--text);
}
.brand-name .accent { color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.build-stamp { font-size: 0.68rem; color: var(--muted); }

.header-right { display: flex; align-items: center; gap: 10px; }
#user-chip { font-size: 0.85rem; color: var(--muted); }

main { flex: 1; padding: 18px; max-width: 1200px; width: 100%; margin: 0 auto; }

.app-footer {
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
}
.muted { color: var(--muted); }

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 15px;
  min-height: 40px;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 700; }
button.primary:hover { filter: brightness(0.95); border-color: transparent; }
button.ghost { background: transparent; }
button:disabled { opacity: 0.45; cursor: not-allowed; border-color: var(--border); }
.icon-btn { min-height: 38px; padding: 6px 12px; font-size: 0.9rem; }

input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; min-height: 64px; }
select { width: auto; }

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

/* ---------- Auth ---------- */
.auth-card {
  max-width: 400px;
  margin: 8vh auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}
.auth-logo-chip {
  background: #fff;
  border-radius: 14px;
  padding: 18px 22px;
  display: inline-block;
  margin-bottom: 18px;
  line-height: 0;
}
.auth-logo-chip img { height: 70px; width: auto; display: block; }
.auth-card h2 { margin: 0 0 6px; }
.auth-card p { margin: 0 0 18px; }
.auth-card .row { display: flex; flex-direction: column; gap: 10px; }
.auth-note { margin-top: 14px; font-size: 0.9rem; }
.authform { display: flex; flex-direction: column; gap: 10px; text-align: left; margin-top: 4px; }
.auth-card .primary, .auth-card .ghost, .auth-card .btn-google { width: 100%; }
.auth-card > button { margin-top: 10px; }
.auth-err { color: var(--danger); font-size: 0.85rem; margin: 2px 0 0; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-weight: 600;
}
.btn-google:hover { border-color: #c0c4c9; background: #f8f9fa; }
.auth-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.85rem; margin: 12px 0 2px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.linkbtn { background: none; border: none; color: var(--link); min-height: auto; padding: 6px; font-size: 0.9rem; width: auto; }
.linkbtn:hover { text-decoration: underline; border: none; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar h2 { margin: 0; font-size: 1.25rem; }

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #000 center/contain no-repeat;
  display: flex; align-items: center; justify-content: center;
}
.thumb .play { font-size: 2rem; color: #fff; opacity: 0.85; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.thumb .dur {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0,0,0,.72); color: #fff; font-size: 0.78rem;
  padding: 2px 7px; border-radius: 6px;
}
.thumb .cc {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(0,0,0,.72); color: #fff; font-size: 0.78rem;
  padding: 2px 7px; border-radius: 6px;
}
.card-body { padding: 11px 12px 13px; }
.card-title { font-weight: 600; margin: 0 0 6px; word-break: break-word; }
.card-meta { font-size: 0.8rem; display: flex; justify-content: space-between; gap: 8px; align-items: center; }

/* Status pills */
.pill { font-size: 0.72rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.s-in_review { color: var(--warn); border-color: var(--warn); }
.s-approved { color: var(--ok); border-color: var(--ok); }
.s-needs_changes { color: var(--danger); border-color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* Toolbar breadcrumb + folder cards */
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-left h2 { margin: 0; font-size: 1.25rem; }
.folder-card { display: flex; flex-direction: column; }
.folder-ic { aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center; font-size: 3rem; background: var(--surface-2); }
.folder-del { background: none; border: none; color: var(--muted); min-height: auto; padding: 0 0 0 8px; cursor: pointer; font-size: 0.9rem; }
.folder-del:hover { color: var(--danger); }

/* ---------- Player ---------- */
.crumbs { margin-bottom: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  align-items: start;
}
.video-col { min-width: 0; }
.video-wrap { background: #000; border-radius: var(--radius); overflow: hidden; }
.video-wrap video { width: 100%; display: block; max-height: 70vh; background: #000; }

.marker-bar {
  position: relative; height: 14px; margin: 8px 2px 0;
  background: var(--surface-2); border-radius: 7px;
}
.marker {
  position: absolute; top: 0; width: 3px; height: 14px; background: var(--accent);
  border-radius: 2px; cursor: pointer; transform: translateX(-1px);
}
.marker:hover { width: 5px; }

/* Audit tabs (4 review passes + General) at the top of the comments column */
.audits { padding: 10px 8px 4px; border-bottom: 1px solid var(--border); }
.audits-head { font-weight: 600; margin: 2px 4px 8px; }
.audits-head #rc-count { font-weight: 400; font-size: 0.82rem; }
.audit-tab { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; margin-bottom: 4px; }
.audit-tab:hover { background: var(--surface-2); }
.audit-tab.active { background: var(--surface-2); border-color: var(--accent); }
.audit-name { flex: 1; font-size: 0.9rem; }
.cat-count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 0.72rem; display: inline-flex; align-items: center; justify-content: center; }
.cat-count:empty { display: none; }
.rc-box, .rc-spacer { width: 20px; height: 20px; flex: none; }
.rc-box { border: 2px solid var(--muted); border-radius: 6px; background: none; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; line-height: 1; cursor: pointer; min-height: 0; }
.rc-box:hover { border-color: var(--ok); }
.rc-box.done { background: var(--ok); border-color: var(--ok); color: #04210f; }
.rc-box.done::after { content: "✓"; }

.video-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 14px 0 4px; flex-wrap: wrap;
}
.video-head h2 { margin: 0; font-size: 1.15rem; word-break: break-word; }
.video-head .controls { display: flex; align-items: center; gap: 10px; }

/* Comments sidebar */
.comments-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
}
.comments-head { padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.comments-list { overflow-y: auto; padding: 6px; flex: 1; min-height: 340px; max-height: 65vh; }
.comment { padding: 10px 10px; border-radius: 10px; }
.comment:hover { background: var(--surface-2); }
.comment-row { display: flex; gap: 9px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
}
.comment-main { flex: 1; min-width: 0; }
.comment-meta { font-size: 0.82rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comment-meta .who { font-weight: 600; }
.comment-meta .when { color: var(--muted); }
.tc-badge {
  background: var(--accent); color: var(--accent-text);
  font-size: 0.74rem; font-weight: 700; padding: 1px 7px; border-radius: 6px;
  border: none; min-height: auto; cursor: pointer;
}
.comment-body { margin: 3px 0 4px; white-space: pre-wrap; word-break: break-word; }
.comment-attach { margin: 6px 0 4px; }
.comment-img { max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--border); display: block; cursor: pointer; }
.img-dl { background: none; border: none; padding: 3px 0 0; min-height: auto; color: var(--link); font-size: 0.8rem; cursor: pointer; }
.img-dl:hover { text-decoration: underline; }
.attach-thumb { height: 34px; max-width: 64px; border-radius: 6px; border: 1px solid var(--border); object-fit: cover; vertical-align: middle; margin-right: 6px; }
.comment-actions { display: flex; gap: 12px; font-size: 0.8rem; }
.comment-actions button { background: none; border: none; padding: 0; min-height: auto; color: var(--muted); }
.comment-actions button:hover { color: var(--accent); }
.edit-box { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 6px; }
.edit-box .edit-ta { min-height: 64px; width: 100%; }
.edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
.edit-actions button { min-height: 34px; padding: 6px 14px; }
.replies { margin: 6px 0 0 37px; border-left: 2px solid var(--border); padding-left: 8px; }
.reply-box, .composer { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.composer { border-top: 0; border-bottom: 1px solid var(--border); }
.composer .composer-row { display: flex; align-items: center; gap: 10px; }
.composer .send-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pin-time { font-size: 0.82rem; color: var(--muted); }
.pin-time b { color: var(--accent); }

/* ---------- Upload overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,8,28,.7);
  display: flex; align-items: center; justify-content: center;
}
.overlay-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 30px; text-align: center; min-width: 240px;
}
.spinner {
  width: 28px; height: 28px; margin: 0 auto 12px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Access requests (admin) ---------- */
.toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.access-panel { text-align: left; min-width: 340px; max-width: 480px; max-height: 80vh; overflow: auto; }
.access-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.access-head h3 { margin: 0; }
.access-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.access-who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; word-break: break-word; }
.access-actions { display: flex; gap: 8px; flex: none; }
.access-actions button { min-height: 34px; padding: 6px 12px; }
.ax-others { margin-top: 12px; }
.ax-others summary { cursor: pointer; padding: 8px 0; }

@media (max-width: 860px) {
  .player-layout { grid-template-columns: 1fr; }
  .comments-col { max-height: none; }
  .comments-list { max-height: 50vh; }
}
