/*
 * Komponentit ja sovelluksen kuori. Käyttää vain tokens.css:n muuttujia: ulkoasu vaihtuu teemalla.
 * Rakenne: perusta → kuori (sivupalkki, yläpalkki, soitin) → yleiset komponentit → sivukohtaiset osat.
 */

/* ---------- perusta ---------- */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font: var(--font-size)/1.45 var(--font); color: var(--text);
  background: var(--bg-image), var(--bg); background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
a { color: var(--accent-text); }
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: var(--font-num); }
.icon { width: 1.25em; height: 1.25em; flex: none; display: inline-block; vertical-align: middle; }

/* ---------- kuori ---------- */
.shell {
  display: grid; height: 100vh;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  grid-template-rows: var(--top-h) minmax(0, 1fr) auto;
  grid-template-areas: "side top" "side main" "player player";
}
.shell.no-player { grid-template-rows: var(--top-h) minmax(0, 1fr) 0; }

.side {
  grid-area: side; display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; min-height: 0; overflow: auto;
  background: var(--side-art) no-repeat, var(--surface-side); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; margin-bottom: 8px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.brand .logo { width: 40px; height: 40px; color: var(--spotify); flex: none; }
.brand > span { min-width: 0; }
.brand b { display: block; font-size: 1.45rem; line-height: 1.1; letter-spacing: -.02em; }
.brand small { display: block; font-size: .7rem; color: var(--text-2); white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius);
  color: var(--text-2); text-decoration: none; font-size: 1rem; font-weight: 500; position: relative; white-space: nowrap;
}
.nav-item .icon { width: 22px; height: 22px; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.on { background: var(--accent-grad); color: var(--accent-ink); box-shadow: var(--glow); }
.nav-item.on .badge { background: #ffffff33; color: var(--accent-ink); }
.nav-item.off { opacity: .45; cursor: default; }
.nav-item.off:hover { background: none; color: var(--text-2); }
.nav-item .badge { margin-left: auto; }
.nav-item > span:not(.badge) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.side-foot { margin-top: auto; padding: 12px 8px 0; font-size: .75rem; color: var(--faint); }
.side-foot a { color: var(--muted); }

.top { grid-area: top; display: flex; align-items: center; gap: 18px; padding: 0 24px; border-bottom: 1px solid var(--line); min-width: 0; }
.search {
  flex: 0 1 720px; margin: 0 auto; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px 0 16px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
}
.search:focus-within { border-color: var(--accent-line); box-shadow: var(--glow); }
.search .icon { color: var(--text-2); width: 22px; height: 22px; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 1.05rem; color: var(--text); }
.search input::placeholder { color: var(--text-2); }
kbd { font: 600 .78rem var(--font); padding: 2px 7px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line-strong); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  appearance: none; background: none; border: 0; padding: 6px; border-radius: var(--radius); color: var(--text-2);
  cursor: pointer; position: relative; display: inline-grid; place-items: center;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn .icon { width: 26px; height: 26px; }
.icon-btn .dot { position: absolute; top: 5px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent-2); }
.user { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-pill); color: var(--text); font-weight: 600; font-size: 1.02rem; }
.user:hover { background: var(--surface-hover); }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--accent-grad); display: inline-grid; place-items: center; color: var(--accent-ink); font-weight: 700; }

.main { grid-area: main; overflow: auto; min-width: 0; scrollbar-gutter: stable; }

/* Soitinpalkki */
.player {
  grid-area: player; height: var(--player-h); display: grid; grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center; gap: 24px; padding: 0 28px 0 36px; background: var(--surface-side); border-top: 1px solid var(--line);
}
.player .now { display: flex; align-items: center; gap: 16px; min-width: 0; }
.player .cover { width: 64px; height: 64px; border-radius: var(--radius-sm); background: var(--surface-3); display: grid; place-items: center; color: var(--faint); }
.player .now b { display: block; font-size: 1.1rem; }
.player .now span { color: var(--muted); }
.player .controls { display: flex; align-items: center; gap: 16px; }
.player .play { width: 54px; height: 54px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; border: 0; }
.player .play:disabled { opacity: .55; }
.player .track { display: flex; align-items: center; gap: 16px; color: var(--muted); }
.progress { flex: 1; height: 4px; border-radius: 4px; background: var(--surface-3); position: relative; min-width: 120px; }
.progress i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--accent-grad); }

