:root {
  --ink: #17233a;
  --paper: #edf0f3;
  --panel: #ffffff;
  --line: #d2d8e0;
  --muted: #5d6a7e;
  --signal: #b77f00;
  --signal-soft: #fdf3dc;
  --sent: #1e7a4c;
  --sent-soft: #e3f3ea;
  --fault: #b3362f;
  --fault-soft: #fbe7e5;
  --focus: #2f6fd6;
  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;
  --radius-large: 14px;
  --radius-small: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--body);
}

h1, h2, .wordmark { font-family: var(--display); letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 2rem; font-weight: 750; line-height: 1.1; margin-bottom: 1.5rem; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.75rem; }
.wordmark { font-weight: 750; font-size: 1.375rem; }
.muted { color: var(--muted); }

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

/* ---------- Buttons ---------- */
.button {
  font: 700 0.9375rem/1 var(--body);
  border-radius: var(--radius-small);
  border: 1.5px solid var(--ink);
  padding: 0.75rem 1.125rem;
  cursor: pointer;
  background: transparent;
  color: var(--ink);
}
.button-primary { background: var(--ink); color: #fff; }
.button-primary:hover { background: #24345a; }
.button-primary:disabled { opacity: 0.55; cursor: progress; }
.button-quiet { border-color: transparent; padding: 0.5rem 0.75rem; }
.button-quiet:hover { border-color: var(--line); }
.button-small { padding: 0.4rem 0.7rem; font-size: 0.8125rem; }
.button-danger { color: var(--fault); border-color: var(--fault); }

/* ---------- Page frame ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar form { margin: 0; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  padding: clamp(1rem, 4vw, 2.5rem);
  max-width: 1240px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.composer {
  background: var(--panel);
  border-radius: var(--radius-large);
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--line);
}
.side { display: grid; gap: 2rem; }

.notice {
  max-width: 1240px;
  margin: 1rem auto 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-small);
  background: var(--sent-soft);
  color: var(--sent);
  width: calc(100% - 2 * clamp(1rem, 4vw, 2.5rem));
}
.notice-error { background: var(--fault-soft); color: var(--fault); }

/* ---------- Form ---------- */
form { display: grid; gap: 1.5rem; }
label, legend { font-weight: 700; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 0.625rem; }

input[type='text'], input[type='email'], input[type='password'], input[type='datetime-local'], textarea, select {
  width: 100%;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-small);
  padding: 0.65rem 0.75rem;
}
input:focus, textarea:focus, select:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgb(47 111 214 / 0.25); }
textarea { resize: vertical; min-height: 7rem; }

.field { display: grid; gap: 0.4rem; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.hint { font-size: 0.8125rem; color: var(--muted); }
.lane-collab { color: var(--muted); }
.counter { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--fault); font-weight: 700; }

/* Video picker */
.dropzone {
  display: block;
  border: 2px dashed var(--line);
  border-radius: var(--radius-large);
  padding: 1.5rem;
  cursor: pointer;
  font-weight: 400;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--ink); background: #f6f8fa; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone-empty { display: grid; gap: 0.25rem; text-align: center; padding: 1.5rem 0; }
