:root {
  --bg: #0b0b0f;
  --card: #17171c;
  --card-light: #212128;
  --text: #ffffff;
  --muted: #9a9aa6;
  --accent: #ffdb4d;
  --ok: #5fd97b;
  --err: #ff6b6b;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
  user-select: none;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 372px 1fr;
  grid-template-rows: 1fr auto auto auto;
  gap: 14px;
  height: 100vh;
  padding: 14px;
}

.muted {
  color: var(--muted);
}

.small-text {
  font-size: 12px;
}

.hidden {
  display: none !important;
}

/* --- левая колонка --- */

.sidebar {
  grid-row: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #141418;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

textarea,
input[type="text"],
input[type="password"] {
  width: 100%;
  background: var(--card-light);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  resize: none;
  user-select: text;
}

textarea:focus,
input:focus {
  outline: none;
  border-color: #3a3a45;
}

textarea::placeholder,
input::placeholder {
  color: #63636e;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

button.accent {
  background: var(--accent);
  color: #141418;
}

button.accent:hover {
  background: #ffe87a;
}

button.ghost {
  background: var(--card-light);
  color: var(--text);
  font-weight: 500;
}

button.ghost:hover {
  background: #2c2c35;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button.small {
  padding: 6px 10px;
  font-size: 12px;
}

.row {
  display: flex;
  gap: 8px;
}

.row.wrap {
  flex-wrap: wrap;
}

.row.end {
  justify-content: flex-end;
  margin-top: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 6px;
}

.queue {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.qitem {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.qitem:hover {
  background: #1e1e24;
}

.qitem.selected {
  background: var(--card-light);
}

.qmeta {
  min-width: 0;
}

.qitem img {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--card-light);
}

.qtitle {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qsub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qbar {
  height: 3px;
  border-radius: 2px;
  background: #2c2c35;
  margin-top: 6px;
  overflow: hidden;
}

.qbar > div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s;
}

.qstatus {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  justify-self: end;
}

.qitem.running .qstatus {
  color: var(--accent);
}

.qitem.done .qstatus {
  color: var(--ok);
}

.qitem.error .qstatus {
  color: var(--err);
}

/* --- правая часть --- */

.content {
  grid-row: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}

.detail {
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 20px;
  align-items: start;
}

.cover {
  width: 232px;
  height: 232px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--card-light);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.detail-meta h1 {
  margin: 4px 0 6px;
  font-size: 30px;
  line-height: 1.15;
}

.detail-meta p {
  margin: 0 0 14px;
}

.progress {
  height: 6px;
  border-radius: 3px;
  background: var(--card-light);
  overflow: hidden;
}

.progress > div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s;
}

.tracks {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #131318;
  border-radius: var(--radius);
  overflow: hidden;
}

.tracks-head,
.track-list li {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: center;
  padding: 0 14px;
}

.tracks-head {
  height: 34px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid #22222a;
}

.col-num {
  text-align: right;
  padding-right: 12px;
}

.col-mark {
  text-align: center;
}

.track-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  flex: 1;
}

.track-list li {
  height: 34px;
  border-radius: 8px;
}

.track-list li:hover {
  background: #1c1c22;
}

.track-list li .num {
  text-align: right;
  padding-right: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.track-list li .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-list li .mark {
  text-align: center;
  color: var(--muted);
}

.track-list li.done .name {
  color: var(--ok);
}

.track-list li.done .mark {
  color: var(--ok);
}

.track-list li.skipped .mark {
  color: var(--muted);
}

.track-list li.empty {
  display: block;
  padding: 18px 14px;
  color: var(--muted);
  height: auto;
}

/* --- нижняя панель --- */

.bar {
  grid-column: 1 / -1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dir {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 260px;
}

.flags {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.flags label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.flags input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.statusbar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.log {
  grid-column: 1 / -1;
  margin: 0;
  max-height: 190px;
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--muted);
  font: 12px/1.5 Consolas, monospace;
  white-space: pre-wrap;
  user-select: text;
}

/* --- окно токена --- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
}

.modal-card {
  width: 420px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
}

.modal-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal-card input {
  margin-top: 14px;
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #2c2c35;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a3a45;
}

/* --- только для веб-версии --- */

.error {
  color: var(--err);
  margin: 10px 0 0;
  min-height: 16px;
}

.spacer {
  flex: 1;
}

.button-like {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  color: #141418;
  background: var(--accent);
}

.button-like:hover {
  background: #ffe87a;
}

#result-row {
  margin-top: 14px;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    height: auto;
    min-height: 100vh;
  }
  body {
    overflow: auto;
  }
  .detail {
    grid-template-columns: 1fr;
  }
  .cover {
    width: 180px;
    height: 180px;
  }
}