/* ---------- sivun runko ---------- */
.page { padding: 22px 24px 28px; display: grid; gap: 18px; align-content: start; min-width: 0; }
.page-split { display: grid; grid-template-columns: minmax(0, 1fr) var(--aside-w); min-height: 100%; }
.page-aside { border-left: 1px solid var(--line); padding: 18px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; min-width: 0; }
.page-head { display: grid; grid-template-columns: auto 1fr; gap: 2px 18px; align-items: center; }
.page-head > .icon { grid-row: span 2; width: 48px; height: 48px; color: var(--accent-2); }
.page-head h1 { font-size: 2.15rem; display: flex; align-items: center; gap: 16px; }
.page-head p { margin: 0; color: var(--text-2); font-size: 1.08rem; }
.section-title { font-size: 1.3rem; font-weight: 700; margin: 2px 0 -4px; }

/* ---------- yleiset komponentit ---------- */
.badge {
  display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 8px; border-radius: var(--radius-pill);
  background: var(--accent); color: var(--accent-ink); font-size: .8rem; font-weight: 700; font-variant-numeric: var(--font-num);
}
.badge.lg { height: 30px; padding: 0 14px; font-size: 1rem; font-weight: 600; background: var(--accent-grad); }
.badge.soft { background: var(--accent-soft); color: var(--accent-text); }

.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 9px; height: 38px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none; font-weight: 500;
}
.btn:hover:not(:disabled) { border-color: var(--accent-line); background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: default; }
.btn .icon { width: 20px; height: 20px; }
.btn .caret { width: 16px; height: 16px; margin-left: -2px; opacity: .8; }
.btn.primary { background: var(--accent-grad); border-color: transparent; color: var(--accent-ink); box-shadow: var(--glow); }
.btn.outline { background: transparent; border-color: var(--accent-line); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-hover); }
.btn.sm { height: 32px; padding: 0 10px; font-size: .9rem; }
.btn.block { width: 100%; justify-content: flex-start; }
.btn.danger { color: var(--bad); }
.link { appearance: none; background: none; border: 0; padding: 0; color: var(--accent-text); cursor: pointer; font-size: .95rem; }
.link .icon { width: 16px; height: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.card-pad { padding: var(--pad); }

/* Välilehdet (isot napit sivun yläosassa) */
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; }
.tab {
  appearance: none; display: flex; align-items: center; justify-content: center; gap: 12px; height: 46px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-size: 1.05rem; cursor: pointer; white-space: nowrap;
}
.tab .icon { width: 22px; height: 22px; color: var(--text-2); }
.tab:hover:not(:disabled) { border-color: var(--accent-line); }
.tab.on { background: var(--accent-grad); border-color: transparent; color: var(--accent-ink); box-shadow: var(--glow); }
.tab.on .icon { color: var(--accent-ink); }
.tab:disabled { opacity: .45; cursor: default; }

/* Jonokortit */
.queues { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.queue {
  appearance: none; position: relative; text-align: left; display: grid; align-content: start; gap: 2px; min-height: 94px;
  padding: 14px 16px; border-radius: var(--radius-lg); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); cursor: pointer;
}
.queue:hover { border-color: var(--accent-line); }
.queue .icon { width: 26px; height: 26px; color: var(--text); margin-bottom: 6px; }
.queue .badge { position: absolute; top: 14px; right: 14px; }
.queue b { font-size: 1rem; font-weight: 600; line-height: 1.25; }
.queue small { color: var(--text-2); font-size: .85rem; }
.queue.on { border-color: var(--accent-2); background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface); box-shadow: var(--glow); }
.queue.add { place-items: center; align-content: center; text-align: center; color: var(--text-2); }
.queue.add .icon { margin: 0; }
.queue .x { position: absolute; bottom: 8px; right: 10px; opacity: 0; color: var(--muted); }
.queue:hover .x { opacity: 1; }
.queue .x:hover { color: var(--bad); }

