/* ─────────────────────────────────────────────────────────────────────────
   Design tokens
   Subject: an AI "intelligence desk" for marketing — briefing documents,
   dossiers, stamped scorecards. Warm paper canvas, ink-navy structure,
   a single gold accent reserved for primary actions, teal/brick for
   qualified vs. cold signal states.
   ───────────────────────────────────────────────────────────────────────── */
:root {
  --paper: #F5F1E7;
  --paper-raised: #FCFAF3;
  --ink: #1E2233;
  --ink-soft: #454A5E;
  --ink-faint: #8A8F9E;
  --gold: #B8863B;
  --gold-soft: #E8D8B8;
  --teal: #3E7C6B;
  --teal-soft: #DCEAE4;
  --brick: #A14E44;
  --brick-soft: #F1DCD8;
  --line: #DDD5C2;
  --line-strong: #C6BC9F;
  --shadow: 0 1px 2px rgba(30, 34, 51, 0.06), 0 8px 24px rgba(30, 34, 51, 0.05);

  /* Fixed brand-chrome tokens — the sidebar, buttons styled "dark", the
     auth screen backdrop, and the ball spinner always use these, regardless
     of light/dark theme, so the brand reads consistently either way. */
  --chrome-bg: #1E2233;
  --chrome-bg-hover: #2A2F45;
  --chrome-text: #F5F1E7;
  --chrome-text-dim: #C9CCDA;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

[data-theme="dark"] {
  --paper: #14161F;
  --paper-raised: #1D2029;
  --ink: #ECE8DD;
  --ink-soft: #B9B6AC;
  --ink-faint: #83807A;
  --gold: #D9A857;
  --gold-soft: #3A2E17;
  --teal: #5FA893;
  --teal-soft: #1B2E29;
  --brick: #D9887A;
  --brick-soft: #3A211D;
  --line: #2E3140;
  --line-strong: #454A5E;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.35);
}

html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
body { transition: background-color 0.2s ease, color 0.2s ease; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.4em;
  letter-spacing: -0.01em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1em; color: var(--ink-soft); }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

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

/* ── App shell ─────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.mobile-topbar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 120;
    background: var(--chrome-bg);
    color: var(--chrome-text);
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .mobile-topbar .brand { font-size: 1rem; margin: 0; }
  .mobile-topbar .brand small { display: none; }
  .nav-toggle, .mobile-theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.22);
    color: var(--chrome-text);
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    width: 84vw;
    max-width: 300px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    padding-top: max(28px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 48px rgba(0,0,0,0.35); }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(10, 11, 16, 0.5);
    z-index: 190;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
}

.sidebar {
  background: var(--chrome-bg);
  color: var(--chrome-text);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--chrome-text);
}
.brand small {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 4px;
}

.nav-tabs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-tabs a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--chrome-text-dim);
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  text-decoration: none;
  border-left: 3px solid transparent;
  min-height: 44px;
  box-sizing: border-box;
}
.nav-tabs a:hover { background: rgba(255,255,255,0.06); color: var(--chrome-text); }
.nav-tabs a.active {
  background: rgba(217, 168, 87, 0.18);
  border-left-color: var(--gold);
  color: var(--chrome-text);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--chrome-text-dim);
}
.sidebar-footer button {
  background: none;
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--chrome-text-dim);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  min-height: 44px;
}
.sidebar-footer button:hover { border-color: var(--gold); color: var(--chrome-text); }
.theme-toggle-row { display: flex; gap: 8px; margin-bottom: 8px; }
.theme-toggle-row button { flex: 1; }


.main {
  padding: 36px 44px;
  max-width: 1100px;
}

@media (max-width: 860px) {
  .main { padding: 20px 16px 90px; }
  .card { padding: 16px; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
  gap: 20px;
  flex-wrap: wrap;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
  display: block;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card .value {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--ink);
}
.stat-card .label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field .hint {
  font-size: 0.76rem;
  color: var(--ink-faint);
  margin-top: 4px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 80px; }

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-primary { background: var(--chrome-bg); color: var(--chrome-text); }
.btn-primary:hover { background: var(--chrome-bg-hover); }
.btn-gold { background: var(--gold); color: #2A1D0A; }
.btn-gold:hover { background: #A6752E; }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-strong);
}
.post-actions::before {
  content: 'Post to:';
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  align-self: center;
  margin-right: 4px;
}

/* ── Score stamps (signature element) ─────────────────────────────────── */
.stamp-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 14px 0; }
.stamp {
  width: 64px; height: 64px;
  border: 2px dashed var(--line-strong);
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  transform: rotate(-4deg);
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.stamp .num { font-size: 1.15rem; font-weight: 700; color: var(--ink); line-height: 1; }
.stamp .lbl { font-size: 0.5rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); margin-top: 2px; }
.stamp.good { border-color: var(--teal); }
.stamp.good .num { color: var(--teal); }
.stamp.warn { border-color: var(--brick); }
.stamp.warn .num { color: var(--brick); }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
}
.badge-cold { background: #EDEBE1; color: var(--ink-faint); }
.badge-warm { background: var(--gold-soft); color: #7A5622; border-color: var(--gold); }
.badge-hot { background: var(--brick-soft); color: var(--brick); border-color: var(--brick); }
.badge-qualified, .badge-sales-ready { background: var(--teal-soft); color: var(--teal); border-color: var(--teal); }

/* ── Table ─────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
th {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}
tr:last-child td { border-bottom: none; }

/* ── Content piece card ────────────────────────────────────────────────── */
.content-piece { border-left: 3px solid var(--gold); }
.content-piece .platform-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.content-piece .hook { font-family: var(--font-display); font-size: 1.15rem; margin: 6px 0 10px; }
.content-piece .body-text { white-space: pre-wrap; color: var(--ink-soft); }
.content-piece .cta { font-weight: 600; margin-top: 10px; }

/* ── Misc ──────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--line); margin: 24px 0; }
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-faint);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--chrome-bg); color: var(--chrome-text);
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 0.85rem; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: 320px;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--brick); }

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chrome-bg);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--paper-raised);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}
.auth-tabs { display: flex; gap: 4px; margin-bottom: 22px; background: var(--paper); border-radius: var(--radius-sm); padding: 4px; }
.auth-tabs button {
  flex: 1; padding: 8px; border: none; background: transparent;
  border-radius: 5px; cursor: pointer; font-weight: 600; color: var(--ink-faint);
}
.auth-tabs button.active { background: var(--paper-raised); color: var(--ink); box-shadow: var(--shadow); }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.checklist li:last-child { border-bottom: none; }

/* ── Magic 8 Ball ──────────────────────────────────────────────────────── */
.premium-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #2A1D0A;
  background: var(--gold);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}

.ball-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 30px 20px;
}

