:root,
[data-theme="light"] {
  --civiky-blue: #0055A4;
  --civiky-blue-dark: #003d7a;
  --civiky-blue-light: #e8f0fc;
  --civiky-red: #EF4135;
  --civiky-ink: #0f172a;
  --civiky-muted: #64748b;
  --civiky-border: #e2e8f0;
  --civiky-bg: #f8fafc;
  --civiky-surface: #ffffff;
  --civiky-surface-2: #f1f5f9;
  --civiky-success: #10b981;
  --civiky-warning: #f59e0b;
  --civiky-danger: #ef4444;
  --civiky-code: #0f172a;
  --civiky-overlay: rgba(15, 23, 42, 0.04);

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.04);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);
}

[data-theme="dark"] {
  --civiky-blue: #3b82f6;
  --civiky-blue-dark: #1e40af;
  --civiky-blue-light: #1e3a5f;
  --civiky-red: #ef4444;
  --civiky-ink: #f1f5f9;
  --civiky-muted: #94a3b8;
  --civiky-border: #1e293b;
  --civiky-bg: #0b1120;
  --civiky-surface: #111827;
  --civiky-surface-2: #0f172a;
  --civiky-success: #34d399;
  --civiky-warning: #fbbf24;
  --civiky-danger: #f87171;
  --civiky-code: #f1f5f9;
  --civiky-overlay: rgba(255, 255, 255, 0.04);

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.25);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.35), 0 2px 4px -2px rgb(0 0 0 / 0.25);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.45), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --civiky-blue: #3b82f6;
    --civiky-blue-dark: #1e40af;
    --civiky-blue-light: #1e3a5f;
    --civiky-red: #ef4444;
    --civiky-ink: #f1f5f9;
    --civiky-muted: #94a3b8;
    --civiky-border: #1e293b;
    --civiky-bg: #0b1120;
    --civiky-surface: #111827;
    --civiky-surface-2: #0f172a;
    --civiky-success: #34d399;
    --civiky-warning: #fbbf24;
    --civiky-danger: #f87171;
    --civiky-code: #f1f5f9;
    --civiky-overlay: rgba(255, 255, 255, 0.04);

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.25);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.35), 0 2px 4px -2px rgb(0 0 0 / 0.25);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.45), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--civiky-bg);
  color: var(--civiky-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--civiky-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand-logo-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, var(--civiky-blue), #0077cc);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.05em;
  box-shadow: var(--shadow-md);
}

