/* ClickBuddy — rozpiska z YouTube. Paleta sceny z aplikacji, kolory fragmentów niosą informację. */

:root {
  --bg: #0E0E12;
  --surface: #17171D;
  --raised: #21212A;
  --line: #30303A;
  --line-strong: #43434F;
  --text: #F2F2F4;
  --dim: #9A9AA7;
  --faint: #6B6B78;
  --amber: #FFB020;
  --cyan: #7FD1FF;
  --red: #FF6B6B;

  --c-intro: #7A86B8;
  --c-verse: #4FA39A;
  --c-chorus: #D9736A;
  --c-bridge: #9A7BD1;
  --c-inst: #7FB069;
  --c-break: #8A8A96;
  --c-outro: #5F6A8A;
  --c-other: #6E6E7C;

  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --radius: 10px;
  --maxw: 1080px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
main { max-width: var(--maxw); margin: 0 auto; padding: 0 24px 120px; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Nagłówek ---------------------------------------------------------------- */
.top {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 24px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  font-family: var(--serif);
  font-size: 26px;
  color: var(--text);
  letter-spacing: 0.005em;
}
.brand:hover { text-decoration: none; }
.brand span { font-family: var(--sans); font-size: 14px; color: var(--dim); margin-left: 10px; }
.mark { width: 28px; height: 28px; border-radius: 22%; vertical-align: -5px; margin-right: 10px; }

/* Przyciski --------------------------------------------------------------- */
.primary {
  background: var(--amber);
  color: #141008;
  border: 0;
  border-radius: var(--radius);
  padding: 0 22px;
  height: 46px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.primary:hover { filter: brightness(1.06); }
.primary:disabled { opacity: 0.5; cursor: default; filter: none; }
.ghost {
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  height: 36px;
}
.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.ghost:disabled { opacity: 0.4; cursor: default; }
.link {
  background: none; border: 0; padding: 0;
  color: var(--cyan);
}
.link:hover { text-decoration: underline; }

/* Wejście ----------------------------------------------------------------- */
.intake { padding: 26px 0 8px; }
.urlbar { display: flex; gap: 10px; }
.urlbar input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
}
.urlbar input::placeholder { color: var(--faint); }
.urlbar input:focus { border-color: var(--line-strong); outline: none; }
.urlbar .file-btn { flex: none; height: 46px; display: inline-flex; align-items: center; gap: 8px; }
.urlbar .file-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* Plik przeciągany nad stroną: pole linku zmienia się w strefę upuszczania. */
.intake.drop .urlbar input { border-color: var(--amber); border-style: dashed; }
.intake.drop .file-btn { color: var(--amber); border-color: var(--amber); }
.hint { color: var(--dim); max-width: 64ch; margin: 12px 0 0; }

.status { margin-top: 18px; }
.status-line { display: flex; justify-content: space-between; gap: 12px; color: var(--text); }
.status-time { color: var(--dim); }
.status.error .status-line { color: var(--red); }
.bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--amber); border-radius: 2px; transition: width 0.4s ease; }
.bar-fill.indeterminate {
  width: 30%;
  animation: slide 1.4s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(340%); }
}
.status.error .bar-fill { background: var(--red); width: 100%; animation: none; }
.status-actions { margin-top: 12px; }

/* Ostatnie ---------------------------------------------------------------- */
.recent { padding: 22px 0 0; }
.recent h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0 0 8px; }
.recent .group { margin-top: 22px; }
.recent .group:first-child { margin-top: 0; }
.recent .count { color: var(--faint); font-family: var(--sans); font-size: 14px; margin-left: 6px; }
.recent .group-empty { margin: 4px 0 0; font-size: 14px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { border-top: 1px solid var(--line); }
.recent-list li:last-child { border-bottom: 1px solid var(--line); }
.recent-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: baseline;
  text-align: left;
  background: none;
  border: 0;
  padding: 12px 4px;
  color: var(--text);
}
.recent-list button:hover { background: var(--surface); }
.recent-list .rt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-list .rs { color: var(--dim); }
.recent-list .rs.error { color: var(--red); }
.recent-list .rd { color: var(--faint); }