.dropzone-empty strong { font-family: var(--display); font-size: 1.25rem; }
.dropzone-filled { display: grid; grid-template-columns: minmax(7.5rem, 14rem) 1fr; gap: 1rem; align-items: center; }
.dropzone-filled video { width: 100%; max-height: 16rem; object-fit: contain; border-radius: var(--radius-small); background: var(--ink); }
.photo-picker { display: grid; gap: 0.875rem; }
.photo-summary { display: grid; gap: 0.15rem; }
.photo-summary > span:first-child { font-weight: 700; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: 0.625rem; }
.photo-tile { position: relative; display: grid; gap: 0.3rem; }
.photo-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-small); background: var(--paper); border: 1px solid var(--line); }
.photo-tile.is-cover img { outline: 3px solid var(--signal); outline-offset: -3px; }
.photo-badge { position: absolute; top: 0.35rem; left: 0.35rem; background: var(--ink); color: #fff; font-size: 0.6875rem; font-weight: 700; padding: 0.1rem 0.45rem; border-radius: 999px; }
.photo-actions { display: flex; justify-content: space-between; gap: 0.25rem; }
.photo-actions button { flex: 1; font: 700 0.8125rem/1 var(--body); padding: 0.35rem 0; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: var(--radius-small); cursor: pointer; }
.photo-actions button:hover:not(:disabled) { border-color: var(--ink); }
.photo-actions button:disabled { opacity: 0.35; cursor: default; }
.photo-actions .photo-remove { color: var(--fault); }
.file-meta { display: grid; gap: 0.25rem; word-break: break-word; }

/* Destination tiles: the one bold element. Each tile is a real checkbox. */
.route-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.625rem; }
.route {
  position: relative;
  display: grid;
  gap: 0.15rem;
  padding: 0.875rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-small);
  cursor: pointer;
  font-weight: 400;
}
.route input { position: absolute; opacity: 0; }
.route-name { font-family: var(--display); font-weight: 600; font-size: 1.0625rem; }
.route-account { font-size: 0.8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route:has(input:checked) { background: var(--ink); border-color: var(--ink); color: #fff; }
.route:has(input:checked) .route-account { color: #c4cddc; }
.route:has(input:checked)::after {
  content: '';
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: #f5c044;
}
.route:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.route.is-unavailable { cursor: not-allowed; opacity: 0.55; border-style: dashed; }

.overrides summary { cursor: pointer; font-weight: 700; }
#override-fields { display: grid; gap: 1rem; margin-top: 1rem; }

.when { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; align-items: center; }
.when legend { width: 100%; }
.choice { font-weight: 400; display: inline-flex; gap: 0.4rem; align-items: center; cursor: pointer; }
.when input[type='datetime-local'] { width: auto; }

.form-errors {
  margin: 0;
  padding: 0.75rem 1rem 0.75rem 2rem;
  background: var(--fault-soft);
  color: var(--fault);
  border-radius: var(--radius-small);
}

.submit-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.progress { flex: 1 1 12rem; height: 0.5rem; background: var(--paper); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--ink); transition: width 0.2s; }

/* ---------- Accounts ---------- */
.accounts, .queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.625rem; }
.account {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
}
.account-text { display: grid; min-width: 0; }
.account-name { font-weight: 700; }
.account-detail { font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; }
.account-warning { font-size: 0.8125rem; color: var(--signal); }
.account-actions { display: flex; gap: 0.375rem; flex-shrink: 0; }
.account-actions a { text-decoration: none; }

/* ---------- Queue ---------- */
.queue-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 1rem;
  display: grid;
  gap: 0.625rem;
}
.queue-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.queue-title { font-weight: 700; overflow-wrap: anywhere; }
.queue-when { font-size: 0.8125rem; color: var(--muted); }
.badge { font-size: 0.75rem; font-weight: 700; padding: 0.2rem 0.55rem; border-radius: 999px; white-space: nowrap; }
.badge-scheduled, .badge-publishing { background: var(--signal-soft); color: var(--signal); }
.badge-published { background: var(--sent-soft); color: var(--sent); }
.badge-partial, .badge-failed { background: var(--fault-soft); color: var(--fault); }

