:root {
  color-scheme: dark;
  --bg: #0b0c11;
  --sidebar: #0e0f15;
  --panel: #12131a;
  --panel-raised: #181922;
  --line: #262732;
  --line-strong: #363846;
  --ink: #f5f3ef;
  --ink-2: #b9bac6;
  --ink-3: #9092a1;
  /* Turquoise matched by eye to the owner's Bahamas water photo. */
  --accent: #35c4c8;
  --accent-bright: #35c4c8;
  --accent-soft: rgba(53, 196, 200, 0.16);
  --on-accent: #0b0c11; /* White on this aqua is too faint to read, so text on it is dark. */
  --chart-bar: #35c4c8;
  --danger: #ff8a8a;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
svg.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Layout */
.shell { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: 100%; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--sidebar); border-right: 1px solid var(--line);
  padding: 28px 16px 22px;
}
.main { padding: 26px 26px 26px 30px; min-width: 0; }

/* Brand and navigation */
.brand { display: flex; align-items: center; gap: 16px; padding: 0 14px 40px; }
.brand-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brand-name { font-size: 20px; line-height: 1.1; letter-spacing: 0.42em; font-weight: 500; }
.brand-sub { font-size: 10px; line-height: 1.2; letter-spacing: 0.42em; font-weight: 400; color: var(--ink-2); white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 18px; width: 100%; height: 60px; padding: 0 22px;
  background: none; border: 1px solid transparent; border-radius: var(--radius);
  color: var(--ink-2); text-align: left; font-size: 16px;
}
.nav-item:hover { background: var(--panel-raised); color: var(--ink); }
.nav-item[aria-current="page"] {
  color: var(--ink); font-weight: 500; border-color: rgba(53, 196, 200, 0.35);
  background: linear-gradient(90deg, rgba(53, 196, 200, 0.26), rgba(53, 196, 200, 0.05));
}

/* Business picker */
.picker { position: relative; margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); }
.picker-button {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 8px 10px;
  background: none; border: 0; border-radius: 12px; text-align: left;
}
.picker-button:hover { background: var(--panel-raised); }
.avatar {
  display: grid; place-items: center; width: 48px; height: 48px; flex: none;
  border-radius: 50%; background: #2a2b36; font-size: 14px; font-weight: 600; letter-spacing: 0.03em;
}
.avatar-empty { background: var(--accent-soft); color: var(--accent-bright); }
.picker-text { min-width: 0; flex: 1; }
.picker-name { display: block; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.picker-sub { display: block; font-size: 13px; color: var(--ink-3); }
.picker-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); padding: 6px; z-index: 5;
  max-height: 60vh; overflow-y: auto;
  background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.picker-menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 10px 12px; background: none; border: 0; border-radius: 8px; text-align: left;
}
.picker-menu button:hover { background: var(--accent-soft); }
.picker-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.picker-menu .truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 20px; }
.eyebrow { font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink-2); }
.page-title { font-size: clamp(34px, 3.6vw, 58px); line-height: 1.08; font-weight: 500; letter-spacing: -0.02em; margin-top: 6px; }
.page-title em { font-style: normal; color: var(--accent-bright); }
.page-actions { display: flex; align-items: center; gap: 20px; flex: none; }