/* Pudotusvalikko (natiivi select tyyliteltynä) */
.select { position: relative; display: inline-flex; max-width: 100%; align-items: center; gap: 8px; height: 38px; padding: 0 34px 0 12px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface-2); min-width: 0; }
.select:hover { border-color: var(--accent-line); }
.select > .icon { width: 18px; height: 18px; }
.select > .caret { position: absolute; right: 10px; width: 16px; height: 16px; pointer-events: none; color: var(--text-2); }
.select select { appearance: none; background: none; border: 0; outline: 0; padding: 0; min-width: 0; cursor: pointer; color: var(--text); font-weight: 500; text-overflow: ellipsis; }
.select select option { background: var(--surface-2); color: var(--text); }
.select .pre { color: var(--text-2); white-space: nowrap; }
.select.plain { border-color: transparent; background: transparent; }
.select.block { display: flex; width: 100%; }
.select.block select { flex: 1; width: 100%; }
.select select { max-width: 100%; }

/* Valintaruutu */
.check { appearance: none; width: 20px; height: 20px; margin: 0; flex: none; border-radius: 5px; border: 1.5px solid var(--muted);
  background: transparent; display: inline-grid; place-items: center; cursor: pointer; vertical-align: middle; }
.check:checked, .check:indeterminate { background: var(--spotify); border-color: var(--spotify); }
.check.accent:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: ""; width: 10px; height: 5px; border: 2px solid #06140b; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check.accent:checked::after { border-color: var(--accent-ink); }
.check:indeterminate::after { content: ""; width: 10px; height: 2px; background: #06140b; }
.radio { border-radius: 50%; }
.radio:checked::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--accent-ink); transform: none; }

/* Sirut: tägit ja alkuperä */
.chip {
  --c: var(--tag-1);
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--radius-sm); font-size: .82rem; white-space: nowrap;
  background: color-mix(in srgb, var(--c) var(--chip-bg-mix), transparent);
  border: 1px solid color-mix(in srgb, var(--c) 70%, transparent);
  color: color-mix(in srgb, var(--c) 45%, var(--chip-ink));
}
.chip.core { --c: var(--faint); border-style: dashed; color: var(--text-2); background: transparent; }
.chip.more { --c: var(--faint); background: transparent; color: var(--muted); }
/* Rivitys + kiinteä korkeus: sirut, jotka eivät mahdu, siirtyvät piiloon toiselle riville (ei puolikkaita) */
.chips { display: flex; flex-wrap: wrap; gap: 4px; height: 24px; overflow: hidden; }
.origin { display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 100%; }
.icon.brand-spotify, .origin .icon { color: var(--spotify); width: 20px; height: 20px; }
.origin span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.origin em { font-style: normal; color: var(--muted); font-size: .82rem; }

/* Tähdet */
.stars { display: inline-flex; gap: 1px; white-space: nowrap; }
.stars > * { appearance: none; background: none; border: 0; padding: 0; color: var(--star-off); line-height: 0; }
.stars > .on { color: var(--star); }
.stars button { cursor: pointer; }
.stars .icon { width: 18px; height: 18px; }
/* Hover-esikatselu: tähdet hiiren kohtaan asti */
.stars:not(.ro):hover > * { color: var(--star); }
.stars:not(.ro) > :hover ~ * { color: var(--star-off); }

