:root {
  --bg: #0f1117;
  --bg-soft: #161a23;
  --card: #1a1f2b;
  --card-2: #212736;
  --line: #2a3140;
  --text: #e8ecf4;
  --muted: #8d97ab;
  --accent: #ff3b5c;
  --accent-2: #ff6b3d;
  --ok: #35d07f;
  --warn: #ffb020;
  --err: #ff5c5c;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

.titlebar {
  height: 28px;
  -webkit-app-region: drag;
  background: var(--bg);
}

.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: calc(100vh - 28px);
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 12px 12px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  padding: 4px 8px 16px;
}

.logo {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.nav span {
  width: 16px;
  text-align: center;
}

.nav:hover {
  background: var(--card);
  color: var(--text);
}

.nav.active {
  background: var(--card-2);
  color: var(--text);
}

.nav em {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
}

.nav em:empty {
  display: none;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.env {
  font-size: 11px;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--card);
  line-height: 1.5;
}

.env b {
  color: var(--text);
  font-weight: 600;
}

.env .bad {
  color: var(--err);
}

.env .good {
  color: var(--ok);
}

/* ---------- main ---------- */
main {
  overflow: hidden;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 24px 28px 40px;
}

.view.active {
  display: block;
}

.hero h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.hero p {
  margin: 0 0 18px;
  color: var(--muted);
}

h2 {
  font-size: 15px;
  margin: 0 0 10px;
}

/* ---------- controls ---------- */
button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 16px;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
}

.ghost {
  background: var(--card-2);
  border-color: var(--line);
  color: var(--text);
}

.ghost:hover {
  border-color: var(--muted);
}

.small {
  padding: 6px 10px;
  font-size: 12px;
}

.danger {
  background: transparent;
  border-color: var(--line);
  color: var(--err);
}

input,
select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  width: 100%;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

label input,
label select {
  margin-top: 6px;
}

.urlbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.urlbar {
  align-items: flex-start;
}

.urlbar textarea {
  flex: 1;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  resize: none;
  max-height: 180px;
  overflow-y: auto;
  line-height: 1.5;
}

.urlbar textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- bulk paste ---------- */
.bulk-rows {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 10px;
}

.bulk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.bulk-row:last-child {
  border-bottom: 0;
}

.bulk-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}

.bulk-row.working .dot {
  background: var(--warn);
}

.bulk-row.ok .dot {
  background: var(--ok);
}

.bulk-row.error .dot {
  background: var(--err);
}

.bulk-row .who {
  flex: 1;
  min-width: 0;
}

.bulk-row .who div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-row .who .link {
  font-size: 11px;
  color: var(--muted);
}

.bulk-row.error .who .link {
  color: var(--err);
}

.bulk-row .drop {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 15px;
  line-height: 1;
}

.bulk-row .drop:hover {
  color: var(--err);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.spread {
  justify-content: space-between;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
}

.checks input {
  width: auto;
  margin: 0;
}

.pathrow {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.pathrow label {
  flex: 1;
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card.warn {
  border-color: var(--warn);
}

.result {
  display: flex;
  gap: 16px;
}

.result img {
  width: 220px;
  height: 124px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--card-2);
  flex-shrink: 0;
}

.result img[src=""] {
  visibility: hidden;
}

.result-body {
  flex: 1;
  min-width: 0;
}

.result h2 {
  margin: 0 0 4px;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
}

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 10px 0 6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.chip {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
}

.chip.on {
  border-color: var(--accent);
  background: rgba(255, 59, 92, 0.14);
  color: #fff;
}

details {
  margin: 6px 0 12px;
}

summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.msg {
  min-height: 20px;
  font-size: 13px;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.msg.error {
  color: var(--err);
}

.msg.info {
  color: var(--muted);
}

/* ---------- lists ---------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty {
  color: var(--muted);
  padding: 28px 0;
  text-align: center;
}

.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.item .top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item .title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.item .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.bar {
  height: 6px;
  background: var(--card-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}

.bar > div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s linear;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge.done {
  color: var(--ok);
}

.badge.error {
  color: var(--err);
}

.badge.recording {
  color: var(--accent);
}

.badge.live {
  color: var(--accent);
}

/* ---------- library gallery ---------- */
.search {
  width: 220px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.tile.missing {
  opacity: 0.55;
  cursor: default;
}

.tile.missing:hover {
  border-color: var(--line);
  transform: none;
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #232a39, #171c26);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb .glyph {
  font-size: 30px;
  color: var(--line);
}

.thumb .stamp {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
}

.thumb .kind {
  position: absolute;
  left: 6px;
  top: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}

.thumb .kind.live {
  background: var(--accent);
  color: #fff;
}

.tile .body {
  padding: 10px 12px 12px;
}

.tile .name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.tile .facts {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tile .actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.tile .actions button {
  flex: 1;
  padding: 5px 8px;
  font-size: 11px;
}

.pl-items {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 10px;
}

.pl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.pl-item:last-child {
  border-bottom: 0;
}

.pl-item input {
  width: auto;
}

.pl-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log {
  background: #0b0d13;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  max-height: 200px;
  overflow: auto;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  white-space: pre-wrap;
  margin: 10px 0 0;
}

.tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.tools code {
  color: var(--muted);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.player {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 24px;
}

.player-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: min(1000px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.player-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.player-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-stage {
  background: #000;
  display: grid;
  place-items: center;
  min-height: 220px;
}

.player-stage video {
  width: 100%;
  max-height: 70vh;
  display: block;
}

.player-stage audio {
  width: 90%;
  margin: 40px 0;
}

.player .hint {
  padding: 0 14px;
}

.player .hint:empty {
  display: none;
}

.player .hint:not(:empty) {
  padding: 10px 14px;
  color: var(--warn);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 70vw;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}