.ball {
  width: 132px; height: 132px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2E3450, var(--chrome-bg) 70%);
  border: 3px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.ball:hover { transform: scale(1.03); }
.ball:active { transform: scale(0.97); }
.ball.spinning { animation: ball-spin 0.7s ease-in-out; }
@keyframes ball-spin {
  0% { transform: rotate(0deg) scale(1); }
  40% { transform: rotate(200deg) scale(1.08); }
  100% { transform: rotate(360deg) scale(1); }
}
.ball .ball-face {
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--paper-raised);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--ink);
}

.prompt-card {
  width: 100%;
  max-width: 560px;
  text-align: center;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}
.prompt-card .category {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}
.prompt-card .prompt-text {
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.35;
  color: var(--ink);
}

.duration-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.duration-chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.duration-chip.active { background: var(--chrome-bg); color: var(--chrome-text); border-color: var(--chrome-bg); }

.studio {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 9 / 16;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 auto;
}
.studio video { width: 100%; height: 100%; object-fit: cover; display: block; }
.studio .overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  gap: 10px;
  background: rgba(30,34,51,0.55);
  color: #fff;
  text-align: center;
  padding: 20px;
}
.countdown-number {
  font-family: var(--font-display);
  font-size: 5rem;
  color: #fff;
}
.rec-timer {
  position: absolute;
  top: 12px; left: 12px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 5px 12px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rec-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brick);
  animation: rec-blink 1s infinite;
}
@keyframes rec-blink { 50% { opacity: 0.2; } }

.studio-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.saved-videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.saved-video-card video { width: 100%; border-radius: var(--radius-sm); background: #000; aspect-ratio: 9/16; object-fit: cover; }
.saved-video-card .caption { font-size: 0.78rem; color: var(--ink-soft); margin: 8px 0; }

.media-attach { margin-top: 12px; }
.attached-media { display: flex; flex-direction: column; gap: 8px; max-width: 220px; }
.attached-media img, .attached-media video { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,11,16,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 250;
}
.modal-box {
  background: var(--paper-raised);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
}
.modal-close {
  float: right;
  background: none; border: none; cursor: pointer;
  font-size: 1.3rem; color: var(--ink-faint); line-height: 1;
  width: 36px; height: 36px;
}
@media (max-width: 640px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-box { max-width: 100%; max-height: 88vh; border-radius: var(--radius) var(--radius) 0 0; }
}

/* ── Tables scroll horizontally instead of breaking layout on mobile ────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { min-width: 480px; }
@media (max-width: 640px) {
  table { min-width: 420px; font-size: 0.82rem; }
  th, td { padding: 8px; }
}

/* ── Touch targets & general mobile-friendliness ─────────────────────────── */
@media (max-width: 640px) {
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 38px; }
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="datetime-local"], input[type="date"],
  input[type="time"], select, textarea {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
    min-height: 44px;
  }
  textarea { min-height: 90px; }
  .grid-2, .grid-3 { gap: 12px; }
  .page-header { align-items: flex-start; }
  .studio { max-width: 100%; }
  .ball { width: 108px; height: 108px; }
  .ball .ball-face { width: 52px; height: 52px; font-size: 1.3rem; }
  .prompt-card .prompt-text { font-size: 1.2rem; }
  .post-actions { gap: 8px; }
  .post-actions button, .post-actions a { min-height: 40px; }
}

/* ── Card hover lift (desktop only — avoids sticky-hover on touch) ──────── */
@media (hover: hover) and (pointer: fine) {
  .content-piece, .stat-card { transition: transform 0.15s ease, box-shadow 0.15s ease; }
  .content-piece:hover, .stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
}

/* ── Skeleton loading state ───────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, var(--paper) 37%, var(--line) 63%);
  background-size: 400% 100%;
  animation: skeleton-shine 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shine { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ── Global quick search ──────────────────────────────────────────────────── */
.quick-search { position: relative; max-width: 320px; }
.quick-search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: 0.88rem;
}
.quick-search::before {
  content: '⌕';
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint);
  font-size: 1rem;
  pointer-events: none;
}
.page-header .quick-search { margin-left: auto; }

/* ── Streak widget ─────────────────────────────────────────────────────────── */
.streak-card {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, var(--gold-soft), var(--paper-raised));
  border: 1px solid var(--gold);
}
.streak-flame { font-size: 2rem; line-height: 1; }
.streak-card .value { font-family: var(--font-display); font-size: 1.6rem; color: var(--ink); }
.streak-card .label { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); }
