:root {
  --bg: #09090b;
  --panel: #121217;
  --panel-2: #17171d;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.16);
  --text: #f5f5f7;
  --muted: rgba(255,255,255,0.58);
  --muted-2: rgba(255,255,255,0.38);
  --accent: #ffffff;
  --danger: #aa3b3b;
  --good: #38a169;
  --shadow: 0 10px 28px rgba(0,0,0,0.28);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar-w: 360px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; font-family: Inter, Arial, sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
input, select, button { outline: none; }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 14px;
  padding: 14px;
}
.sidebar, .content { min-width: 0; min-height: 0; }
.sidebar { display: grid; gap: 12px; grid-template-rows: auto auto auto 1fr; }
.content { display: flex; min-height: 0; }
.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.sidebar-header {
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.brand-logo { width: 100%; max-width: 100%; height: 52px; object-fit: contain; }
.sidebar-header h1 { margin: 0; font-size: 22px; line-height: 1; text-align: center; }
.sidebar-header p { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.topbar-panel, .live-panel, .library-panel { padding: 12px; }
.topbar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-pill, .topbar-meta {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.status-pill { gap: 6px; }
.status-pill strong, .topbar-meta strong { font-size: 14px; font-weight: 700; }
.topbar-meta span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted-2); box-shadow: 0 0 0 4px rgba(255,255,255,0.03); }
.dot.online { background: var(--good); }
.dot.waiting { background: #d6a73e; }
.transport-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 10px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.panel-title-row h2 { margin: 0; font-size: 15px; }
.toggles-inline { display: flex; gap: 8px; }
.mini-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,0.04); font-size: 12px; color: var(--muted);
}
.mini-toggle input { transform: scale(.95); }
.compact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini-field {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px;
  min-height: 40px; border: 1px solid var(--line); border-radius: 12px; padding: 0 8px; background: rgba(255,255,255,0.03);
}
.mini-field span, .mini-field small { font-size: 12px; color: var(--muted); }
.mini-field input {
  height: 28px; border: 0; background: rgba(255,255,255,0.06); color: var(--text); border-radius: 8px; text-align: center; min-width: 0; width: 100%;
}
.compact-stack { display: flex; flex-direction: column; gap: 8px; }
.save-row { display: grid; grid-template-columns: 1fr 36px; gap: 8px; }
.save-row:nth-child(2) { grid-template-columns: 1fr 36px 36px; }
.end-row { grid-template-columns: 36px 36px; justify-content: end; }
.compact-input {
  height: 36px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,0.04); color: var(--text); padding: 0 10px; min-width: 0;
}
.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer; transition: background .16s ease, border-color .16s ease, transform .12s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.10); border-color: var(--line-strong); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn.primary { background: rgba(255,255,255,0.12); }
.icon-btn.danger { background: rgba(170,59,59,0.16); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.file-icon-btn { position: relative; overflow: hidden; display: inline-flex; }
.file-icon-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.work-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.work-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.work-header-title h2 { margin: 0; font-size: 17px; }
.work-header-title p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.work-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.compact-select { min-width: 180px; }
.library-panel { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.playlist-list, .library-list { width: 100%; height: 100%; overflow: auto; scroll-behavior: smooth; }
.playlist-list::-webkit-scrollbar, .library-list::-webkit-scrollbar { width: 10px; }
.playlist-list::-webkit-scrollbar-thumb, .library-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.playlist-list::-webkit-scrollbar-track, .library-list::-webkit-scrollbar-track { background: transparent; }
.playlist-list, .library-list { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.16) transparent; }
.playlist-list { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.playlist-list.roomy { gap: 12px; }
.library-list.compact { padding: 2px 0 0; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.library-card {
  display: grid; grid-template-columns: 108px 1fr auto; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: 16px; padding: 10px; background: rgba(255,255,255,0.04); min-height: 96px;
}
.library-thumb {
  width: 108px; height: 72px; border-radius: 12px; overflow: hidden; background: #000; border: 1px solid rgba(255,255,255,0.05); display: grid; place-items: center;
}
.library-thumb img, .library-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.library-fallback { width: 30px; height: 30px; opacity: .55; }
.library-body { min-width: 0; }
.library-name { font-size: 13px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.library-meta { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; }
.playlist-item {
  position: relative; display: grid; grid-template-columns: 22px 92px minmax(0,1fr) auto; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,0.04); min-height: 106px; overflow: hidden;
}
.playlist-item.active { border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.07); }
.playlist-item.done { opacity: .62; }
.playlist-item.next-up { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }
.drag-handle { cursor: grab; color: var(--muted-2); user-select: none; text-align: center; font-size: 16px; }
.playlist-thumb { width: 92px; height: 68px; border-radius: 12px; overflow: hidden; background: #000; border: 1px solid rgba(255,255,255,0.05); }
.playlist-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.playlist-body { min-width: 0; padding: 12px 6px 20px 0; }
.playlist-topline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.playlist-index {
  flex: none; width: 24px; height: 24px; border-radius: 999px; background: rgba(255,255,255,0.08); color: var(--muted); font-size: 11px; display: grid; place-items: center;
}
.playlist-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist-state { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.playlist-meta-row { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); }
.playlist-actions { display: flex; align-items: center; gap: 8px; padding-right: 12px; }
.repeat-stepper {
  display: inline-flex; align-items: center; gap: 0; height: 34px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(255,255,255,0.04);
}
.repeat-btn {
  width: 30px; height: 34px; border: 0; background: transparent; color: var(--text); cursor: pointer; display: grid; place-items: center;
}
.repeat-btn:hover { background: rgba(255,255,255,0.08); }
.repeat-value {
  min-width: 42px; padding: 0 8px; text-align: center; font-size: 12px; font-weight: 700; color: var(--text); border-left: 1px solid rgba(255,255,255,0.06); border-right: 1px solid rgba(255,255,255,0.06);
}
.progress-cluster {
  position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: rgba(255,255,255,0.05); display: flex; overflow: hidden;
}
.progress-total, .progress-current {
  position: absolute; left: 0; bottom: 0; transform-origin: left center; will-change: transform; transition: transform .22s cubic-bezier(.22,.61,.36,1);
}
.progress-total { height: 10px; width: 100%; background: rgba(255,255,255,0.14); }
.progress-current { height: 10px; width: 100%; background: rgba(255,255,255,0.92); }
.progress-segments {
  position: absolute; inset: 0; display: flex; pointer-events: none; mix-blend-mode: multiply;
}
.progress-segments span { flex: 1; border-right: 1px solid rgba(0,0,0,0.16); }
.progress-segments span:last-child { border-right: 0; }
.empty-state {
  width: 100%; display: grid; place-items: center; color: var(--muted); min-height: 180px; text-align: center; padding: 20px;
}
.player-body { overflow: hidden; background: #000; }
.player-root { position: fixed; inset: 0; background: #000; }
.video-el { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.preload-el { display: none; }
.idle-logo {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .38s ease; z-index: 1; background: #000;
}
.idle-logo.visible { opacity: 1; }
.idle-logo img { width: min(38vw, 420px); max-width: 70%; object-fit: contain; opacity: .5; }
.fade-overlay { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 3; transition: opacity .25s linear; }
@media (max-width: 1180px) {
  :root { --sidebar-w: 330px; }
  .playlist-item { grid-template-columns: 18px 72px minmax(0,1fr) auto; }
  .playlist-thumb { width: 72px; height: 54px; }
  .library-card { grid-template-columns: 88px 1fr auto; }
  .library-thumb { width: 88px; height: 62px; }
  .work-header { align-items: flex-start; }
}
