:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #181b21;
  --panel-2: #22262e;
  --border: #2f343e;
  --text: #eceef2;
  --muted: #9aa2af;
  --accent: #5b9dff;
  --danger: #e5484d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Color Emoji", sans-serif;
}

h1, h2, p { margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 17px; overflow-wrap: anywhere; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: #ff8d8f; font-size: 13px; }

input, select, button { font: inherit; color: inherit; }
input[type="search"], input[type="password"], select {
  width: 100%;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
:is(input, select, button, a):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.button {
  padding: 7px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { border-color: var(--muted); }
.button:disabled { opacity: 0.55; cursor: default; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #07121f; font-weight: 600; }
.button.danger { background: transparent; border-color: var(--danger); color: #ff8d8f; }
.button.danger:hover { background: var(--danger); color: #fff; }
.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: 13px; }

.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.app { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: 100%; }
.stage { min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 16px; overflow: auto; }

.video-box {
  position: relative;
  flex: 1 1 auto;
  min-height: 240px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.video-box video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.video-box:fullscreen { border-radius: 0; }
.placeholder, .loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  color: var(--muted);
}
.loading { pointer-events: none; color: var(--text); background: rgb(0 0 0 / 35%); }
.error-box { background: #000; }

.controls { display: grid; gap: 8px; }
.seek { width: 100%; margin: 0; accent-color: var(--accent); }
.control-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.spacer { flex: 1; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.inline input { width: 80px; accent-color: var(--accent); }
.inline select { width: auto; padding: 5px 6px; }

.details { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.details-text { min-width: 0; display: grid; gap: 2px; }

.library { min-height: 0; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--border); }
.library-head { display: grid; gap: 8px; padding: 16px; border-bottom: 1px solid var(--border); }
.library-title { display: flex; align-items: baseline; justify-content: space-between; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.list { flex: 1; min-height: 0; margin: 0; padding: 0; overflow: auto; list-style: none; }
.item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
}
.item:hover { background: var(--panel-2); }
.item[aria-current="true"] { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.item-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.item-title { display: block; font-size: 13px; overflow-wrap: anywhere; }
.item-meta { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.empty { padding: 16px; }

.confirm {
  width: min(440px, calc(100% - 32px));
  padding: 20px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.confirm::backdrop { background: rgb(0 0 0 / 60%); }
.confirm form { display: grid; gap: 10px; }
.confirm-name { font-size: 14px; overflow-wrap: anywhere; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

@media (max-width: 860px) {
  .app { display: block; height: auto; }
  .stage { padding: 16px; overflow: visible; }
  .video-box { flex: none; height: 58vh; }
  .library { border-left: 0; border-top: 1px solid var(--border); }
  .list { overflow: visible; }
  .inline input { width: 64px; }
}
