:root {
  --bg: #0f0f14;
  --surface: #17171f;
  --surface-2: #1f1f2a;
  --surface-3: #2a2a38;
  --border: #2a2a36;
  --text: #ececf1;
  --muted: #8d8da0;
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --danger: #f87171;
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
svg { width: 18px; height: 18px; flex: none; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  min-width: 0;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: #343445; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #7c4dee; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger:hover { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  color: var(--muted);
  background: transparent;
  border: 0; border-radius: 50%;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.active { color: var(--accent-2); }
.icon-btn.big { width: 48px; height: 48px; }
.icon-btn.big svg { width: 22px; height: 22px; }
.icon-btn.primary { background: var(--accent); color: #fff; }
.icon-btn.primary:hover { background: #7c4dee; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--danger); }
.badge {
  position: absolute; right: 2px; bottom: 2px;
  font-size: 9px; font-weight: 700; line-height: 1;
  background: var(--accent); color: #fff;
  border-radius: 6px; padding: 2px 3px;
}
.badge:empty { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.head-actions { display: flex; gap: 2px; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* ---------- üst bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
  background: rgba(15, 15, 20, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; min-width: 0; }
.brand .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand.big { font-size: 24px; justify-content: center; margin-bottom: 8px; }
.logo {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #ec4899);
  color: #fff;
}
.logo svg { width: 18px; height: 18px; }
.voice { display: flex; align-items: center; gap: 8px; min-width: 0; }
.voice select { max-width: 240px; padding: 7px 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .2); }
.dot.warn { background: var(--warn); }

/* ---------- düzen ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}
.col-main, .col-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-side .card { position: sticky; top: 76px; }

/* ---------- şimdi çalıyor ---------- */
.now {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  grid-template-areas: "art info" "controls controls";
  gap: 16px 20px;
  background: linear-gradient(160deg, #1d1a2e, var(--surface) 60%);
}
.art {
  grid-area: art;
  width: 128px; height: 128px;
  border-radius: 12px;
  background: var(--surface-2) center/cover no-repeat;
  display: grid; place-items: center;
  color: var(--muted);
  overflow: hidden;
}
.art svg { width: 44px; height: 44px; }
.art.live svg { color: var(--accent-2); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.now-info { grid-area: info; display: flex; flex-direction: column; justify-content: center; min-width: 0; gap: 4px; }
.now-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-2); font-weight: 600; }
.now-label.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-right: 6px; vertical-align: 1px; }
.now-title {
  font-size: 19px; font-weight: 700; text-decoration: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.now-title[href]:hover { text-decoration: underline; }
.now-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-sub b { color: var(--text); font-weight: 500; }
.progress { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ec4899); border-radius: 3px; transition: width .5s linear; }
.progress.live .bar { background: repeating-linear-gradient(90deg, var(--surface-3) 0 6px, transparent 6px 10px); }
.progress.live .fill { display: none; }
.controls { grid-area: controls; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.volume { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.volume span { width: 26px; text-align: right; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 140px; height: 5px; padding: 0; border: 0; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--surface-3) var(--p, 50%));
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }

/* ---------- ekleme ---------- */
.add { display: flex; gap: 8px; flex-wrap: wrap; }
.add input { flex: 1 1 300px; }
.add-buttons { display: flex; gap: 8px; }
.toggle { display: flex; align-items: center; gap: 10px; flex-basis: 100%; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; flex: none; width: 34px; height: 20px; border-radius: 10px; background: var(--surface-3); transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(14px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.toggle:has(input:checked) { color: var(--text); }
.add.loading { opacity: .6; pointer-events: none; }

/* ---------- listeler ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px; border-radius: 10px;
  transition: background .12s;
}
.item:hover { background: var(--surface-2); }
.item .num { width: 22px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.thumb {
  width: 44px; height: 44px; border-radius: 8px; flex: none;
  background: var(--surface-3) center/cover no-repeat;
  display: grid; place-items: center; color: var(--muted);
}
.thumb svg { width: 18px; height: 18px; }
.meta { flex: 1; min-width: 0; }
.meta .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.meta .s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 0; opacity: .0; transition: opacity .12s; }
.item:hover .actions, .item:focus-within .actions { opacity: 1; }
#queue { max-height: min(70vh, 640px); overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; font-size: 13px; }

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 11px; margin-bottom: 14px; }
.tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; color: var(--muted);
  background: transparent; border: 0; border-radius: 8px;
  padding: 8px; cursor: pointer;
}
.tab svg { width: 16px; height: 16px; }
.tab.active { background: var(--surface-3); color: var(--text); }
.tab-panel { display: flex; flex-direction: column; gap: 12px; }
.tab-panel .list { max-height: calc(100vh - 330px); overflow-y: auto; margin: 0 -8px; padding: 0 8px; }

.station.playing .thumb { background: var(--accent-soft); color: var(--accent-2); }
.station.playing .meta .t { color: var(--accent-2); }

.pl { flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
.pl:hover { background: transparent; }
.pl-head { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; }
.pl-head:hover { background: var(--surface-2); }
.pl-head .chev { color: var(--muted); transition: transform .15s; }
.pl.open .pl-head .chev { transform: rotate(90deg); }
.pl-head:hover .actions { opacity: 1; }
.pl-body { display: none; padding: 4px 0 10px 18px; }
.pl.open .pl-body { display: block; }
.pl-body .row { margin: 6px 0 6px 8px; }
.pl-body input { padding: 7px 10px; font-size: 13px; }
.pl-body .item { padding: 5px 8px; gap: 8px; }
.pl-body .meta .t { font-weight: 400; font-size: 13px; }
.pl-body .num { width: 18px; }

/* ---------- giriş ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; padding: 28px; }
.error-text { color: var(--danger); margin: 0; min-height: 1.2em; font-size: 13px; text-align: center; }

/* ---------- bildirimler ---------- */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 20; width: min(440px, calc(100% - 32px)); }
.toast {
  background: var(--surface-3); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
  animation: toast-in .2s ease-out;
}
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- mobil ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .col-side .card { position: static; }
  .tab-panel .list { max-height: none; }
}
@media (max-width: 600px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .brand .muted { display: none; }
  .voice { flex: 1; justify-content: flex-end; }
  .voice select { flex: 1; max-width: none; }
  .layout { padding: 12px 16px; gap: 12px; }
  .now { grid-template-columns: 84px minmax(0, 1fr); gap: 14px; }
  .art { width: 84px; height: 84px; }
  .now-title { font-size: 16px; }
  .volume { margin-left: 0; flex: 1 1 100%; }
  .volume input { flex: 1; }
  .add-buttons { flex: 1; }
  .add-buttons .btn { flex: 1; padding: 9px 8px; }
  .hide-sm { display: none; }
  .actions { opacity: 1; }
  .item .num { display: none; }
  #queue [data-q="up"], #queue [data-q="down"] { display: none; }
}

/* ---------- hesap / kullanıcılar ---------- */
.user-btn { max-width: 160px; }
.user-btn span { overflow: hidden; text-overflow: ellipsis; }
.modal {
  width: min(460px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.modal::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
.modal-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal h3 { font-size: 13px; margin: 0; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.modal .section { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.modal .row > select { flex: none; }
.small-text { font-size: 13px; margin: 0; }
.role { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.role.admin { background: var(--accent-soft); color: var(--accent-2); }
#users .item { padding: 6px 8px; }
#users .actions { opacity: 1; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; }
.hist { cursor: pointer; }
.hist.playing .meta .t { color: var(--accent-2); }
.hist.playing .thumb:not([style]) { background: var(--accent-soft); color: var(--accent-2); }
#cookies-text { resize: vertical; min-height: 70px; font: 12px/1.4 ui-monospace, Consolas, monospace; }
.cookie-status { display: flex; flex-direction: column; gap: 3px; font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.cookie-status .head { font-weight: 600; display: flex; align-items: center; gap: 7px; }
.cookie-status .head::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.cookie-status.ok .head::before { background: var(--ok); }
.cookie-status.warn .head::before { background: var(--warn); }
.cookie-status.bad .head::before { background: var(--danger); }
.cookie-status .s { color: var(--muted); overflow-wrap: anywhere; }
.cookie-help summary { cursor: pointer; }
.cookie-help ol { margin: 8px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.cookie-help code { font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; color: var(--text); }
