:root {
  color-scheme: dark;
  --bg: #080b12;
  --surface: #111722;
  --surface-2: #171f2d;
  --line: #273246;
  --text: #f7f8fb;
  --muted: #9ca9bb;
  --primary: #f2b705;
  --primary-2: #ffd761;
  --danger: #ef4444;
  --success: #22c55e;
  --shadow: 0 18px 45px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(242, 183, 5, .09), transparent 28%),
    radial-gradient(circle at bottom left, rgba(79, 70, 229, .08), transparent 25%),
    var(--bg);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: rgba(10, 14, 22, .94);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 24px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 14px; background: linear-gradient(135deg, var(--primary), #8b5e00);
  color: #111; font-weight: 900; box-shadow: 0 10px 25px rgba(242, 183, 5, .22);
}
.brand strong, .brand span { display: block; }
.brand span { font-size: 12px; color: var(--muted); margin-top: 2px; }
.nav { display: grid; gap: 8px; }
.nav-item {
  border: 0; color: var(--muted); background: transparent; text-align: left;
  border-radius: 12px; padding: 12px 14px; font-weight: 700;
}
.nav-item:hover, .nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active { box-shadow: inset 3px 0 var(--primary); }
.sidebar-footer { margin-top: auto; color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; padding: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 12px var(--success); }

.main { min-width: 0; padding: 24px 28px 48px; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.topbar h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.topbar select { min-width: 200px; }
.icon-button { display: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); width: 42px; height: 42px; border-radius: 12px; }

