/* ClipMind – style.
 *
 * Język wizualny: stół montażowy z napisami.
 * - Nagranie to scena: "monitor" jest zawsze ciemny, niezależnie od motywu.
 * - Żółty jak napisy oznacza "teraz / czas": aktualna linia, głowica, timecody.
 * - Turkus to mowa (bloki mowy na osi, fale dźwięku), czerwony – błędy i usuwanie.
 * - Ruch pojawia się jako odpowiedź na działanie (otwarcie, przewinięcie, wysłanie)
 *   oraz raz na starcie – w krótkiej scence na stronie głównej.
 */

:root {
  --paper: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #e8ecf2;
  --line: #dde2ea;
  --line-strong: #c9d0db;
  --text: #141821;
  --muted: #5d6677;

  --caption: #ffd23f;           /* żółty jak napisy */
  --caption-ink: #141821;       /* tekst na żółtym */
  --marker: rgba(255, 210, 63, 0.62);        /* karaoke: już powiedziane */
  --marker-ahead: rgba(255, 210, 63, 0.18);  /* karaoke: reszta aktywnej linii */
  --wave: #0f9e90;              /* mowa, fala dźwięku */
  --wave-soft: #e3f5f2;
  --danger: #d8382f;
  --danger-soft: #fdecea;
  --focus: #0b8276;

  --cta-bg: #141821;            /* przycisk główny: czarne pole, żółty napis */
  --cta-fg: #ffd23f;
  --chip-bg: #141821;           /* timecode jak wypalony w obrazie */
  --chip-fg: #ffd23f;
  --bubble-user-bg: #141821;
  --bubble-user-fg: #f4f6f9;
  --skeleton: #e4e8ee;
  --skeleton-hi: #f3f5f8;
  --spot: rgba(255, 210, 63, 0.16);   /* poświata pod kursorem (Magic Card) */
  --dot: rgba(20, 24, 33, 0.14);      /* kropki w tle sekcji powitalnej */

  /* monitor – zawsze ciemny */
  --monitor: #11141b;
  --monitor-2: #1a1f29;
  --monitor-line: #2a303c;
  --monitor-text: #e9ecf2;
  --monitor-muted: #8d96a8;

  --shadow-sm: 0 1px 2px rgba(20, 24, 33, 0.07);
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.06), 0 12px 32px -18px rgba(20, 24, 33, 0.28);
  --shadow-monitor: 0 30px 60px -30px rgba(10, 12, 18, 0.65), 0 2px 6px rgba(10, 12, 18, 0.18);

  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 9px;

  --font-display: "Bahnschrift", "DIN Alternate", "DIN Next", "Barlow", "Segoe UI", system-ui, sans-serif;
  --font-body: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --header-height: 60px;
}

[data-theme="dark"] {
  --paper: #0e1117;
  --surface: #161a22;
  --surface-2: #1c212b;
  --surface-3: #242a36;
  --line: #262c38;
  --line-strong: #353d4c;
  --text: #e8ebf1;
  --muted: #98a1b3;

  --marker: rgba(255, 210, 63, 0.3);
  --marker-ahead: rgba(255, 210, 63, 0.08);
  --wave: #2ecfbe;
  --wave-soft: #14302d;
  --danger: #ff5c52;
  --danger-soft: #3a1c1c;
  --focus: #3dd6c6;

  --cta-bg: #ffd23f;
  --cta-fg: #141821;
  --chip-bg: rgba(255, 210, 63, 0.13);
  --chip-fg: #ffd23f;
  --bubble-user-bg: #2b3242;
  --bubble-user-fg: #eef1f6;
  --skeleton: #1f2530;
  --skeleton-hi: #2a313e;
  --spot: rgba(255, 210, 63, 0.08);
  --dot: rgba(232, 235, 241, 0.09);

  --monitor: #090b10;
  --monitor-2: #141821;
  --monitor-line: #262c38;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 36px -20px rgba(0, 0, 0, 0.8);
  --shadow-monitor: 0 30px 70px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px #1d222c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
}
h1 { font-size: 1.4rem; }
h2 { font-size: 1.08rem; display: flex; align-items: center; gap: 9px; }
h3 { font-size: 0.98rem; }

::selection { background: var(--marker); color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Ikony */
.icon-sprite { display: none; }
.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}
.heading-icon { color: var(--muted); width: 18px; height: 18px; }

/* Paski przewijania */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }

/* Fokus z klawiatury – zawsze widoczny */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------------------------------------------------------------- nagłówek */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
  /* nagłówek stoi w miejscu podczas przejść między widokami */
  view-transition-name: app-header;
}
.app-header.scrolled { border-bottom-color: var(--line); }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #141821;
  color: var(--caption);
}
[data-theme="dark"] .brand-mark { background: var(--surface-3); }
.brand-mark svg { width: 22px; height: 22px; fill: currentColor; }
.brand-mark rect { transform-origin: center; transform-box: fill-box; }
.brand:hover .brand-mark rect { animation: bar-dance 0.9s var(--ease-out) 1; }
.brand:hover .brand-mark rect:nth-child(2) { animation-delay: 0.08s; }
.brand:hover .brand-mark rect:nth-child(3) { animation-delay: 0.16s; }
.brand:hover .brand-mark rect:nth-child(4) { animation-delay: 0.24s; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.22rem;
  letter-spacing: 0.01em;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s var(--ease-out), border-color 0.15s;
}
.icon-button:hover { border-color: var(--line-strong); }
.icon-button:active { transform: scale(0.92) rotate(-12deg); }

.global-alert {
  max-width: 1180px;
  margin: 12px auto 0;
  width: calc(100% - 56px);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}

/* ---------------------------------------------------------------- wspólne */

.view { padding: 26px 28px 40px; max-width: 1560px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-header h2 { margin: 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: var(--cta-bg);
  color: var(--cta-fg);
  font: inherit;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s var(--ease-out), filter 0.15s, background 0.15s, border-color 0.15s;
}
.button:hover { filter: brightness(1.12); }
.button:active { transform: scale(0.96); }
.button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; }
.button.ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
  font-family: var(--font-body);
  font-weight: 550;
}
.button.ghost:hover { filter: none; border-color: var(--line-strong); background: var(--surface-2); }
.button.danger { color: var(--danger); }
.button.danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.button.small { padding: 5px 11px; font-size: 0.85rem; border-radius: 9px; }
.button.icon-only { padding: 10px; }
.button.small.icon-only { padding: 6px; }

input[type="url"], input[type="text"], input[type="search"], textarea {
  appearance: none;
  width: 100%;
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}

