/* ===== For You studio (frontend/js/for-you-studio.js) =====
 * Prefix: fys-. Only the app's own variables (app.css / theme-dark.css), so the dark theme
 * needs nothing of its own. Buttons, badges, fields, tables and the empty state come from the
 * shared render layer (ui-kit.js -> design-review.css); this file lays them out and adds the
 * few pieces that layer does not have (tabs, the editor grid, the preview frame, messages).
 * Display type stays at or under 23px; nothing moves on its own. */
.fys { --fys-border: var(--border, #e2e8f0); --fys-card: var(--bg-card, #fff); --fys-text: var(--text, #253378); --fys-muted: var(--text-secondary, #676865);
  --fys-soft: var(--bg-secondary, #f8f9fc); --fys-bad: var(--fail, #c1153a); --fys-focus: var(--primary-light, #474ecb);
  display: flex; flex-direction: column; gap: 16px; max-width: 1240px; color: var(--fys-text); }
.fys [hidden] { display: none !important; }
.fys h2, .fys h3, .fys p { margin: 0; }
.fys-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.fys-title { font-size: 20px; line-height: 28px; font-weight: 700; color: var(--fys-text); }
.fys-lede { font-size: 13.5px; line-height: 20px; color: var(--fys-muted); margin-top: 2px; max-width: 62ch; }
.fys-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--fys-border); }
.fys-nav-btn { font: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 14px; margin-bottom: -1px; background: transparent; color: var(--fys-muted); border: 0; border-bottom: 2px solid transparent; cursor: pointer; }
.fys-nav-btn:hover { color: var(--fys-text); }
.fys-nav-btn[aria-current="page"] { color: var(--fys-text); border-bottom-color: var(--fys-focus); }
.fys :is(button, input, select, textarea, summary, a):focus-visible { outline: 2px solid var(--fys-focus); outline-offset: 2px; }
.fys-file:focus-within { outline: 2px solid var(--fys-focus); outline-offset: 2px; }
/* Help text also sits straight on the tinted page background (the Settings tab), where the app's lighter
 * grey measures 4.3:1. The Studio's own muted colour is 6.7:1 there and 7.5:1 on a card. */