.primary, .secondary, .danger {
  border-radius: 11px; padding: 11px 15px; border: 1px solid transparent; font-weight: 800;
  transition: transform .15s ease, opacity .15s ease, border-color .15s ease;
}
.primary { background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #17120a; }
.secondary { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.danger { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }
.primary:hover, .secondary:hover, .danger:hover { transform: translateY(-1px); }
.hidden { display: none !important; }

.view { display: none; animation: enter .22s ease; }
.view.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card, .panel {
  background: linear-gradient(180deg, rgba(23, 31, 45, .96), rgba(14, 19, 29, .96));
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.stat-card { padding: 20px; }
.stat-card span { color: var(--muted); font-weight: 700; }
.stat-card strong { display: block; font-size: 30px; margin: 10px 0 4px; }
.stat-card small { color: var(--muted); }
.stat-card.accent { border-color: rgba(242, 183, 5, .4); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr); gap: 18px; }
.panel { padding: 20px; }
.panel-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.panel-header h2 { margin: 0; font-size: 19px; }
.panel-header p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.connection-list { display: grid; gap: 10px; }
.connection-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.02); }
.connection-row strong { display: block; }
.connection-row small { color: var(--muted); }
.badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.badge.connected, .badge.sent { color: #86efac; background: rgba(34,197,94,.14); }
.badge.pending, .badge.scheduled { color: #fde68a; background: rgba(242,183,5,.14); }
.badge.draft { color: #bfdbfe; background: rgba(59,130,246,.14); }
.badge.error { color: #fecaca; background: rgba(239,68,68,.14); }
.empty-state { min-height: 180px; display: grid; place-items: center; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; padding: 20px; }

.composer-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr); gap: 18px; align-items: start; }
.form-panel label, .settings-panel label { display: grid; gap: 8px; color: #dce4ef; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); background: #0b1019; color: var(--text); border-radius: 11px; padding: 11px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(242,183,5,.10); }
textarea { resize: vertical; min-height: 140px; }
.counter { color: var(--muted); justify-self: end; font-size: 12px; }
.file-drop {
  min-height: 145px; margin-bottom: 16px; border: 1px dashed #46536a; border-radius: 16px; place-items: center; align-content: center; text-align: center; padding: 18px;
  background: rgba(255,255,255,.02); transition: border-color .2s ease, background .2s ease;
}
.file-drop:hover, .file-drop.drag { border-color: var(--primary); background: rgba(242,183,5,.05); }
.file-drop input { position: absolute; opacity: 0; pointer-events: none; }
.file-drop span, .file-drop small { color: var(--muted); font-weight: 500; }
fieldset { border: 0; padding: 0; margin: 18px 0; }
legend { font-weight: 800; margin-bottom: 10px; }
.platform-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.platform-option { display: flex !important; align-items: center; justify-content: center; gap: 7px !important; padding: 12px 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.02); }
.platform-option input { width: auto; }
.platform-option:has(input:checked) { border-color: rgba(242,183,5,.6); background: rgba(242,183,5,.08); }
.notice { border-left: 3px solid var(--primary); background: rgba(242,183,5,.07); color: #f3ead0; padding: 13px 14px; border-radius: 8px 12px 12px 8px; line-height: 1.45; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.preview-panel { position: sticky; top: 20px; }
.preview-canvas { width: min(100%, 370px); margin: 0 auto; border-radius: 24px; overflow: hidden; position: relative; background: #03050a; border: 1px solid #30394a; box-shadow: 0 24px 45px rgba(0,0,0,.34); }
.ratio-9-16 { aspect-ratio: 9 / 16; }
.ratio-1-1 { aspect-ratio: 1 / 1; }
.ratio-4-5 { aspect-ratio: 4 / 5; }
.preview-media { position: absolute; inset: 0; display: grid; place-items: center; color: #748096; background: radial-gradient(circle at 50% 30%, #202b3c, #05070b 70%); }
.preview-media img, .preview-media video { width: 100%; height: 100%; object-fit: cover; }
.preview-overlay { position: absolute; inset: auto 0 0; padding: 60px 18px 20px; background: linear-gradient(transparent, rgba(0,0,0,.92)); }
.preview-overlay strong { color: var(--primary-2); }
.preview-overlay p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.35; }
.preview-platforms { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; justify-content: center; }
.preview-chip { border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; color: var(--muted); font-size: 11px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td { font-size: 14px; }
.table-action { background: transparent; color: #fca5a5; border: 0; font-weight: 800; }

.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.account-card { border: 1px solid var(--line); border-radius: 15px; padding: 16px; background: rgba(255,255,255,.02); }
.account-card header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.account-card p { color: var(--muted); min-height: 40px; }
.account-card button { width: 100%; }
.settings-panel { max-width: 760px; }
.settings-panel > label { margin-bottom: 18px; }
.switch-row { display: flex !important; justify-content: space-between; align-items: center; gap: 20px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.switch-row span { display: grid; gap: 4px; }
.switch-row small { color: var(--muted); font-weight: 500; }
.switch-row input { width: 22px; height: 22px; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: 360px; transform: translateY(25px); opacity: 0; pointer-events: none; background: #111827; color: white; border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; box-shadow: var(--shadow); transition: .22s ease; z-index: 100; }
.toast.show { transform: none; opacity: 1; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid, .composer-grid { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .preview-canvas { max-height: 680px; }
}
@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; transform: translateX(-105%); width: 260px; transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .main { padding: 18px 14px 40px; }
  .icon-button { display: inline-grid; place-items: center; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .topbar-actions { width: 100%; margin-left: 0; display: grid; grid-template-columns: 1fr; }
  .topbar select { min-width: 0; }
  .stat-grid, .form-grid, .account-grid { grid-template-columns: 1fr; }
  .platform-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { flex-direction: column-reverse; }
  .form-actions button { width: 100%; }
}

/* v0.3.0 AUTO */
.media-queue { display: grid; gap: 10px; margin: -4px 0 18px; }
.media-item { display: grid; grid-template-columns: 68px minmax(0,1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 9px; background: rgba(255,255,255,.025); }
.media-item img { width: 68px; height: 68px; border-radius: 9px; object-fit: cover; background: #05070b; }
.media-item strong, .media-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item small { color: var(--muted); margin-top: 4px; }
.media-actions { display: flex; gap: 5px; }
.media-actions button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 900; }
.carousel-count { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,.72); color: white; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; }
.platform-option.disabled { opacity: .45; cursor: not-allowed; }
.badge.publishing { color: #bae6fd; background: rgba(14,165,233,.14); }
.badge.published { color: #86efac; background: rgba(34,197,94,.14); }
.badge.cancelled { color: #cbd5e1; background: rgba(100,116,139,.16); }
.error-detail { display: block; max-width: 270px; margin-top: 5px; color: #fca5a5; }
.table-action.retry { color: #86efac; margin-right: 8px; }
.pending-feature { opacity: .8; }
