:root {
  color-scheme: dark;
  --bg: #08101d;
  --surface: #101a2b;
  --surface-2: #17243a;
  --line: #263650;
  --text: #f4f7fb;
  --muted: #91a0b8;
  --accent: #7c5cff;
  --accent-2: #37d4a7;
  --danger: #ff6b7a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at top, #14213b 0, var(--bg) 42%); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; padding-bottom: 96px; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; padding: max(14px, env(safe-area-inset-top)) 16px 12px; background: rgba(8, 16, 29, .86); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(255,255,255,.06); }
.topbar h1 { margin: 2px 0 0; font-size: 18px; }
.topbar-actions { display: flex; gap: 8px; }
.eyebrow { margin: 0; color: var(--accent-2); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font-size: 20px; }
main { width: min(100%, 820px); margin: 0 auto; padding: 14px; display: grid; gap: 12px; }
.card, .hero-card { border: 1px solid rgba(255,255,255,.08); border-radius: 20px; background: linear-gradient(145deg, rgba(23,36,58,.96), rgba(13,23,39,.96)); box-shadow: 0 14px 38px rgba(0,0,0,.18); }
.card { padding: 16px; }
.hero-card { padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hero-card h2 { margin: 10px 0 0; font-size: 20px; line-height: 1.25; }
.status { display: inline-flex; padding: 6px 9px; border-radius: 999px; background: rgba(55,212,167,.12); color: var(--accent-2); font-size: 12px; font-weight: 700; }
h3 { margin: 4px 0 0; font-size: 17px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
label { display: grid; gap: 7px; margin-top: 14px; color: #cbd5e5; font-size: 13px; font-weight: 650; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 14px; outline: none; background: rgba(5,12,23,.65); color: var(--text); padding: 13px 14px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,255,.15); }
select { width: auto; min-width: 100px; }
.platform-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.platform-grid button, .quick-actions button, .tabs button { border: 1px solid var(--line); border-radius: 13px; background: rgba(5,12,23,.52); color: var(--muted); padding: 12px; font-weight: 700; }
.platform-grid button.active, .tabs button.active { color: white; border-color: var(--accent); background: rgba(124,92,255,.2); }
.platform-grid button.connected::after { content: attr(data-connection-count); display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 7px; padding: 0 5px; border-radius: 999px; color: #07131c; background: var(--accent-2); font-size: 10px; font-weight: 900; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.tabs button { white-space: nowrap; padding: 9px 12px; }
.quick-actions { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.quick-actions button { white-space: nowrap; padding: 9px 12px; }
.quick-actions button.active { border-color: var(--accent-2); color: var(--accent-2); }
.primary, .secondary { min-height: 46px; border-radius: 14px; padding: 11px 16px; font-weight: 800; }
.primary { border: 0; color: white; background: linear-gradient(135deg, var(--accent), #a14dff); box-shadow: 0 8px 20px rgba(124,92,255,.28); }
.secondary { border: 1px solid var(--line); color: var(--text); background: var(--surface-2); }
.wide { width: 100%; }
.upload-button { display: inline-flex; align-items: center; margin: 0; }
.spark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #08101d; background: var(--accent-2); font-size: 12px; font-weight: 900; }
.media-list { display: grid; gap: 8px; }
.media-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5,12,23,.45); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.5; }
.bottom-bar { position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; padding: 10px 14px max(10px, env(safe-area-inset-bottom)); background: rgba(8,16,29,.9); backdrop-filter: blur(18px); border-top: 1px solid rgba(255,255,255,.08); }
.draft-panel { position: fixed; z-index: 30; inset: 0 18% 0 0; max-width: 420px; padding: max(18px, env(safe-area-inset-top)) 14px 20px; background: #0d1727; transform: translateX(-105%); transition: transform .22s ease; overflow-y: auto; box-shadow: 18px 0 50px rgba(0,0,0,.45); }
.draft-panel.open { transform: translateX(0); }
.account-panel { position: fixed; z-index: 30; inset: 0 0 0 8%; max-width: 480px; margin-left: auto; padding: max(18px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom)); background: #0d1727; transform: translateX(105%); transition: transform .22s ease; overflow-y: auto; box-shadow: -18px 0 50px rgba(0,0,0,.45); }
.account-panel.open { transform: translateX(0); }
.account-owner-note { display: grid; gap: 6px; margin-bottom: 14px; padding: 13px; border: 1px solid rgba(55,212,167,.25); border-radius: 14px; background: rgba(55,212,167,.08); }
.account-owner-note span, .empty-state span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.connection-list { display: grid; gap: 9px; }
.oauth-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 14px; }
.oauth-button { min-height: 44px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: var(--surface-2); font-size: 12px; font-weight: 800; }
.oauth-button:disabled { opacity: .42; cursor: not-allowed; }
.connection-card { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.connection-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; color: white; background: linear-gradient(135deg, #53657f, #263650); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.connection-mark.telegram { background: linear-gradient(135deg, #2aabee, #1678b7); }
.connection-mark.instagram { background: linear-gradient(135deg, #f9ce34, #ee2a7b 48%, #6228d7); }
.connection-mark.youtube { background: linear-gradient(135deg, #ff3434, #b80000); }
.connection-mark.tiktok { background: linear-gradient(135deg, #25f4ee, #111 48%, #fe2c55); }
.connection-details { min-width: 0; display: grid; gap: 3px; }
.connection-details strong, .connection-details span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-details span { color: var(--muted); font-size: 11px; }
.connection-status { width: fit-content; padding: 3px 6px; border-radius: 999px; color: var(--accent-2); background: rgba(55,212,167,.1); font-size: 10px; }
.connection-status.pending { color: #ffd166; background: rgba(255,209,102,.1); }
.connection-actions { display: flex; gap: 5px; }
.small-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: rgba(5,12,23,.52); }
.small-button.danger { color: var(--danger); }
.connection-form { display: grid; gap: 2px; margin-top: 18px; padding: 15px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgba(23,36,58,.96), rgba(13,23,39,.96)); }
.connection-form select { width: 100%; }
.empty-state { display: grid; gap: 5px; padding: 18px; border: 1px dashed var(--line); border-radius: 15px; text-align: center; }
.target-connections { display: grid; gap: 8px; margin-top: 12px; }
.target-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 9px; }
.target-row strong { font-size: 12px; }
.target-row select { width: 100%; min-width: 0; padding: 10px 12px; }
.quota-note { margin: -5px 0 10px; color: var(--muted); font-size: 12px; }
.job-list { display: grid; gap: 7px; margin-top: 12px; }
.job-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5,12,23,.4); font-size: 11px; }
.job-item span { color: var(--muted); }
.job-status { color: var(--accent-2); font-weight: 800; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.draft-list { display: grid; gap: 8px; margin-top: 14px; }
.draft-item { width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); text-align: left; }
.draft-item small { display: block; margin-top: 5px; color: var(--muted); }
.scrim { position: fixed; z-index: 25; inset: 0; visibility: hidden; opacity: 0; background: rgba(0,0,0,.5); transition: opacity .2s; }
.scrim.open { visibility: visible; opacity: 1; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 90px; max-width: calc(100% - 28px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 11px 14px; border-radius: 13px; background: #f5f7fb; color: #111827; font-size: 13px; font-weight: 700; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 760px) {
  main { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 24px; gap: 16px; }
  .hero-card, .editor-card, .ai-card, .schedule-card { grid-column: 1 / -1; }
  .platform-grid { grid-template-columns: repeat(4, 1fr); }
  .bottom-bar { left: 50%; right: auto; width: min(100%, 820px); transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; }
}
