:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3250;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
  --text: #e2e8f0;
  --muted: #8892a4;
  --radius: 10px;
  --font: 'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Layout ── */
#app { display: flex; min-height: 100vh; }
#sidebar { width: 240px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 24px 0; flex-shrink: 0; }
#main { flex: 1; overflow-y: auto; }

/* ── Sidebar ── */
.sidebar-logo { padding: 0 20px 24px; font-size: 18px; font-weight: 700; color: var(--accent); letter-spacing: -0.5px; }
.sidebar-logo span { color: var(--muted); font-weight: 400; font-size: 13px; display: block; margin-top: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--muted); cursor: pointer; font-size: 14px; border-left: 3px solid transparent; transition: all 0.15s; }
.nav-item:hover, .nav-item.active { color: var(--text); background: var(--surface2); border-left-color: var(--accent); }
.sidebar-footer { margin-top: auto; padding: 20px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.sidebar-footer strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ── Topbar ── */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; }

/* ── Pages ── */
.page { padding: 28px; display: none; }
.page.active { display: block; }

/* ── Auth Page ── */
#auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 380px; }
.auth-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.auth-card p { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.auth-logo { font-size: 28px; font-weight: 800; color: var(--accent); margin-bottom: 20px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea { width: 100%; padding: 10px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 14px; font-family: var(--font); outline: none; transition: border-color 0.2s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 120px; }

/* ── Buttons ── */
.btn { padding: 10px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 500; cursor: pointer; border: none; transition: all 0.15s; font-family: var(--font); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.card-actions { display: flex; gap: 8px; flex-shrink: 0; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-draft { background: rgba(100,116,139,0.2); color: #94a3b8; }
.badge-published { background: rgba(34,197,94,0.15); color: var(--success); }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Block list ── */
.block-item { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; cursor: grab; }
.block-item:active { cursor: grabbing; }
.block-header { display: flex; align-items: center; justify-content: space-between; }
.block-type { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--accent); letter-spacing: 0.5px; }
.block-preview { font-size: 12px; color: var(--muted); margin-top: 6px; font-family: monospace; word-break: break-all; }

/* ── Upload ── */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center; cursor: pointer; transition: border-color 0.2s; }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); }
.upload-zone p { color: var(--muted); font-size: 13px; margin-top: 8px; }
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 12px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.3s; }

/* ── Media grid ── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.media-item { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color 0.2s; }
.media-item:hover { border-color: var(--accent); }
.media-item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.media-thumb { width: 100%; height: 100px; object-fit: cover; background: var(--surface); display: block; }
.media-thumb-icon { width: 100%; height: 100px; display: flex; align-items: center; justify-content: center; font-size: 32px; background: var(--surface); }
.media-name { font-size: 11px; padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }

/* ── Toast ── */
#toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: var(--radius); font-size: 14px; font-weight: 500; z-index: 999; transform: translateY(100px); opacity: 0; transition: all 0.3s; }
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { background: var(--success); color: white; }
#toast.error { background: var(--danger); color: white; }

/* ── Misc ── */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h3 { font-size: 16px; margin-bottom: 8px; }
.flex { display: flex; align-items: center; gap: 10px; }
.mt-16 { margin-top: 16px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