/* Timecode – jak czas wypalony w obrazie. Ta sama forma w transkrypcji, czacie i podsumowaniu. */
.timestamp {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  margin: 0 1px;
  border: 0;
  border-radius: 6px;
  background: var(--chip-bg);
  color: var(--chip-fg);
  font-family: var(--font-display);
  font-size: 0.84em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.6;
  white-space: nowrap;
  cursor: pointer;
  vertical-align: 0.05em;
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s;
}
.timestamp:hover { transform: translateY(-1px); box-shadow: 0 4px 10px -4px rgba(20, 24, 33, 0.5); }
.timestamp:active { transform: scale(0.93); }

.progress {
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: repeating-linear-gradient(-45deg, var(--caption) 0 10px, color-mix(in srgb, var(--caption) 70%, #fff) 10px 20px);
  background-size: 28px 100%;
  animation: stripes 0.8s linear infinite;
  transition: width 0.4s var(--ease-out);
}
@keyframes stripes { to { background-position: 28px 0; } }

.form-error {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--text);
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Szkielety ładowania – linie jak nieodczytane jeszcze napisy */
.skeleton-line {
  height: 11px;
  margin: 12px 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-hi) 45%, var(--skeleton) 90%);
  background-size: 220% 100%;
  animation: skeleton 1.3s ease-in-out infinite;
}
@keyframes skeleton { from { background-position: 100% 0; } to { background-position: -120% 0; } }

/* Przełącznik "śledź odtwarzanie" */
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.86rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: relative; width: 32px; height: 18px; border-radius: 99px; background: var(--line-strong); transition: background 0.2s; }
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s var(--ease-spring);
}
.switch input:checked + .switch-track { background: var(--wave); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------------------------------------------------------------- biblioteka */

.library-view { max-width: 1180px; }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 56px;
  align-items: center;
  padding: 28px 0 46px;
}

.intro-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 4.1rem);
  font-weight: 700;
  font-stretch: 87.5%;
  line-height: 0.98;
  letter-spacing: -0.015em;
}
.intro-lead {
  max-width: 34em;
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 1.06rem;
}

.dropzone {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.25s var(--ease-out), box-shadow 0.2s;
}
.dropzone:hover { border-color: var(--text); }
.dropzone.dragover {
  border-style: solid;
  border-color: var(--caption);
  background: color-mix(in srgb, var(--caption) 12%, var(--surface));
  transform: scale(1.015);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--caption) 22%, transparent);
}
.dropzone input { display: none; }
.dropzone-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 13px;
  background: var(--cta-bg);
  color: var(--cta-fg);
  transition: transform 0.3s var(--ease-spring);
}
.dropzone-icon .icon { width: 24px; height: 24px; }
.dropzone:hover .dropzone-icon { transform: translateY(-2px); }
.dropzone.dragover .dropzone-icon { animation: hop 0.6s var(--ease-out) infinite alternate; }
@keyframes hop { to { transform: translateY(-5px); } }
.dropzone-copy { display: flex; flex-direction: column; gap: 2px; }
.dropzone-title { font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; }
.dropzone-title u { text-decoration-color: var(--caption); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.dropzone-formats { color: var(--muted); font-size: 0.86rem; }

.upload-progress { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.upload-progress-text { min-width: 130px; text-align: right; font-family: var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }

.url-form { display: flex; gap: 10px; margin-top: 12px; }
.input-with-icon { position: relative; flex: 1; }
.input-with-icon .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-with-icon input { padding-left: 40px; }

/* Scenka na starcie: fala → napisy z czasem → pytanie i odpowiedź */
.demo-monitor {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 340px;
  padding: 18px 20px 20px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 70% at 50% 0%, #1b2130 0%, transparent 65%),
    var(--monitor);
  color: var(--monitor-text);
  box-shadow: var(--shadow-monitor);
  overflow: hidden;
}
.demo-top { display: flex; justify-content: space-between; align-items: center; font-size: 0.82rem; color: var(--monitor-muted); }
.demo-file::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--monitor-line);
  vertical-align: 0.05em;
}
.demo-monitor.playing .demo-file::before { background: var(--caption); box-shadow: 0 0 10px var(--caption); }
.demo-tc { font-family: var(--font-display); font-size: 1rem; color: var(--caption); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }

.demo-wave { display: flex; align-items: center; gap: 3px; height: 74px; }
.demo-bar {
  flex: 1;
  height: calc(var(--h) * 1%);
  min-height: 4px;
  border-radius: 99px;
  background: #3a4252;
  transform-origin: center;
  transition: background 0.4s;
}
.demo-monitor.playing .demo-bar {
  background: #2ecfbe;
  animation: bar-dance 0.9s ease-in-out infinite alternate;
  animation-delay: calc(var(--d) * -1s);
}
@keyframes bar-dance {
  0% { transform: scaleY(0.35); }
  50% { transform: scaleY(1.1); }
  100% { transform: scaleY(0.6); }
}

.demo-captions { display: flex; flex-direction: column; gap: 8px; min-height: 64px; }
.demo-caption {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-family: var(--font-display);
  font-size: 1.04rem;
  line-height: 1.35;
  transition: opacity 0.5s, transform 0.5s var(--ease-out);
}
.demo-caption.past { opacity: 0.45; }
.demo-caption .timestamp { background: rgba(255, 210, 63, 0.14); color: var(--caption); cursor: default; }
.demo-word { opacity: 0; display: inline-block; transform: translateY(4px); transition: opacity 0.25s, transform 0.25s var(--ease-out); }
.demo-word.on { opacity: 1; transform: none; }

