:root {
  --bg: #0e1015;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #8b93a3;
  --accent: #ff4500;
  --accent-2: #1d9bf0;
  --ok: #2ecc71;
  --warn: #f1c40f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-size: 22px; }
header .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

main {
  display: grid;
  grid-template-columns: 220px 1fr 320px;
  gap: 16px;
  padding: 16px 28px;
  align-items: start;
}

h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }

aside, #posts-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

/* Subreddits */
#subreddit-list { list-style: none; padding: 0; margin: 0 0 12px; }
#subreddit-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
#subreddit-list li:hover { background: var(--panel-2); }
#subreddit-list li.active { background: var(--accent); color: #fff; }
#subreddit-list li .del { opacity: 0; color: var(--muted); border: none; background: none; cursor: pointer; font-size: 14px; }
#subreddit-list li:hover .del { opacity: 1; }
#subreddit-list li.active .del { color: #fff; }

#add-sub-form { display: flex; gap: 6px; }
#add-sub-input {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 8px;
}

/* Posts */
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.card {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.card .title { font-size: 14px; line-height: 1.4; font-weight: 600; }
.card .stats { display: flex; gap: 12px; color: var(--muted); font-size: 13px; }
.card .gen-btn {
  margin-top: auto; padding: 8px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer; font-weight: 600;
}
.card .gen-btn:disabled { background: #3a3f4a; color: var(--muted); cursor: not-allowed; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; align-self: flex-start; }
.badge.generated { background: rgba(46,204,113,.15); color: var(--ok); }
.badge.generating { background: rgba(241,196,15,.15); color: var(--warn); }
.badge.failed { background: rgba(231,76,60,.15); color: #e74c3c; }

button { font-family: inherit; }
#refresh-btn {
  background: var(--accent-2); color: #fff; border: none; border-radius: 8px;
  padding: 8px 12px; cursor: pointer;
}
#refresh-btn:disabled { background: #3a3f4a; color: var(--muted); cursor: not-allowed; }

.empty { color: var(--muted); font-size: 14px; margin-top: 16px; }
.spinner { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Jobs */
.job { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; font-size: 13px; }
.job .bar { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.job .bar > div { height: 100%; background: var(--ok); transition: width .3s; }
.job .msg { color: var(--muted); margin-top: 4px; }
.job.error { border-color: #e74c3c; }

/* Vidéos */
.vcard { margin-bottom: 14px; }
#videos video { width: 100%; border-radius: 8px; margin-top: 8px; background: #000; }
#videos .vtitle { font-size: 13px; margin-top: 6px; color: var(--muted); }
.vfooter { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* TikTok */
.tt-connected { display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 8px 10px; background: rgba(46,204,113,.1); border-radius: 8px; margin-bottom: 10px; }
.tt-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.tt-disconnect { margin-left: auto; font-size: 12px; background: none; border: 1px solid var(--border);
  color: var(--muted); border-radius: 6px; padding: 3px 8px; cursor: pointer; }
.tt-disconnect:hover { border-color: #e74c3c; color: #e74c3c; }
.tt-connect-btn { display: block; text-align: center; padding: 8px; border-radius: 8px;
  background: #010101; color: #fff; text-decoration: none; font-size: 13px; font-weight: 600;
  margin-bottom: 10px; border: 1px solid var(--border); }
.tt-connect-btn:hover { background: #2a2a2a; }
.tt-warn { font-size: 12px; color: var(--warn); margin-bottom: 10px; }
.tt-demo-link { display: block; text-align: center; font-size: 12px; padding: 5px;
  border-radius: 6px; border: 1px dashed var(--border); color: var(--muted);
  text-decoration: none; margin-top: 6px; margin-bottom: 10px; }
.tt-demo-link:hover { border-color: var(--accent-2); color: var(--accent-2); }
.tt-badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; font-weight: 600; }
.tt-badge.ok { background: rgba(46,204,113,.15); color: var(--ok); }
.tt-badge.warn { background: rgba(241,196,15,.15); color: var(--warn); }
.tt-badge.err { background: rgba(231,76,60,.15); color: #e74c3c; cursor: help; }
.tt-upload-btn { font-size: 12px; padding: 3px 10px; border-radius: 6px;
  background: #010101; color: #fff; border: 1px solid var(--border); cursor: pointer; }
.tt-upload-btn:hover { background: #2a2a2a; }
.tt-upload-btn:disabled { opacity: .5; cursor: not-allowed; }
.dl-btn { font-size: 12px; padding: 3px 10px; border-radius: 6px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  text-decoration: none; }
.dl-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }
