/* beddha control — design system (spec §6) */
:root {
  --bg: #EFEBF5;
  --surface: #FFFFFF;
  --text: #231536;
  --text-2: #6E637D;
  --purple: #7047D6;
  --purple-hover: #5F39C2;
  --lavender: #A68EC9;
  --teal: #157F83;
  --rose: #A95365;
  --hl-purple: #F2EDFA;
  --hl-mint: #E3F2EB;
  --hl-blush: #F6E9ED;
  --line: rgba(35, 21, 54, 0.10);
  --line-strong: rgba(35, 21, 54, 0.18);
  --shadow: 0 1px 2px rgba(35, 21, 54, 0.04), 0 8px 24px rgba(35, 21, 54, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
  --font-head: 'Plus Jakarta Sans', 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Manrope', 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --header-h: 60px;
  --footer-h: 118px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, .head { font-family: var(--font-head); letter-spacing: -0.01em; }
button, input, textarea, select { font-family: var(--font-body); font-size: 14px; color: var(--text); }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
.hdr {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 0 20px;
  background: rgba(239, 235, 245, 0.88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.hdr-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hdr-mid { display: flex; align-items: center; gap: 12px; min-width: 240px; width: min(420px, 38vw); }
.hdr-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.brand { display: flex; align-items: baseline; gap: 6px; flex: none; }
.brand-name { font-family: var(--font-head); font-weight: 800; font-size: 16px; color: var(--text); letter-spacing: -0.02em; }
.brand-sub { font-family: var(--font-head); font-weight: 600; font-size: 11px; color: var(--lavender); text-transform: uppercase; letter-spacing: 0.12em; }

.tenant-sel { position: relative; min-width: 0; }
.tenant-sel select {
  appearance: none; -webkit-appearance: none;
  height: 36px; padding: 0 34px 0 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-family: var(--font-head); font-weight: 700; font-size: 13px;
  max-width: 220px; text-overflow: ellipsis; cursor: pointer;
}
.tenant-sel select:disabled { cursor: default; opacity: 1; color: var(--text); }
.tenant-sel::after {
  content: ''; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px;
  border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.tenant-sel.single::after { display: none; }
.tenant-sel.single select { padding-right: 12px; }
.tenant-sel select:focus { outline: 2px solid var(--purple); outline-offset: 1px; }

.progress { flex: 1; height: 8px; border-radius: 999px; background: rgba(35, 21, 54, 0.10); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--purple), var(--lavender)); border-radius: 999px; transition: width .35s ease; }
.progress-label { flex: none; font-family: var(--font-head); font-weight: 700; font-size: 12px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.progress-label b { color: var(--text); }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: rgba(35, 21, 54, 0.08); gap: 2px; }
.seg button {
  height: 30px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent;
  font-family: var(--font-head); font-weight: 700; font-size: 12.5px; color: var(--text-2);
  transition: background .15s ease, color .15s ease;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--purple); box-shadow: 0 1px 2px rgba(35, 21, 54, 0.10); }
.seg button:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; }
.seg-sm { flex: none; }
.seg-sm button { height: 28px; padding: 0 10px; font-size: 11.5px; }
.seg-sm.icons button { padding: 0 8px; }
.seg-sm.icons button svg { width: 15px; height: 15px; display: block; }
.seg-sm.icons button[data-platform="all"] { padding: 0 10px; }
.order-btn {
  flex: none; height: 30px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--text-2);
  font-family: var(--font-head); font-weight: 700; font-size: 12px; white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
}
.order-btn:hover { color: var(--purple); border-color: var(--purple); }
.order-btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; }