.demo-chat { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.demo-q, .demo-a {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.92rem;
  animation: pop-in 0.45s var(--ease-spring) both;
}
.demo-q { align-self: flex-end; background: #2b3242; border-bottom-right-radius: 4px; }
.demo-a { align-self: flex-start; background: var(--monitor-2); border: 1px solid var(--monitor-line); border-bottom-left-radius: 4px; }
.demo-a .timestamp { background: var(--caption); color: var(--caption-ink); cursor: default; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } }

/* Lista nagrań */
.library-section .section-header h2 { font-size: 1.2rem; }
.count-pill {
  padding: 1px 9px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.video-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.video-item {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 10px 12px 10px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.video-item:hover { border-color: var(--line-strong); background: var(--surface-2); }
.video-item.entering { animation: row-in 0.5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes row-in { from { opacity: 0; transform: translateY(10px); } }

.video-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 112px;
  aspect-ratio: 16 / 9;
  border-radius: 9px;
  overflow: hidden;
  background: var(--monitor);
  color: var(--monitor-muted);
}
.video-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.4s, transform 0.4s var(--ease-out); }
.video-thumb img.loaded { opacity: 1; }
.video-item:hover .video-thumb img { transform: scale(1.05); }
.thumb-bars { display: flex; align-items: center; gap: 3px; height: 26px; }
.thumb-bars span { width: 4px; border-radius: 3px; background: var(--wave); }

.video-item-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.video-item-title { font-family: var(--font-display); font-weight: 600; font-size: 1.04rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-item-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.84rem; }
.video-item-meta .timestamp { cursor: inherit; font-size: 0.8rem; }
.video-item-meta .timestamp:hover { transform: none; box-shadow: none; }

.video-status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.86rem; white-space: nowrap; color: var(--muted); }
.video-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.video-status.ready { color: var(--wave); }
.video-status.error { color: var(--danger); }
.video-status.working { color: var(--text); }
.video-status.working::before { background: var(--caption); animation: blink-dot 1.1s ease-in-out infinite; }
.video-status-percent { font-variant-numeric: tabular-nums; }
@keyframes blink-dot { 50% { opacity: 0.25; } }

.video-item-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.video-item-progress span { display: block; height: 100%; width: 0; background: var(--caption); transition: width 0.6s var(--ease-out); }

.video-item-delete {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.video-item:hover .video-item-delete, .video-item:focus-within .video-item-delete { opacity: 1; }
.video-item-delete:hover { color: var(--danger); background: var(--danger-soft); }

.empty-state {
  padding: 30px 20px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}
.empty-state p { margin: 0; }

/* ---------------------------------------------------------------- widok nagrania */

.workspace-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.video-title { flex: 1; min-width: 0; margin: 0; font-size: 1.45rem; font-weight: 700; overflow-wrap: anywhere; }
/* ---------- zmiana nazwy nagrania ---------- */
.title-input { flex: 1 1 auto; min-width: 0; font: inherit; font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: inherit; }
.title-input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
#rename-button { flex: none; }
.workspace-actions { display: flex; gap: 8px; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform-origin: top right;
  animation: menu-in 0.18s var(--ease-out);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.97); } }
.dropdown-menu a { display: flex; justify-content: space-between; align-items: center; padding: 9px 11px; border-radius: 8px; color: var(--text); text-decoration: none; cursor: pointer; }
.dropdown-menu a span { font-family: var(--font-display); font-size: 0.76rem; color: var(--muted); }
.dropdown-menu a:hover { background: var(--surface-2); }
.dropdown-menu a.disabled { opacity: 0.4; pointer-events: none; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 22px;
  align-items: start;
}

/* Monitor */
.monitor-slot { margin-bottom: 18px; scroll-margin-top: calc(var(--header-height) + 18px); }
.monitor {
  position: relative;
  border-radius: var(--radius-lg);
  background: var(--monitor);
  color: var(--monitor-text);
  box-shadow: var(--shadow-monitor);
  overflow: hidden;
}
/* Mini-odtwarzacz: gdy nagranie gra, a strona jest przewinięta niżej, monitor "odkleja się" do rogu. */
.monitor.floating {
  position: fixed;
  left: 28px;
  bottom: 24px;
  z-index: 45;
  width: min(420px, 38vw);
  box-shadow: 0 34px 70px -24px rgba(10, 12, 18, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.07);
  animation: float-in 0.5s var(--ease-spring);
}
.monitor.floating .monitor-screen video { max-height: none; }
.monitor.floating .monitor-bar { padding: 6px 12px 0; }
.monitor.floating .monitor-tc { font-size: 0.9rem; }
.monitor.floating .timeline { height: 44px; margin: 4px 12px 10px; }
.monitor.floating .timeline-marks, .monitor.floating .vu { display: none; }
.monitor.floating .timeline-tip { display: none; }
@keyframes float-in { from { opacity: 0; transform: translateY(28px) scale(0.92); } }
.monitor.docked { animation: dock-in 0.4s var(--ease-out); }
@keyframes dock-in { from { opacity: 0.4; transform: scale(0.97); } }
.monitor-dock {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: rgba(10, 12, 18, 0.72);
  color: #fff;
  cursor: pointer;
}
.monitor.floating .monitor-dock { display: grid; }
/* Uchwyt do przesuwania mini-odtwarzacza: pasek u góry (obraz pod spodem dalej reaguje na klik) */
.monitor-grip { display: none; }
.monitor.floating .monitor-grip {
  display: grid;
  place-items: center;
  position: absolute;
  top: 0;
  left: 0;
  right: 44px; /* miejsce na przycisk powrotu */
  z-index: 3;
  height: 28px;
  background: linear-gradient(rgba(10, 12, 18, 0.55), transparent);
  cursor: grab;
  touch-action: none;
}
.monitor.floating .monitor-grip::before {
  content: "";
  width: 44px;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.55);
  transition: background 0.15s;
}
.monitor.floating .monitor-grip:hover::before,
.monitor.floating .monitor-grip:focus-visible::before { background: var(--caption); }
.monitor.floating .monitor-grip:focus-visible { outline-offset: -3px; }
.monitor.floating.dragging { user-select: none; } /* bez ruszania animacji – jej zdjęcie i powrót odpaliłyby wjazd od nowa */
.monitor.floating.dragging .monitor-grip { cursor: grabbing; }