.lanes { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.375rem; }
.lane { display: grid; grid-template-columns: 0.625rem 6rem 1fr; gap: 0.5rem; align-items: baseline; font-size: 0.875rem; }
.lane-dot { width: 0.625rem; height: 0.625rem; border-radius: 50%; background: var(--line); align-self: center; }
.lane-running .lane-dot { background: var(--signal); animation: pulse 1.2s ease-in-out infinite; }
.lane-done .lane-dot { background: var(--sent); }
.lane-failed .lane-dot { background: var(--fault); }
.lane-name { font-weight: 700; }
.lane-detail { color: var(--muted); overflow-wrap: anywhere; }
.lane-failed .lane-detail { color: var(--fault); }
.lane-detail a { color: var(--ink); }
.queue-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .lane-running .lane-dot { animation: none; }
  .progress-bar, .dropzone { transition: none; }
}

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card {
  width: min(100%, 24rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  padding: 2rem;
  display: grid;
  gap: 1rem;
}
.login-card .wordmark { font-size: 2rem; }
.login-card .notice { width: 100%; margin: 0; }
.login-card form { gap: 0.75rem; }

@media (max-width: 480px) {
  .account { flex-wrap: wrap; }
  .account-actions { width: 100%; }
}

/* ---------- Signed-in user ---------- */
.topbar-user { display: flex; align-items: center; gap: 0.625rem; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; object-fit: cover; }
.user-name { font-weight: 700; font-size: 0.9375rem; }
@media (max-width: 560px) { .user-name { display: none; } }

.page-picker { margin-top: 0.375rem; font-size: 0.875rem; padding: 0.35rem 0.5rem; }

/* ---------- Admin ---------- */
.invite-form { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.invite-row { display: flex; gap: 0.5rem; }
.invite-row input { flex: 1; min-width: 0; }
.admin-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.375rem; }
.admin-item {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: 0.625rem 0.875rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-small);
  font-size: 0.875rem;
}
.admin-item-text { display: grid; min-width: 0; overflow-wrap: anywhere; }
.admin-item.is-disabled .admin-item-text { opacity: 0.55; }
.account-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-small); padding: 1rem; display: grid; gap: 0.75rem; justify-items: start; }
.account-box p { margin: 0; font-size: 0.875rem; }
.legal-links { display: flex; gap: 1rem; font-size: 0.8125rem; }
.legal-links a, .site-footer a { color: var(--muted); }

/* ---------- Public pages ---------- */
.landing-page, .legal-page { min-height: 100vh; display: grid; grid-template-rows: 1fr auto; }
.landing { max-width: 34rem; margin: 0 auto; padding: clamp(3rem, 12vh, 7rem) 1.5rem 3rem; display: grid; gap: 1.25rem; justify-items: start; align-content: start; }
.landing h1 { font-size: clamp(2.25rem, 7vw, 3.5rem); margin: 0; }
.landing h2 { font-size: clamp(1.5rem, 4.5vw, 2.125rem); margin: 0; }
.landing-lead { font-size: 1.1875rem; margin: 0; }
.landing-small { font-size: 0.875rem; margin: 0; }
.landing .notice { width: 100%; margin: 0; }
.button-google { font-size: 1rem; padding: 0.95rem 1.4rem; text-decoration: none; display: inline-block; }
.legal { max-width: 44rem; margin: 0 auto; padding: 3rem 1.5rem; }
.legal .wordmark { color: var(--ink); text-decoration: none; display: inline-block; margin-bottom: 2rem; }
.legal h1 { margin-bottom: 1rem; }
.legal h2 { margin: 1.75rem 0 0.5rem; font-size: 1.125rem; }
.legal p { margin: 0 0 0.75rem; }
.site-footer { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; justify-content: center; padding: 1.5rem; border-top: 1px solid var(--line); font-size: 0.875rem; }

/* ---------- Coming soon ---------- */
.badge-soon { background: var(--signal-soft); color: var(--signal); }
.account.is-coming-soon .account-name { color: var(--muted); }

@media (max-width: 560px) {
  .dropzone-filled { grid-template-columns: 1fr; }
  .dropzone-filled video { max-height: 20rem; }
}

@media (max-width: 560px) {
  .dropzone-filled { grid-template-columns: 1fr; }
  .dropzone-filled video { max-height: 20rem; }
}