/* Taulukko */
.table { width: 100%; border-collapse: collapse; }
.table.fixed { table-layout: fixed; min-width: 900px; }
.table.fixed td { overflow: hidden; text-overflow: ellipsis; }
.table th { text-align: left; font-weight: 500; color: var(--text-2); font-size: .95rem; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th .icon { width: 14px; height: 14px; opacity: .7; }
.table th button.sort { appearance: none; background: none; border: 0; padding: 0; cursor: pointer; color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th button.sort.on { color: var(--text); }
.table td { padding: 0 8px; height: var(--row-h); border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.selected { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.table td.clip { max-width: 0; overflow: hidden; text-overflow: ellipsis; }
.table .w-check { width: 40px; }
.table .w-num { width: 36px; color: var(--text-2); }
.table .title { display: flex; align-items: center; gap: 12px; min-width: 0; font-weight: 600; }
.table .title span { overflow: hidden; text-overflow: ellipsis; }
.thumb { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; background: var(--surface-3); flex: none; }
.thumb.empty { display: inline-grid; place-items: center; color: var(--faint); }
.liked { color: var(--heart); width: 15px; height: 15px; }

/* Paneeli taulukolle */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 16px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h3 { font-size: 1.2rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.panel-head h3 .icon { color: var(--accent-2); width: 24px; height: 24px; }
.panel-head .spacer { flex: 1; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px 4px; }
.panel-body { padding: 0 6px; overflow-x: auto; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* Sivutus */
.pager { display: flex; align-items: center; gap: 6px; }
.pager button { appearance: none; display: inline-grid; place-items: center; min-width: 34px; height: 32px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid transparent; background: none; cursor: pointer; color: var(--text); font-variant-numeric: var(--font-num); }
.pager button:hover:not(:disabled) { background: var(--surface-hover); }
.pager button.on { background: var(--accent-grad); color: var(--accent-ink); }
.pager button.nav { border-color: var(--line-strong); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .gap { color: var(--muted); padding: 0 4px; }

/* Suodatinpaneeli */
.aside-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 6px; }
.aside-head h2 { font-size: 1.35rem; font-weight: 700; flex: 1; display: flex; align-items: center; gap: 12px; }
.aside-head .icon { width: 24px; height: 24px; }
.fgroup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 6px 12px; }
.fsec + .fsec { border-top: 1px solid var(--line); }
.fsec > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 9px 2px; cursor: pointer; font-weight: 600; font-size: 1.05rem; }
.fsec > summary::-webkit-details-marker { display: none; }
.fsec > summary .icon { width: 18px; height: 18px; transition: transform .15s; color: var(--text-2); }
.fsec[open] > summary .icon { transform: rotate(180deg); }
.fsec .fbody { padding: 0 2px 10px; display: grid; gap: 6px; }
.fsec .flabel { font-weight: 600; font-size: 1.02rem; padding: 6px 2px 2px; }
.opt { display: flex; align-items: center; gap: 12px; font-size: .95rem; color: var(--text); cursor: pointer; }
.opt .n { color: var(--text-2); }
.opt .stars { pointer-events: none; }
.empty-note { color: var(--muted); font-size: .9rem; }
.tools { display: grid; gap: 10px; }
.tools .btn { height: 40px; }

/* Ponnahdusvalikot */
.pop {
  position: fixed; z-index: 50; min-width: 220px; max-width: 340px; max-height: 60vh; overflow: auto; padding: 6px;
  background: var(--overlay); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.pop .mi { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); background: none; border: 0; text-align: left; cursor: pointer; color: var(--text); white-space: nowrap; }
.pop .mi:hover:not(:disabled), .pop .mi.active { background: var(--surface-hover); }
.pop .mi:disabled { opacity: .4; cursor: default; }
.pop .mi .icon { width: 18px; height: 18px; color: var(--text-2); }
.pop .mi .n { margin-left: auto; color: var(--muted); font-size: .85rem; }
.pop .mi.danger { color: var(--bad); }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.pop .pop-title { padding: 6px 10px 4px; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.pop input.field { width: 100%; margin: 2px 0 6px; }

.field { height: 38px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); outline: 0; }
.field:focus { border-color: var(--accent-line); }

/* Ilmoitukset */
.toasts { position: fixed; bottom: calc(var(--player-h) + 16px); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--overlay); border: 1px solid var(--line-strong); padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.toast.ok { border-color: var(--ok); }
.toast.bad { border-color: var(--bad); }

/* Etusivu ja asetukset */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat small { color: var(--text-2); }
.stat b { display: block; font-size: 1.7rem; font-variant-numeric: var(--font-num); }
.msg { padding: 10px 12px; border-radius: var(--radius); background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.theme-card { appearance: none; text-align: left; cursor: pointer; padding: 14px; display: grid; gap: 6px; border-radius: var(--radius-lg); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); }
.theme-card.on { border-color: var(--accent-2); box-shadow: var(--glow); }
.theme-card small { color: var(--muted); }

/* ---------- kapeat näytöt ---------- */
@media (max-width: 1400px) {
  :root { --aside-w: 260px; --side-w: 230px; }
  .tab { font-size: .95rem; gap: 8px; }
  .col-album { display: none; }
}
@media (max-width: 1180px) {
  .page-split { grid-template-columns: minmax(0, 1fr); }
  .page-aside { border-left: 0; border-top: 1px solid var(--line); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .col-origin { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto var(--top-h) minmax(0, 1fr) auto; grid-template-areas: "side" "top" "main" "player"; }
  .side { flex-direction: row; overflow-x: auto; padding: 8px; }
  .brand small, .side-foot, .nav-sep, .side .nav-item span:not(.badge) { display: none; }
  .nav { flex-direction: row; }
  .tabs { grid-auto-flow: row; }
  .player { display: none; }
}

/* ======================= Näkymät: ruudukot, sankarit, etusivu ======================= */
.spacer { flex: 1; }
.view { display: grid; gap: 14px; align-content: start; min-width: 0; }
.page-split.single { grid-template-columns: minmax(0, 1fr); }
.small { font-size: .85rem; }
a.plain { color: inherit; text-decoration: none; }
a.plain:hover { text-decoration: underline; }
.flip { transform: scaleX(-1); }
.unliked { color: var(--faint); }
.w-heart { text-align: center; }
.w-heart .icon { width: 16px; height: 16px; }
.table.selectable tbody { user-select: none; }
.chips.wrap { flex-wrap: wrap; height: auto; overflow: visible; }

/* Kansikuvat */
.cover { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); background: var(--surface-3); }
.cover.ph { display: grid; place-items: center; color: color-mix(in srgb, var(--c) 70%, var(--text));
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 45%, var(--surface-3)), var(--surface-3)); }
.cover.ph .icon { width: 34%; height: 34%; opacity: .8; }
.cover.thumb { width: 34px; height: 34px; border-radius: 5px; flex: none; }
.cover.round, .round .cover, .hero-cover.round .cover { border-radius: 50%; }
.cover.big { border-radius: var(--radius-lg); }
.art { display: block; }

/* Esimerkkidata-merkintä */
.mock-badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: var(--radius-pill); font: 600 .7rem var(--font);
  letter-spacing: .03em; text-transform: uppercase; color: var(--mock); background: var(--mock-bg); border: 1px dashed var(--mock); vertical-align: middle; }
[data-placeholder].panel { border-style: dashed; border-color: color-mix(in srgb, var(--mock) 55%, var(--line)); }

/* Työkalurivi ja ruudukko */
.toolbar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { appearance: none; border: 0; background: none; padding: 8px 12px; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--accent-grad); color: var(--accent-ink); }
.seg button:disabled { opacity: .45; cursor: default; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.acard { display: grid; gap: 2px; padding: 8px 8px 6px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  color: var(--text); text-decoration: none; min-width: 0; }
.acard:hover { border-color: var(--accent-line); background: var(--surface-hover); }
.acard .art { margin-bottom: 6px; }
.acard b, .acard small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acard small { color: var(--text-2); }
.acard .meta { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); font-size: .85rem; min-height: 28px; }
.acard .acts { display: inline-flex; align-items: center; gap: 4px; }
.acard .acts .icon { width: 17px; height: 17px; }
.icon-btn.mini { padding: 2px; }
.icon-btn.mini .icon { width: 20px; height: 20px; }
.acard.artist .art { padding: 6px 14px 0; }
.pager-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.fsec-soon { display: flex; justify-content: space-between; align-items: center; padding: 11px 2px; font-weight: 600; font-size: 1.05rem; color: var(--muted); }
.fsec-soon + .fsec, .fsec + .fsec-soon { border-top: 1px solid var(--line); }
.fsec-soon:not(:last-child) { border-bottom: 1px solid var(--line); }