.monitor-screen { position: relative; background: #000; }
.monitor-screen video { display: block; width: 100%; max-height: 58vh; background: #000; }
.monitor-screen video::cue {
  background-color: rgba(10, 12, 18, 0.82);
  color: #ffd23f;
  font-family: "Bahnschrift", "DIN Alternate", "Segoe UI", sans-serif;
}
.monitor.audio-mode .monitor-screen {
  padding: 26px 22px 14px;
  background:
    radial-gradient(90% 80% at 50% 0%, #1c2231 0%, transparent 70%),
    var(--monitor);
}
.monitor-screen audio { display: block; width: 100%; margin-top: 12px; color-scheme: dark; }
.monitor-screen video { color-scheme: dark; }

.caption-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 6px 0 4px; }
.stage-bars { display: flex; align-items: center; gap: 3px; height: 54px; width: min(420px, 100%); }
.stage-bars span { flex: 1; height: calc(var(--h) * 1%); min-height: 3px; border-radius: 99px; background: #3a4252; transform-origin: center; }
.monitor.playing .stage-bars span { background: #2ecfbe; animation: bar-dance 0.8s ease-in-out infinite alternate; animation-delay: calc(var(--d) * -1s); }
.stage-text {
  max-width: 36em;
  min-height: 2.8em;
  margin: 0;
  color: var(--caption);
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}
.stage-text.swap { animation: stage-swap 0.45s var(--ease-out); }
@keyframes stage-swap { from { opacity: 0; transform: translateY(10px); filter: blur(2px); } }

.seek-flash {
  position: absolute;
  left: 50%;
  top: 42%;
  padding: 8px 16px;
  border-radius: 12px;
  background: rgba(10, 12, 18, 0.78);
  color: var(--caption);
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  opacity: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.seek-flash.show { animation: seek-flash 0.95s var(--ease-out) both; }
@keyframes seek-flash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1); }
}

.monitor-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px 2px; }
.monitor-tc { font-family: var(--font-display); font-size: 1.02rem; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; color: var(--caption); }
.monitor-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--monitor-line);
  border-radius: 8px;
  background: transparent;
  color: var(--monitor-muted);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.monitor-button[aria-pressed="true"] { color: var(--caption); border-color: color-mix(in srgb, var(--caption) 45%, transparent); background: rgba(255, 210, 63, 0.08); }

