:root {
  --bg: #000000;
  --surface: #0f0f0f;
  --surface-2: #1c1c1c;
  --surface-3: #272727;
  --border: #272727;
  --text: #f1f1f1;
  --text-2: #aaaaaa;
  --text-3: #717171;
  --link: #3ea6ff;
  --red: #ff0033;
  --green: #2ba640;
  --radius: 12px;
  --maxw: 1280px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Roboto, -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.conn {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.conn-name {
  color: var(--text);
  font-weight: 500;
}

.conn-tag {
  font-size: 11px;
  color: var(--text-3);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.on {
  background: var(--green);
}
.dot.off {
  background: var(--text-3);
}

/* Layout */
main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 8px 15px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text);
  transition: background 0.12s, opacity 0.12s;
}
.btn:hover {
  background: var(--surface-3);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn.solid {
  background: var(--text);
  color: #0f0f0f;
}
.btn.solid:hover {
  background: #d6d6d6;
}
.btn.ghost {
  background: transparent;
  border-color: var(--border);
}
.btn.ghost:hover {
  background: var(--surface-2);
}
.btn.red {
  background: transparent;
  border-color: #5a1f27;
  color: #ff6b81;
}
.btn.red:hover {
  background: rgba(255, 0, 51, 0.12);
}
.btn.sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 16px;
}

.iconbtn {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: inline-flex;
}
.iconbtn:hover {
  background: var(--surface-2);
}

/* Playlist head */
.plhead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.plhead-info h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.plmeta {
  margin-top: 6px;
  color: var(--text-2);
  font-size: 13px;
}
.plhead-actions {
  display: flex;
  gap: 8px;
}

.status {
  min-height: 20px;
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--text-2);
}
.status.ok {
  color: var(--green);
}
.status.err {
  color: #ff6b81;
}

.notice {
  background: rgba(255, 0, 51, 0.1);
  border: 1px solid #5a1f27;
  color: #ff9aa8;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 13px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover {
  background: var(--surface-3);
}
.tab.active {
  background: var(--text);
  color: #0f0f0f;
}
.cnt {
  margin-left: 6px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* Toolbar */
.toolbar {
  margin-bottom: 16px;
}
.toolbar:empty {
  margin: 0;
}
.search {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 16px;
  font-family: inherit;
}
.search:focus {
  outline: none;
  border-color: #3f3f3f;
}
.toolbar-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
}

/* Card grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px 14px;
}

.card {
  display: flex;
  flex-direction: column;
  color: var(--text);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb img.broken {
  opacity: 0;
}

.chip-dur {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 5px;
}

.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  color: #fff;
}
.badge.del {
  background: var(--red);
}
.badge.priv {
  background: #8a6d1a;
}
.badge.rem {
  background: #444;
}
.tag-arch {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text-2);
}

.card-body {
  padding: 10px 2px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.card-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-title.muted {
  color: var(--text-3);
  font-weight: 400;
}
.card-sub {
  font-size: 12px;
  color: var(--text-2);
}
.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.empty {
  color: var(--text-2);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
}

/* Pending rows */
.prow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--surface);
}
.prow img {
  width: 120px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: #000;
}
.prow img.broken {
  opacity: 0;
}
.prow-info {
  flex: 1;
  min-width: 0;
}
.prow-old {
  color: var(--text-3);
  font-size: 13px;
}
.prow-old s {
  color: var(--text-2);
}
.prow-new {
  margin-top: 3px;
  font-size: 13px;
}
.prow-wait {
  font-size: 12px;
  color: var(--text-3);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sheet {
  width: 100%;
  max-width: 680px;
  max-height: 86vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.sheet-title {
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-body {
  padding: 12px 18px 18px;
  overflow-y: auto;
}
.sheet-sub {
  color: var(--text-2);
  font-size: 13px;
  margin: 4px 0 14px;
}

.alt {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.alt:last-child {
  border-bottom: none;
}
.alt img {
  width: 140px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: #000;
}
.alt-info {
  flex: 1;
  min-width: 0;
}
.alt-name {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.alt-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 3px;
}
.dur-good {
  color: var(--green);
  font-weight: 500;
}
.dur-off {
  color: var(--text-2);
}
.alt-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.spinner {
  padding: 40px 0;
  text-align: center;
  color: var(--text-2);
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  main,
  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .alt img {
    width: 104px;
  }
  .prow img {
    width: 92px;
  }
}
