:root {
  --bg: #0a0c11; --bg2: #0f1218; --panel: #14171f; --panel2: #1a1e28;
  --line: #232834; --line2: #303644;
  --text: #eef1f6; --muted: #8b93a5; --faint: #5b6273;
  --accent: #fe2c55; --accent-soft: #ff5c7a; --accent2: #25f4ee;
  --ok: #2ecc71; --warn: #f1c40f; --err: #e74c3c;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 10px 34px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background:
    radial-gradient(900px 480px at 12% -8%, rgba(254,44,85,.12), transparent 60%),
    radial-gradient(800px 460px at 100% -5%, rgba(37,244,238,.09), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text); font-size: 14px; line-height: 1.5; letter-spacing: .1px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- header ---------- */
header {
  display: flex; align-items: center; gap: 16px;
  padding: 14px clamp(14px, 3.5vw, 30px);
  background: rgba(15,17,23,.72); backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.logo { display: block; border-radius: 10px; flex: 0 0 auto;
  filter: drop-shadow(0 4px 12px rgba(254,44,85,.35)); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text h1 { font-size: 16px; margin: 0; font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.tagline { font-size: 11px; color: var(--faint); white-space: nowrap;
  text-transform: uppercase; letter-spacing: .8px; }
#openSettings { margin-left: auto; white-space: nowrap; }

/* ---------- layout ---------- */
main { max-width: 1160px; margin: 0 auto; padding: clamp(16px, 3vw, 26px);
  display: grid; gap: clamp(16px, 2.4vw, 22px); }
.panel { background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(15px, 2.6vw, 22px); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 15px; }
.panel-head h2 { font-size: 12px; margin: 0; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }

/* ---------- stat bar ---------- */
.statbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(10px, 1.6vw, 16px); }
.stat { position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: grid; grid-template-columns: auto 1fr;
  grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  box-shadow: var(--shadow); }
.stat-icon { grid-row: 1 / 3; font-size: 22px; width: 44px; height: 44px;
  display: grid; place-items: center; border-radius: 12px;
  background: var(--panel2); border: 1px solid var(--line); }
.stat-num { font-size: 26px; font-weight: 800; line-height: 1; align-self: end; }
.stat-label { color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .8px; align-self: start; }
.stat.live { border-color: rgba(254,44,85,.5); }
.stat.live .stat-icon { background: rgba(254,44,85,.12); border-color: rgba(254,44,85,.4); }
.stat.live .stat-num { color: var(--accent-soft); }
.stat.mon .stat-num { color: var(--accent2); }
.stat.proc .stat-num { color: var(--warn); }

/* ---------- buttons / inputs ---------- */
button {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft)); color: #fff;
  border: 0; border-radius: var(--radius-sm); padding: 9px 16px; font-weight: 650;
  cursor: pointer; font-size: 13px; transition: transform .08s, filter .15s, box-shadow .15s;
  box-shadow: 0 5px 16px rgba(254,44,85,.28);
}
button:hover { filter: brightness(1.07); box-shadow: 0 7px 20px rgba(254,44,85,.38); }
button:active { transform: translateY(1px); }
button.ghost { background: rgba(255,255,255,.02); border: 1px solid var(--line2);
  color: var(--text); box-shadow: none; }
button.ghost:hover { background: var(--panel2); filter: none; }
button.sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
button.danger { background: transparent; border: 1px solid rgba(231,76,60,.55); color: #ff7468;
  box-shadow: none; }
button.danger:hover { background: rgba(231,76,60,.12); filter: none; }

input, select, textarea {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none;
  border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(37,244,238,.16); }
input::placeholder, textarea::placeholder { color: var(--faint); }

/* ---------- add host row ---------- */
.add-row { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.add-row input[name=username] { flex: 1 1 220px; min-width: 0; }
.add-row select { flex: 0 1 170px; }
.add-row input[type=number] { flex: 0 1 110px; width: 110px; min-width: 0; }
.add-row button { flex: 0 0 auto; }

/* ---------- host cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { position: relative; background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  transition: transform .14s, border-color .15s, box-shadow .15s; }
.card:hover { transform: translateY(-3px); border-color: var(--line2);
  box-shadow: 0 12px 26px rgba(0,0,0,.35); }
.card.recording { border-color: rgba(254,44,85,.6);
  box-shadow: 0 0 0 1px rgba(254,44,85,.5), 0 0 28px rgba(254,44,85,.22); }
.card-top { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }
.avatar { position: relative; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  overflow: hidden; background: var(--panel); border: 1px solid var(--line2);
  display: grid; place-items: center; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar .ph-letter { position: absolute; font-weight: 800; font-size: 18px; color: var(--faint); }
.avatar img + .ph-letter { display: none; }
.card.recording .avatar { border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(254,44,85,.45); }
.who { display: flex; flex-direction: column; min-width: 0; gap: 1px; flex: 1 1 auto; }
.card-top .name { font-weight: 700; font-size: 15px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-top .name::before { content: "@"; color: var(--faint); }
.dname { font-size: 12px; color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.livetitle { font-size: 12.5px; color: var(--text); margin-bottom: 8px;
  background: rgba(254,44,85,.08); border: 1px solid rgba(254,44,85,.25);
  border-radius: 9px; padding: 7px 10px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.viewers { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  font-weight: 600; color: var(--accent2); background: rgba(37,244,238,.1);
  border: 1px solid rgba(37,244,238,.22); border-radius: 20px; padding: 3px 10px; margin-bottom: 9px; }
.rec-title { font-size: 11.5px; color: var(--faint); margin-top: 3px; max-width: 320px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { margin-left: auto; font-size: 10px; padding: 4px 11px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .7px; font-weight: 800; white-space: nowrap; }
.badge.recording { background: var(--accent); color: #fff; animation: pulse 1.4s infinite; }
.badge.monitoring { background: rgba(37,244,238,.14); color: var(--accent2); }
.badge.idle { background: #262b37; color: var(--muted); }
.badge.error { background: rgba(231,76,60,.2); color: #ff7468; }
@keyframes pulse { 50% { opacity: .5; } }
.card .meta { color: var(--muted); font-size: 12px; line-height: 1.65; }
.card .msg { color: var(--faint); font-size: 11px; margin-top: 7px; font-family: ui-monospace, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; gap: 8px; margin-top: 13px; flex-wrap: wrap; }

/* empty-state text */
#hosts > p { color: var(--muted); margin: 4px 0; }

/* ---------- recordings table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px;
  -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 580px; }
th, td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line);
  font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td:nth-child(2) { white-space: normal; word-break: break-all; min-width: 160px; color: var(--muted); }
thead th { color: var(--muted); font-weight: 600; background: var(--bg2);
  text-transform: uppercase; font-size: 11px; letter-spacing: .6px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255,255,255,.025); }
td a { color: var(--accent2); text-decoration: none; }
td a:hover { text-decoration: underline; }
a.pill { display: inline-block; }
.pill { font-size: 11px; padding: 3px 10px; border-radius: 12px; background: #262b37; color: var(--muted); }
.pill.done, .pill.uploaded, .pill.uploaded_deleted { background: rgba(46,204,113,.15); color: var(--ok); }
.pill.converting, .pill.uploading, .pill.processing { background: rgba(241,196,15,.15); color: var(--warn); }
.pill.failed { background: rgba(231,76,60,.18); color: #ff7468; }

/* ---------- activity log ---------- */
.log { background: #06080c; border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  height: clamp(180px, 30vh, 260px); overflow: auto; font-family: ui-monospace, "SF Mono", monospace;
  font-size: 12px; line-height: 1.7; color: #9fd0c8; margin: 0; white-space: pre-wrap; word-break: break-word; }
.log .err { color: #ff7468; } .log .warn { color: var(--warn); }

/* ---------- settings modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.66); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 14px; z-index: 30; overflow: auto; }
.modal.hidden { display: none; }
.modal-box { background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line2); border-radius: var(--radius); padding: clamp(18px, 3vw, 26px);
  width: 620px; max-width: 100%; box-shadow: var(--shadow); animation: pop .18s ease-out; }
@keyframes pop { from { transform: translateY(10px) scale(.99); opacity: 0; } }
.modal-box h2 { margin: 0 0 18px; font-size: 19px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 16px; padding: 16px 18px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 13px 18px; }
legend { color: var(--accent2); font-size: 11px; padding: 0 7px; text-transform: uppercase;
  letter-spacing: .8px; font-weight: 700; }
fieldset label { display: flex; flex-direction: column; gap: 6px; margin: 0; font-size: 12px; color: var(--muted); }
fieldset label.chk { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 9px; }
fieldset label.chk input { width: auto; }
fieldset label:has(textarea) { grid-column: 1 / -1; }
fieldset input, fieldset select, fieldset textarea { color: var(--text); width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.hidden { display: none; }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 10px;
  border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #3d4456; background-clip: content-box; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .statbar { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .add-row { gap: 8px; }
  .add-row > * { flex: 1 1 100%; width: 100%; }
  .cards { grid-template-columns: 1fr; }
  fieldset { grid-template-columns: 1fr; }
}
@media (max-width: 460px) {
  .tagline { display: none; }
  .stat { padding: 13px 14px; column-gap: 10px; }
  .stat-icon { width: 38px; height: 38px; font-size: 19px; }
  .stat-num { font-size: 22px; }
}
@media (max-width: 380px) {
  .statbar { grid-template-columns: 1fr; }
}