/* Oś nagrania: rozdziały, bloki mowy, kluczowe punkty, głowica */
.timeline {
  --pos: 0;
  --transcribed: 1;
  position: relative;
  height: 54px;
  margin: 6px 16px 14px;
  cursor: pointer;
  outline-offset: 4px;
  border-radius: 6px;
}
.timeline-chapters { position: absolute; left: 0; right: 0; top: 0; height: 6px; }
/* Prawdziwa fala dźwięku: szara warstwa pod spodem, żółta (już odtworzone) przycięta do głowicy */
.timeline-wave { position: absolute; left: 0; right: 0; top: 10px; height: 28px; }
.timeline-wave canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave-played { clip-path: inset(0 calc((1 - var(--pos)) * 100%) 0 0); }
.timeline.has-wave .timeline-played { display: none; }
/* Postęp transkrypcji: nierozpoznana część jest przygaszona, a na granicy "skanuje" jasna linia */
.timeline-scan {
  display: none;
  position: absolute;
  left: calc(var(--transcribed) * 100%);
  right: 0;
  top: 8px;
  height: 38px;
  background: repeating-linear-gradient(-45deg, rgba(9, 11, 16, 0.72) 0 5px, rgba(9, 11, 16, 0.55) 5px 10px);
  transition: left 1s linear;
  pointer-events: none;
}
.timeline-scan::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #2ecfbe;
  box-shadow: 0 0 14px 2px rgba(46, 207, 190, 0.8);
  animation: scan-pulse 1.1s ease-in-out infinite;
}
@keyframes scan-pulse { 50% { opacity: 0.35; } }
.timeline.transcribing .timeline-scan { display: block; }
.tl-chapter {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
  background: #3a4252;
  box-shadow: inset -2px 0 0 var(--monitor);
  transition: background 0.3s;
}
.tl-chapter.odd { background: #4a5366; }
.tl-chapter.current { background: var(--caption); }
/* Pasek mowy: gdzie Whisper rozpoznał wypowiedzi */
.timeline-track { position: absolute; left: 0; right: 0; top: 40px; height: 3px; border-radius: 2px; background: #1e2430; }
.tl-speech { position: absolute; top: 0; height: 100%; min-width: 2px; border-radius: 2px; background: #2ecfbe; }
.tl-speech.new { animation: speech-in 0.6s var(--ease-out); }
@keyframes speech-in { from { opacity: 0; transform: scaleY(3); } }
.timeline-marks { position: absolute; left: 0; right: 0; top: 45px; height: 9px; }
.tl-mark {
  position: absolute;
  top: 1px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: var(--caption);
  transform: rotate(45deg);
  border-radius: 1.5px;
}
.timeline-played {
  position: absolute;
  left: 0;
  right: 0;
  top: 10px;
  height: 28px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255, 210, 63, 0.05), rgba(255, 210, 63, 0.28));
  transform-origin: left;
  transform: scaleX(var(--pos));
  pointer-events: none;
}
.timeline-playhead {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: calc(var(--pos) * 100%);
  width: 2px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--caption);
  box-shadow: 0 0 12px rgba(255, 210, 63, 0.7);
  pointer-events: none;
}
.timeline-playhead::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--caption);
}
.timeline.gliding .timeline-playhead { transition: left 0.45s var(--ease-out); }
.timeline.gliding .timeline-played { transition: transform 0.45s var(--ease-out); }
.timeline-hover {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: rgba(255, 255, 255, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.timeline:hover .timeline-hover { opacity: 1; }
.timeline-tip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  width: max-content;
  max-width: 280px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(10, 12, 18, 0.94);
  border: 1px solid var(--monitor-line);
  color: var(--monitor-text);
  font-size: 0.82rem;
  line-height: 1.35;
  transform: translateX(var(--tip-shift, -50%));
  white-space: normal;
}
.timeline-tip b { display: block; color: var(--caption); font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; }
/* Klatka z nagrania w podpowiedzi (fragment siatki storyboard) */
.tip-frame {
  display: block;
  margin: -1px -2px 7px;
  border-radius: 6px;
  background-color: #000;
  background-repeat: no-repeat;
  box-shadow: 0 0 0 1px var(--monitor-line);
}

/* Poziom dźwięku (VU) jak na konsoli montażowej */
.vu { display: inline-flex; align-items: center; gap: 2px; height: 12px; margin-right: auto; margin-left: 14px; }
.vu span { width: 4px; height: 10px; border-radius: 1px; background: #262c38; transition: background 0.06s; }
.vu span.on { background: #2ecfbe; }
.vu span.on:nth-child(n + 11) { background: var(--caption); }
.vu span.on:nth-child(n + 15) { background: #ff5c52; }
.vu span.peak { background: #e9ecf2; }

/* Ekran przetwarzania na monitorze */
.processing-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 16 / 9;
  max-height: 58vh;
  width: 100%;
  overflow: hidden;
  background:
    radial-gradient(70% 60% at 50% 40%, #1c2231 0%, transparent 70%),
    var(--monitor);
  text-align: center;
}
/* Linia "skanera" przesuwa się po ekranie, gdy nagranie jest przetwarzane */
.processing-screen::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 30%;
  top: -30%;
  background: linear-gradient(180deg, transparent, rgba(46, 207, 190, 0.1) 80%, rgba(46, 207, 190, 0.35));
  animation: scanner 2.8s linear infinite;
  pointer-events: none;
}
@keyframes scanner { to { top: 100%; } }
.processing-screen.error::after { display: none; }
.processing-bars { display: flex; align-items: center; gap: 3px; height: 48px; width: min(300px, 70%); margin-bottom: 10px; }
.processing-bars span { flex: 1; height: calc(var(--h) * 1%); min-height: 3px; border-radius: 99px; background: #2ecfbe; opacity: 0.8; animation: bar-dance 0.9s ease-in-out infinite alternate; animation-delay: calc(var(--d) * -1s); }
.processing-screen.error .processing-bars span { background: #ff5c52; animation: none; opacity: 0.6; }
.processing-label { margin: 0; color: var(--monitor-text); font-family: var(--font-display); font-size: clamp(1.1rem, 2.2vw, 1.5rem); font-weight: 600; }
.processing-label.shiny-text { --shiny-base: var(--monitor-text); --shiny-hi: var(--caption); }
.processing-value { margin: 0; min-height: 1.2em; color: var(--caption); font-family: var(--font-display); font-size: clamp(2rem, 5vw, 3.6rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.processing-screen.error .processing-value { color: #ff5c52; font-size: 1rem; font-weight: 500; max-width: 80%; }

/* Znacznik "rozpoznawanie na żywo" przy nagłówku transkrypcji */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  padding: 2px 9px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--caption) 22%, transparent);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
}
.live-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--caption); box-shadow: 0 0 8px var(--caption); animation: blink-dot 1s ease-in-out infinite; }
.segment.live-in { animation: caption-in 0.6s var(--ease-out) both; }

/* Podgląd timestampu: klatka + wypowiedź, zanim klikniesz */
.ts-preview {
  position: fixed;
  z-index: 70;
  width: 214px;
  padding: 7px 7px 9px;
  border-radius: 12px;
  background: rgba(10, 12, 18, 0.96);
  border: 1px solid var(--monitor-line);
  color: var(--monitor-text);
  font-size: 0.8rem;
  line-height: 1.35;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  animation: pop-in 0.22s var(--ease-out);
}
.ts-preview .tip-frame { margin: 0 0 7px; }
.ts-preview b { display: block; margin: 0 2px 2px; color: var(--caption); font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.ts-preview span { display: block; margin: 0 2px; }

/* Wejście nagłówka na stronie głównej: słowa wysuwają się spod linii */
.intro-title .word { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: 0.06em; }
.intro-title .word > span { display: inline-block; }
.intro.intro-animate .intro-title .word > span { animation: word-up 0.85s var(--ease-out) both; animation-delay: calc(var(--w) * 90ms); }
.intro.intro-animate .intro-lead { animation: vt-in 0.7s var(--ease-out) 0.35s both; }
.intro.intro-animate .dropzone { animation: vt-in 0.7s var(--ease-out) 0.47s both; }
.intro.intro-animate .url-form { animation: vt-in 0.7s var(--ease-out) 0.57s both; }
.intro.intro-animate .demo-monitor { animation: monitor-in 0.9s var(--ease-out) 0.2s both; }
@keyframes word-up { from { transform: translateY(105%); } }
@keyframes monitor-in { from { opacity: 0; transform: translateY(24px) scale(0.97); } }
.stage-bars.live span { animation: none; }

/* Status przetwarzania */
.status-box {
  margin-bottom: 16px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.status-line { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; }
.status-percent { font-variant-numeric: tabular-nums; }
.status-message.shiny-text { --shiny-base: var(--text); --shiny-hi: var(--wave); }
.status-box .progress { margin-top: 12px; }
.status-box.error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); }
.status-box.error .status-line { color: var(--danger); }
.status-steps { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 14px 0 0; padding: 0; font-size: 0.82rem; color: var(--muted); }
.status-steps li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px 4px 6px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.status-steps li::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
}
.status-steps li.done { color: var(--text); }
.status-steps li.done::before {
  border: 0;
  background: var(--wave) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 10px no-repeat;
  animation: pop 0.35s var(--ease-spring);
}
.status-steps li.current { color: var(--caption-ink); background: var(--caption); border-color: var(--caption); font-weight: 600; }
.status-steps li.current::before { border-color: var(--caption-ink); border-top-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes pop { from { transform: scale(0.3); } }
#retry-button { margin-top: 12px; }

.tabs { display: none; }
.tab-panel { display: block; }

/* Transkrypcja */
.transcript-card { padding-right: 12px; }
.transcript { max-height: 62vh; overflow-y: auto; padding-right: 8px; }
.transcript:empty::before {
  content: "Tekst pojawi się tutaj linia po linii, gdy tylko ruszy rozpoznawanie mowy.";
  display: block;
  padding: 18px 8px;
  color: var(--muted);
}
.segment {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 7px 10px 7px 12px;
  border-radius: 10px;
  scroll-margin: 80px;
  transition: background 0.3s;
  /* Wydajność: przeglądarka nie rysuje linii poza ekranem (ważne przy transkrypcjach z tysiącami linii). */
  content-visibility: auto;
  contain-intrinsic-size: auto 38px;
}
.segment:hover { background: var(--surface-2); }
.segment::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: var(--caption);
  transform: scaleY(0);
  transition: transform 0.3s var(--ease-out);
}
.segment.active::before { transform: scaleY(1); }
.segment > .timestamp { margin-top: 2px; height: fit-content; }
.segment-text { flex: 1; }
/* Karaoke: w aktywnej linii zaznaczacz "przesuwa się" razem z odtwarzaniem.
   Tło elementu inline przy łamaniu wierszy biegnie w kolejności czytania. */
.segment-line { border-radius: 3px; padding: 1px 1px; -webkit-box-decoration-break: slice; box-decoration-break: slice; }
.segment.active .segment-line {
  background-image: linear-gradient(90deg, var(--marker) var(--p, 0%), var(--marker-ahead) var(--p, 0%));
}
.segment.pulse { animation: row-pulse 1s var(--ease-out); }
@keyframes row-pulse { 0% { background: color-mix(in srgb, var(--caption) 40%, transparent); } 100% { background: transparent; } }
.transcript.reveal .segment { animation: caption-in 0.55s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes caption-in { from { opacity: 0; transform: translateY(8px); filter: blur(3px); } }

/* Podsumowanie i rozdziały */
.summary-card.reveal, #chapters-card.reveal { animation: card-in 0.6s var(--ease-out) both; }
#chapters-card.reveal { animation-delay: 0.12s; }
@keyframes card-in { from { opacity: 0; transform: translateY(12px); } }
.summary-short { font-size: 1.02rem; }
.summary-card p { margin: 0 0 0.6rem; }
.summary-card ul { margin: 0.2rem 0 0; padding-left: 1.2rem; }
.summary-details { margin: 6px 0 14px; padding: 10px 14px; border-radius: 11px; background: var(--surface-2); }
.summary-details summary { cursor: pointer; font-weight: 600; }
.summary-details[open] summary { margin-bottom: 8px; }
.summary-details p { margin: 0 0 0.6rem; }
.key-points-title { display: flex; align-items: center; gap: 8px; margin: 16px 0 8px; }
.key-points-title .icon { color: var(--muted); }
.summary-card .key-points { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.summary-card .key-points li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 9px;
  transition: background 0.15s;
}
.summary-card .key-points li:hover { background: var(--surface-2); }

/* Rozdziały to kolejne części nagrania – numerujemy je jak na osi czasu. */
.chapter-list { position: relative; margin: 0; padding: 0; list-style: none; counter-reset: chapter; }
.chapter-list::before { content: ""; position: absolute; left: 13px; top: 14px; bottom: 14px; width: 2px; background: var(--line); }
.chapter-list li { position: relative; padding: 2px 0 16px 42px; counter-increment: chapter; }
.chapter-list li:last-child { padding-bottom: 2px; }
.chapter-list li::before {
  content: counter(chapter);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--text);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
}
.chapter-list li.current::before { background: var(--caption); border-color: var(--caption); color: var(--caption-ink); }
.chapter-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 2px; }
.chapter-title { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; }
.chapter-description { color: var(--muted); font-size: 0.92rem; }

.summary-notice { color: var(--muted); }
.summary-notice-line { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.summary-notice.error { color: var(--text); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.skeleton-block { margin-top: 6px; }
#summary-short p, #summary-long p { margin: 0 0 0.6rem; }

/* Czat */
.right-column { position: sticky; top: calc(var(--header-height) + 18px); }
.chat {
  display: flex;
  flex-direction: column;
  /* Od góry do dołu ekranu: 18 px odstępu nad (przyklejenie) i pod czatem */
  height: calc(100vh - var(--header-height) - 36px);
  min-height: 460px;
  margin-bottom: 0;
  padding: 18px;
}
.chat-header { display: flex; justify-content: space-between; align-items: center; }
.chat-header h2 { margin: 0; }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 14px 0 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s var(--ease-out);
}
.chip .icon { width: 15px; height: 15px; color: var(--muted); }
.chip:hover { border-color: var(--text); }
.chip:active { transform: scale(0.96); }
.chip:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.chat-notice { margin: 0 0 10px; padding: 9px 12px; border-radius: 11px; font-size: 0.87rem; background: var(--surface-2); color: var(--muted); }
.chat-notice.warning { background: var(--danger-soft); color: var(--text); }

.chat-messages { flex: 1; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding: 6px 4px 6px 2px; }
.chat-empty { margin: auto 0; padding: 20px 16px; color: var(--muted); font-size: 0.92rem; text-align: center; }
.chat-empty p { margin: 0 0 6px; }
.chat-empty .chat-empty-title { color: var(--text); font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; }
.chat-examples { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin-top: 14px; }
.chat-example { white-space: normal; }

.message { max-width: 90%; padding: 10px 14px; border-radius: 15px; overflow-wrap: anywhere; animation: message-in 0.35s var(--ease-out) both; }
@keyframes message-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.message.user { align-self: flex-end; background: var(--bubble-user-bg); color: var(--bubble-user-fg); border-bottom-right-radius: 5px; white-space: pre-wrap; transform-origin: bottom right; }
.message.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; transform-origin: bottom left; }
.message.assistant p { margin: 0 0 0.55rem; }
.message.assistant p:last-child { margin-bottom: 0; }
.message.assistant ul, .message.assistant ol { margin: 0.2rem 0 0.55rem; padding-left: 1.3rem; }
.message.assistant li { margin-bottom: 3px; }
.message.assistant h3, .message.assistant h4 { margin: 0.5rem 0 0.3rem; font-size: 1rem; }
.message.assistant code { padding: 1px 5px; border-radius: 5px; background: var(--surface-3); font-size: 0.9em; }
.message.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

.tool-steps { display: flex; flex-direction: column; gap: 4px; }
.tool-steps:not(:empty) { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px dashed var(--line-strong); }
.tool-step { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.81rem; animation: step-in 0.3s var(--ease-out) both; }
@keyframes step-in { from { opacity: 0; transform: translateX(-6px); } }
.tool-step .spinner { width: 12px; height: 12px; }
.tool-ok { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--wave-soft); color: var(--wave); animation: pop 0.35s var(--ease-spring); }
.tool-ok .icon { width: 11px; height: 11px; stroke-width: 3; }
.tool-failed { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); font-size: 0.7rem; font-weight: 800; }

