/* ═══════════════════════════════════════════════
   Vic Content OS — Light Theme, Mobile-First
═══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --surface-3: #e5e5ea;
  --border: #d1d1d6;
  --border-soft: #e5e5ea;
  --text: #1c1c1e;
  --text-muted: #8e8e93;
  --text-dim: #636366;
  --accent: #1c1c1e;
  --red: #d70015;
  --orange: #c93400;
  --green: #248a52;
  --blue: #0071e3;
  --tag-bg: #e5e5ea;
  --tag-text: #636366;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ─── Screens ─────────────────────────────────── */

.screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  overflow-y: auto;
  padding-bottom: calc(1rem + var(--safe-bottom));
}

.screen.active { display: flex; }

/* ─── App Header ──────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(1rem + var(--safe-top)) 1.25rem 0.75rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  border-bottom: 1px solid var(--border-soft);
}

.app-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.streak {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ─── Brief Card ──────────────────────────────── */

.brief-card {
  margin: 1rem 1.25rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.brief-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.brief-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.brief-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
}

.brief-content {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ─── Prompts ─────────────────────────────────── */

.prompts-container {
  padding: 1rem 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.prompts-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.prompt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.prompt-card.selected {
  border-color: var(--accent);
  background: var(--surface-2);
}

.prompt-persona {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.prompt-text {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 0.75rem;
}

.prompt-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 4px;
  padding: 0.2rem 0.45rem;
  text-transform: uppercase;
}

.tag-hook   { background: #1a1a2e; color: #7b7bff; }
.tag-type   { background: #1a2e1a; color: #4caf7d; }
.tag-frame  { background: #2e1a1a; color: #e08484; }

/* ─── Link Button ─────────────────────────────── */

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.5rem 1.25rem;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ─── Record Actions ──────────────────────────── */

.record-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 1rem 1.25rem 0;
}

.btn-record {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-record svg {
  width: 22px;
  height: 22px;
}

.btn-record:active { background: var(--surface-2); }

/* ─── Free-form ───────────────────────────────── */

.freeform-section {
  padding: 0.75rem 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.freeform-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.75rem;
  resize: none;
  line-height: 1.5;
}

.freeform-input::placeholder { color: var(--text-muted); }
.freeform-input:focus { outline: none; border-color: #444; }

/* ─── Audience Capture ────────────────────────── */

.audience-capture {
  margin: 0.75rem 1.25rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.audience-capture-toggle {
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.audience-capture-toggle::-webkit-details-marker { display: none; }

.audience-capture-body {
  padding: 0 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.audience-capture-meta {
  display: flex;
  gap: 0.5rem;
}

.select-sm {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.75rem;
  padding: 0.4rem 0.5rem;
}

.recent-phrases {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.phrase-chip {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.2rem 0;
  border-top: 1px solid var(--border-soft);
}

/* ─── Accountability Strip ────────────────────── */

.accountability-strip {
  padding: 0.75rem 1.25rem;
  margin-top: auto;
}

.next-publish {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ─── Buttons ─────────────────────────────────── */

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  width: 100%;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  width: 100%;
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  flex: 1;
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
}

.icon-btn svg { width: 20px; height: 20px; }

/* ─── Recording Screen ────────────────────────── */

#screen-recording {
  justify-content: center;
  align-items: center;
  background: var(--bg);
}

.recording-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  padding: 2rem 1.25rem;
}

.recording-mode-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.audio-recording-ui,
.video-recording-ui {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.waveform {
  width: 100%;
  max-width: 320px;
  height: 80px;
}

.camera-preview {
  width: 100%;
  max-width: 320px;
  border-radius: var(--radius);
  aspect-ratio: 9/16;
  background: #111;
  object-fit: cover;
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.recording-timer {
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.recording-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.recording-actions {
  display: flex;
  gap: 1rem;
  width: 100%;
  max-width: 320px;
}

.btn-stop {
  flex: 1;
  padding: 1rem;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-discard {
  padding: 1rem 1.25rem;
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  cursor: pointer;
}

/* ─── Processing Screen ───────────────────────── */

#screen-processing {
  justify-content: center;
  align-items: center;
}

.processing-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 1.25rem;
  text-align: center;
}

.processing-title {
  font-size: 1.1rem;
  font-weight: 500;
}

.processing-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ─── Spinner ─────────────────────────────────── */

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Review Screen ───────────────────────────── */

.review-meta {
  padding: 0.75rem 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-soft);
}

.review-cards {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.review-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
}

.content-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.content-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}

.platform-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.platform-schedule {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.hook-tag {
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: #1a1a2e;
  color: #7b7bff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.content-card-body {
  padding: 1rem;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.content-card-body::-webkit-scrollbar { width: 3px; }
.content-card-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.content-card-footer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-soft);
}

.btn-card-action {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  text-align: center;
}

.btn-card-action.btn-approve {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn-card-action.btn-skip {
  color: var(--text-muted);
}

.card-status {
  font-size: 0.78rem;
  padding: 0.4rem 0;
  display: block;
}

.card-status-published {
  color: var(--green);
}

.card-status-scheduled {
  color: var(--blue);
}

.btn-repurpose {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0.4rem 0;
  display: block;
  width: 100%;
  text-align: left;
  transition: color 0.15s;
}

.btn-repurpose:hover { color: var(--text-dim); }
.btn-repurpose:disabled { opacity: 0.5; cursor: default; }

.btn-edit-content {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0 0.25rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─── Modals ──────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  padding-bottom: calc(1rem + var(--safe-bottom));
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
}

.modal-box-lg {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.modal-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.modal-actions .btn-secondary { flex: 1; }

.modal-textarea {
  width: 100%;
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.75rem;
  resize: none;
  line-height: 1.6;
  min-height: 200px;
  margin-top: 0.75rem;
}

.modal-textarea:focus { outline: none; border-color: #444; }

.modal-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.65rem 0.75rem;
  margin-top: 0.75rem;
}

.modal-input:focus { outline: none; border-color: #444; }

.modal-select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.65rem 0.75rem;
  margin-top: 0.5rem;
  appearance: none;
}

/* ─── History link row ────────────────────────── */

.history-link-row {
  padding: 0 1rem 0.5rem;
  text-align: center;
}

/* ─── History Screen ──────────────────────────── */

#screen-history {
  overflow-y: auto;
  padding-bottom: calc(2rem + var(--safe-bottom));
}

.history-list {
  padding: 0.5rem 1rem;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.history-item:hover { border-color: #444; }

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.history-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.history-status {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

.history-status-complete  { background: rgba(76,175,125,0.15); color: var(--green); }
.history-status-pending   { background: rgba(74,143,224,0.15); color: var(--blue); }
.history-status-failed    { background: rgba(224,82,82,0.15);  color: var(--red); }

.history-prompt {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.history-tag {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.history-perf {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.history-perf-score {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--green);
}

.history-perf-btn {
  font-size: 0.68rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  padding: 0.15rem 0.4rem;
  cursor: pointer;
}

.history-perf-btn:hover { border-color: #555; color: var(--text); }

.history-publish-counts {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* ─── Performance modal ───────────────────────── */

.perf-score-row { margin-top: 0.75rem; }

.perf-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.perf-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ─── Settings Screen ─────────────────────────── */

#screen-settings {
  overflow-y: auto;
  padding-bottom: calc(2rem + var(--safe-bottom));
}

.settings-section {
  margin: 1rem 1rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.settings-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border-soft);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}

.settings-row:last-of-type { border-bottom: none; }

.settings-row-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.settings-label {
  font-size: 0.9rem;
  color: var(--text);
}

.settings-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.settings-action {
  margin: 0.75rem 1rem;
  display: block;
}

.settings-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0 1rem 0.75rem;
  min-height: 1.2rem;
}

/* ─── Toggle switch ───────────────────────────── */

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: 26px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

/* ─── IP Bank list ────────────────────────────── */

.ip-bank-list {
  padding: 0.5rem 0;
}

.ip-bank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}

.ip-bank-item:last-child { border-bottom: none; }

.ip-bank-item:hover { background: var(--surface-2); }

.ip-bank-item-name {
  font-size: 0.875rem;
  color: var(--text);
}

.ip-bank-item-type {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.ip-bank-item-archive {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.ip-bank-item-archive:hover { color: var(--red); }

/* ─── Utilities ───────────────────────────────── */

.hidden { display: none !important; }
