/* KlipX dashboard */
html, body { height: 100%; }
body { background: var(--white); font-size: 14px; }
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: var(--r1); color: var(--ink-2); flex: none; }
.icon-btn:hover { background: var(--soft); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }

/* Sidebar */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s4); padding: var(--s4) var(--s3); background: #fafafb; border-right: 1px solid var(--line); overflow-y: auto; }
.side__top { display: flex; align-items: center; justify-content: space-between; padding: var(--s1) var(--s2); }
.side .logo { font-size: 18px; }
.side .logo svg { width: 15px; height: 15px; }
.side__close { display: none; }
.brand { padding: 0 var(--s2); font-size: 13px; color: var(--muted); }
.side__new { width: 100%; height: 36px; font-size: 14px; }
.side__nav { display: grid; gap: 2px; }
.side__nav a { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: var(--r1); color: var(--ink-2); }
.side__nav a:hover { background: #f0f1f4; color: var(--ink); }
.side__nav a[aria-current="page"] { background: var(--white); box-shadow: 0 0 0 1px var(--line); color: var(--ink); font-weight: 500; }
.count { font-size: 12px; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.side__demo { margin-top: auto; padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r2); background: var(--white); font-size: 13px; color: var(--ink-2); }
.side__demo b { color: var(--ink); font-weight: 500; }
.side__link { display: inline-block; margin-top: var(--s2); font-weight: 500; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }

.top { display: none; }
.main { min-width: 0; }
.view { padding: var(--s7) var(--s7) var(--s8); max-width: 1240px; }
.view:focus, [tabindex="-1"]:focus { outline: none; }

/* Page header */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s6); flex-wrap: wrap; }
.ph h1 { font-size: 26px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; }
.ph p { color: var(--muted); margin-top: var(--s1); font-size: 14px; }
.ph__actions { display: flex; gap: var(--s2); }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: var(--s3); }
.back:hover { color: var(--ink); }

.section { margin-top: var(--s7); }
.section__h { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.section__h h2 { font-size: 15px; font-weight: 500; }
.section__h a { font-size: 13px; color: var(--muted); }
.section__h a:hover { color: var(--ink); }

/* Quick create */
.quick { display: flex; gap: var(--s2); padding: var(--s2); border: 1px solid var(--line); border-radius: var(--r2); background: var(--white); }
.quick .input { border: 0; height: 40px; }
.quick .input:focus-visible { outline-offset: 0; }
.quick-err { min-height: 20px; margin-top: var(--s2); }

/* Metric strip */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--r2); margin-top: var(--s5); }
.metric { padding: var(--s4); border-left: 1px solid var(--line); }
.metric:first-child { border-left: 0; }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric b { display: block; font-size: 26px; font-weight: 400; letter-spacing: -0.02em; margin-top: var(--s1); font-variant-numeric: tabular-nums; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s6); }