/* Czekanie na odpowiedź: mała fala zamiast kropek */
.typing { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); }
.typing-bars { display: inline-flex; align-items: center; gap: 2px; height: 16px; }
.typing-bars span { width: 3px; height: 100%; border-radius: 3px; background: var(--wave); animation: bar-dance 0.7s ease-in-out infinite alternate; }
.typing-bars span:nth-child(2) { animation-delay: -0.2s; }
.typing-bars span:nth-child(3) { animation-delay: -0.4s; }
.typing-bars span:nth-child(4) { animation-delay: -0.1s; }
.typing-bars span:nth-child(5) { animation-delay: -0.3s; }

/* Kursor na końcu odpowiedzi, która się jeszcze pisze */
.caret {
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  margin-left: 3px;
  border-radius: 2px;
  background: var(--caption);
  vertical-align: -0.17em;
  animation: caret-blink 0.9s steps(2, start) infinite;
}
@keyframes caret-blink { to { visibility: hidden; } }

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding: 6px 6px 6px 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-form:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.chat-form textarea { min-height: 40px; max-height: 160px; padding: 8px 10px; border: 0; background: transparent; box-shadow: none; resize: none; line-height: 1.45; }
.chat-form textarea:focus { box-shadow: none; }
.send-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 11px;
  background: var(--cta-bg);
  color: var(--cta-fg);
  cursor: pointer;
  transition: transform 0.15s var(--ease-spring), opacity 0.15s;
}
.send-button:hover .icon { transform: translateX(2px); }
.send-button .icon { transition: transform 0.2s var(--ease-out); }
.send-button:active { transform: scale(0.9); }
.send-button.launch .icon { animation: launch 0.45s var(--ease-out); }
@keyframes launch { 50% { transform: translateX(14px); opacity: 0; } 51% { transform: translateX(-14px); opacity: 0; } }
.send-button:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.chat-hint { margin: 6px 4px 0; color: var(--muted); font-size: 0.75rem; text-align: right; }

