/* Video Distributor — mobile-first styles.
 * Dark, cinematic, clean and professional. System fonts only; no external assets.
 */

:root {
  --bg: #0b0e14;
  --bg-raised: #12161f;
  --surface: #161b27;
  --surface-2: #1e2534;
  --border: #2a3347;
  --text: #f2f4f8;
  --muted: #9aa4b6;
  --accent: #5b8def;
  --accent-strong: #7aa5f5;
  --accent-text: #0b0e14;
  --danger: #e5484d;
  --gray: #8a94a6;
  --amber: #f5a623;
  --green: #3fb68b;
  --red: #e5484d;
  --radius: 14px;
  --tap: 44px;
  --max-width: 720px;
}

* { box-sizing: border-box; }

/* `hidden` must win over display rules from component classes
 * (e.g. .btn sets display:inline-flex, which would otherwise override
 * the UA's [hidden] rule and show supposedly-hidden buttons). */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

a { color: var(--accent-strong); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

h1 {
  font-size: 1.6rem;
  line-height: 1.2;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

h2 { font-size: 1.1rem; margin: 0; }

.lede { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.fine-print { color: var(--muted); font-size: 0.85rem; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 12px 16px;
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- Header & nav ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 14, 20, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 16px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wordmark {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-account {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.account-email {
  font-size: 0.85rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4px 16px 10px;
  display: flex;
  gap: 8px;
}

.nav-btn {
  flex: 1;
  min-height: var(--tap);
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 4px;
}

.nav-btn.is-active {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

/* ---------- Layout ---------- */

.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 16px 8px;
}

.view { animation: fade-in 0.15s ease-in; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
}
.row-actions:empty { display: none; }

.step-heading {
  margin: 28px 0 12px;
  font-size: 1.05rem;
}
.step-heading:first-of-type { margin-top: 8px; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.details-card summary {
  cursor: pointer;
  font-weight: 600;
  min-height: var(--tap);
  display: flex;
  align-items: center;
}
.details-card summary::-webkit-details-marker { margin-right: 8px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-secondary { background: var(--surface-2); }
.btn-ghost { background: transparent; }
.btn-small { min-height: var(--tap); padding: 8px 14px; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn-large { min-height: 52px; font-size: 1.1rem; }

.btn.is-busy { position: relative; }
.btn.is-busy::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.btn-secondary.is-busy::before,
.btn-ghost.is-busy::before {
  border-color: rgba(242, 244, 248, 0.3);
  border-top-color: var(--text);
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .btn.is-busy::before { animation: none; }
  .view { animation: none; }
}

/* ---------- Forms ---------- */

.form-card { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; }

.field input[type="email"],
.field input[type="password"],
.field input[type="text"],
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
.field textarea { resize: vertical; min-height: 96px; }

.char-count {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.field-error {
  margin: 0;
  color: #ff8589;
  background: rgba(229, 72, 77, 0.1);
  border: 1px solid rgba(229, 72, 77, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}
p.field-error { margin: 8px 0; }

.warning-text {
  margin: 0;
  color: #ffd08a;
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

/* ---------- Auth tabs ---------- */

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.auth-tab {
  flex: 1;
  min-height: var(--tap);
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.auth-tab.is-active {
  background: var(--surface-2);
  color: var(--text);
}

/* ---------- Banners & notices ---------- */

.banner {
  max-width: var(--max-width);
  margin: 12px 16px 0;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.95rem;
}
.banner-error {
  color: #ffd7d8;
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid rgba(229, 72, 77, 0.45);
}
.banner-info {
  color: #d3e2ff;
  background: rgba(91, 141, 239, 0.12);
  border: 1px solid rgba(91, 141, 239, 0.45);
}

.notice {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin: 10px 0;
}
.notice-warning {
  color: #ffd08a;
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.4);
}

/* ---------- Pills (status colors) ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}
.pill-gray { background: #2a3347; color: #c6cddb; }
.pill-amber { background: rgba(245, 166, 35, 0.18); color: #ffcf7d; }
.pill-green { background: rgba(63, 182, 139, 0.18); color: #7fdcc0; }
.pill-red { background: rgba(229, 72, 77, 0.18); color: #ff9a9e; }

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

/* ---------- Platform cards & picker ---------- */

.platform-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.platform-name { font-size: 1.05rem; }
.platform-notes { margin: 8px 0; padding-left: 20px; color: var(--muted); font-size: 0.9rem; }
.platform-notes li { margin: 2px 0; }

.picker-card { display: block; }
.picker-card-selectable {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}
.picker-card-selectable.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.picker-checkbox {
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.picker-card-body { flex: 1; min-width: 0; }
.picker-card-body .platform-card-top { margin-bottom: 2px; }

/* ---------- Drop zone & file panel ---------- */

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(91, 141, 239, 0.08);
}
.drop-zone-title { margin: 0; font-weight: 600; }
.drop-zone p { margin: 0; }

.file-panel-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.file-thumb {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
  flex: none;
}
.file-meta { min-width: 0; }
.file-name {
  margin: 0 0 4px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.file-meta p { margin: 0 0 4px; }

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.progress {
  flex: 1;
  height: 10px;
  appearance: none;
  -webkit-appearance: none;
}
.progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
.progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* ---------- Library ---------- */

.library-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-raised);
}
.library-item-info { min-width: 0; }
.library-item-name { margin: 0 0 2px; font-weight: 600; overflow-wrap: anywhere; }
.library-item-info p { margin: 0; }

/* ---------- Overrides & distribute ---------- */

.override-card summary { text-transform: none; }
.override-card .field { margin-top: 12px; }

.distribute-box {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}
.distribute-hint { text-align: center; margin: 10px 0 0; }

/* ---------- Handoff ---------- */

.handoff-steps { margin: 8px 0 4px; padding-left: 22px; }
.handoff-steps li { margin: 4px 0; }

/* ---------- Jobs ---------- */

.job-title { font-size: 1.05rem; overflow-wrap: anywhere; }
.job-card .muted { margin: 4px 0; }

/* ---------- Footer ---------- */

.app-footer {
  max-width: var(--max-width);
  margin: 32px auto 0;
  padding: 20px 16px 0;
  border-top: 1px solid var(--border);
  text-align: center;
}
.footer-wordmark { margin: 0 0 8px; font-weight: 700; }
.app-footer nav { display: flex; gap: 8px; justify-content: center; align-items: center; }
.app-footer nav a { min-height: var(--tap); display: inline-flex; align-items: center; padding: 0 8px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100% - 32px);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  z-index: 50;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.toast-error { border-color: var(--danger); color: #ffd7d8; }

/* ---------- Wider screens ---------- */

@media (min-width: 560px) {
  .main { padding-top: 28px; }
  .banner { margin: 12px auto 0; }
  h1 { font-size: 1.9rem; }
  .file-thumb { width: 160px; height: 90px; }
}
