*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f17;
  --sidebar: #1a1a2e;
  --card: #1e1e30;
  --border: #2a2a42;
  --accent: #f97316;
  --text: #e2e2f0;
  --muted: #8888aa;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}
.sidebar-logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.5px;
}
.sidebar-logo span { color: var(--text); }
.sidebar nav { padding: 16px 0; flex: 1; }
.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s, background 0.15s;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover, .sidebar nav a.active {
  color: var(--text);
  background: rgba(249,115,22,0.1);
  border-left-color: var(--accent);
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.main { margin-left: 220px; flex: 1; padding: 32px; }
.page-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 24px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.card-meta { font-size: 0.8rem; color: var(--muted); margin-bottom: 16px; }
.card-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  border: none; text-decoration: none; transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }

.toggle { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.toggle-switch {
  width: 36px; height: 20px; background: var(--border);
  border-radius: 10px; position: relative; cursor: pointer;
  transition: background 0.2s; border: none;
}
.toggle-switch.on { background: var(--accent); }
.toggle-switch::after {
  content: ''; width: 14px; height: 14px; background: #fff;
  border-radius: 50%; position: absolute; top: 3px; left: 3px;
  transition: transform 0.2s;
}
.toggle-switch.on::after { transform: translateX(16px); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 500; }
.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-yellow { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-gray { background: rgba(136,136,170,0.15); color: var(--muted); }

.platforms { display: flex; gap: 4px; flex-wrap: wrap; }
.platform-pill { padding: 2px 8px; background: var(--border); border-radius: 12px; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

.post-list { display: flex; flex-direction: column; gap: 12px; }
.post-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.post-item-meta { flex: 1; min-width: 0; }
.post-item-text { font-size: 0.88rem; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-item-sub { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.form-group input { width: 100%; padding: 10px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 0.9rem; }
.form-group input:focus { outline: none; border-color: var(--accent); }

.login-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100%; background: var(--bg); }
.login-box { width: 360px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.login-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; color: var(--accent); }
.login-subtitle { font-size: 0.85rem; color: var(--muted); margin-bottom: 24px; }
.error-msg { color: var(--red); font-size: 0.85rem; margin-bottom: 12px; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request.htmx-indicator { display: inline; }

.connection-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.connection-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sub-items { padding-left: 12px; display: flex; flex-direction: column; gap: 6px; }
.sub-item { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.spinner { display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Post-Grid */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.post-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.post-card-img { width: 100%; aspect-ratio: 1; background: var(--border); overflow: hidden; position: relative; }
.post-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card-img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 2rem; }
.post-card-body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.post-card-text { font-size: 0.82rem; line-height: 1.45; color: var(--text); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.post-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.post-card-footer { padding: 8px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.post-card-img-badge { position: absolute; top: 8px; right: 8px; }