/* Lists */
.list { border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.row { display: grid; grid-template-columns: 30px 1fr auto; gap: var(--s3); align-items: center; padding: 10px var(--s3); border-top: 1px solid var(--line); color: inherit; width: 100%; text-align: left; }
.row:first-child { border-top: 0; }
a.row:hover, button.row:hover { background: var(--soft); }
.row b { display: block; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row span.meta { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row > div { min-width: 0; }
.empty { padding: var(--s6) var(--s4); text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--r2); }
.empty b { display: block; color: var(--ink); font-weight: 500; margin-bottom: var(--s1); }

.th { display: block; width: 30px; height: 46px; border-radius: 5px; background: var(--g, linear-gradient(160deg, #3a3c48, #15161c)); flex: none; }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px var(--s2); border-radius: 999px; background: var(--soft); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.pill--review::before { background: #f59e0b; }
.pill--approved::before { background: #3b82f6; }
.pill--scheduled::before { background: var(--ink); }
.pill--published::before { background: var(--ok); }
.pill--processing::before { background: #3b82f6; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Tables */
.table-wrap { border: 1px solid var(--line); border-radius: var(--r2); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th { text-align: left; font-weight: 400; font-size: 12px; color: var(--muted); padding: 10px var(--s4); border-bottom: 1px solid var(--line); background: #fafafb; }
.table td { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover { background: #fafafb; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table a.cell-link { font-weight: 500; }
.table a.cell-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.table .sub { display: block; font-size: 12px; color: var(--muted); }

/* Tabs (filters) */
.tabs { display: flex; gap: var(--s1); margin-bottom: var(--s3); flex-wrap: wrap; }
.tabs button { padding: 6px var(--s3); border-radius: var(--r1); color: var(--muted); font-size: 13px; }
.tabs button:hover { color: var(--ink); background: var(--soft); }
.tabs button[aria-pressed="true"] { color: var(--ink); box-shadow: 0 0 0 1px var(--line); background: var(--white); }
.tabs .count { margin-left: 4px; }

/* Project workspace */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: var(--s5); align-items: start; }
.clip-row { grid-template-columns: 30px 1fr auto; }
.clip-row[aria-current="true"] { background: var(--soft); box-shadow: inset 2px 0 0 var(--ink); }
.clip-row .right { display: flex; align-items: center; gap: var(--s3); }
.score { font-family: var(--mono); font-size: 12px; color: var(--ink-2); min-width: 22px; text-align: right; }

.insp { position: sticky; top: var(--s5); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s5); }
.insp__head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.insp__head h2 { font-size: 15px; font-weight: 500; }
.insp__body { display: grid; grid-template-columns: 150px 1fr; gap: var(--s4); margin-bottom: var(--s5); }
.preview { aspect-ratio: 9 / 16; border-radius: 16px; padding: 5px; background: var(--ink); }
.preview__v { position: relative; height: 100%; border-radius: 12px; background: var(--g); display: flex; flex-direction: column; justify-content: flex-end; padding: var(--s3) var(--s2) 30%; overflow: hidden; }
.preview__cap { color: var(--white); font-weight: 600; font-size: 11px; line-height: 1.3; text-align: center; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.preview__cap mark { background: var(--hl, var(--accent)); color: var(--ink); text-shadow: none; padding: 0 3px; border-radius: 3px; }
.preview--minimal .preview__cap { font-weight: 500; font-size: 10px; text-transform: none; }
.preview--bold .preview__cap { text-transform: uppercase; font-weight: 700; }
.preview__dur { position: absolute; top: var(--s2); right: var(--s2); font-family: var(--mono); font-size: 10px; color: var(--white); background: rgba(0,0,0,.45); padding: 1px 5px; border-radius: 4px; }
.facts { display: grid; gap: var(--s2); align-content: start; font-size: 13px; }
.facts div { display: flex; justify-content: space-between; gap: var(--s2); padding-bottom: var(--s2); border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { font-variant-numeric: tabular-nums; text-align: right; }

.form { display: grid; gap: var(--s4); }
.hooks { display: grid; gap: var(--s2); border: 0; }
.hooks legend, .chips legend { font-size: 14px; font-weight: 500; margin-bottom: var(--s2); }
.hook { display: grid; grid-template-columns: 16px 1fr auto; gap: 10px; align-items: center; padding: 10px var(--s3); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.hook:hover { border-color: var(--line-2); }
.hook:has(input:checked) { border-color: var(--ink); }
.hook:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.hook input { accent-color: var(--ink); margin: 0; }
.hook span { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); border: 0; }
.chips legend { width: 100%; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-flex; align-items: center; gap: 6px; padding: 6px var(--s3); border: 1px solid var(--line-2); border-radius: 999px; font-size: 13px; cursor: pointer; user-select: none; }
.chip span:hover { border-color: var(--ink); }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--white); }
.chip input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.chip input:disabled + span { opacity: .45; cursor: not-allowed; border-style: dashed; }
.help { font-size: 12px; color: var(--muted); }
.help a { text-decoration: underline; text-underline-offset: 2px; }
.err { color: var(--danger); font-size: 13px; }
.err:empty { display: none; }
.counter { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); padding-top: var(--s4); border-top: 1px solid var(--line); }
.actions .btn--danger { margin-left: auto; color: var(--danger); }
.actions .btn--danger:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Processing */
.proc { max-width: 560px; border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s6); }
.proc h2 { font-size: 17px; font-weight: 500; margin-bottom: var(--s1); }
.proc > p { color: var(--muted); margin-bottom: var(--s5); }
.prog { height: 4px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-bottom: var(--s5); }
.prog i { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width .4s ease; }
.proc li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; color: var(--muted); }
.proc li::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-2); flex: none; }
.proc li.done { color: var(--ink-2); }
.proc li.done::before { border-color: var(--ok); background: var(--ok); box-shadow: inset 0 0 0 3px var(--white); }
.proc li.run { color: var(--ink); }
.proc li.run::before { border-color: var(--ink); border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Calendar */
.cal-nav { display: flex; align-items: center; gap: var(--s2); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.day { min-height: 360px; border-left: 1px solid var(--line); padding: var(--s2); display: flex; flex-direction: column; gap: 6px; }
.day:first-child { border-left: 0; }
.day__h { display: flex; justify-content: space-between; align-items: baseline; padding: var(--s1) var(--s1) var(--s2); font-size: 13px; color: var(--muted); }
.day__h b { font-weight: 500; color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.day.today .day__h b { background: var(--ink); color: var(--white); border-radius: 6px; padding: 0 6px; }
.day.past { background: #fcfcfd; }
.post { display: block; text-align: left; width: 100%; padding: var(--s2); border: 1px solid var(--line); border-radius: var(--r1); background: var(--white); font-size: 12px; }
.post:hover { border-color: var(--ink); }
.post time { display: block; font-family: var(--mono); color: var(--muted); font-size: 11px; }
.post b { display: block; font-weight: 400; margin: 2px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post span { color: var(--muted); }
.post--published { background: #fafafb; }
.post--published b { color: var(--ink-2); }
.day__empty { color: var(--faint); font-size: 12px; padding: var(--s1); }

/* Accounts */
.acc { display: grid; grid-template-columns: 40px 1fr auto; gap: var(--s4); align-items: center; padding: var(--s4); border-top: 1px solid var(--line); }
.acc:first-child { border-top: 0; }
.acc__logo { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.acc b { display: block; font-weight: 500; }
.acc span { font-size: 13px; color: var(--muted); }
.acc span.on { color: var(--ok); }

/* Insights */
.chart { border: 1px solid var(--line); border-radius: var(--r2); padding: var(--s5) var(--s4) var(--s3); }
.cbars { display: grid; grid-template-columns: repeat(14, 1fr); gap: var(--s2); height: 200px; align-items: end; border-bottom: 1px solid var(--line); }
.cbar { height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.cbar i { display: block; width: min(100%, 40px); background: var(--ink); border-radius: 4px 4px 0 0; min-height: 0; }
.cbar:hover i { background: #3ccf38; }
.clabels { display: grid; grid-template-columns: repeat(14, 1fr); gap: var(--s2); margin-top: var(--s2); }
.clabels span { text-align: center; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hbar { display: grid; grid-template-columns: 110px 1fr 64px; gap: var(--s3); align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.hbar:first-child { border-top: 0; }
.hbar div { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.hbar b { font-weight: 400; font-family: var(--mono); font-size: 12px; text-align: right; }
.card-b { border: 1px solid var(--line); border-radius: var(--r2); padding: var(--s4); }

/* Settings */
.settings { max-width: 720px; display: grid; gap: var(--s6); }
.set { border: 1px solid var(--line); border-radius: var(--r2); }
.set__h { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.set__h h2 { font-size: 15px; font-weight: 500; }
.set__h p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.set__b { padding: var(--s5); display: grid; gap: var(--s5); }
.set__row { display: grid; grid-template-columns: 1fr 260px; gap: var(--s4); align-items: center; }
.set__row > div:first-child b { display: block; font-weight: 500; }
.set__row > div:first-child span { color: var(--muted); font-size: 13px; }
.swatches { display: flex; gap: var(--s2); border: 0; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch span { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 1px solid rgba(13,13,18,.12); cursor: pointer; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--ink); }
.swatch input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 4px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s3); cursor: pointer; justify-self: end; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { width: 40px; height: 24px; border-radius: 999px; background: var(--line-2); position: relative; transition: background-color .15s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--ink); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--ink); outline-offset: 2px; }
.set__foot { display: flex; justify-content: flex-end; gap: var(--s2); }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.btn--warn { border-color: #f1c7b3; color: var(--danger); background: var(--white); }
.btn--warn:hover { border-color: var(--danger); }

/* Dialog */
.dialog { margin: auto; border: 0; border-radius: var(--r3); padding: 0; width: min(480px, calc(100% - 32px)); box-shadow: 0 24px 60px -12px rgba(13,13,18,.35); color: var(--ink); }
.dialog::backdrop { background: rgba(13,13,18,.4); }
.dialog__in { display: grid; gap: var(--s4); padding: var(--s5); }
.dialog__head { display: flex; justify-content: space-between; align-items: center; }
.dialog__head h2 { font-size: 17px; font-weight: 500; }
.dialog__note { font-size: 13px; color: var(--muted); }
.dialog__foot { display: flex; justify-content: flex-end; gap: var(--s2); padding-top: var(--s2); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: var(--s5); transform: translate(-50%, 16px); background: var(--ink); color: var(--white); padding: 10px var(--s4); border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Responsive */
@media (max-width: 1180px) {
  .work { grid-template-columns: 1fr; }
  .insp { position: static; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; visibility: hidden; }
  .side.open { transform: none; visibility: visible; }
  .side__close { display: inline-grid; }
  .scrim { position: fixed; inset: 0; background: rgba(13,13,18,.35); z-index: 30; }
  .top { display: flex; align-items: center; gap: var(--s3); height: 56px; padding: 0 var(--s4); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--white); z-index: 10; }
  .top__logo { font-size: 17px; }
  .top__logo svg { width: 14px; height: 14px; }
  .top__demo { margin-left: auto; font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 2px var(--s2); border-radius: 999px; }
  .view { padding: var(--s6) var(--s5) var(--s8); }
  .cols { grid-template-columns: 1fr; gap: 0; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; border-left: 0; border-top: 1px solid var(--line); }
  .day:first-child { border-top: 0; }
  .set__row { grid-template-columns: 1fr; }
  .switch { justify-self: start; }
}
@media (max-width: 560px) {
  .view { padding: var(--s5) var(--s4) var(--s8); }
  .ph h1 { font-size: 22px; }
  .quick { flex-direction: column; }
  .insp { padding: var(--s4); }
  .insp__body { grid-template-columns: 120px 1fr; }
  .hbar { grid-template-columns: 90px 1fr 56px; }
  .clip-row .pill { font-size: 0; gap: 0; padding: 0; background: none; }
  .clip-row .pill::before { width: 8px; height: 8px; }
  .clabels span:nth-child(even) { visibility: hidden; }
}