/* Powiadomienia: na komputerze na górze, na środku – nie zasłaniają czatu (prawa kolumna)
   ani mini-odtwarzacza (lewy dolny róg). Na telefonie na dole (reguła w bloku telefonu). */
.toasts {
  position: fixed;
  top: calc(var(--header-height) + 10px);
  left: 50%;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 11px 16px 11px 12px;
  border-radius: 13px;
  background: #141821;
  color: #f1f3f7;
  box-shadow: 0 16px 36px -14px rgba(10, 12, 18, 0.6);
  font-size: 0.92rem;
  pointer-events: auto;
  animation: toast-in 0.45s var(--ease-spring) both;
}
[data-theme="dark"] .toast { background: #eef1f6; color: #141821; }
.toast-mark { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--caption); }
.toast.success .toast-mark { background: #2ecfbe; }
.toast.error .toast-mark { background: #ff5c52; }
.toast.leaving { animation: toast-out 0.3s var(--ease-out) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(0.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px) scale(0.97); } }
@keyframes toast-in-up { from { opacity: 0; transform: translateY(16px) scale(0.95); } }
@keyframes toast-out-down { to { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* W widoku nagrania powiadomienia stają nad lewą kolumną – czat (prawa kolumna, przyklejony
   przy przewijaniu) nigdy nie jest zasłonięty, także na wąskim ekranie komputera. */
@media (min-width: 901px) {
  #workspace-view:not(.hidden) ~ .toasts { left: calc(50% - 231px); }
}

/* ---------------------------------------------------------------- przejścia między widokami (View Transitions API) */

::view-transition-old(root) { animation: vt-out 0.2s ease both; }
::view-transition-new(root) { animation: vt-in 0.42s var(--ease-out) both; }
html[data-nav="back"]::view-transition-new(root) { animation-name: vt-in-back; }
::view-transition-group(monitor),
::view-transition-group(video-title) { animation-duration: 0.5s; animation-timing-function: var(--ease-out); }
::view-transition-old(monitor), ::view-transition-new(monitor) { height: 100%; object-fit: cover; }
html[data-nav="upload"]::view-transition-old(monitor) { animation: vt-out 0.12s ease both; }
html[data-nav="upload"]::view-transition-new(monitor) { animation: none; }
@keyframes vt-out { to { opacity: 0; transform: scale(0.985); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(18px); } }
@keyframes vt-in-back { from { opacity: 0; transform: translateY(-14px); } }

/* Zmiana motywu: nowy motyw "rozlewa się" kołem od przycisku (animacja w app.js) */
html[data-nav="theme"]::view-transition-old(root),
html[data-nav="theme"]::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* Zapasowe wejście widoku dla przeglądarek bez View Transitions */
/* "backwards", nie "both": animacja trzymana po zakończeniu robiłaby z widoku punkt odniesienia
   dla elementów position: fixed (mini-odtwarzacz wyjeżdżałby poza ekran). */
.view.view-enter { animation: vt-in 0.4s var(--ease-out) backwards; }

/* ---------------------------------------------------------------- telefon: jedna kolumna z zakładkami */

@media (max-width: 900px) {
  .app-header { padding: 0 14px; }
  .view { padding: 14px 12px 30px; }
  .global-alert { width: calc(100% - 24px); }

  .intro { grid-template-columns: 1fr; gap: 26px; padding: 12px 0 30px; }
  .intro-title { font-size: min(2.5rem, 10vw); }
  .intro-lead { font-size: 0.98rem; }
  .demo-monitor { min-height: 300px; }
  .library-view.has-videos .demo-monitor { display: none; }
  .url-form { flex-direction: column; }

  .video-item { gap: 12px; }
  .video-thumb { width: 84px; }
  /* Linia z czasem, datą i statusem nigdy się nie łamie – wiersz ma 2 linie. Gdy brakuje miejsca,
     skraca się data; w trakcie przetwarzania data znika, a skraca się napis statusu.
     Czas trwania, kropka i procent zostają zawsze. */
  .video-item-meta { flex-wrap: nowrap; }
  .video-item-meta .timestamp, .video-status, .video-status::before, .video-status-percent { flex: none; }
  .video-item-date { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .video-item.is-working .video-item-date { display: none; }
  .video-item.is-working .video-status { flex: 0 1 auto; min-width: 0; }
  .video-status-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .video-item-delete { opacity: 1; }

  .workspace { display: block; }
  /* Góra widoku nagrania w jednym rzędzie: przyciski jako ikony, tytuł z wielokropkiem. */
  .workspace-top { flex-wrap: nowrap; gap: 8px; margin-bottom: 12px; }
  .workspace-top .video-title { font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
  .workspace-top .button { padding: 10px; }
  .workspace-top .button-label { display: none; }
  /* Tytuł playlisty nie mieści się na telefonie – zostaje pozycja i strzałki. */
  .workspace-top .playlist-bar-title { display: none; }
  .workspace-top .video-title { min-width: 40px; }
  .workspace-top .title-input { font-size: 1.1rem; min-width: 0; }

  /* Na telefonie monitor przykleja się pod nagłówkiem (slot nie może go ograniczać). */
  .monitor-slot { display: contents; }
  .monitor {
    position: sticky;
    top: var(--header-height);
    z-index: 10;
    margin: 0 -12px 12px;
    border-radius: 0;
  }
  /* Zakładka Czat: czat leży poza kolumną monitora, więc przyklejony monitor byłby ucinany w połowie
     i zasłaniałby zakładki. Monitor zostaje w miejscu, a czat wypełnia ekran pod zakładkami. */
  .workspace-view[data-tab="chat"] .monitor { position: relative; top: auto; }
  /* Klik w timestamp przewija do monitora – zatrzymuje się pod nagłówkiem, nie za nim. */
  .monitor { scroll-margin-top: var(--header-height); }
  .monitor-screen video { max-height: 30vh; }
  .monitor.audio-mode .monitor-screen { padding: 16px 14px 10px; }
  .stage-bars { height: 36px; }
  .timeline { margin: 4px 12px 10px; }
  .vu { display: none; }

  .tabs {
    position: relative;
    display: flex;
    margin-bottom: 12px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
  }
  /* Wskaźnik aktywnej zakładki przesuwa się pod przyciskami */
  .tabs::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc((100% - 8px) / 3);
    border-radius: 10px;
    background: var(--cta-bg);
    transform: translateX(calc(var(--tab-index, 0) * 100%));
    transition: transform 0.4s var(--ease-spring);
  }
  .tab {
    position: relative;
    z-index: 1;
    flex: 1;
    padding: 9px 4px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.25s;
  }
  .tab.active { color: var(--cta-fg); }
  .tab-panel { display: none; }
  .tab-panel.active { display: block; animation: vt-in 0.3s var(--ease-out); }

  .right-column { position: static; }
  .card { padding: 16px; }
  /* 74 px = pasek zakładek z odstępem + margines na dole */
  .chat { height: calc(100vh - var(--header-height) - 74px); height: calc(100dvh - var(--header-height) - 74px); min-height: 360px; padding: 14px; }
  .quick-actions { display: flex; gap: 6px; margin: 8px -14px 6px; padding: 4px 14px; overflow-x: auto; scrollbar-width: none; }
  .quick-actions::-webkit-scrollbar { display: none; }
  .quick-actions .chip { flex: none; }
  .chat-hint { display: none; }
  .transcript { max-height: none; }
  .toasts { top: auto; left: 16px; right: 16px; bottom: 16px; transform: none; }
  /* Zakładka Czat: powiadomienia nad polem pytania, a nie na nim; dotyk przechodzi przez nie. */
  #workspace-view[data-tab="chat"]:not(.hidden) ~ .toasts { bottom: 100px; }
  .toast { pointer-events: none; }
  .toast { animation-name: toast-in-up; }
  .toast.leaving { animation-name: toast-out-down; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- role: admin / odwiedzający ---------- */
body:not(.is-admin) .admin-only { display: none !important; }
body:not(.public-mode) .public-only { display: none !important; }
.workspace-view.read-only .owner-only { display: none !important; }

.admin-view { display: grid; place-items: center; min-height: calc(100vh - var(--header-height) - 80px); }
.admin-card { width: min(420px, 100%); display: grid; gap: 12px; padding: 28px; }
.admin-card h1 { margin: 0; font-family: var(--font-display); font-size: 1.5rem; }
.admin-card input {
  font: inherit; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
}
.muted { color: var(--muted); margin: 0; }

/* ---------- playlisty ---------- */
.playlists-section { margin-top: 28px; }
.playlists-section .section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 12px; }
.playlist-card {
  display: grid; gap: 8px; text-align: left; padding: 0 0 14px; overflow: hidden; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font: inherit; box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.playlist-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.playlist-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.playlist-cover { aspect-ratio: 16 / 9; background: var(--monitor); display: grid; place-items: center; overflow: hidden; }
.playlist-cover img { width: 100%; height: 100%; object-fit: cover; }
.playlist-card-title { padding: 0 14px; font-family: var(--font-display); font-size: 1.05rem; }
.playlist-card-meta { padding: 0 14px; color: var(--muted); font-size: 0.85rem; }

.playlist-header { margin: 18px 0 20px; }
.playlist-header h1 { margin: 0 0 6px; font-family: var(--font-display); font-size: clamp(1.5rem, 3vw, 2.2rem); }
.playlist-meta { color: var(--muted); font-size: 0.9rem; margin: 6px 0 0; }
.playlist-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.playlist-item {
  display: grid; grid-template-columns: 2.2em 132px 1fr auto; align-items: center; gap: 14px;
  padding: 10px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); cursor: pointer;
}
.playlist-item:hover { border-color: var(--line-strong); }
.playlist-item-index { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.playlist-item .video-thumb { width: 132px; }
.playlist-item-teaser { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.playlist-item-tools { display: flex; gap: 4px; }
.playlist-editor, .playlist-picker { display: grid; gap: 8px; padding: 18px; margin-bottom: 18px; }
.playlist-editor input, .playlist-editor textarea {
  font: inherit; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
}
.editor-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 6px; }
.picker-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.picker-list label { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.playlist-bar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; font-size: 0.9rem; color: var(--muted); }
.playlist-bar-title { color: inherit; font-weight: 600; text-decoration: none; max-width: 22ch; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.playlist-bar-title:hover { text-decoration: underline; }
.button .icon.flip, .flip .icon { transform: scaleX(-1); }
.visitor-tag { font-size: 0.75rem; padding: 1px 7px; border-radius: 999px; background: var(--wave-soft); color: var(--wave); }

/* ---------- szukanie we wszystkich nagraniach ---------- */
.search-section { margin: 8px 0 24px; }
.search-box input { width: 100%; }
.library-view.searching .playlists-section,
.library-view.searching .library-section { display: none !important; }
.search-result-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
.search-result { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); min-width: 0; }
.search-result-header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.search-result-title { font: inherit; font-weight: 600; background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.search-result-title:hover { text-decoration: underline; }
.search-result-count { color: var(--muted); font-size: 0.9em; }
.search-hits { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.search-hit { display: flex; gap: 10px; align-items: baseline; width: 100%; text-align: left; font: inherit; background: none; border: 0; padding: 6px 8px; border-radius: var(--radius-sm); color: inherit; cursor: pointer; }
.search-hit:hover, .search-hit:focus-visible { background: var(--surface-2); }
.search-hit .timestamp { flex: none; }
.search-hit-text { min-width: 0; overflow-wrap: anywhere; }
.search-hit mark { background: var(--marker); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-empty, .search-more { margin: 14px 0 0; }

@media (max-width: 640px) {
  .playlist-item { grid-template-columns: 1.6em 88px 1fr; }
  .playlist-item .video-thumb { width: 88px; }
  .playlist-item-tools { grid-column: 1 / -1; justify-content: flex-end; }
}
.rotate-up .icon { transform: rotate(90deg); }
.rotate-down .icon { transform: rotate(-90deg); }

.chat-limit-info { color: var(--muted); font-size: 0.82rem; margin: 4px 0 0; }
.dropzone.disabled { opacity: 0.5; pointer-events: none; }

/* ---------- "Wypróbuj na przykładowym nagraniu" ---------- */
.try-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin: 0 0 20px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.try-copy { min-width: 0; }
.try-card h2 { margin: 0 0 4px; font-size: 1.1rem; }
.try-card p { margin: 0; }
#feature-button.active .icon { fill: currentColor; }
.feature-hint { margin: 4px 0 8px; font-size: 0.9em; }