/* Piosenka ---------------------------------------------------------------- */
.song { padding-top: 26px; }
.song-head { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.title {
  flex: 1;
  min-width: 240px;
  font-family: var(--serif);
  font-size: 42px;
  line-height: 1.1;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 2px 0;
  color: var(--text);
}
.title:hover { border-bottom-color: var(--line); }
.title:focus { outline: none; border-bottom-color: var(--line-strong); }
.song-meta { color: var(--dim); white-space: nowrap; }
.song-meta b { color: var(--text); font-weight: 500; }
.song-meta i { font-style: normal; display: inline-block; width: 1px; height: 12px; background: var(--line-strong); margin: 0 10px; vertical-align: -1px; }
.song-meta .warn { color: var(--amber); }

.transport { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.play {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--amber);
  background: transparent;
  color: var(--amber);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.play:hover { background: rgba(255, 176, 32, 0.12); }
.play svg { width: 16px; height: 16px; fill: currentColor; }
.time { color: var(--dim); min-width: 38px; }
.time:last-of-type { text-align: right; }
.seek { flex: 1; appearance: none; height: 3px; background: var(--line); border-radius: 2px; margin: 0; }
.seek::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text); }
.seek::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text); }
.source { color: var(--faint); font-size: 14px; }
.source[href]:hover { color: var(--cyan); }
.source:not([href]) { cursor: default; text-decoration: none; }

/* Siatka taktów — bohater strony ---------------------------------------- */
.grid-wrap { position: relative; margin-top: 18px; padding-bottom: 22px; }
.grid { display: flex; gap: 3px; height: 56px; }
.seg {
  position: relative;
  display: flex;
  gap: 1px;
  min-width: 0;
}
.seg-label {
  position: absolute;
  left: 1px; top: calc(100% + 5px);
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  pointer-events: none;
}
.seg.narrow .seg-label { display: none; }
.cell {
  flex: 1 1 0;
  min-width: 3px;
  background: color-mix(in srgb, var(--c) 62%, var(--bg));
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.cell.group { margin-left: 2px; }
.cell:hover { background: color-mix(in srgb, var(--c) 88%, white); }
.cell.now { background: color-mix(in srgb, var(--c) 100%, white 10%); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35); }
.cell.dead { background: repeating-linear-gradient(135deg, var(--raised) 0 3px, var(--surface) 3px 6px); cursor: default; }
.cut {
  position: absolute;
  top: -4px; bottom: -4px;
  width: 9px;
  transform: translateX(-50%);
  cursor: col-resize;
  z-index: 2;
}
.cut::after {
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: var(--text);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.cut:hover::after { opacity: 1; }
/* Uchwyt granicy między fragmentami: kreska w przerwie, w trakcie przeciągania etykieta z podziałem taktów. */
.handle {
  position: absolute;
  top: -6px; bottom: -6px;
  left: 0;
  width: 14px;
  transform: translateX(calc(-50% - 1.5px));
  cursor: ew-resize;
  z-index: 4;
  touch-action: none;
  border-radius: 4px;
}
.handle:focus-visible { outline-offset: -2px; }
.handle::after {
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--text);
  opacity: 0.3;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.handle:hover::after, .handle:focus-visible::after, .handle.hl::after { opacity: 1; }
.handle.dragging::after { background: var(--amber); opacity: 1; box-shadow: 0 0 8px rgba(255, 176, 32, 0.6); }
.handle::before {
  content: attr(data-tip);
  position: absolute;
  left: 50%; bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.handle.dragging::before, .handle:focus-visible::before { opacity: 1; }
.grid.dragging { cursor: ew-resize; user-select: none; }
.grid.dragging .cell { cursor: ew-resize; }
.playhead {
  position: absolute;
  top: -6px;
  height: 68px;
  width: 2px;
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255, 176, 32, 0.7);
  pointer-events: none;
  z-index: 3;
}
.playhead::before {
  content: "";
  position: absolute;
  top: -3px; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top: 6px solid var(--amber);
}
.grid-hint { color: var(--faint); font-size: 13px; max-width: 72ch; margin: 22px 0 0; }

/* Propozycja Claude ------------------------------------------------------- */
.ai-cta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 22px; color: var(--faint); font-size: 14px; }
.ai-cta .ghost { color: var(--text); border-color: var(--line-strong); }
.proposal { margin-top: 26px; padding: 18px 20px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.proposal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.proposal h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0; }
.proposal-state { color: var(--dim); font-size: 14px; }
.proposal-state.working::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber); margin-right: 8px; vertical-align: 1px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.proposal-state.error { color: var(--red); }
.proposal-summary { color: var(--text); max-width: 78ch; margin: 10px 0 0; }
.proposal-grid { height: 30px; margin-top: 14px; padding-bottom: 20px; position: relative; }
.proposal-grid .seg-label { top: calc(100% + 4px); }
.proposal-grid .cell { cursor: default; }
.proposal-grid .cell:hover { background: color-mix(in srgb, var(--c) 62%, var(--bg)); }
.proposal-grid .seg.changed .cell { box-shadow: inset 0 -2px 0 var(--amber); }
.proposal-notes { list-style: none; margin: 14px 0 0; padding: 0; color: var(--dim); font-size: 14px; }
.proposal-notes li { padding: 3px 0; }
.proposal-notes b { color: var(--text); font-weight: 500; }
.proposal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.proposal-actions .primary { height: 38px; }
.lyrics { margin: 16px 0 0; padding: 0 0 0 0; list-style: none; color: var(--dim); font-size: 14px; columns: 2; column-gap: 32px; }
.lyrics li { break-inside: avoid; padding: 2px 0; }
.lyrics b { color: var(--faint); font-weight: 400; display: inline-block; min-width: 64px; }
@media (max-width: 760px) { .lyrics { columns: 1; } .proposal { padding: 14px; } }

