@font-face { font-family: 'DM Sans'; src: url('/fonts/dmsans.woff') format('woff'); font-weight: 100 1000; font-display: swap; }
@font-face { font-family: 'Bitter'; src: url('/fonts/bitter.woff') format('woff'); font-weight: 100 900; font-display: swap; }

:root {
  --mist: #edf1f5;
  --paper: #ffffff;
  --ink: #172338;
  --slate: #5e6b7e;
  --rule: #d3dae3;
  --rule-soft: #e4e9ef;
  --teal: #0e7c6b;
  --teal-ink: #0a5e52;
  --teal-wash: #e3f2ef;
  --amber: #a8670f;
  --amber-wash: #fbf1df;
  --red: #b93228;
  --red-wash: #fbe9e7;
  --green: #2e7d4f;
  --ig: #c13584;
  --li: #0a66c2;
  --yt: #d62817;
  --manual: #7a6a4f;
  --fb: #1877f2;
  --tt: #e2165d;
  --serif: 'Bitter', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-lg: 12px;
  --r-md: 8px;
  --r-sm: 5px;
  --nav-w: 216px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--mist); color: var(--ink); font: 400 15px/1.5 var(--sans); font-optical-sizing: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal-ink); }
img { max-width: 100%; display: block; }
main svg { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--rule); background: var(--paper); display: flex; flex-direction: column; gap: 2px; }
.brand { font: 700 21px/1 var(--serif); letter-spacing: -0.01em; padding: 4px 10px 22px; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 22px; height: 22px; flex: none; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r-md); color: var(--slate); text-decoration: none; font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--mist); color: var(--ink); }
.nav a[aria-current='page'] { background: var(--teal-wash); color: var(--teal-ink); }
.nav .nav-compose { margin: 0 0 14px; background: var(--teal); color: #fff; justify-content: center; font-weight: 600; }
.nav .nav-compose:hover { background: var(--teal-ink); color: #fff; }
.nav .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700; border-radius: 99px; padding: 0 7px; line-height: 19px; }
.nav-foot { margin-top: auto; padding: 10px; font-size: 13px; color: var(--slate); }
.nav-foot button { background: none; border: 0; padding: 0; color: var(--slate); cursor: pointer; text-decoration: underline; }

main { min-width: 0; padding: 30px clamp(16px, 4vw, 44px) 80px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head > *, .row > .seg { min-width: 0; max-width: 100%; }
h1 { font: 650 clamp(26px, 3.2vw, 34px)/1.12 var(--serif); letter-spacing: -0.015em; margin: 0; }
h2 { font: 650 19px/1.25 var(--serif); margin: 0 0 12px; }
h3 { font: 600 15px/1.3 var(--sans); margin: 0 0 6px; }
.sub { color: var(--slate); margin: 6px 0 0; max-width: 64ch; }
.muted { color: var(--slate); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- surfaces ---------- */
.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.totals > .panel, .pf-setup > .panel, .grid-2 > .panel, .grid-2 > .stack { margin-top: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
hr { border: 0; border-top: 1px solid var(--rule-soft); margin: 16px 0; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 15px; border-radius: var(--r-md); border: 1px solid var(--rule); background: var(--paper); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #b7c2cf; background: #f7f9fb; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-ink); border-color: var(--teal-ink); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-wash); border-color: #efc4bf; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--mist); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--slate) transparent var(--slate) transparent; animation: spin .8s linear infinite; }
.btn.primary.busy::after { border-color: #fff transparent #fff transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

label.field { display: block; }
.field > span { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.field small { display: block; color: var(--slate); font-size: 12.5px; margin-top: 4px; }
input[type=text], input:not([type]), input[type=password], input[type=url], input[type=number], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--paper); padding: 9px 11px; min-height: 40px; }
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-wash); }
.fields { display: grid; gap: 14px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--teal); }

.seg { max-width: 100%; overflow-x: auto; display: inline-flex; background: var(--mist); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font-weight: 600; font-size: 13.5px; color: var(--slate); cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(23, 35, 56, .12); }

/* ---------- platform identity ---------- */
.pf { --pf: var(--slate); }
.pf-instagram { --pf: var(--ig); }
.pf-linkedin { --pf: var(--li); }
.pf-youtube { --pf: var(--yt); }
.pf-manual { --pf: var(--manual); }
.pf-facebook { --pf: var(--fb); }
.pf-tiktok { --pf: var(--tt); }
.pf-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pf); flex: none; display: inline-block; }
.pf-icon { width: 18px; height: 18px; color: var(--pf); flex: none; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 99px; background: var(--mist); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip .pf-icon { width: 14px; height: 14px; }
.chip.st-published { background: #e5f2ea; color: var(--green); }
.chip.st-failed { background: var(--red-wash); color: var(--red); }
.chip.st-needs_action, .chip.st-retrying { background: var(--amber-wash); color: var(--amber); }
.chip.st-publishing { background: var(--teal-wash); color: var(--teal-ink); }

.status { font-size: 12.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--mist); color: var(--slate); white-space: nowrap; }
.status.scheduled { background: var(--teal-wash); color: var(--teal-ink); }
.status.published { background: #e5f2ea; color: var(--green); }
.status.failed, .status.partial { background: var(--red-wash); color: var(--red); }
.status.needs_action, .status.publishing { background: var(--amber-wash); color: var(--amber); }

/* ---------- today ---------- */
.today-date { font: 650 clamp(30px, 4.4vw, 46px)/1.05 var(--serif); letter-spacing: -0.02em; margin: 0; }
.today-next { margin-top: 10px; color: var(--slate); font-size: 16px; }
.today-next strong { color: var(--ink); }
.counts { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 18px; }
.counts div { display: flex; flex-direction: column; }
.counts b { font: 650 24px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.counts span { color: var(--slate); font-size: 13px; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--amber-wash); color: #6b4309; font-size: 14px; }
.alert.error { background: var(--red-wash); color: #7e1f18; }
.alert.info { background: var(--teal-wash); color: var(--teal-ink); }
.alert + .alert { margin-top: 8px; }
.alert .btn { margin-left: auto; }

/* list of posts (stubs) */
.stubs { list-style: none; margin: 0; padding: 0; }
.stub { display: grid; grid-template-columns: 74px 1fr auto; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--rule-soft); cursor: pointer; }
.stub:first-child { border-top: 0; }
.stub:hover .stub-title { text-decoration: underline; }
.stub-when { font: 600 15px/1.15 var(--serif); font-variant-numeric: tabular-nums; }
.stub-when small { display: block; font: 500 12px/1.3 var(--sans); color: var(--slate); }
.stub-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stub-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.stub-thumb { width: 44px; height: 44px; border-radius: var(--r-sm); object-fit: cover; background: var(--mist); }
.empty { padding: 26px 8px; text-align: center; color: var(--slate); }
.empty .btn { margin-top: 10px; }

.issue { border-top: 1px solid var(--rule-soft); padding: 14px 0; }
.issue:first-child { border-top: 0; padding-top: 0; }
.issue-err { font-size: 13.5px; color: var(--red); margin: 6px 0 8px; overflow-wrap: anywhere; }
.issue-err.warn { color: var(--amber); }

/* ---------- calendar (timetable) ---------- */
.cal-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.cal-title { font: 650 20px/1.2 var(--serif); margin: 0 6px; min-width: 200px; }
.tt { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.tt-head { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--rule); background: var(--paper); position: sticky; top: 0; z-index: 2; }
.tt-head div { padding: 10px 8px; font-size: 13px; color: var(--slate); border-left: 1px solid var(--rule-soft); }
.tt-head div:first-child { border-left: 0; }
.tt-head b { display: block; font: 650 20px/1.1 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.tt-head .is-today b { color: var(--teal); }
.tt-body { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); max-height: 70vh; overflow-y: auto; }
.tt-hour { font: 500 11.5px/1 var(--sans); color: var(--slate); text-align: right; padding: 4px 8px 0 0; height: 52px; border-top: 1px solid var(--rule-soft); font-variant-numeric: tabular-nums; }
.tt-cell { min-height: 52px; border-top: 1px solid var(--rule-soft); border-left: 1px solid var(--rule-soft); position: relative; padding: 2px 3px; cursor: pointer; }
.tt-cell:hover { background: #f6f9fb; }
.tt-cell.past { background: repeating-linear-gradient(135deg, #fafbfc, #fafbfc 6px, #f3f5f8 6px, #f3f5f8 12px); cursor: default; }
.tt-cell.drop { background: var(--teal-wash); }
.tt-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--teal); z-index: 1; }
.ticket { display: block; width: 100%; text-align: left; border: 0; border-left: 4px solid var(--pf); background: color-mix(in srgb, var(--pf) 9%, white); border-radius: 4px; padding: 3px 6px; font-size: 12px; line-height: 1.3; margin-bottom: 2px; cursor: pointer; overflow: hidden; position: relative; z-index: 1; }
.ticket b { font-variant-numeric: tabular-nums; font-weight: 700; margin-right: 4px; }
.ticket .pf-icon { width: 11px; height: 11px; vertical-align: -1px; margin-left: 2px; display: inline-block; }
.tt-more { font-size: 11.5px; color: var(--slate); font-weight: 600; padding: 0 4px; }
.ticket span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.ticket.multi { border-left-image: linear-gradient(var(--c1), var(--c2)) 1; border-left-style: solid; }
.ticket.draft { background: repeating-linear-gradient(135deg, #fff, #fff 5px, #f3f5f8 5px, #f3f5f8 10px); }
.ticket.failed, .ticket.partial { background: var(--red-wash); }
.ticket.published { opacity: .78; }
.ticket[draggable='true'] { cursor: grab; }

.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.month .dow { padding: 8px; font-size: 12.5px; color: var(--slate); border-bottom: 1px solid var(--rule); }
.month .day { min-height: 108px; border-top: 1px solid var(--rule-soft); border-left: 1px solid var(--rule-soft); padding: 6px; cursor: pointer; }
.month .day:nth-child(7n + 1) { border-left: 0; }
.month .day.other { background: #fafbfc; color: var(--slate); }
.month .day .d { font: 600 14px/1 var(--serif); font-variant-numeric: tabular-nums; display: inline-block; margin-bottom: 5px; }
.month .day.is-today .d { color: #fff; background: var(--teal); border-radius: 99px; padding: 3px 6px; }

.agenda-day { margin-bottom: 16px; }
.agenda-day h3 { font: 650 16px/1.2 var(--serif); margin: 0 0 8px; }

/* ---------- composer ---------- */
.compose > * { min-width: 0; }
.compose { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.accounts-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1.5px solid var(--rule); border-radius: 99px; background: var(--paper); cursor: pointer; font-weight: 600; font-size: 13.5px; }
.acc-toggle img, .acc-toggle .av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: var(--mist); display: grid; place-items: center; }
.acc-toggle[aria-pressed='true'] { border-color: var(--pf); background: color-mix(in srgb, var(--pf) 7%, white); }
.acc-toggle[aria-pressed='true']::after { content: '✓'; color: var(--pf); font-weight: 800; }
.acc-toggle.off { opacity: .55; }
.editor { position: relative; }
.editor textarea { min-height: 190px; font-size: 15.5px; }
.counter { font-size: 12.5px; color: var(--slate); text-align: right; margin-top: 4px; font-variant-numeric: tabular-nums; }
.counter .over { color: var(--red); font-weight: 700; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 12px; font-weight: 600; color: var(--slate); border-bottom: 2.5px solid transparent; margin-bottom: -1px; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; white-space: nowrap; }
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--pf, var(--teal)); }

.dropzone { border: 1.5px dashed #b8c3d0; border-radius: var(--r-lg); padding: 18px; text-align: center; color: var(--slate); cursor: pointer; background: #fafbfc; }
.dropzone.over { border-color: var(--teal); background: var(--teal-wash); color: var(--teal-ink); }
.media-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 12px; }
.media-item { position: relative; border-radius: var(--r-md); overflow: hidden; background: var(--ink); aspect-ratio: 1; }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; }
.media-item .mi-bar { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 4px; background: linear-gradient(transparent, rgba(10, 16, 28, .7)); }
.media-item button { border: 0; background: rgba(255, 255, 255, .92); border-radius: 5px; width: 26px; height: 26px; cursor: pointer; font-weight: 700; display: grid; place-items: center; padding: 0; }
.media-item .mi-kind { position: absolute; top: 5px; left: 5px; background: rgba(10, 16, 28, .7); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.progress { height: 6px; background: var(--mist); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress div { height: 100%; background: var(--teal); width: 0; transition: width .2s; }

.slots { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.slot { border: 1px dashed var(--teal); color: var(--teal-ink); background: var(--paper); border-radius: 99px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.slot:hover { background: var(--teal-wash); }

.problems { list-style: none; padding: 0; margin: 0; }
.problems li { padding: 8px 0; border-top: 1px solid var(--rule-soft); font-size: 13.5px; }
.problems li:first-child { border-top: 0; }
.problems b { display: block; }
.ok-line { color: var(--green); font-weight: 600; font-size: 13.5px; }

.ai-box { background: linear-gradient(180deg, #f3f8fb, #fff); }
.ai-box textarea { min-height: 76px; }

.preview { max-width: 380px; margin: 0 auto; border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; background: #fff; font-size: 13.5px; }
.preview-head { display: flex; align-items: center; gap: 8px; padding: 9px 10px; font-weight: 700; font-size: 13px; }
.preview-head .av { width: 26px; height: 26px; border-radius: 50%; background: var(--mist); object-fit: cover; }
.preview-media { background: var(--mist); aspect-ratio: 1; display: grid; place-items: center; color: var(--slate); }
.preview-media img, .preview-media video { width: 100%; height: 100%; object-fit: cover; }
.preview-text { padding: 9px 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 210px; overflow: auto; }

.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--mist) 30%); padding: 18px 0 6px; margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; z-index: 3; }

/* ---------- post check ---------- */
.check-result { border-top: 1px solid var(--rule-soft); margin-top: 14px; padding-top: 14px; }
.check-head { display: flex; align-items: center; gap: 7px; }
.check-score { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.check-score b { font: 650 40px/1 var(--serif); font-variant-numeric: tabular-nums; }
.check-score span { color: var(--slate); font-weight: 600; }
.check-score em { font-style: normal; font-weight: 600; margin-left: 4px; }
.meter { height: 6px; border-radius: 99px; background: var(--mist); overflow: hidden; margin-top: 8px; }
.meter div { height: 100%; border-radius: 99px; }
.check-list { margin: 0; padding-left: 18px; font-size: 13.5px; }
.check-list li { margin: 4px 0; }
.check-list.good li::marker { color: var(--green); }
.check-list.fix li::marker { color: var(--amber); }
.check-list li.warn { color: var(--amber); }
.suggest { background: var(--teal-wash); border-radius: var(--r-md); padding: 10px 12px; margin-top: 10px; }
.suggest p { margin: 2px 0 8px; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- tables / lists ---------- */
.list-filters { margin-bottom: 14px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12.5px; color: var(--slate); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f7f9fb; }
.clip { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- accounts ---------- */
.pf-setup { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.pf-card { border-top: 4px solid var(--pf); }
.pf-card h2 { display: flex; align-items: center; gap: 9px; }
.pf-card .pf-icon { width: 22px; height: 22px; }
.checks { list-style: none; margin: 10px 0; padding: 0; font-size: 13.5px; }
.checks li { display: grid; grid-template-columns: 20px 1fr; gap: 6px; padding: 5px 0; }
.checks .ic { font-weight: 800; }
.checks .ok .ic { color: var(--green); }
.checks .bad .ic { color: var(--red); }
.checks .detail { color: var(--slate); overflow-wrap: anywhere; display: block; }
.copyline { display: flex; gap: 6px; align-items: center; margin-top: 3px; }
.copyline code { background: var(--mist); border-radius: 4px; padding: 3px 6px; font-size: 12px; overflow-wrap: anywhere; }
.acc-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--rule-soft); }
.acc-row:first-child { border-top: 0; }
.acc-row .av { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--mist); display: grid; place-items: center; }
.acc-row .av svg { width: 22px; height: 22px; }
.acc-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.diag { grid-column: 2 / -1; }

/* ---------- insights ---------- */
.heat { display: grid; grid-template-columns: 44px repeat(8, minmax(0, 1fr)); gap: 3px; font-size: 12px; }
.heat .h { color: var(--slate); text-align: center; font-variant-numeric: tabular-nums; }
.heat .d { color: var(--slate); align-self: center; font-weight: 600; }
.heat .c { aspect-ratio: 1.5; border-radius: 4px; background: var(--mist); display: grid; place-items: center; font-weight: 700; font-size: 11.5px; color: var(--ink); }
.best { list-style: none; padding: 0; margin: 0; }
.best li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--rule-soft); }
.best li:first-child { border-top: 0; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.totals .panel { padding: 16px; }
.totals dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; margin: 8px 0 0; font-size: 13.5px; }
.totals dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.totals dt { color: var(--slate); }

/* ---------- modal / drawer / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 24, 40, .38); display: flex; justify-content: flex-end; z-index: 50; animation: fade .15s ease-out; }
.drawer { width: min(560px, 100%); background: var(--mist); height: 100%; overflow-y: auto; padding: 24px; box-shadow: -10px 0 30px rgba(15, 24, 40, .14); animation: slide .2s ease-out; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
.dialog { width: min(460px, 100%); background: var(--paper); border-radius: var(--r-lg); padding: 22px; box-shadow: 0 20px 50px rgba(15, 24, 40, .25); }
.drawer-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 18px; }
.drawer-head h2 { margin: 0; flex: 1; font-size: 22px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: .4; } }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; width: min(440px, calc(100% - 24px)); }
.toast { background: var(--ink); color: #fff; padding: 11px 15px; border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(15, 24, 40, .25); font-size: 14px; animation: fade .2s; }
.toast.error { background: var(--red); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); }
.login-card .brand { justify-content: center; font-size: 30px; padding-bottom: 8px; }
.login-card p { text-align: center; color: var(--slate); margin: 0 0 22px; }

pre.code { background: var(--ink); color: #e6ecf3; padding: 14px; border-radius: var(--r-md); overflow: auto; font-size: 12.5px; white-space: pre-wrap; max-height: 320px; }
.log { font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.log div { padding: 4px 0; border-top: 1px solid var(--rule-soft); overflow-wrap: anywhere; }
.log .error { color: var(--red); }
.log .warn { color: var(--amber); }

/* ---------- mobile ---------- */
.mobile-bar { display: none; }
@media (max-width: 1080px) {
  .compose { grid-template-columns: minmax(0, 1fr); }
  .pf-setup { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { display: none; }
  main { padding: 20px 14px 96px; }
  .grid-2, .fields-2 { grid-template-columns: 1fr; }
  .mobile-bar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; background: var(--paper); border-top: 1px solid var(--rule); z-index: 40; padding-bottom: env(safe-area-inset-bottom); }
  .mobile-bar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; font-size: 11px; font-weight: 600; color: var(--slate); text-decoration: none; position: relative; }
  .mobile-bar a svg { width: 22px; height: 22px; }
  .mobile-bar a[aria-current='page'] { color: var(--teal-ink); }
  .mobile-bar .compose-fab svg { background: var(--teal); color: #fff; border-radius: 10px; padding: 3px; width: 30px; height: 30px; margin-top: -4px; }
  .mobile-bar .badge { position: absolute; top: 4px; right: calc(50% - 20px); background: var(--red); color: #fff; font-size: 10px; border-radius: 99px; padding: 0 5px; line-height: 16px; }
  .stub { grid-template-columns: 62px 1fr; }
  .stub .stub-thumb { display: none; }
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; border-bottom: 1px solid var(--rule-soft); padding: 8px 0; }
  .table.responsive td { display: block; border: 0; padding: 3px 4px; }
  .clip { max-width: 100%; white-space: normal; }
  .drawer { padding: 18px 16px; }
  .sticky-actions { bottom: calc(58px + env(safe-area-inset-bottom)); }
  .sticky-actions .btn { flex: 1 1 0; padding: 0 8px; }
  .sticky-actions .spacer, .sticky-actions .ghost { display: none; }
  .seg button { white-space: nowrap; }
  .acc-row { grid-template-columns: 40px 1fr; }
  .acc-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .heat { grid-template-columns: 34px repeat(8, minmax(0, 1fr)); gap: 2px; }
  .heat .c { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- clips ---------- */
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.clips-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.clips-layout > .panel { margin-top: 0; }
.proj-list { display: grid; gap: 2px; margin: 0 -8px; }
.proj-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border: 0; background: none; border-radius: var(--r-md); text-align: left; font: inherit; color: inherit; cursor: pointer; }
.proj-row:hover { background: var(--mist); }
.proj-thumb { width: 56px; height: 56px; border-radius: 8px; background: var(--mist); display: grid; place-items: center; overflow: hidden; color: var(--slate); }
.proj-thumb video { width: 100%; height: 100%; object-fit: cover; }
.proj-main { display: grid; gap: 2px; min-width: 0; }
.proj-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.learn-meter { height: 8px; background: var(--mist); border-radius: 99px; overflow: hidden; margin: 12px 0 8px; }
.learn-meter div { height: 100%; background: var(--teal); border-radius: 99px; min-width: 8px; }
.learn-patterns { margin: 0; padding-left: 18px; font-size: 14px; }
.learn-patterns li + li { margin-top: 4px; }
.learn-row { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px 0; border-top: 1px solid var(--rule); font-size: 14px; }
.learn-x { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; }
.learn-x.up { color: var(--green); }
.learn-x.down { color: var(--slate); }
.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.clip-card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; }
.clip-video { aspect-ratio: 9 / 16; background: #0f1828; display: grid; }
.clip-video video { width: 100%; height: 100%; object-fit: contain; background: #0f1828; }
.clip-wait { display: grid; place-content: center; justify-items: center; gap: 10px; padding: 16px; text-align: center; background: var(--mist); }
.clip-body { padding: 12px 14px 12px; display: flex; flex-direction: column; flex: 1; }
.clip-title { font-size: 14.5px; line-height: 1.3; }
.clip-score { flex: none; min-width: 30px; height: 24px; padding: 0 6px; border-radius: 99px; background: var(--teal-wash); color: var(--teal-ink); font-weight: 800; font-size: 12.5px; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.clip-actions { margin-top: auto; padding-top: 10px; gap: 6px; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--teal); border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
.tx { max-height: 260px; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--paper); padding: 4px; }
.tx-line { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 6px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.tx-line:hover { background: var(--mist); }
.tx-line.on { background: var(--teal-wash); }
.tx-t { color: var(--slate); font-variant-numeric: tabular-nums; font-size: 12.5px; padding-top: 1px; }
.nudge { display: flex; gap: 6px; align-items: center; }
.nudge input { min-width: 0; text-align: center; }
@media (max-width: 860px) {
  .clips-layout { grid-template-columns: 1fr; }
  .clip-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}
@media (max-width: 420px) {
  .grid2 { grid-template-columns: 1fr; }
  .clip-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .clip-body { padding: 10px; }
  .proj-row { grid-template-columns: 44px minmax(0, 1fr); }
  .proj-row .status { grid-column: 2; justify-self: start; }
  .proj-thumb { width: 44px; height: 44px; }
}