.fys .field-help { color: var(--fys-muted); }
.fys-view { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.fys-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.fys-muted { color: var(--fys-muted); font-size: 12px; line-height: 18px; }
.fys-note { font-size: 12.5px; line-height: 19px; color: var(--fys-muted); }
.fys-grow { flex: 1 1 260px; }

/* list: tabs, search, table */
.fys-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.fys-tabs, .fys-pvtabs { display: flex; flex-wrap: wrap; gap: 6px; }
.fys-tab { font: inherit; font-size: 12.5px; font-weight: 600; height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--fys-border); background: var(--fys-card); color: var(--fys-text); cursor: pointer; }
.fys-tab[aria-pressed="true"] { background: var(--fys-text); color: var(--fys-card); border-color: var(--fys-text); }
.fys-tab-n { font-variant-numeric: tabular-nums; opacity: .8; margin-left: 2px; }
.fys-search { margin-left: auto; flex: 0 1 280px; min-width: 180px; }
.fys-input { width: 100%; box-sizing: border-box; font: inherit; font-size: 13.5px; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--fys-border); background: var(--bg-input, var(--fys-card)); color: var(--fys-text); }
.fys-scroll { overflow-x: auto; border: 1px solid var(--fys-border); border-radius: 8px; background: var(--fys-card); }
.fys-scroll table { width: 100%; border-collapse: collapse; }
.fys-scroll th, .fys-scroll td { vertical-align: top; }
.fys-scroll td:first-child { min-width: 220px; }
.fys-link { font: inherit; font-weight: 600; color: var(--primary-light, #474ecb); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.fys-link:hover { color: var(--fys-text); }
.fys-state { padding: 18px 16px; border: 1px dashed var(--fys-border); border-radius: 8px; font-size: 13.5px; line-height: 20px; color: var(--fys-muted); background: var(--fys-card); }
.fys-state-bad { border-style: solid; border-color: var(--fys-bad); color: var(--fys-text); }
.fys-state-bad > span { color: var(--fys-bad); }

/* editor */
.fys-edhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fys-edtitle { font-size: 16px; font-weight: 700; color: var(--fys-text); }
.fys-note-box { padding: 10px 14px; border: 1px solid var(--fys-border); border-left: 3px solid var(--fys-focus); border-radius: 6px; background: var(--fys-soft); font-size: 13px; line-height: 20px; }
.fys-edgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 24px; align-items: start; }
.fys-edform { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.fys-form { display: flex; flex-direction: column; gap: 14px; }
.fys-set { margin: 0; padding: 14px 16px 6px; border: 1px solid var(--fys-border); border-radius: 8px; background: var(--fys-card); min-width: 0; }
.fys-set > legend { padding: 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--fys-muted); text-transform: uppercase; }
.fys-fld { margin-bottom: 12px; }
.fys-fld .field { margin-bottom: 0; }
.fys-fld .field input:not([type="checkbox"]), .fys-fld .field select, .fys-fld .field textarea { width: 100%; box-sizing: border-box; }
.fys-counter { margin-top: 2px; font-size: 11.5px; line-height: 16px; color: var(--fys-muted); text-align: right; font-variant-numeric: tabular-nums; }
.fys-err { margin-top: 4px; font-size: 12.5px; line-height: 18px; color: var(--fys-bad); font-weight: 600; }
.fys-fld [aria-invalid="true"] { border-color: var(--fys-bad) !important; }
.fys-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; line-height: 20px; padding: 3px 0; cursor: pointer; }
.fys-check input { width: 16px; height: 16px; flex: none; }
.fys-group { border: 0; margin: 0; padding: 0; min-width: 0; }
.fys-group > legend { padding: 0; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.fys-checks { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.fys-imgbox { display: flex; align-items: center; justify-content: center; min-height: 120px; border: 1px dashed var(--fys-border); border-radius: 8px; background: var(--fys-soft); overflow: hidden; padding: 6px; }
.fys-imgbox img { display: block; max-width: 100%; max-height: 240px; border-radius: 4px; }
.fys-imgbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0; }
.fys-file { position: relative; cursor: pointer; }
.fys-file input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.fys-genrow { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.fys-genrow .field { flex: 1 1 240px; margin: 0; }
/* the picture style and, beside it, the brand colour: labels on one line, controls on the next */
.fys-stylerow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; margin-top: 10px; }
.fys-stylerow .field { flex: 1 1 200px; margin: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.fys-stylerow .field .fys-input { display: block; height: 36px; }
.fys-stylerow + .field-help { margin-bottom: 8px; }
.fys-problems { padding: 12px 16px; border: 1px solid var(--fys-bad); border-radius: 8px; background: var(--fys-card); font-size: 13.5px; line-height: 20px; }
.fys-problems ul { margin: 6px 0 0; padding-left: 20px; }
.fys-problems strong::before { content: "⚠ "; color: var(--fys-bad); }
.fys-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 4px 0 8px; }
.fys-edform > #fys-actions { position: sticky; bottom: 0; z-index: 2; background: var(--bg-page, var(--fys-soft)); border-top: 1px solid var(--fys-border); margin: 0 -4px; padding: 8px 4px; }
.fys-status { font-size: 12.5px; color: var(--fys-muted); }
.fys-sched { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 12px 14px; border: 1px solid var(--fys-border); border-radius: 8px; background: var(--fys-soft); }
.fys-sched .field { margin: 0; }
.fys-sched .fys-err { flex-basis: 100%; margin: 0; }
.fys-setrow { padding: 10px 0; border-bottom: 1px solid var(--fys-border); }
.fys-setrow:last-of-type { border-bottom: 0; }
.fys-settings { max-width: 640px; }
.fys-range { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.fys-range .fys-input { width: auto; }

/* the preview: the real card, on a quiet plate so it stays itself in both themes */
.fys-edpv { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fys-pvhead { font-size: 13px; }
.fys-pvcard { pointer-events: none; }
.fys-pv { background: var(--fys-card); border: 1px solid var(--fys-border); border-radius: 12px; overflow: hidden; }
.fys-pv-img { display: block; width: 100%; max-height: 200px; object-fit: cover; }
.fys-pv-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.fys-pv-meta { font-size: 12px; color: var(--fys-muted); }
.fys-pv h3 { font-size: 16.5px; line-height: 24px; font-weight: 700; color: var(--fys-text); }
.fys-pv p { font-size: 13.5px; line-height: 21px; color: var(--fys-muted); }
.fys-pv-cta { align-self: flex-start; padding: 7px 16px; border-radius: 999px; background: #d9531a; color: #fff; font-size: 13px; font-weight: 600; }

@media (max-width: 900px) {
  .fys-edgrid { grid-template-columns: minmax(0, 1fr); }
  .fys-edpv { position: static; }
}
@media (max-width: 600px) {
  .fys-list-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fys-list-table, .fys-list-table tbody { display: block; }
  .fys-list-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 12px; border-bottom: 1px solid var(--fys-border); }
  .fys-list-table td { display: block; border: 0 !important; padding: 0 !important; text-align: left !important; min-width: 0 !important; }
  .fys-list-table td:first-child, .fys-list-table td:last-child { grid-column: 1 / -1; }
  .fys-list-table td:nth-child(n+2):nth-child(-n+8)::before { display: block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--fys-muted); }
  .fys-list-table td:nth-child(2)::before { content: "Kind"; } .fys-list-table td:nth-child(3)::before { content: "Audience"; }
  .fys-list-table td:nth-child(4)::before { content: "Publish window"; } .fys-list-table td:nth-child(5)::before { content: "Views"; }
  .fys-list-table td:nth-child(6)::before { content: "Opens"; } .fys-list-table td:nth-child(7)::before { content: "Clicks"; }
  .fys-list-table td:nth-child(8)::before { content: "Useful"; }
  .fys-search { margin-left: 0; flex: 1 1 100%; }
  .fys-head > .u-btn { width: 100%; }
  .fys-nav-btn { flex: 1; }
  .fys-actions .u-btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: no-preference) {
  .fys-tab, .fys-nav-btn { transition: background-color .12s, color .12s; }
}