/* Lista fragmentów -------------------------------------------------------- */
.sections { margin-top: 26px; border-top: 1px solid var(--line); }
.row { position: relative; border-bottom: 1px solid var(--line); scroll-margin: 16px 0 96px; }
/* Bieżący fragment nagrania: bursztynowa krawędź i tło, numer taktu przy nazwie, pasek postępu na dole. */
.row.now {
  background: linear-gradient(90deg, rgba(255,176,32,0.16), rgba(255,176,32,0.05) 55%, transparent);
  box-shadow: inset 3px 0 0 var(--amber);
}
.row.now .idx { color: var(--amber); }
.row.now::after {
  content: "";
  position: absolute;
  left: 0; bottom: -1px;
  height: 2px;
  width: calc(var(--p, 0) * 100%);
  background: var(--amber);
  box-shadow: 0 0 6px rgba(255, 176, 32, 0.6);
  pointer-events: none;
}
.name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name-cell .name { flex: 1; min-width: 0; }
.now-badge {
  display: none;
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1;
  color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 55%, transparent);
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
}
.row.now .now-badge { display: inline-block; }
.seg.now .seg-label { color: var(--amber); }
.row-main {
  display: grid;
  grid-template-columns: 26px 10px minmax(120px, 1fr) auto auto auto 52px auto;
  align-items: center;
  gap: 14px;
  padding: 8px 4px;
}
.idx { color: var(--faint); text-align: right; }
.chip { width: 10px; height: 26px; border-radius: 3px; background: var(--c); }
.row input[type="text"], .row input[type="number"], .row select {
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  padding: 6px 2px;
  color: var(--text);
  min-width: 0;
}
.row input:hover, .row select:hover { border-bottom-color: var(--line); }
.row input:focus, .row select:focus { outline: none; border-bottom-color: var(--line-strong); }
.row input[type="number"] { width: 58px; text-align: right; -moz-appearance: textfield; }
.row input.beats { width: 34px; }
.row input[type="number"]::-webkit-inner-spin-button { appearance: none; }
.row select { appearance: none; padding-right: 2px; cursor: pointer; }
.row select option { background: var(--raised); }
.field { display: inline-flex; align-items: baseline; gap: 5px; color: var(--dim); white-space: nowrap; }
.field .sep { color: var(--faint); }
/* Zakres taktów: początek wynika z poprzednich fragmentów, koniec to granica z następnym (pole + ‹ ›). */
.field.range { align-items: center; gap: 4px; }
.field.range .rng-lbl { color: var(--faint); }
.field.range .rng-start, .field.range .rng-end { color: var(--text); padding: 6px 0; }
.row .field.range .end { width: 40px; text-align: left; padding-left: 3px; }
.field.range .cnt { color: var(--faint); margin-left: 6px; }
.nudges { display: inline-flex; gap: 1px; margin-left: 2px; }
.nudge {
  width: 24px; height: 24px;
  padding: 0; border: 0; border-radius: 6px;
  background: transparent;
  color: var(--dim);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.nudge:hover:not(:disabled) { color: var(--text); background: var(--raised); }
.nudge:disabled { opacity: 0.3; cursor: default; }
.nudge svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dur { color: var(--faint); text-align: right; }
.actions { display: flex; gap: 2px; }
.icon {
  width: 30px; height: 30px;
  border: 0; border-radius: 7px;
  background: transparent;
  color: var(--dim);
  display: grid; place-items: center;
}
.icon:hover:not(:disabled) { color: var(--text); background: var(--raised); }
.icon:disabled { opacity: 0.3; cursor: default; }
.icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.danger:hover { color: var(--red); }
.icon.on { color: var(--amber); }

.row-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  padding: 4px 4px 14px 50px;
  color: var(--dim);
}
.row-more label { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.row-more input[type="checkbox"] { accent-color: var(--amber); width: 16px; height: 16px; }
.row-more input[type="text"] { min-width: 200px; }
.row-more .spacer { flex: 1; }
/* Długość fragmentu (zmienia sumę taktów) celowo schowana pod ⋯, z jawnym ostrzeżeniem. */
.len { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.row .len .bars { width: 44px; text-align: center; }
.len em { font-style: normal; color: var(--faint); font-size: 13px; margin-left: 6px; }
@media (pointer: coarse) {
  .nudge { width: 32px; height: 32px; }
  .handle { width: 22px; }
}

.row-split {
  padding: 4px 4px 16px 50px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  color: var(--dim);
}
.split-strip { display: flex; gap: 1px; height: 26px; flex: 1; min-width: 160px; max-width: 520px; position: relative; }
.split-strip .cell { cursor: default; }
.split-strip .cell:hover { background: color-mix(in srgb, var(--c) 62%, var(--bg)); }
.split-strip .cell.left { background: color-mix(in srgb, var(--c) 90%, white 6%); }
.split-strip .cut::after { opacity: 0.25; }
.split-strip .cut.chosen::after { opacity: 1; background: var(--amber); }
.split-strip .cut:hover::after { opacity: 1; }
.split-words b { color: var(--text); font-weight: 500; }

.sections-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.restore { color: var(--dim); font-size: 14px; }

/* Eksport ----------------------------------------------------------------- */
.exportbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.exportbar > div { display: flex; align-items: center; gap: 12px; }
.exportbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
}
.import-hint { color: var(--faint); font-size: 13px; }
.saved { color: var(--faint); font-size: 13px; min-width: 0; }
/* Link do aplikacji (tylko telefon/tablet, pokazuje go app.js) — wygląda jak przycisk. */
a.app-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; white-space: nowrap; }
.saved.warn { color: var(--amber); }