.userchip { position: relative; }
.userchip > button {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--hl-purple); color: var(--purple);
  font-family: var(--font-head); font-weight: 800; font-size: 12px;
}
.usermenu {
  position: absolute; right: 0; top: 42px; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 8px; z-index: 30;
}
.usermenu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.usermenu .who b { display: block; font-family: var(--font-head); font-size: 13px; }
.usermenu .who span { font-size: 12px; color: var(--text-2); }
.usermenu .who.small { font-size: 11px; color: var(--text-2); padding-top: 6px; }
.usermenu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; font-size: 13px; }
.usermenu button:hover { background: var(--hl-purple); }
.sync { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.sync.err { color: var(--rose); font-weight: 700; }
.sync.ok { color: var(--teal); }

/* ---------- Main ----------
   ≥ 1180px: three columns that fit the viewport — video | stats | your review (no page scroll).
   < 1180px: single column, actions pinned to the bottom of the screen.                    */
.main { margin: 0 auto; padding: 24px 20px calc(var(--footer-h) + 24px); }
.main-single { max-width: 760px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.review { display: grid; gap: 16px; }
.col { display: flex; flex-direction: column; min-width: 0; }
.col-video { overflow: hidden; }
.col-side { padding: 16px; gap: 12px; }
.col-inputs { padding: 18px 20px; gap: 16px; }

.creator { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--purple), var(--lavender)); color: #fff;
  display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: 14px;
}
.creator .who { min-width: 0; flex: 1; }
.creator .handle { font-family: var(--font-head); font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.creator .meta { font-size: 12px; color: var(--text-2); display: flex; gap: 8px; flex-wrap: wrap; }
.creator .meta time { font-variant-numeric: tabular-nums; }
/* "commented N days after the video went up" — the signal that we hit a stale video */
.creator .meta .agegap { color: #B4530A; font-weight: 700; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-family: var(--font-head); font-weight: 700; font-size: 11px; letter-spacing: .02em;
}
.badge svg { width: 12px; height: 12px; }
.badge.tiktok { background: #231536; color: #fff; }
.badge.instagram { background: var(--hl-blush); color: var(--rose); }
.badge.unknown { background: rgba(35, 21, 54, 0.08); color: var(--text-2); }
.badge.status-posted { background: var(--hl-mint); color: var(--teal); }
.badge.status-pending { background: var(--hl-blush); color: var(--rose); }

.media {
  position: relative; background: #17101f; min-height: 420px; flex: 1;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.media iframe { width: 100%; height: 100%; min-height: 560px; border: 0; display: block; background: #000; }
.media video.native { width: 100%; height: 100%; min-height: 560px; display: block; background: #000; object-fit: contain; }
.media .unmute {
  position: absolute; left: 10px; top: 10px; z-index: 2;
  height: 30px; padding: 0 11px; border: 0; border-radius: 999px;
  background: rgba(35, 21, 54, 0.72); color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 12px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.media .unmute:hover { background: var(--purple); }
.media .fallback.loading .why { color: #A99EB6; }
.media .fallback { padding: 28px 24px; text-align: center; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.media .fallback .badge.instagram { background: rgba(255,255,255,.12); color: #fff; }
.media .fallback .why { margin: 4px 0 0; font-size: 13px; color: #D9CFEA; max-width: 260px; }
.media .fallback .tip { margin: 0; font-size: 12px; color: #A99EB6; }
.media .fallback .btn-primary { min-width: 0; height: 42px; font-size: 14px; }
.media .fallback .btn-primary:hover { text-decoration: none; }
.col-video .openlink { padding: 10px 16px; border-top: 1px solid var(--line); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 10px 12px; border-radius: 10px; background: var(--hl-purple); }
.stat b { display: block; font-family: var(--font-head); font-size: 18px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.label { font-family: var(--font-head); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--text-2); }
.topc { padding: 12px 14px; border-radius: 10px; background: var(--hl-mint); }
.topc .label { color: var(--teal); margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }
.topc .label small { font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--teal); }
.topc p { margin: 0; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.openlink { font-size: 12px; font-weight: 700; }

.aicomment { padding: 16px 18px; border-radius: 12px; background: var(--hl-purple); border: 1px solid rgba(112, 71, 214, 0.18); }
.aicomment .label { color: var(--purple); display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.aicomment .label small { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--lavender); font-variant-numeric: tabular-nums; }
.aicomment p { margin: 0; font-family: var(--font-head); font-size: 19px; line-height: 1.4; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }

/* Translation boxes — one under the top comment, one under the AI comment.
   Deliberately quieter than the originals: white, hairline border, smaller type. */
.trbox { padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px dashed var(--line-strong); }
.trbox.on { border-style: solid; }
.trbox .label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.trbox.on .label { margin-bottom: 6px; }
.trbox p { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--text); overflow-wrap: anywhere; }
#tr-ai.trbox p { font-family: var(--font-head); font-size: 15px; font-weight: 700; }
.trbox p.muted { font-size: 12px; font-weight: 600; }
.trbox p .linkbtn { font-size: 12px; margin-left: 8px; }
.trchips { display: inline-flex; gap: 4px; }
.trchips button {
  height: 22px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  font-family: var(--font-head); font-size: 10.5px; font-weight: 800; letter-spacing: .06em; color: var(--text-2);
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.trchips button:hover { color: var(--purple); border-color: var(--purple); }
.trchips button[aria-pressed="true"] { background: var(--purple); border-color: var(--purple); color: #fff; }
.trchips button:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; }

.muted { color: var(--text-2); }
.muted-head { color: var(--text-2); font-weight: 700; }
.field .fhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.field .fhead .val { font-size: 12px; color: var(--text-2); font-weight: 700; }
.field .fhead .val.on { color: var(--purple); }
.scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.scale button {
  height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface);
  font-family: var(--font-head); font-weight: 800; font-size: 14px; color: var(--text-2);
  transition: all .12s ease;
}
.scale button:hover { border-color: var(--purple); color: var(--purple); }
.scale button[aria-pressed="true"] { background: var(--purple); border-color: var(--purple); color: #fff; }
.scale button:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.scale.low button[aria-pressed="true"] { background: var(--rose); border-color: var(--rose); }
.scale.high button[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); }
textarea {
  width: 100%; min-height: 76px; resize: vertical; padding: 11px 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  line-height: 1.5; outline: none; transition: border-color .12s ease, box-shadow .12s ease;
}
textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(112, 71, 214, 0.14); }
textarea::placeholder { color: #A99EB6; }
.optional { font-size: 11px; color: var(--lavender); font-weight: 700; text-transform: none; letter-spacing: 0; margin-left: 6px; }

/* ---------- Actions (Submit / Skip) ---------- */
.actions { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--line); }
.actions .btn-primary { width: 100%; }
.conflict { width: 100%; padding: 10px 12px; border-radius: 10px; background: var(--hl-blush); color: var(--rose); font-size: 13px; line-height: 1.4; }
.conflict b { display: block; font-family: var(--font-head); }
.btn-primary {
  min-width: 240px; height: 48px; padding: 0 28px; border: 0; border-radius: 12px;
  background: var(--purple); color: #fff; font-family: var(--font-head); font-weight: 800; font-size: 15px;
  box-shadow: 0 6px 18px rgba(112, 71, 214, 0.28); transition: background .15s ease, transform .05s ease, box-shadow .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-primary:hover { background: var(--purple-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: var(--lavender); box-shadow: none; }
.btn-primary kbd { font-family: var(--font-body); font-size: 11px; font-weight: 700; opacity: .75; border: 1px solid rgba(255,255,255,.45); border-radius: 5px; padding: 1px 6px; }
.btn-link { border: 0; background: transparent; color: var(--text-2); font-weight: 700; font-size: 13px; padding: 4px 8px; border-radius: 6px; }
.btn-link:hover { color: var(--purple); background: rgba(112, 71, 214, 0.08); }
.btn-link.block { width: 100%; margin-top: 8px; }
.hint { font-size: 12px; color: var(--text-2); min-height: 16px; text-align: center; }
.hint.warn { color: var(--rose); font-weight: 700; }

/* ---------- Login / states ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 400px; padding: 32px 30px; }
.login h1 { margin: 6px 0 4px; font-size: 22px; font-weight: 800; }
.login p { margin: 0 0 20px; color: var(--text-2); font-size: 13px; }
.login label { display: block; font-size: 12px; font-weight: 700; color: var(--text-2); margin: 12px 0 6px; }
.login input {
  width: 100%; height: 44px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); outline: none;
}
.login input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(112, 71, 214, 0.14); }
.login .btn-primary { width: 100%; margin-top: 18px; min-width: 0; }
.login .err { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--hl-blush); color: var(--rose); font-size: 13px; font-weight: 700; }
.empty { text-align: center; padding: 64px 24px; }
.empty h1 { font-size: 26px; margin: 12px 0 8px; }
.empty p { color: var(--text-2); margin: 0 0 20px; }
.empty .btn-primary { min-width: 0; }
.skeleton { height: 620px; border-radius: var(--radius); background: linear-gradient(90deg, rgba(255,255,255,.7), rgba(255,255,255,1), rgba(255,255,255,.7)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { from { background-position: 200% 0 } to { background-position: -200% 0 } }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
  background: var(--text); color: #fff; font-size: 13px; box-shadow: 0 10px 28px rgba(35, 21, 54, 0.25);
  animation: pop .18s ease;
}
.toast.err { background: var(--rose); }
.toast button { border: 0; background: transparent; color: #DCCFF7; font-weight: 800; padding: 0; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 6px) } to { opacity: 1; transform: translate(-50%, 0) } }
.banner { margin-bottom: 14px; padding: 10px 14px; border-radius: 10px; background: var(--hl-blush); color: var(--rose); font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.banner button { border: 0; background: var(--rose); color: #fff; border-radius: 7px; padding: 6px 10px; font-weight: 800; font-size: 12px; }

/* ---------- Layout: desktop (three columns, fits the viewport) ---------- */
@media (min-width: 1180px) {
  .main-review { max-width: 1400px; padding: 16px 20px 16px; height: calc(100vh - var(--header-h)); overflow: hidden; }
  .review { grid-template-columns: 372px minmax(280px, 340px) minmax(420px, 520px); justify-content: center; align-items: start; height: 100%; }
  /* Row track stretches to fill the viewport (default align-content: stretch on a single-row grid),
     but only the video column opts back into filling it (align-self: stretch) — the video is the
     naturally tall element. Stats/inputs stay content-height and sit at the top of that same row,
     so a short column ends where its content ends instead of dragging a card's white background
     all the way down with nothing in it. */
  .col { max-height: 100%; }
  .col-video { align-self: stretch; }
  .col-side, .col-inputs { overflow-y: auto; }
  .col-video .media { min-height: 0; }
  .media iframe, .media video.native { min-height: 0; }
  .col-inputs { gap: 14px; }
  .scale button { height: 36px; }
  textarea { min-height: 64px; }
  .aicomment p { font-size: 17px; }
}

/* ---------- Layout: narrow (single column, actions pinned to the bottom) ---------- */
@media (max-width: 1179px) {
  .main-review { max-width: 760px; }
  .review { grid-template-columns: 1fr; }
  .col-side { padding: 18px; }
  .actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0; border-top: 1px solid var(--line);
    padding: 14px 20px 16px; background: rgba(239, 235, 245, 0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
  .actions .btn-primary { width: auto; }
  .toast { bottom: calc(var(--footer-h) + 14px); }
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .hdr { grid-template-columns: 1fr auto; gap: 8px; padding: 0 12px; position: sticky; }
  .hdr-left { gap: 8px; }
  .brand-name { font-size: 15px; }
  .brand-sub { display: none; }
  .tenant-sel { flex: 1; min-width: 0; }
  .tenant-sel select { width: 100%; max-width: 100%; }
  .hdr-mid { position: absolute; left: 0; right: 0; bottom: -1px; width: auto; min-width: 0; height: 4px; }
  .progress { height: 4px; border-radius: 0; background: transparent; }
  .progress > i { border-radius: 0; }
  .progress-label { display: none; }
  .sync.ok, .sync:not(.err) { display: none; }
  .kbd, .btn-primary kbd, .hint { display: none; }
  /* Fixed 60px header (--header-h) has no room for the platform/order toggles
     once the tenant switcher needs to stay usable — hidden here, same as the
     other secondary controls above. Still available at tablet width (>820px). */
  .seg-sm.icons, .order-btn { display: none; }
  #skipBtn { padding-bottom: 8px; }
  .main { padding-top: 16px; }
  .media { min-height: 0; }
  .media iframe { min-height: 520px; }
  .scale { grid-template-columns: repeat(5, 1fr); }
  .btn-primary, .actions .btn-primary { width: 100%; }
  .seg button { padding: 0 10px; }
}

/* ---------- Change password (user menu) ---------- */
.pwform { display: grid; gap: 8px; padding: 6px 10px 10px; }
.pwform input { height: 38px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); outline: none; }
.pwform input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(112, 71, 214, 0.14); }
.pwform .btn-primary { min-width: 0; height: 38px; font-size: 13px; box-shadow: none; }
.pwmsg { font-size: 12px; font-weight: 700; }
.pwmsg.ok { color: var(--teal); }
.pwmsg.err { color: var(--rose); }

/* ---------- Auth extras ---------- */
.authmsg { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; line-height: 1.5; }
.authmsg.err { background: var(--hl-blush); color: var(--rose); }
.authmsg.ok { background: var(--hl-mint); color: var(--teal); }
.authlinks { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 18px; font-size: 13px; color: var(--lavender); }
.linkbtn { border: 0; background: transparent; padding: 0; color: var(--purple); font-weight: 700; font-size: 13px; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.authmsg .linkbtn { display: block; margin-top: 6px; }
.login p b { color: var(--text); }
