:root {
  --bg: #0d0f14;
  --panel: #161a23;
  --panel-2: #1e2330;
  --line: #2a3142;
  --text: #eef1f7;
  --muted: #8b93a7;
  --accent: #ff3c6e;
  --accent-2: #7b2cff;
  --ok: #2bd47d;
  --err: #ff5b5b;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(800px 400px at 10% -10%, rgba(255, 60, 110, .18), transparent 60%),
    radial-gradient(700px 400px at 110% 0%, rgba(123, 44, 255, .18), transparent 60%),
    var(--bg);
}

.wrap { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; }

.top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.logo { border-radius: 10px; }
.top h1 { font-size: 1.35rem; margin: 0; flex: 1; letter-spacing: .01em; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: .85rem; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.live .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(43, 212, 125, .15); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 1.1rem; }

label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 12px; }

input, textarea {
  width: 100%; margin-top: 6px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font: inherit; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; margin-top: 0; }

button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.primary {
  width: 100%; border: 0; border-radius: 12px; padding: 12px 16px;
  background: var(--grad); color: #fff; font-weight: 700;
}
.primary.big { padding: 15px 16px; font-size: 1.05rem; }
.secondary {
  width: 100%; margin-top: 10px; padding: 10px; border-radius: 12px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
}
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }

.error { color: var(--err); min-height: 1.4em; margin: 10px 0 0; font-size: .9rem; }

.who { color: var(--muted); font-size: .9rem; margin-bottom: 14px; }
.who b { color: var(--text); }

.tabs { display: flex; gap: 6px; background: var(--panel-2); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tabs { flex-wrap: wrap; }
.tabs button {
  flex: 1 1 auto; border: 0; border-radius: 9px; padding: 9px;
  background: transparent; color: var(--muted); font-weight: 600;
}
.tabs button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 0 var(--line); }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-height: 130px; margin: 0;
  border: 2px dashed var(--line); border-radius: 14px;
  text-align: center; padding: 16px; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(255, 60, 110, .06); }
.drop-title { color: var(--text); font-weight: 600; }

.gif-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  max-height: 340px; overflow-y: auto; margin-top: 10px; border-radius: 12px;
}
.gif-grid > button {
  padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden;
  background: var(--panel-2); aspect-ratio: 1;
}
.gif-grid > button.picked { border-color: var(--accent); }
.gif-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-grid .empty { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 20px; }
#yt-url { margin-top: 0; }
.hint { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
#import-btn { margin-top: 8px; font-size: .9rem; }
.lib-add { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.lib-add .hint { margin: 0; }
.lib-add .secondary { margin-top: 0; }
.import-row { display: flex; gap: 8px; }
.import-row input { margin-top: 0; flex: 1; min-width: 0; }
.import-row .secondary { width: auto; padding: 0 18px; white-space: nowrap; }
.link-preview {
  aspect-ratio: 9 / 16; max-height: 120px; margin: 0 auto; border-radius: 8px;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: #fff;
  background: linear-gradient(135deg, #25f4ee, #fe2c55);
}
.lib-item { position: relative; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--panel-2); aspect-ratio: 1; }
.lib-item.picked { border-color: var(--accent); }
.lib-pick { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; position: relative; }
.lib-pick video, .lib-pick img { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.lib-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px;
  font-size: .72rem; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, .8));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lib-delete {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: .8rem; line-height: 1;
  opacity: 0; transition: opacity .15s;
}
.lib-item:hover .lib-delete, .lib-delete:focus-visible { opacity: 1; }
@media (hover: none) { .lib-delete { opacity: 1; } }
.lib-delete:hover { background: var(--err); }
.giphy { font-size: .75rem; color: var(--muted); text-align: right; margin: 8px 0 0; }

.selected {
  display: flex; gap: 12px; align-items: center;
  margin-top: 14px; padding: 10px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.selected-preview { width: 120px; flex: none; }
.selected-preview video, .selected-preview img { width: 100%; max-height: 120px; object-fit: contain; border-radius: 8px; display: block; background: #000; }
.selected-info { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; min-width: 0; }
.selected-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.text-row { position: relative; margin: 14px 0; }
.counter { position: absolute; right: 10px; bottom: 8px; font-size: .75rem; color: var(--muted); }

.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress div { height: 100%; width: 0; background: var(--grad); transition: width .1s; }

.status { min-height: 1.4em; margin: 12px 0 0; text-align: center; font-size: .95rem; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.foot { margin-top: 22px; text-align: center; color: var(--muted); font-size: .9rem; display: flex; flex-direction: column; gap: 4px; }
.foot a { color: var(--text); font-weight: 600; }

[hidden] { display: none !important; }