.toast {
  position: fixed;
  left: 50%; bottom: 84px;
  transform: translateX(-50%);
  background: var(--raised);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  z-index: 10;
}

/* Wąskie ekrany ----------------------------------------------------------- */
@media (max-width: 760px) {
  main { padding: 0 16px 150px; }
  .top { padding: 18px 16px 6px; }
  .brand span { display: block; margin: 2px 0 0; }
  .urlbar .file-btn { padding: 0 12px; }
  .urlbar .file-btn span { display: none; }
  .title { font-size: 32px; }
  .song-meta { white-space: normal; }
  .row-main {
    grid-template-columns: 22px 10px 1fr auto;
    grid-template-areas:
      "idx chip name actions"
      ". . fields fields";
    gap: 6px 10px;
  }
  .idx { grid-area: idx; }
  .chip { grid-area: chip; }
  .name-cell { grid-area: name; }
  .actions { grid-area: actions; }
  .fields { grid-area: fields; display: flex; flex-wrap: wrap; gap: 6px 16px; }
  .dur { display: none; }
  .row-more, .row-split { padding-left: 4px; }
  .exportbar { flex-wrap: wrap; padding: 10px 16px; }
  .import-hint { display: none; }
  .export-right { flex: 1 1 100%; flex-wrap: wrap; }
  a.app-link { flex: 1 1 100%; order: -1; height: 48px; font-size: 16px; }
  .grid-hint { display: none; }
  .transport { flex-wrap: wrap; }
  .source { flex-basis: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .grid { gap: 2px; height: 44px; }
  .seg { gap: 0; }
  .cell { min-width: 0; border-radius: 1px; }
  .cell.group { margin-left: 1px; }
  .grid-wrap { padding-bottom: 20px; }
}
@media (min-width: 761px) {
  .fields { display: contents; }
  /* Wspólne kolumny dla wszystkich wierszy (subgrid): metrum, tempa i zakresy stoją w jednej linii. */
  .sections { display: grid; grid-template-columns: 26px 10px minmax(120px, 1fr) auto auto auto 52px auto; column-gap: 14px; }
  .row { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; column-gap: 14px; }
  .row-main { grid-column: 1 / -1; grid-template-columns: subgrid; column-gap: 14px; }
  .row-more, .row-split { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .bar-fill.indeterminate { width: 100%; opacity: 0.5; }
}

/* Blokada edycji ---------------------------------------------------------- */
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; color: var(--dim); font-size: 14px; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .knob {
  position: relative; width: 36px; height: 20px; flex: none;
  border-radius: 999px; background: var(--raised); border: 1px solid var(--line-strong);
  transition: background 0.15s, border-color 0.15s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--dim); transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .knob { background: color-mix(in srgb, var(--amber) 28%, var(--raised)); border-color: var(--amber); }
.switch input:checked + .knob::after { transform: translateX(16px); background: var(--amber); }
.switch input:focus-visible + .knob { outline: 2px solid var(--cyan); outline-offset: 2px; }
.switch input:checked ~ .switch-text { color: var(--text); }
.lock-tag { display: inline-flex; align-items: center; gap: 5px; color: var(--amber); }
.lock-tag svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.recent-list .rt .lock-tag { margin-right: 6px; vertical-align: -2px; }

/* Zablokowana rozpiska: pola wyglądają jak tekst, znikają przyciski edycji, siatka bez uchwytów. */
.song.locked .title, .song.locked .row input, .song.locked .row select { border-bottom-color: transparent !important; cursor: default; }
.song.locked .row select { opacity: 1; color: var(--text); }
.song.locked .row input[type="checkbox"] { opacity: 0.6; }
.song.locked .nudges, .song.locked .len .nudge, .song.locked .len em,
.song.locked .actions .icon:not(.act-listen):not(.act-more),
.song.locked .row-more .icon { display: none; }

dialog.confirm {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 14px;
  padding: 24px 26px; max-width: min(460px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
dialog.confirm::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); }
dialog.confirm h2 { font-family: var(--serif); font-weight: 400; font-size: 26px; margin: 0 0 10px; }
dialog.confirm p { color: var(--dim); font-size: 14px; line-height: 1.5; margin: 0 0 16px; }
dialog.confirm .ack { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; margin-bottom: 20px; }
dialog.confirm .ack input { accent-color: var(--amber); width: 18px; height: 18px; flex: none; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.confirm-actions .primary { height: 40px; padding: 0 18px; }
.confirm-actions .ghost { height: 40px; }

/* Nagłówek: przestrzeń robocza i menu użytkownika --------------------------- */
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
select.workspace, .song-where select {
  height: 36px; padding: 0 30px 0 12px; max-width: 220px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239A9AA7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center / 14px;
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
  appearance: none; cursor: pointer; text-overflow: ellipsis;
}
select.workspace:hover, .song-where select:hover { border-color: var(--line-strong); }
.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; max-width: 200px; }
.user-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 160px; z-index: 20;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); padding: 6px; display: flex; flex-direction: column;
}
.menu-item { background: none; border: 0; text-align: left; padding: 9px 12px; border-radius: 6px; color: var(--text); }
.menu-item:hover { background: var(--surface); }