.tricolor-bar {
  display: inline-flex;
  height: 3px;
  width: 3rem;
  border-radius: 999px;
  overflow: hidden;
}
.tricolor-bar span { flex: 1; }
.tricolor-bar span:nth-child(1) { background: var(--civiky-blue); }
.tricolor-bar span:nth-child(2) { background: white; border-top: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; }
.tricolor-bar span:nth-child(3) { background: var(--civiky-red); }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  border-radius: 0.625rem;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--civiky-blue);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--civiky-blue-dark); text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--civiky-ink);
  border: 1px solid var(--civiky-border);
}
.btn-ghost:hover { background: var(--civiky-surface-2); text-decoration: none; }
.btn-danger { background: var(--civiky-danger); color: white; }
.btn-danger:hover { background: #dc2626; text-decoration: none; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* CARDS */
.card {
  background: var(--civiky-surface);
  border: 1px solid var(--civiky-border);
  border-radius: 0.875rem;
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--civiky-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-body { padding: 1.5rem; }
.card-title { font-size: 1rem; font-weight: 600; margin: 0; }
.card-subtitle { font-size: 0.85rem; color: var(--civiky-muted); margin: 0.25rem 0 0; }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #f1f5f9;
  color: #475569;
}
.badge-blue { background: var(--civiky-blue-light); color: var(--civiky-blue); }
.badge-green { background: #d1fae5; color: #047857; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

/* LAYOUT: APP SHELL */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 0.5rem 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 1rem;
  color: white;
}
.sidebar-brand .brand-logo { color: white; font-size: 1.15rem; }
.sidebar-brand .brand-logo-mark {
  background: linear-gradient(135deg, #60a5fa, var(--civiky-blue));
}
.sidebar-tenant {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 1.25rem 0.75rem 0.5rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 0.125rem;
  transition: all 0.12s ease;
}
.sidebar-item:hover { background: rgba(255,255,255,0.05); color: white; text-decoration: none; }
.sidebar-item.active {
  background: var(--civiky-blue);
  color: white;
  box-shadow: inset 2px 0 0 white;
}
.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-item .sidebar-badge {
  margin-left: auto;
  font-size: 0.65rem;
  background: rgba(255,255,255,0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #ef4135, #c8102e);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.sidebar-user { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.85rem; color: white; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 0.72rem; color: #94a3b8; }

/* MAIN AREA */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: white;
  border-bottom: 1px solid var(--civiky-border);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-search {
  flex: 1;
  max-width: 500px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid var(--civiky-border);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  background: var(--civiky-bg);
  font-family: inherit;
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--civiky-blue);
  background: white;
  box-shadow: 0 0 0 3px rgba(0,85,164,0.1);
}
.topbar-search svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--civiky-muted);
}
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  border: 1px solid var(--civiky-border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  color: var(--civiky-muted);
}
.icon-btn:hover { background: var(--civiky-bg); color: var(--civiky-ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  background: var(--civiky-red);
  border-radius: 999px;
  border: 2px solid white;
}

.content { padding: 2rem; flex: 1; }
.content-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.content-title { font-size: 1.625rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.content-subtitle { color: var(--civiky-muted); margin: 0.35rem 0 0; font-size: 0.95rem; }

/* STAT-CARDS */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: white;
  border: 1px solid var(--civiky-border);
  border-radius: 0.875rem;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}
.stat-label { font-size: 0.78rem; color: var(--civiky-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-delta { font-size: 0.78rem; margin-top: 0.35rem; font-weight: 500; }
.stat-delta.up { color: var(--civiky-success); }
.stat-delta.down { color: var(--civiky-danger); }
.stat-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.625rem;
  background: var(--civiky-blue-light);
  color: var(--civiky-blue);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon svg { width: 18px; height: 18px; }

/* MODULE-GRID */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}
.module {
  background: white;
  border: 1px solid var(--civiky-border);
  border-radius: 0.875rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  color: inherit;
}
.module:hover {
  border-color: var(--civiky-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}
.module-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.625rem;
  background: var(--civiky-blue-light);
  color: var(--civiky-blue);
  display: flex;
  align-items: center;
  justify-content: center;
}
.module-icon svg { width: 20px; height: 20px; }
.module-title { font-size: 1rem; font-weight: 600; margin: 0; }
.module-text { font-size: 0.85rem; color: var(--civiky-muted); margin: 0; line-height: 1.5; }

/* LIST ITEMS */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--civiky-border);
}
.list-item:last-child { border-bottom: 0; }
.list-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: var(--civiky-blue-light);
  color: var(--civiky-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.list-content { flex: 1; min-width: 0; }
.list-title { font-size: 0.9rem; font-weight: 600; margin: 0; }
.list-sub { font-size: 0.78rem; color: var(--civiky-muted); margin: 0.15rem 0 0; }

/* PROGRESS */
.progress {
  height: 6px;
  background: var(--civiky-border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--civiky-blue), #2563eb);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* LOGIN */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-aside {
  background: linear-gradient(145deg, #0055A4 0%, #003d7a 40%, #1e293b 100%);
  color: white;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-aside::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(239,65,53,0.12) 0%, transparent 50%);
  pointer-events: none;
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside-brand { color: white; font-size: 1.15rem; }
.auth-aside-brand .brand-logo-mark { background: white; color: var(--civiky-blue); }
.auth-aside-hero { max-width: 460px; }
.auth-aside-hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 1rem;
}
.auth-aside-hero p { font-size: 1.05rem; line-height: 1.6; color: rgba(255,255,255,0.85); }
.auth-aside-features {
  margin-top: 2rem;
  display: grid;
  gap: 0.75rem;
}
.auth-aside-feature {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.92rem;
  color: rgba(255,255,255,0.9);
}
.auth-aside-check {
  width: 1.25rem;
  height: 1.25rem;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.auth-aside-check svg { width: 12px; height: 12px; color: white; }
.auth-aside-foot { font-size: 0.8rem; color: rgba(255,255,255,0.5); }
.auth-aside-foot a { color: rgba(255,255,255,0.75); }

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: white;
}
.auth-form { width: 100%; max-width: 400px; }
.auth-form h2 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
.auth-form .lead { color: var(--civiky-muted); margin: 0 0 2rem; }

.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--civiky-ink);
}
.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--civiky-border);
  border-radius: 0.5rem;
  font-size: 0.92rem;
  font-family: inherit;
  background: white;
  transition: all 0.12s ease;
}
.form-input:focus {
  outline: none;
  border-color: var(--civiky-blue);
  box-shadow: 0 0 0 3px rgba(0,85,164,0.1);
}
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: 0.85rem; margin-bottom: 1.25rem; }
.form-check { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--civiky-muted); }