/* Tilastolaatat */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-tile { --hc: var(--accent-2); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  padding: 14px 16px; border-radius: var(--radius-lg); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); text-decoration: none; }
a.stat-tile:hover { border-color: var(--accent-line); }
.stat-tile .icon { grid-area: 1 / 1 / 3 / 2; width: 34px; height: 34px; color: var(--hc); align-self: center; }
.stat-tile b { grid-area: 1 / 2; font-size: 1.7rem; line-height: 1.1; text-align: left; align-self: end; }
.stat-tile small { grid-area: 2 / 2; color: var(--text-2); font-size: 1rem; text-align: left; align-self: start; }
.stat-tile.blue { --hc: var(--tag-1); }
.stat-tile.green { --hc: var(--tag-3); }
.stat-tile.purple { --hc: var(--accent-2); }

/* Murupolku ja sankari */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs .sep .icon { width: 16px; height: 16px; color: var(--muted); }
.hero { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 22px; align-items: center; padding: 20px; border-radius: var(--radius-lg);
  border: 1px solid var(--line); overflow: hidden; background-color: var(--surface); }
.hero::before { content: ""; position: absolute; inset: -30px; background-image: var(--hero-img); background-size: cover; background-position: center; filter: blur(22px) saturate(1.2); opacity: .55; }
.hero::after { content: ""; position: absolute; inset: 0; background: var(--hero-overlay); }
.hero > * { position: relative; z-index: 1; }
.hero-cover { width: 190px; }
.hero.artist .hero-cover { width: 170px; }
.hero-cover .cover { box-shadow: var(--shadow); }
.hero-body { display: grid; gap: 10px; min-width: 0; }
.hero-body h1 { font-size: 2.4rem; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-body .sub { margin: 0; font-size: 1.1rem; color: var(--text-2); }
.hero-stats { display: grid; grid-auto-flow: column; background: var(--overlay); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); backdrop-filter: blur(8px); }
.hero-stats > div { display: grid; justify-items: center; gap: 2px; padding: 14px 20px; min-width: 100px; }
.hero-stats > div + div { border-left: 1px solid var(--line); }
.hero-stats .icon { color: var(--accent-2); width: 26px; height: 26px; }
.hero-stats b { font-size: 1.15rem; }
.hero-stats small { color: var(--text-2); }