/* Logowanie ---------------------------------------------------------------- */
.auth { display: flex; justify-content: center; padding: 40px 0 20px; }
.auth-box { width: min(420px, 100%); }
.auth-invite {
  margin: 0 0 18px; padding: 12px 16px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--amber) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--amber) 50%, var(--line));
  color: var(--text); font-size: 14px;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 0 0 4px; }
.auth-form h3 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 18px 0 0; }
.auth-hint { color: var(--dim); font-size: 14px; margin: -6px 0 2px; line-height: 1.5; }
.auth-hint b { color: var(--text); font-weight: 500; }
.af { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--dim); }
.af small { color: var(--faint); margin-left: 6px; }
.af input {
  height: 44px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
}
.af input:focus { outline: none; border-color: var(--line-strong); }
.af input.code { font-size: 24px; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.auth-error { margin: 0; color: var(--red); font-size: 14px; }
.auth-form .primary { height: 46px; margin-top: 4px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 0; font-size: 14px; }
.auth-links .link:disabled { color: var(--faint); text-decoration: none; cursor: default; }
.auth-form.inline { max-width: 420px; }
.auth-form.inline .ghost { align-self: flex-start; height: 40px; }

/* Strony: zespoły, konto --------------------------------------------------- */
.page { padding: 24px 0 0; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-family: var(--serif); font-weight: 400; font-size: 34px; margin: 0; }
.page .hint b { color: var(--text); font-weight: 500; }
.team-new { display: flex; gap: 10px; margin: 20px 0 8px; max-width: 520px; }
.team-new input {
  flex: 1; min-width: 0; height: 46px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
}
.team-new input:focus { outline: none; border-color: var(--line-strong); }
.team-card { margin-top: 20px; padding: 18px 20px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.team-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.team-head h3 { font-family: var(--serif); font-weight: 400; font-size: 26px; margin: 0; }
.team-head .role { color: var(--faint); font-size: 13px; }
.team-head .spacer { flex: 1; }
.members { list-style: none; margin: 12px 0 0; padding: 0; }
.members li { display: flex; align-items: baseline; gap: 14px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.members li:first-child { border-top: 0; }
.members .mname { color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.members .mname em { font-style: normal; color: var(--faint); }
.members .mphone { color: var(--faint); }
.members .mrole { color: var(--faint); font-size: 13px; flex: 1; }
.invite { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.invite-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.invite-label { color: var(--dim); font-size: 14px; margin-right: 4px; }
.invite-url {
  flex: 1; min-width: 200px; height: 36px; padding: 0 12px; font-size: 13px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
}
.invite-off { color: var(--faint); font-size: 14px; }
.invite .hint { font-size: 13px; margin-top: 8px; }
.team-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.ghost.danger:hover:not(:disabled), .link.danger { color: var(--red); }
.ghost.danger:hover:not(:disabled) { border-color: color-mix(in srgb, var(--red) 50%, var(--line)); }
.primary.danger { background: var(--red); color: #1a0a0a; }
.ask-input { margin: 6px 0 20px; }

/* Piosenka: gdzie leży i kto dodał ---------------------------------------- */
.song-where { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 10px; color: var(--dim); font-size: 14px; }
.song-where label { display: inline-flex; align-items: center; gap: 10px; }
.song-owner { color: var(--faint); }
.recent-list .ro { color: var(--faint); margin-left: 10px; font-size: 13px; }
.recent-list .ro::before { content: "· "; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; }
  .top-right { flex: 1 1 100%; justify-content: flex-start; }
  select.workspace { flex: 1; max-width: none; }
  .user-btn span { display: none; }
  .team-card { padding: 14px 14px 12px; }
}

/* Historia zmian ------------------------------------------------------------ */
.foot-left { display: flex; gap: 8px; flex-wrap: wrap; }
.ghost.on { color: var(--text); border-color: var(--line-strong); background: var(--surface); }
.history { margin-top: 18px; padding: 16px 18px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.history-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.history-head h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0; }
.history-head .hint { flex: 1; margin: 0; font-size: 13px; min-width: 200px; }
.history-list { list-style: none; margin: 12px 0 0; padding: 0; }
.h-item { display: grid; grid-template-columns: 96px 150px 1fr auto; gap: 12px; align-items: baseline; padding: 8px 6px; border-top: 1px solid var(--line); font-size: 14px; }
.h-item.current { background: color-mix(in srgb, var(--amber) 9%, transparent); border-radius: 6px; }
.h-item.minor .h-what { color: var(--faint); }
.h-when { color: var(--faint); white-space: nowrap; }
.h-who { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-who em { font-style: normal; color: var(--faint); }
.h-what { color: var(--dim); min-width: 0; }
.h-item.current .h-what { color: var(--text); }
.h-tag { color: var(--amber); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.h-empty { color: var(--faint); padding: 8px 0; }
.song-last { color: var(--faint); }
@media (max-width: 760px) {
  .h-item { grid-template-columns: auto 1fr auto; }
  .h-what { grid-column: 1 / -1; }
}

/* Dokąd trafia nowa piosenka (pod polem linku) -------------------------------- */
.dest { display: inline-flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--dim); font-size: 14px; }
.dest select.workspace { height: 34px; }

/* Panel administratora (admin.js) ------------------------------------------- */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 18px; }
.stat { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.stat b { display: block; font-family: var(--serif); font-weight: 400; font-size: 26px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat span { color: var(--dim); font-size: 13px; }
.stat small { display: block; color: var(--faint); font-size: 12px; margin-top: 3px; line-height: 1.35; }
.stat.warn b { color: var(--amber); }
.tabs { display: flex; gap: 2px; margin-top: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { background: none; border: 0; padding: 10px 14px; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 15px; white-space: nowrap; border-radius: 6px 6px 0 0; }
.tab:hover { color: var(--text); background: var(--surface); }
.tab.on { color: var(--text); border-bottom-color: var(--amber); }
.tab .count { color: var(--faint); font-size: 13px; margin-left: 6px; }
.admin-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 0 12px; }
.admin-toolbar .search {
  flex: 1 1 220px; min-width: 0; height: 38px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
}
.admin-toolbar .search:focus { outline: none; border-color: var(--line-strong); }
.admin-toolbar select.workspace { height: 38px; }
.admin-toolbar .toolbar-hint { flex: 1 1 260px; margin: 0; font-size: 13px; }
.admin-toolbar .primary { height: 38px; padding: 0 16px; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 500; color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:hover td { background: var(--surface); }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl .nw { white-space: nowrap; }
.tbl .main { color: var(--text); font-weight: 500; }
.tbl a.main:hover { color: var(--cyan); text-decoration: none; }
.tbl .sub { display: block; color: var(--faint); font-size: 12px; margin-top: 2px; }
.tbl .off { color: var(--faint); font-style: italic; }
.tbl .acts { display: inline-flex; gap: 10px; flex-wrap: wrap; white-space: nowrap; align-items: baseline; }
.tbl .acts .link { font-size: 13px; }
.tbl .err { color: var(--red); display: block; font-size: 12px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.tbl .state.error { color: var(--red); }
.tbl .state.run { color: var(--amber); }
.tbl tr.empty td { color: var(--faint); text-align: center; padding: 28px 10px; }
.lock-mini { width: 13px; height: 13px; fill: none; stroke: var(--amber); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -1px; margin-right: 5px; }
.badge {
  display: inline-block; padding: 1px 7px; margin-left: 6px; border-radius: 999px; vertical-align: 1px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; border: 1px solid var(--line-strong); color: var(--dim);
}
.badge.admin { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); }
.badge.me { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 55%, var(--line)); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-t { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 12px; color: var(--dim); white-space: nowrap; }
.chip-t.owner { color: var(--text); }
.chip-m { display: inline-flex; align-items: center; gap: 3px; padding: 2px 3px 2px 9px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
.chip-m.owner { border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); }
.chip-m .star { color: var(--amber); margin-right: 3px; }
.chip-m button { border: 0; background: none; color: var(--faint); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; padding: 0; font-size: 13px; line-height: 1; }
.chip-m button:hover { color: var(--text); background: var(--surface); }
.chip-m button[data-act="owner"]:hover { color: var(--amber); }
.chip-m button[data-act="remove"]:hover { color: var(--red); }
.chips .link { font-size: 13px; }
.pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; color: var(--faint); font-size: 14px; }
.pager span { margin-right: auto; }
.admin .hint { font-size: 13px; }

/* Dialog z formularzem (admin.js) */
dialog.form-dialog { max-width: min(520px, calc(100vw - 32px)); width: 100%; }
.fd-fields { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.fd-fields .af select {
  height: 44px; padding: 0 36px 0 14px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239A9AA7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 14px;
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); appearance: none; cursor: pointer;
}
.fd-fields .af select:focus { outline: none; border-color: var(--line-strong); }
.fd-fields .af select option { background: var(--raised); }
.fd-fields .ack { margin: 0; align-items: flex-start; }
.fd-fields .ack input { margin-top: 1px; }
.fd-fields .ack small { display: block; color: var(--faint); font-size: 12px; }
.fd-radio { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.fd-radio legend { color: var(--dim); font-size: 14px; padding: 0; margin-bottom: 8px; }
.fd-radio label { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.fd-radio input { accent-color: var(--amber); width: 18px; height: 18px; flex: none; margin: 1px 0 0; }
.fd-radio small { display: block; color: var(--faint); font-size: 12px; margin-top: 2px; }
dialog.form-dialog .fd-text { margin-bottom: 18px; }
@media (max-width: 760px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .stat b { font-size: 22px; }
  .tbl th, .tbl td { padding: 8px 6px; }
}