.auth-divider {
  position: relative;
  text-align: center;
  margin: 1.5rem 0;
  font-size: 0.8rem;
  color: var(--civiky-muted);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 2rem);
  height: 1px;
  background: var(--civiky-border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* TABLE */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--civiky-muted);
  font-weight: 600;
  padding: 0.6rem 1rem;
  background: var(--civiky-bg);
  border-bottom: 1px solid var(--civiky-border);
}
.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--civiky-border);
}
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--civiky-bg); }

/* UPLOAD DROPZONE */
.dropzone {
  border: 2px dashed var(--civiky-border);
  border-radius: 0.875rem;
  padding: 3rem 2rem;
  text-align: center;
  background: var(--civiky-bg);
  transition: all 0.18s ease;
  cursor: pointer;
}
.dropzone:hover {
  border-color: var(--civiky-blue);
  background: var(--civiky-blue-light);
}
.dropzone svg {
  width: 3rem;
  height: 3rem;
  color: var(--civiky-blue);
  margin-bottom: 1rem;
}
.dropzone h3 { font-size: 1.05rem; margin: 0 0 0.25rem; }
.dropzone p { color: var(--civiky-muted); font-size: 0.88rem; margin: 0; }

/* ARTICLE */
.article-card {
  background: white;
  border: 1px solid var(--civiky-border);
  border-radius: 0.875rem;
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: all 0.15s ease;
}
.article-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}
.article-thumb {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 0.625rem;
  background: linear-gradient(135deg, var(--civiky-blue-light), #dbeafe);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--civiky-blue);
  font-size: 1.5rem;
  font-weight: 700;
}
.article-body { flex: 1; min-width: 0; }
.article-title { font-size: 1rem; font-weight: 600; margin: 0 0 0.25rem; }
.article-excerpt { font-size: 0.85rem; color: var(--civiky-muted); line-height: 1.5; margin: 0 0 0.5rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.article-meta { display: flex; gap: 0.75rem; font-size: 0.78rem; color: var(--civiky-muted); align-items: center; flex-wrap: wrap; }

/* EDITOR */
.editor-shell {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
}
.editor-main {
  background: white;
  border: 1px solid var(--civiky-border);
  border-radius: 0.875rem;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
}
.editor-toolbar {
  display: flex;
  gap: 0.25rem;
  padding: 0.625rem;
  border-bottom: 1px solid var(--civiky-border);
  flex-wrap: wrap;
}
.editor-btn {
  padding: 0.4rem 0.625rem;
  border-radius: 0.4rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--civiky-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.editor-btn:hover { background: var(--civiky-bg); color: var(--civiky-ink); }
.editor-btn.active { background: var(--civiky-blue-light); color: var(--civiky-blue); }
.editor-btn svg { width: 14px; height: 14px; }
.editor-divider { width: 1px; background: var(--civiky-border); margin: 0.25rem 0.3rem; }
.editor-body {
  padding: 2rem 3rem;
  flex: 1;
  font-size: 1rem;
  line-height: 1.7;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.editor-body h1 { font-size: 2rem; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
.editor-body .byline { color: var(--civiky-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.editor-body p { margin: 0 0 1rem; }
.editor-body blockquote {
  border-left: 4px solid var(--civiky-blue);
  padding: 0.5rem 1.25rem;
  color: var(--civiky-ink);
  font-style: italic;
  background: var(--civiky-blue-light);
  border-radius: 0 0.5rem 0.5rem 0;
  margin: 1.5rem 0;
}
.editor-body .image-block {
  border-radius: 0.75rem;
  overflow: hidden;
  margin: 1.5rem 0;
  position: relative;
}
.editor-body .image-block-placeholder {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--civiky-blue);
  font-weight: 600;
}
.editor-body figcaption { font-size: 0.82rem; color: var(--civiky-muted); margin-top: 0.5rem; text-align: center; }

.editor-side { display: flex; flex-direction: column; gap: 1rem; }

/* TIMELINE */
.timeline {
  position: relative;
  padding-left: 1.25rem;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 0.325rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--civiky-border);
}
.timeline-item {
  position: relative;
  padding-bottom: 1.25rem;
}
.timeline-dot {
  position: absolute;
  left: -1.25rem;
  top: 0.35rem;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 999px;
  background: white;
  border: 2px solid var(--civiky-blue);
}
.timeline-dot.done { background: var(--civiky-blue); }
.timeline-dot.pending { border-color: var(--civiky-warning); }
.timeline-title { font-size: 0.9rem; font-weight: 600; margin: 0; }
.timeline-sub { font-size: 0.78rem; color: var(--civiky-muted); margin: 0.15rem 0 0; }

/* PAPER (PREVIEW) */
.paper {
  background: white;
  border: 1px solid var(--civiky-border);
  box-shadow: var(--shadow-xl);
  padding: 2.5rem 2rem;
  aspect-ratio: 210 / 297;
  max-width: 500px;
  margin: 0 auto;
  font-family: 'Georgia', serif;
  overflow: hidden;
  position: relative;
}
.paper-masthead {
  border-bottom: 3px double var(--civiky-ink);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  text-align: center;
}
.paper-masthead .logo { font-family: 'Inter', sans-serif; font-weight: 800; letter-spacing: 0.15em; font-size: 0.72rem; color: var(--civiky-blue); text-transform: uppercase; }
.paper-masthead h1 { font-size: 1.75rem; margin: 0.25rem 0; font-weight: 700; letter-spacing: -0.01em; }
.paper-masthead .meta { font-size: 0.7rem; color: var(--civiky-muted); display: flex; justify-content: space-between; }
.paper-columns { column-count: 2; column-gap: 1rem; font-size: 0.65rem; line-height: 1.4; color: #333; }
.paper-columns h3 { font-size: 0.85rem; margin: 0.5rem 0 0.35rem; font-weight: 700; column-span: all; color: var(--civiky-blue); font-family: 'Inter', sans-serif; }
.paper-columns h3:first-child { margin-top: 0; }

/* SEGMENT TABS */
.segments {
  display: inline-flex;
  background: var(--civiky-bg);
  border: 1px solid var(--civiky-border);
  padding: 0.25rem;
  border-radius: 0.625rem;
  gap: 0.125rem;
}
.segment {
  padding: 0.375rem 0.875rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0.4rem;
  color: var(--civiky-muted);
  border: 0;
  background: transparent;
  font-family: inherit;
}
.segment.active {
  background: white;
  color: var(--civiky-ink);
  box-shadow: var(--shadow-sm);
}

/* UTILITIES */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.flex-1 { flex: 1; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--civiky-muted); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }

/* RESPONSIVE */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { padding: 2rem; min-height: 280px; }
  .editor-shell { grid-template-columns: 1fr; }
}

/* DEMO BANNER */
.demo-banner {
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  border-bottom: 1px solid #fbbf24;
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: 0.78rem;
  color: #78350f;
  font-weight: 500;
}
.demo-banner strong { color: #78350f; }

/* ==========================================================================
   DARK MODE OVERRIDES — Elements with hardcoded "white" backgrounds
   ========================================================================== */
[data-theme="dark"] .topbar,
[data-theme="dark"] .card,
[data-theme="dark"] .stat,
[data-theme="dark"] .module,
[data-theme="dark"] .icon-btn,
[data-theme="dark"] .form-input,
[data-theme="dark"] .segment.active,
[data-theme="dark"] .article-card,
[data-theme="dark"] .editor-main,
[data-theme="dark"] .rubric,
[data-theme="dark"] .issue,
[data-theme="dark"] .template,
[data-theme="dark"] .plan,
[data-theme="dark"] .auth-main {
  background: var(--civiky-surface);
  color: var(--civiky-ink);
}

[data-theme="dark"] .topbar-search input,
[data-theme="dark"] .segments {
  background: var(--civiky-bg);
  color: var(--civiky-ink);
}

[data-theme="dark"] select.form-input option {
  background: var(--civiky-surface);
  color: var(--civiky-ink);
}

[data-theme="dark"] .table th {
  background: var(--civiky-surface-2);
  color: var(--civiky-muted);
}

[data-theme="dark"] .badge { background: var(--civiky-surface-2); color: var(--civiky-muted); }
[data-theme="dark"] .badge-blue  { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
[data-theme="dark"] .badge-green { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
[data-theme="dark"] .badge-amber { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
[data-theme="dark"] .badge-red   { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }

[data-theme="dark"] .list-avatar { background: var(--civiky-surface-2); color: var(--civiky-muted); }

[data-theme="dark"] .dropzone { background: var(--civiky-surface-2); }
[data-theme="dark"] .dropzone:hover { background: var(--civiky-blue-light); }

[data-theme="dark"] .rubric.pending { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.4); }
[data-theme="dark"] .rubric.done    { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.4); }

[data-theme="dark"] .paper {
  background: var(--civiky-surface);
  color: var(--civiky-ink);
}
[data-theme="dark"] .paper-columns,
[data-theme="dark"] .paper-col,
[data-theme="dark"] .paper-hero-article .body { color: var(--civiky-muted); }
[data-theme="dark"] .paper-masthead { border-color: var(--civiky-ink); }

[data-theme="dark"] .media-thumb { background: linear-gradient(135deg, var(--civiky-blue-light), var(--civiky-surface-2)); }

[data-theme="dark"] .ai-suggest {
  background: linear-gradient(135deg, rgba(109, 40, 217, 0.2), rgba(109, 40, 217, 0.1));
  border-color: rgba(167, 139, 250, 0.3);
}
[data-theme="dark"] .ai-suggest-head { color: #c4b5fd; }

[data-theme="dark"] .callout-block { background: var(--civiky-blue-light); }

[data-theme="dark"] .stat-icon { background: var(--civiky-blue-light); color: var(--civiky-blue); }

[data-theme="dark"] .paper-stage { background: linear-gradient(135deg, var(--civiky-bg) 0%, var(--civiky-surface-2) 100%); }

[data-theme="dark"] .editor-btn:hover { background: var(--civiky-surface-2); }
[data-theme="dark"] .editor-btn.active { background: var(--civiky-blue-light); color: var(--civiky-blue); }

[data-theme="dark"] .tiptap-highlight { background: rgba(251, 191, 36, 0.25); }

[data-theme="dark"] blockquote,
[data-theme="dark"] .editor-body blockquote { background: var(--civiky-blue-light); color: var(--civiky-ink); }

[data-theme="dark"] .demo-banner {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.2));
  border-color: rgba(251, 191, 36, 0.3);
  color: #fcd34d;
}
[data-theme="dark"] .demo-banner strong { color: #fcd34d; }

[data-theme="dark"] .participant { border-color: var(--civiky-surface); }

[data-theme="dark"] .timeline-dot { background: var(--civiky-surface) !important; }
[data-theme="dark"] .timeline-dot.done { background: var(--civiky-blue) !important; }

[data-theme="dark"] .slash-menu { background: var(--civiky-surface); }
[data-theme="dark"] .slash-icon { background: var(--civiky-surface-2); }
[data-theme="dark"] .slash-item:hover,
[data-theme="dark"] .slash-item.highlighted { background: var(--civiky-blue-light); }

[data-theme="dark"] .product-card { background: var(--civiky-surface-2); }

[data-theme="dark"] .paper-banner { background: var(--civiky-blue); color: white; }

[data-theme="dark"] .issue-cover,
[data-theme="dark"] .template-preview {
  background: var(--civiky-surface-2);
  color: var(--civiky-ink);
}
[data-theme="dark"] .issue-cover .headline { color: var(--civiky-ink); }
[data-theme="dark"] .issue-cover .body,
[data-theme="dark"] .template-preview .body { color: var(--civiky-muted); }

/* Theme toggle button */
.theme-toggle {
  position: relative;
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { transition: opacity 0.2s; }
[data-theme="light"] .theme-toggle .icon-moon,
:root:not([data-theme]) .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun,
:root:not([data-theme]) .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* Language dropdown */
.lang-dropdown {
  position: relative !important;
  display: inline-block !important;
}
.lang-menu {
  position: absolute !important;
  top: calc(100% + 6px) !important;
  right: 0 !important;
  background: var(--civiky-surface) !important;
  border: 1px solid var(--civiky-border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
  padding: 0.3rem;
  min-width: 200px;
  max-width: calc(100vw - 24px);
  z-index: 100 !important;
  display: none !important;
}
.lang-menu.open { display: block !important; }
.lang-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.35rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--civiky-ink);
}
.lang-option:hover { background: var(--civiky-surface-2); }
.lang-option.active { background: var(--civiky-blue-light); color: var(--civiky-blue); font-weight: 600; }
.lang-flag { font-size: 1.1rem; }