/* Paneelit */
.panel.pad { padding: 14px 16px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-title h3, .side-card h3 { font-size: 1.15rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.panel-title h3 .icon, .side-card h3 .icon { color: var(--accent-2); }
.ov { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 14px; align-items: start; }
.ov-left { display: grid; gap: 14px; min-width: 0; }
.ov-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.side-card { padding: 14px 16px; display: grid; gap: 10px; }
.side-card h3 { margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; }

/* Kokoelmat */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ccard { position: relative; display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 14px; padding: 12px; border-radius: var(--radius-lg); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; }
.ccard:hover { border-color: var(--accent-line); }
.ccard.on { border-color: var(--accent-2); box-shadow: var(--glow); }
.ccard .info { display: grid; gap: 3px; align-content: center; min-width: 0; padding-right: 38px; }
.ccard .info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.05rem; }
.ccard .info small { color: var(--text-2); }
.ccard .icon-btn.mini { position: absolute; top: 8px; right: 8px; }
.round-play { position: absolute; right: 12px; bottom: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--spotify); color: #04140a; display: grid; place-items: center; }
.round-play:disabled { opacity: .5; }
.round-play .icon { width: 16px; height: 16px; }
.coll-head { display: grid; grid-template-columns: 90px 1fr; gap: 14px; align-items: center; }
.coll-head h2 { font-size: 1.5rem; }
.coll-head p { margin: 4px 0 0; }
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.facts li { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.facts .icon { color: var(--text); width: 18px; height: 18px; }
.soon-block { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.soon-block h3 { font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.soon-block p { margin: 0; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.mini-stats b { display: block; font-size: 1.15rem; }
.mini-stats small { color: var(--text-2); }

/* Etusivu */
.dash { gap: 14px; }
.dash-hero { padding: 6px 0 2px; background: var(--hero-art); margin: -22px -24px 0; padding: 26px 24px 8px; }
.dash-hero h1 { font-size: 2.4rem; }
.dash-hero p { margin: 4px 0 0; font-size: 1.1rem; color: var(--text-2); }
.dash-grid { display: grid; gap: 14px; grid-template-columns: repeat(10, minmax(0, 1fr)) minmax(280px, 330px); }
.dg-tiles { grid-column: 1 / span 10; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dg-sync { grid-column: 11; }
.dg-chart { grid-column: 1 / span 6; }
.dg-donut { grid-column: 7 / span 4; }
.dg-side { grid-column: 11; grid-row: 2 / span 2; display: grid; gap: 14px; align-content: start; }
.dg-recent { grid-column: 1 / span 5; }
.dg-colls { grid-column: 6 / span 5; }
.sync-card { padding: 16px; display: grid; gap: 8px; background: color-mix(in srgb, var(--spotify) 8%, var(--surface)); border-color: color-mix(in srgb, var(--spotify) 40%, var(--line)); }
.sync-card p { margin: 0; }
.sync-row { display: flex; align-items: center; gap: 14px; }
.sync-row > div { flex: 1; display: grid; gap: 4px; }
.sync-row b { font-size: 1.2rem; }
.icon.big { width: 44px; height: 44px; }
.ok-pill { justify-self: start; padding: 2px 12px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); font-size: .9rem; }
.ok-pill.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.chart { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 16px; align-items: end; }
.bars { display: flex; align-items: end; gap: 4px; height: 150px; border-bottom: 1px solid var(--line); }
.bars i { flex: 1; background: var(--accent-grad); border-radius: 3px 3px 0 0; opacity: .85; }
.chart-side { display: grid; gap: 2px; text-align: center; }
.chart-side b { font-size: 2rem; }
.chart-side small { color: var(--text-2); }
.chart-side .up { color: var(--ok); font-weight: 600; }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.donut span { width: 100px; height: 100px; border-radius: 50%; background: var(--surface); display: grid; place-content: center; text-align: center; }
.donut small { color: var(--text-2); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; flex: 1; min-width: 140px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; }
.legend b { margin-left: auto; font-weight: 500; color: var(--text-2); }
.inbox-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; color: var(--text); }
.inbox-card:hover { border-color: var(--accent-line); }
.inbox-card > div { flex: 1; display: grid; }
.inbox-card b { font-size: 1.2rem; }
.inbox-card small { color: var(--text-2); }
.inbox-card .icon.big { color: var(--accent-2); }
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.quick .btn { justify-content: flex-start; padding: 0 8px; gap: 6px; font-size: .85rem; min-width: 0; }
.quick .btn span { overflow: hidden; text-overflow: ellipsis; }
.quick .btn.spot { border-color: color-mix(in srgb, var(--spotify) 60%, transparent); }
.recent, .colls { display: grid; gap: 12px; }
.recent { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.colls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rtrack, .mini-coll { display: grid; gap: 2px; min-width: 0; text-decoration: none; color: var(--text); }
.rtrack b, .mini-coll b, .rtrack small, .mini-coll small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtrack small, .mini-coll small { color: var(--text-2); }
.rtrack .art, .mini-coll .art { margin-bottom: 4px; }
.mini-coll:hover b { text-decoration: underline; }

@media (max-width: 1400px) {
  .hero-stats > div { min-width: 80px; padding: 12px 14px; }
  .hero-cover { width: 150px; }
  .dash-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .dg-sync, .dg-side { grid-column: 1 / -1; grid-row: auto; }
  .dg-chart { grid-column: 1 / span 6; } .dg-donut { grid-column: 7 / span 4; }
  .dg-recent, .dg-colls { grid-column: 1 / -1; }
}
@media (max-width: 1180px) {
  .ov { grid-template-columns: 1fr; }
  .hero { grid-template-columns: auto minmax(0, 1fr); }
  .hero-stats { grid-column: 1 / -1; }
}
.panel-title { flex-wrap: wrap; }
.panel-title h3, .soon-block h3 { flex-wrap: wrap; }
.mock-badge, .badge.soft { white-space: nowrap; }
.table.fixed th { overflow: hidden; text-overflow: ellipsis; }
