:root {
  color-scheme: light;
  --ink: #18181b;
  --muted: #66616f;
  --line: #dfdbe8;
  --panel: #fffdf8;
  --panel-strong: #ffffff;
  --wash: #f4efe6;
  --accent: #e53746;
  --accent-deep: #ad1d32;
  --gold: #d6a128;
  --teal: #1e9a8a;
  --blue: #4169d8;
  --shadow: 0 18px 55px rgba(43, 34, 28, .12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(255, 253, 248, .94), rgba(244, 239, 230, .96)), repeating-linear-gradient(90deg, rgba(36, 36, 43, .04) 0 1px, transparent 1px 72px);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #19191f; color: #f7f1e8; padding: 22px 18px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; min-height: 42px; }
.brand-mark { width: 40px; height: 40px; border-radius: 7px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), #ff7a32); box-shadow: 0 10px 24px rgba(229, 55, 70, .35); }
.brand-mark svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 2.4; }
.brand h1 { font-size: 16px; line-height: 1.1; margin: 0; font-weight: 760; letter-spacing: 0; }
.brand span { display: block; color: #bfb6ae; font-size: 12px; margin-top: 3px; }
.nav-group { display: grid; gap: 6px; }
.nav-button { appearance: none; border: 0; color: #eee8df; background: transparent; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 10px; border-radius: 7px; text-align: left; font-size: 14px; }
.nav-button.is-active, .nav-button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav-badge { min-width: 24px; height: 20px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--accent); color: #fff; font-size: 11px; font-weight: 750; }
.connection-box { margin-top: auto; border: 1px solid rgba(255, 255, 255, .13); border-radius: var(--radius); padding: 13px; background: rgba(255, 255, 255, .06); display: grid; gap: 12px; }
.connection-box h2 { font-size: 13px; margin: 0; }
.service-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; color: #d9d1c9; font-size: 12px; }
.service-logo { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800; }
.yt { background: #e62117; } .db { background: #0061ff; } .pin { background: #bd081c; } .ai { background: #1e9a8a; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #55d88a; box-shadow: 0 0 0 3px rgba(85, 216, 138, .14); }
.status-dot.warn { background: #f4c542; box-shadow: 0 0 0 3px rgba(244, 197, 66, .14); }

.main { min-width: 0; padding: 22px; }
.topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: start; margin-bottom: 18px; }
.title-block h2 { margin: 0; font-size: clamp(28px, 4vw, 46px); line-height: .96; font-weight: 820; color: #17151a; letter-spacing: 0; }
.title-block p { max-width: 820px; margin: 10px 0 0; color: var(--muted); line-height: 1.5; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.top-actions.left { justify-content: flex-start; }
.button, .icon-button { min-height: 40px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-strong); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 13px; font-weight: 720; box-shadow: 0 6px 16px rgba(28, 23, 20, .06); white-space: nowrap; }
.icon-button { width: 40px; padding: 0; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 10px 22px rgba(229, 55, 70, .22); }
.button.ghost { box-shadow: none; background: transparent; }
.button:hover, .icon-button:hover { transform: translateY(-1px); }

.grid { display: grid; gap: 16px; }
.dashboard-grid { grid-template-columns: minmax(280px, 1.22fr) minmax(280px, .78fr); align-items: start; }
.panel { background: rgba(255, 253, 248, .92); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-wide { margin-top: 16px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px; border-bottom: 1px solid rgba(223, 219, 232, .75); }
.panel-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.panel-title h3 { margin: 0; font-size: 16px; line-height: 1.2; letter-spacing: 0; }
.panel-title p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 16px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { background: var(--panel-strong); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-height: 96px; display: grid; gap: 6px; align-content: center; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { font-size: 26px; letter-spacing: 0; }
.metric small { color: var(--teal); font-weight: 730; }
.workflow { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.step { position: relative; min-height: 104px; border-radius: var(--radius); padding: 13px; background: var(--panel-strong); border: 1px solid var(--line); overflow: hidden; }
.step::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.step:nth-child(2)::before { background: var(--blue); } .step:nth-child(3)::before { background: var(--teal); } .step:nth-child(4)::before { background: var(--gold); }
.step span { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: #f1ece4; color: #4c4541; font-size: 12px; font-weight: 800; }
.step strong { display: block; margin-top: 10px; font-size: 14px; }
.step p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }

.upload-zone { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr); gap: 14px; }
.drop-zone { min-height: 234px; border: 1.5px dashed #b9b2c2; border-radius: var(--radius); background: linear-gradient(135deg, rgba(229, 55, 70, .08), transparent 42%), var(--panel-strong); display: grid; place-items: center; padding: 18px; text-align: center; transition: border-color .18s ease, transform .18s ease, background .18s ease; }
.drop-zone.is-over { border-color: var(--accent); transform: translateY(-2px); background: linear-gradient(135deg, rgba(229, 55, 70, .13), rgba(30, 154, 138, .08)), var(--panel-strong); }
.drop-zone svg { width: 46px; height: 46px; stroke: var(--accent); stroke-width: 1.9; margin-bottom: 13px; }
.drop-zone h4 { margin: 0 0 6px; font-size: 16px; }
.drop-zone p { margin: 0 auto 14px; max-width: 290px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.file-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.asset-list { display: grid; gap: 8px; min-height: 234px; }
.asset-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 54px; border: 1px solid var(--line); background: var(--panel-strong); border-radius: 7px; padding: 8px; }
.asset-type { width: 40px; height: 38px; border-radius: 6px; display: grid; place-items: center; background: #f1ece4; color: #3c3733; font-size: 11px; font-weight: 850; text-transform: uppercase; }
.asset-row strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-row span { color: var(--muted); font-size: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 9px; border-radius: 999px; background: #f1ece4; color: #504943; font-size: 12px; font-weight: 720; white-space: nowrap; }
.pill.green { background: rgba(30, 154, 138, .12); color: #117566; }
.pill.red { background: rgba(229, 55, 70, .12); color: var(--accent-deep); }

.source-grid { display: grid; grid-template-columns: repeat(3, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
.source-card { border: 1px solid var(--line); background: var(--panel-strong); border-radius: var(--radius); padding: 12px; min-height: 92px; display: grid; gap: 8px; text-align: left; transition: transform .18s ease, border-color .18s ease; }
.source-card:hover, .source-card.is-selected { transform: translateY(-2px); border-color: var(--accent); }
.source-card span:first-child { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 850; }
.source-card strong { font-size: 13px; } .source-card small { color: var(--muted); }
.thumb-grid { display: grid; grid-template-columns: repeat(3, minmax(96px, 1fr)); gap: 10px; }
.thumb-card { appearance: none; padding: 0; border: 2px solid transparent; border-radius: var(--radius); background: var(--panel-strong); overflow: hidden; text-align: left; box-shadow: 0 8px 18px rgba(28, 23, 20, .06); }
.thumb-card.is-selected { border-color: var(--accent); }
.cover { aspect-ratio: 16 / 9; min-height: 82px; position: relative; overflow: hidden; background: #ddd; }
.cover::before, .cover::after { content: ""; position: absolute; inset: auto; }
.cover.one { background: linear-gradient(135deg, rgba(255, 255, 255, .16), transparent 32%), linear-gradient(160deg, #111111 0%, #d51e30 42%, #f6b331 100%); }
.cover.one::before { width: 58%; height: 120%; right: -18%; top: -15%; background: rgba(255, 255, 255, .16); transform: rotate(18deg); }
.cover.two { background: radial-gradient(circle at 28% 38%, rgba(255, 255, 255, .26), transparent 0 24%, transparent 25%), linear-gradient(135deg, #163b5f, #36a9a1 46%, #f7d064); }
.cover.two::before { left: 12%; right: 12%; top: 44%; height: 6px; background: rgba(255, 255, 255, .58); box-shadow: 0 16px 0 rgba(255, 255, 255, .34), 0 -16px 0 rgba(255, 255, 255, .34); }
.cover.three { background: linear-gradient(90deg, rgba(255, 255, 255, .16) 0 2px, transparent 2px 16px), linear-gradient(135deg, #2a1f3d, #df3f5b 44%, #222 100%); }
.cover.three::before { width: 52%; height: 52%; border: 2px solid rgba(255, 255, 255, .54); border-radius: 50%; left: 22%; top: 23%; }
.cover.four { background: conic-gradient(from 90deg at 50% 50%, #111, #e53746, #ffd166, #1e9a8a, #111); }
.cover.four::before { width: 46%; height: 46%; border-radius: 50%; background: #fffdf8; left: 27%; top: 27%; }
.cover.five { background: linear-gradient(120deg, transparent 0 42%, rgba(255, 255, 255, .28) 42% 58%, transparent 58%), linear-gradient(135deg, #0d0d0f, #4169d8 52%, #e1e0d7); }
.cover.six { background: radial-gradient(circle at 75% 30%, rgba(255, 255, 255, .35), transparent 0 22%, transparent 23%), linear-gradient(135deg, #332b24, #b13f25 45%, #eed071); }
.thumb-meta { padding: 8px; display: grid; gap: 2px; }
.thumb-meta strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-meta span { color: var(--muted); font-size: 11px; }

.draft-layout { display: grid; grid-template-columns: minmax(220px, .95fr) minmax(260px, 1.05fr); gap: 14px; }
.preview { background: #111116; color: #fff; border-radius: var(--radius); overflow: hidden; min-height: 360px; display: grid; grid-template-rows: auto 1fr; }
.video-frame { aspect-ratio: 16 / 9; background: linear-gradient(135deg, rgba(255, 255, 255, .12), transparent 36%), linear-gradient(135deg, #141417, #e53746 52%, #f0b64d); position: relative; display: grid; place-items: center; }
.video-frame::before { content: ""; width: 58px; height: 42px; border-radius: 8px; background: rgba(255, 255, 255, .9); clip-path: polygon(0 0, 100% 50%, 0 100%); transform: scale(.65); filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .24)); }
.preview-copy { padding: 14px; display: grid; gap: 8px; align-content: start; }
.preview-copy h4 { margin: 0; font-size: 16px; line-height: 1.25; letter-spacing: 0; }
.preview-copy p { margin: 0; color: #cfcbd3; font-size: 13px; line-height: 1.45; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.tag { border-radius: 999px; background: rgba(255, 255, 255, .1); color: #f4f1ef; padding: 5px 8px; font-size: 11px; font-weight: 720; }
.form-grid { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; color: #4e4854; font-weight: 760; }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 7px; background: var(--panel-strong); min-height: 40px; padding: 9px 10px; color: var(--ink); width: 100%; }
.field textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
.split-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.agent-strip { margin-top: 2px; padding: 12px; border: 1px solid rgba(30, 154, 138, .25); border-radius: var(--radius); background: rgba(30, 154, 138, .08); display: grid; gap: 10px; }
.agent-strip strong { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check-list { display: grid; grid-template-columns: repeat(2, minmax(170px, 1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.check input { width: 16px; height: 16px; accent-color: var(--teal); }

.schedule-grid { display: grid; grid-template-columns: minmax(260px, .92fr) minmax(280px, 1.08fr); gap: 14px; }
.calendar { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-strong); overflow: hidden; }
.calendar-head, .calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-head span { padding: 10px 0; text-align: center; color: var(--muted); font-size: 11px; font-weight: 760; background: #f5f0ea; }
.day { min-height: 70px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px; display: grid; align-content: start; gap: 5px; font-size: 12px; color: #59525e; }
.day:nth-child(7n) { border-right: 0; }
.day.is-muted { color: #b5aeb9; background: #faf7f1; }
.day.has-post { background: rgba(229, 55, 70, .07); }
.event-dot { width: 100%; min-height: 18px; border-radius: 5px; background: var(--accent); color: #fff; display: flex; align-items: center; padding: 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 760; }
.queue { display: grid; gap: 10px; }
.queue-item { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-strong); }
.queue-art { width: 52px; min-height: 52px; border-radius: 7px; }
.queue-item strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item span { color: var(--muted); font-size: 12px; }
.status-menu { display: grid; gap: 6px; justify-items: end; }
.api-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 12px; }
.api-card { border: 1px solid var(--line); background: var(--panel-strong); border-radius: var(--radius); padding: 14px; display: grid; gap: 11px; min-height: 168px; }
.api-card-head { display: flex; align-items: center; gap: 9px; }
.api-card h4 { margin: 0; font-size: 14px; }
.api-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.quota-bar { height: 8px; background: #eee8df; border-radius: 999px; overflow: hidden; }
.quota-bar span { display: block; height: 100%; background: var(--teal); border-radius: inherit; }
.log { margin-top: 16px; display: grid; gap: 8px; }
.log-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid rgba(223, 219, 232, .72); font-size: 13px; }
.log-row:last-child { border-bottom: 0; }
.log-time { color: var(--muted); font-size: 12px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 10; background: #19191f; color: #fff; border-radius: 7px; padding: 12px 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .25); transform: translateY(18px); opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; max-width: min(380px, calc(100vw - 36px)); font-size: 13px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1180px) {
  .metrics, .workflow, .api-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .dashboard-grid, .schedule-grid, .draft-layout { grid-template-columns: 1fr; }
}
@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav-group { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .connection-box { margin-top: 0; }
  .topbar { grid-template-columns: 1fr; }
  .top-actions { justify-content: flex-start; }
  .upload-zone, .split-fields { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .main { padding: 14px; }
  .metrics, .workflow, .source-grid, .thumb-grid, .api-grid, .check-list { grid-template-columns: 1fr; }
  .queue-item, .asset-row, .log-row { grid-template-columns: auto minmax(0, 1fr); }
  .status-menu, .log-row .pill { grid-column: 2; justify-items: start; }
  .calendar { overflow-x: auto; }
  .calendar-head, .calendar-days { min-width: 520px; }
}