/* Buttons and controls */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 24px;
  border: 0; border-radius: 12px; font-weight: 600; color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 8px 26px rgba(53, 196, 200, 0.2);
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { background: #2b2c38; color: var(--ink-3); box-shadow: none; filter: none; }
.btn-secondary {
  min-height: 44px; padding: 0 18px; background: none;
  border: 1px solid var(--line-strong); border-radius: 10px;
}
.btn-secondary:hover { background: var(--panel-raised); }
.btn-danger { margin-right: auto; min-height: 44px; padding: 0 18px; background: none; border: 1px solid transparent; border-radius: 10px; color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-danger-solid { min-height: 44px; padding: 0 18px; border: 0; border-radius: 10px; background: #c43c3c; color: #fff; font-weight: 600; }
.control {
  display: inline-flex; align-items: center; gap: 12px; height: 52px; padding: 0 18px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px; color: var(--ink);
}
.control select { background: none; border: 0; outline-offset: 4px; }
.control select option { background: var(--panel-raised); }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; }
.segmented button { min-width: 74px; height: 34px; background: none; border: 0; border-radius: 7px; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.search {
  display: inline-flex; align-items: center; gap: 10px; width: 230px; height: 40px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink-3);
}
.search input { width: 100%; min-width: 0; background: none; border: 0; outline: 0; }
.search input::placeholder { color: var(--ink-3); }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-title { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.panel-subtitle { font-size: 22px; font-weight: 600; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.panel-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Stat row */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 20px 0; margin-bottom: 18px; }
.stat { padding: 0 34px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat-label { color: var(--ink-2); }
.stat-value { font-size: 36px; font-weight: 600; line-height: 1.25; }
.stat-note { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.meter { height: 10px; margin-top: 10px; border-radius: 5px; background: #2a2b36; overflow: hidden; }

/* Dashboard grid */
.dashboard { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 16px; align-items: stretch; }
.dashboard-left { display: grid; gap: 16px; grid-template-rows: 1fr auto; min-width: 0; }
.campaigns { padding: 18px; display: flex; flex-direction: column; min-height: 320px; }
.results { padding: 18px 22px; }
.results .control { height: 40px; }

/* Empty states */
.empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 20px 24px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 12px;
}
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 6px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-bright); }
.empty h3 { font-size: 21px; font-weight: 600; }
.empty p { max-width: 460px; color: var(--ink-2); }
.empty .btn-primary { margin-top: 12px; }
.facts { color: var(--ink-3); font-size: 14px; }
.chart-empty { position: relative; height: 120px; display: grid; place-items: center; }
.chart-grid { position: absolute; inset: 4px 0; display: flex; flex-direction: column; justify-content: space-between; }
.chart-grid span { display: block; border-top: 1px solid var(--line); }
.chart-empty p { position: relative; padding: 4px 14px; background: var(--panel); color: var(--ink-2); text-align: center; }

/* Detail panel */
.detail { padding: 22px 16px 16px; display: flex; flex-direction: column; gap: 16px; }
.detail-head { padding: 0 8px; }
.detail-title { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.detail-sub { color: var(--ink-3); margin-top: 2px; }
.media-blank {
  flex: 1; min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; text-align: center; color: var(--ink-3);
  background: var(--panel-raised); border: 1px dashed var(--line-strong); border-radius: 12px;
}
.detail-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0 8px; }
.detail-stats > div { min-width: 0; padding-left: 14px; border-left: 1px solid var(--line); overflow-wrap: anywhere; }
.detail-stats > div:first-child { padding-left: 0; border-left: 0; }
.detail-label { font-size: 13px; color: var(--ink-2); }
.detail-value { font-size: 18px; font-weight: 600; line-height: 1.3; }
.next-move { padding: 18px; background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: 12px; }
.next-move-head { display: flex; gap: 14px; }
.next-move-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 10px; background: var(--accent-soft); color: var(--accent-bright); }
.next-move-eyebrow { font-size: 11px; letter-spacing: 0.26em; color: var(--accent-bright); font-weight: 600; }
.next-move h3 { font-size: 17px; font-weight: 600; margin-top: 3px; }
.next-move p { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.next-move .btn-primary { width: 100%; margin-top: 14px; min-height: 46px; }

/* Other pages */
.page-body { padding: 26px; display: flex; flex-direction: column; min-height: 430px; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rule { display: flex; gap: 16px; padding: 16px 18px; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 12px; }
.rule svg { color: var(--accent-bright); margin-top: 1px; }
.rule h3 { font-size: 16px; font-weight: 600; }
.rule p { color: var(--ink-2); margin-top: 2px; }
.cap-summary { display: flex; flex-wrap: wrap; gap: 8px 40px; margin-bottom: 20px; }
.cap-summary strong { display: block; font-size: 24px; font-weight: 600; overflow-wrap: anywhere; }
.rules-note { margin-top: 16px; color: var(--ink-3); font-size: 14px; }

/* Dialogs */
.dialog {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 16px;
}
.dialog-small { width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(4, 4, 8, 0.72); }
.dialog form, .dialog-content { padding: 26px; }
.dialog h2 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.dialog-lead { color: var(--ink-2); margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label, .field legend { font-size: 14px; font-weight: 500; padding: 0; }
.field .required { color: var(--accent-bright); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: 9px;
}
.field textarea { min-height: 72px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-bright); outline: 0; }
.field-hint { font-size: 12px; color: var(--ink-3); }
.field-error { font-size: 13px; color: var(--danger); }
.field-error:empty { display: none; }
.field-invalid input, .field-invalid select { border-color: var(--danger); }
.form-error { margin-top: 14px; color: var(--danger); }
.form-error:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 22px; }
.dialog-actions .btn-primary { min-height: 44px; padding: 0 20px; }

/* Ad writing */
.ad-writer { padding: 22px; margin-bottom: 16px; }
.ad-writer-row { display: flex; align-items: flex-end; gap: 14px; margin-top: 16px; }
.ad-writer-row .field { flex: 1; }
.ad-writer-row input { width: 100%; padding: 13px 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 9px; }
.ad-writer-row input:focus { border-color: var(--accent-bright); outline: 0; }
.ad-notice { margin-top: 12px; font-size: 14px; color: #ffc46b; }
.page-body-short { min-height: 0; margin-bottom: 16px; }
.page-body-short .empty { padding: 26px 20px; }
.ad-set { padding: 22px; margin-bottom: 16px; }
.btn-danger-inline { margin-right: 0; }
.ad-angles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-bottom: 8px; }
.ad-angle-note { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--panel-raised); border-radius: 10px; font-size: 14px; color: var(--ink-2); }
.ad-angle-note strong { color: var(--ink); font-weight: 600; }
.ad-group-title { margin-top: 20px; font-size: 17px; font-weight: 600; }
.ad-group-note { margin: 2px 0 10px; font-size: 14px; color: var(--ink-3); }
.ad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.ad-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; min-width: 0; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 12px; }
.ad-card-kept { border-color: var(--accent-bright); }
.ad-card-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.ad-label { font-weight: 600; color: var(--accent-bright); }
.ad-angle { color: var(--ink-3); text-align: right; }
.ad-hook { font-weight: 600; }
.ad-body { color: var(--ink-2); white-space: pre-line; flex: 1; }
.ad-card mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 1px 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.ad-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--bg); border-radius: 9px; }
.ad-link-text { min-width: 0; }
.ad-headline { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.ad-description { font-size: 13px; color: var(--ink-3); overflow-wrap: anywhere; }
.ad-cta { flex: none; padding: 6px 10px; font-size: 13px; font-weight: 500; background: #2a2b36; border-radius: 7px; }
.ad-cta-changed { background: var(--accent); color: var(--on-accent); }
.ad-warnings { margin: 0; padding: 0; list-style: none; font-size: 13px; color: #ffc46b; }
.ad-warnings li + li { margin-top: 3px; }
.ad-actions { display: flex; align-items: center; gap: 14px; padding-top: 4px; font-size: 14px; }
.ad-keep { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; cursor: pointer; }
.ad-keep input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.btn-text { padding: 4px 2px; background: none; border: 0; color: var(--accent-bright); }
.btn-text:hover { text-decoration: underline; }
@media (max-width: 860px) {
  .ad-writer-row { flex-direction: column; align-items: stretch; }
  .ad-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Meta results */
.is-refreshing .stats, .is-refreshing .dashboard, .is-refreshing .insights-table { opacity: 0.55; transition: opacity 0.15s; }
.meta-notice { margin-bottom: 14px; padding: 12px 16px; font-size: 14px; color: var(--ink-2); background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: 10px; }
.meta-notice strong { color: var(--ink); font-weight: 600; }
.connection .meta-notice { margin: 14px 0 0; }
.meter-bar { display: block; width: 100%; height: 10px; margin-top: 10px; border-radius: 5px; background: #2a2b36; overflow: hidden; }
.meter-fill { fill: var(--chart-bar); }
.meter-over { fill: var(--danger); }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table thead th { font-size: 13px; font-weight: 500; color: var(--ink-3); }
.data-table tbody th { font-weight: 500; white-space: normal; min-width: 180px; overflow-wrap: anywhere; }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-link { font: inherit; text-align: left; overflow-wrap: anywhere; }
.table-link[aria-pressed="true"] { color: var(--ink); text-decoration: underline; }
.campaign-status { display: inline-block; padding: 2px 8px; font-size: 12px; border-radius: 999px; background: #2a2b36; color: var(--ink-2); }
.campaign-status-on { background: var(--accent-soft); color: var(--ink); }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.board-column { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.board-title { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.board-title span { color: var(--ink-3); font-weight: 400; }
.campaign-card { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 12px; text-align: left; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 10px; }
.campaign-card:hover { border-color: var(--line-strong); }
.campaign-card[aria-pressed="true"] { border-color: var(--accent-bright); }
.campaign-name { font-weight: 500; overflow-wrap: anywhere; }
.campaign-figures { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 10px; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; }
.chart-gridline { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--ink-3); font-size: 12px; }
.chart-bar { fill: var(--chart-bar); pointer-events: none; }
.chart-hit { fill: transparent; }
.chart-day { outline: none; }
.chart-day:hover .chart-hit, .chart-day:focus-visible .chart-hit { fill: rgba(255, 255, 255, 0.05); }
.chart-day:focus-visible .chart-hit { stroke: var(--accent-bright); }
.chart-tooltip { position: absolute; top: 0; display: flex; flex-direction: column; padding: 8px 12px; font-size: 13px; color: var(--ink-2); white-space: nowrap; pointer-events: none; background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45); }
.chart-tooltip[hidden] { display: none; }
.chart-tooltip strong { color: var(--ink); font-size: 15px; font-weight: 600; }
.chart-table { margin-top: 8px; font-size: 14px; color: var(--ink-2); }
.chart-table summary { cursor: pointer; }
.chart-table .table-scroll { max-height: 260px; margin-top: 6px; overflow-y: auto; }
.connection, .insights-table { padding: 22px; margin-bottom: 16px; }
.connection .rules-note { margin-top: 10px; }
.connection-page { max-width: 420px; margin-top: 14px; }
.connection-page select { padding: 11px 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 9px; }
.connection-heading { font-size: 18px; font-weight: 600; }
.insights-table .table-scroll { margin-top: 14px; }
.insights-table .empty { margin-top: 14px; }
@media (max-width: 860px) {
  .board { grid-template-columns: minmax(0, 1fr); }
}

/* Campaigns made in Unreel */
.drafts { padding: 22px; margin-bottom: 16px; }
.draft-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.drafts .detail-sub + .draft-row { margin-top: 12px; }
.draft-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.draft-main .detail-sub { margin-top: 0; font-size: 14px; }
.draft-progress { font-size: 14px; color: var(--accent-bright); }
.draft-error { font-size: 14px; color: var(--danger); }
.draft-actions { display: flex; align-items: center; gap: 12px; }
.btn-compact { min-height: 40px; padding: 0 16px; }
.btn-off { min-height: 40px; color: var(--danger); border-color: var(--danger); }
.detail-head .btn-off { margin-top: 10px; }
.draft-ages { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.review-list { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px 14px; margin: 0 0 16px; font-size: 14px; }
.review-list dt { color: var(--ink-3); }
.review-list dd { margin: 0; overflow-wrap: anywhere; }
.review-text { white-space: pre-line; }
.review-link { color: var(--accent-bright); }
.cap-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cap-table th { font-weight: 400; text-align: left; color: var(--ink-2); overflow-wrap: anywhere; }
.cap-table th, .cap-table td { padding: 6px 0; border-top: 1px solid var(--line); }
.cap-table td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 14px; }
.cap-item th { padding-left: 14px; color: var(--ink-3); }
.cap-total th, .cap-total td { color: var(--ink); font-weight: 600; }
.cap-blocked { margin-top: 12px; color: var(--danger); }
.confirm-amount { margin-bottom: 8px; font-size: 18px; }
.audience-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: 12px; padding: 14px 16px; background: var(--panel-raised); border-radius: 10px; }
.audience-card p { color: var(--ink-2); font-size: 14px; }
.audience-button { margin-top: 14px; }
@media (max-width: 860px) {
  .draft-row { grid-template-columns: minmax(0, 1fr); }
  .review-list { grid-template-columns: minmax(0, 1fr); }
}

/* Photo and video sizing */
.studio { padding: 22px; margin-bottom: 16px; }
.studio-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; margin-top: 16px; }
.studio-preview { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.studio-preview video, .studio-preview img { width: 100%; max-height: 420px; object-fit: contain; background: #000; border-radius: 10px; }
.studio-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.studio-form .field input, .studio-form .field select { width: 100%; padding: 11px 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 9px; }
.studio-form .field input:focus, .studio-form .field select:focus { border-color: var(--accent-bright); outline: 0; }
.studio-form .field input[type="range"] { padding: 0; accent-color: var(--accent); }
.studio-form .form-error { margin-top: 0; }
.studio-form .btn-primary { align-self: flex-start; }
.studio-times { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.creative-batch { padding: 6px 22px 22px; margin-bottom: 16px; }
.creative-headline { overflow-wrap: anywhere; }
.creative-grid { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.creative-card { display: flex; flex-direction: column; gap: 8px; width: 270px; max-width: 100%; padding: 10px; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 12px; }
.creative-media { display: block; width: 100%; background: #000; border-radius: 8px; }
.creative-feed { aspect-ratio: 4 / 5; }
.creative-vertical { aspect-ratio: 9 / 16; }
.creative-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px; text-align: center; color: var(--ink-2); font-size: 14px; }
.creative-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.creative-meta .detail-sub { margin-top: 0; font-size: 13px; }
.creative-warning { font-size: 13px; color: #ffc46b; }
.creative-card .ad-actions { justify-content: space-between; padding-top: 0; }
.btn-text-danger { margin-left: auto; color: var(--danger); }
a.btn-text { text-decoration: none; }
a.btn-text:hover { text-decoration: underline; }
@media (max-width: 860px) {
  .studio-row { grid-template-columns: minmax(0, 1fr); }
  .creative-card { width: 100%; }
}

/* Fill from website */
.dialog-wide { width: min(720px, calc(100vw - 32px)); }
.btn-fill { align-self: flex-start; min-height: 36px; padding: 0 14px; font-size: 14px; color: var(--accent-bright); border-color: rgba(53, 196, 200, 0.5); }
.scrape-progress { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 44px 26px; }
.spinner { width: 38px; height: 38px; margin-bottom: 18px; border: 3px solid var(--line-strong); border-top-color: var(--accent-bright); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 4s; } }
.suggestion { padding: 14px 0; border-top: 1px solid var(--line); }
.suggestion-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; font-weight: 500; }
.suggestion-head input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.suggestion-tag { padding: 2px 8px; font-size: 12px; font-weight: 400; color: var(--ink-2); background: var(--panel-raised); border-radius: 999px; }
.suggestion textarea { width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 9px; resize: vertical; }
.suggestion textarea:focus { border-color: var(--accent-bright); outline: 0; }
.suggestion-none { color: var(--ink-3); font-size: 14px; }
.suggestion-warning { margin-top: 6px; font-size: 13px; color: #ffc46b; }
.suggestion-current { margin-top: 6px; font-size: 13px; color: var(--ink-3); }
.suggestion-current summary { cursor: pointer; }
.suggestion-current p { margin-top: 4px; white-space: pre-line; }
.scrape-pages { padding-top: 10px; font-size: 13px; color: var(--ink-3); overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 20;
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 18px;
  background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

/* Smaller windows */
@media (max-width: 1240px) {
  .dashboard { grid-template-columns: minmax(0, 1fr); }
  .media-blank { min-height: 160px; }
  .stat { padding: 0 20px; }
  .stat-value { font-size: 30px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 18px 14px; }
  .brand { padding-bottom: 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { width: auto; height: 44px; padding: 0 12px; gap: 8px; font-size: 14px; }
  .picker { margin-top: 12px; }
  .main { padding: 18px 14px; }
  .page-header { flex-direction: column; }
  .page-actions { flex-wrap: wrap; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 20px; }
  .stat:nth-child(odd) { border-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .search { width: 100%; }
}

/* Login and setup pages */
.auth-page { display: flex; justify-content: center; align-items: flex-start; min-height: 100%; padding: clamp(20px, 8vh, 80px) 16px 32px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.auth-card .brand { margin-bottom: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card [hidden] { display: none; }
.auth-title { margin: 0; font-size: 26px; font-weight: 500; letter-spacing: -0.01em; }
.auth-lead { margin: 0; color: var(--ink-2); }
.auth-small { font-size: 14px; }
.auth-lead a { color: var(--accent-bright); }
.auth-card .field input { font-size: 16px; } /* Under 16px, iPhones zoom the page when a box is tapped. */
.auth-error { margin: 0; font-size: 14px; color: var(--danger); }
.auth-error:empty { display: none; }
.auth-submit { width: 100%; min-height: 48px; }
.auth-link { min-height: 44px; background: none; border: 0; color: var(--accent-bright); font-size: 14px; }
.auth-qr { display: block; width: 100%; max-width: 240px; margin: 0 auto; border-radius: 8px; }
.auth-key { color: var(--ink); overflow-wrap: anywhere; }
.auth-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; padding: 12px; list-style: none; background: var(--panel-raised); border-radius: 10px; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.auth-check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 8px 0; }
.auth-gap { margin-top: 14px; }
a.auth-submit { text-decoration: none; }
.picker-account { padding: 8px 12px 4px; font-size: 13px; color: var(--ink-3); }
.picker-warning { display: block; margin-top: 2px; color: var(--danger); }
.history { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.history summary { min-height: 36px; font-weight: 500; cursor: pointer; }
.history-list { display: flex; flex-direction: column; gap: 12px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 14px; }
.history-list li { display: flex; flex-direction: column; gap: 2px; }

/* Phones. Menu along the bottom within reach of a thumb, one column, full-screen forms, and tap targets of 44px or more. */
@media (max-width: 860px) {
  /* Under 16px, iPhones zoom the page when a box is tapped. */
  input, select, textarea { font-size: 16px; }
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }

  .sidebar {
    position: sticky; z-index: 10; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left));
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { gap: 10px; padding: 0; flex: none; }
  .brand img { width: 32px; height: 32px; }
  .brand-name { font-size: 14px; letter-spacing: 0.3em; }
  .brand-sub { font-size: 8px; letter-spacing: 0.3em; }

  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); flex-wrap: nowrap; gap: 0;
    padding: 4px calc(4px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) calc(4px + env(safe-area-inset-left));
    background: var(--sidebar); border-top: 1px solid var(--line);
  }
  .nav-item { flex-direction: column; justify-content: center; gap: 2px; width: 100%; height: 54px; padding: 0; font-size: 11px; text-align: center; border-radius: 10px; }
  .nav-item[aria-current="page"] { color: var(--accent-bright); background: var(--accent-soft); border-color: transparent; }

  .picker { flex: 0 1 auto; min-width: 0; margin: 0; padding: 0; border: 0; }
  .picker-button { gap: 8px; min-height: 44px; padding: 2px 4px; }
  .picker .avatar { width: 34px; height: 34px; font-size: 12px; }
  .picker-sub { display: none; }
  .picker-name { font-size: 14px; }
  .picker-menu { position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 12px; right: 12px; bottom: auto; max-height: 70dvh; }
  .picker-menu button { min-height: 44px; }

  .main { padding: 16px 14px calc(84px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); width: max-content; }

  .page-header { gap: 14px; margin-bottom: 14px; }
  .page-title { font-size: 30px; }
  .page-actions { width: 100%; gap: 10px; }
  .page-actions > * { flex: 1 1 100%; }
  .control { height: 48px; }
  .control select { width: 100%; min-height: 44px; }
  .panel-head { align-items: flex-start; }
  .panel-tools { width: 100%; }
  .panel-title { font-size: 22px; }
  .panel-subtitle { font-size: 19px; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; height: 40px; }
  .search { height: 46px; }

  .stats { padding: 14px 0; margin-bottom: 14px; }
  .stat { padding: 0 14px; }
  .stat-value { font-size: 24px; overflow-wrap: anywhere; }

  .drafts, .connection, .insights-table, .ad-writer, .ad-set, .studio { padding: 16px; }
  .creative-batch { padding: 4px 14px 16px; }
  .page-body { padding: 16px; min-height: 0; }
  .campaigns { padding: 16px; min-height: 0; }
  .results { padding: 16px; }
  .detail { padding: 16px 10px 10px; scroll-margin-top: calc(70px + env(safe-area-inset-top)); }
  .data-table th, .data-table td { padding: 12px 10px; }

  .btn-text { min-height: 44px; padding: 8px 6px; }
  .btn-compact, .btn-off, .btn-fill { min-height: 44px; }
  .draft-actions { flex-wrap: wrap; }
  .draft-actions .btn-primary, .draft-actions .btn-off { flex: 1 1 100%; }
  .detail-head .btn-off { width: 100%; }
  .history summary { display: flex; align-items: center; gap: 8px; min-height: 44px; }
  .chart-label { font-size: 22px; }
  .chart-table summary { min-height: 44px; display: flex; align-items: center; }
  .creative-media { max-height: 70dvh; }
  .creative-card { min-width: 0; }
  .ad-actions { flex-wrap: wrap; }
  .ad-keep { min-height: 44px; }
  .ad-keep input, .suggestion-head input { width: 22px; height: 22px; }
  .studio-form .btn-primary, .ad-writer-row .btn-primary { align-self: stretch; }
  .studio-times, .draft-ages { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .connection-page { max-width: none; }

  /* Every form fills the screen. Approve buttons stay at the end, so the details get seen first. */
  .dialog, .dialog-small, .dialog-wide {
    width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0;
  }
  .dialog form, .dialog-content {
    padding: calc(18px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  }
  .dialog h2 { font-size: 22px; }
  .dialog-actions { flex-direction: column-reverse; align-items: stretch; }
  .dialog-actions > * { width: 100%; min-height: 48px; margin: 0; }
  .btn-danger { margin-right: 0; }
  .scrape-progress { min-height: 70dvh; justify-content: center; }
}

@media (max-width: 360px) {
  .brand-text { display: none; }
  .stat-value { font-size: 21px; }
}

/* When added to a phone's home screen, there's no browser bar, so the top edge is the phone's own status bar. */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}
