/* ══════════════════════════════════════
   LyricEar — styles.css  v7
   ══════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #0e0b1a;
  --surface: #1a1528;
  --card:    #231d35;
  --border:  #362e50;
  --text:    #e8e0f0;
  --muted:   #9a8eba;
  --accent:  #a855f7;
  --accent2: #c084fc;
  --good:    #22c55e;
  --bad:     #ef4444;
  --warn:    #f59e0b;
  --radius:  10px;
}

html { background: var(--bg); color: var(--text); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Utility ── */
.mini  { font-size: 0.78rem; }
.mono  { font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace; }
.muted { color: var(--muted); }

.pill {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.hint { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

/* ── Buttons ── */
button {
  font: inherit; cursor: pointer; border: none;
  border-radius: var(--radius); padding: 10px 18px;
  transition: background .15s, opacity .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: .35; cursor: default; }

.primary          { background: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: #9333ea; }
.ghost            { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.ghost:hover:not(:disabled)   { background: var(--border); }
.bad              { background: var(--bad); color: #fff; }
.bad:hover:not(:disabled)     { background: #dc2626; }
.tiny             { font-size: .82rem; padding: 5px 10px; }
.btn-primary      { background: var(--accent); color: #fff; }
.btn-good         { background: var(--good); color: #fff; }
.btn-reveal       { font-size: .78rem; padding: 3px 8px; }

.pulse { animation: pulse-glow 1.2s ease-in-out infinite; }
@keyframes pulse-glow {
  0%,100% { box-shadow: 0 0 4px var(--accent); }
  50%     { box-shadow: 0 0 18px var(--accent), 0 0 40px rgba(168,85,247,.3); }
}

/* ═══ Logo ═══ */
.logo-bar { transition: transform .3s, opacity .3s; }
.logo-bar.hidden { transform: translateY(-100%); opacity: 0; pointer-events: none; }

.logo-link {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit; margin-bottom: 12px;
  transition: opacity 150ms ease;
}
.logo-link:hover { opacity: 0.85; }
.logo-svg { flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; gap: 1px; }
.logo-name {
  font-size: 18px; font-weight: 800;
  background: linear-gradient(135deg, #c084fc, #22d3ee, #34d399);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; line-height: 1.15;
}
.logo-sub { font-size: 11px; color: #71717a; letter-spacing: 0.5px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 10px 20px; border-radius: var(--radius);
  font-size: .88rem; opacity: 0; pointer-events: none;
  transition: transform .3s, opacity .3s;
  z-index: 9999; text-align: center; max-width: 92vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast small { display: block; color: var(--muted); margin-top: 2px; }

/* ── Song header ── */
.song-header { padding: 16px 4px 8px; }
.song-header h1 { font-size: 1.5rem; color: var(--accent2); }
.song-header p  { color: var(--muted); font-size: .95rem; }

/* ── Panel ── */
.panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 10px;
}

/* ══════════════════════════════════════
   Two-column layout
   ══════════════════════════════════════ */
.main-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.col-player {
  flex: 0 0 380px;
  min-width: 0;
}

.col-lines {
  flex: 1 1 0;
  min-width: 0;
}

/* ══════════════════════════════════════
   Sticky block — player + spectrogram
   ══════════════════════════════════════ */
.sticky-block {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
}

/* ── Player ── */
.player-panel { padding: 10px; }

/* ── Video wrap ── */
.video-wrap {
  position: relative; width: 100%;
  border-radius: var(--radius); background: #000;
  overflow: hidden;
}
.video-wrap.is-video { aspect-ratio: 16 / 9; }
.video-wrap.is-video video {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 60%;
  display: block;
}
.video-wrap.is-audio { height: auto; overflow: visible; }
.video-wrap.is-audio video { display: none; }

/* Timecode overlay — bottom right of video */
.video-timecode {
  position: absolute;
  bottom: 6px; right: 8px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.5);
  padding: 1px 6px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
  display: none;
}
.video-wrap.is-video .video-timecode { display: block; }

/* Play overlay */
.video-wrap .play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.25);
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
  font-size: 2rem; width: auto; height: auto;
  border-radius: 0; border: none;
  color: #fff;
}
.video-wrap.paused .play-overlay { opacity: 1; pointer-events: auto; }

/* ── Overlay progress bar (seek) ── */
.overlay-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  display: flex;
  align-items: flex-end;
  z-index: 3;
  padding: 0 4px 2px;
}

.overlay-progress input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 0;
  padding: 0;
  cursor: pointer;
  accent-color: var(--accent);
  opacity: 0.7;
  transition: opacity 0.2s, height 0.2s;
}

.overlay-progress input[type="range"]:hover {
  opacity: 1;
  height: 6px;
}

/* Для audio — ползунок видимый отдельной строкой */
.video-wrap.is-audio .overlay-progress {
  position: relative;
  height: 24px;
  padding: 8px 0 0;
}

/* ── Media source (collapsible after load) ── */
.media-source {
  margin-top: 8px;
  transition: max-height .3s ease, opacity .3s ease, margin .3s ease;
  max-height: 120px; opacity: 1; overflow: hidden;
}
.media-source.collapsed {
  max-height: 0; opacity: 0; margin: 0; pointer-events: none;
}

.media-btns {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}

/* ── Play row (HIDDEN — replaced by overlay seek) ── */
.play-row {
  display: none;
}

/* ── Lamp ── */
.lamp { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.lamp-off   { background: #555; }
.lamp-green { background: var(--good); box-shadow: 0 0 6px var(--good); }
.lamp-red   { background: var(--bad);  box-shadow: 0 0 6px var(--bad); }

/* ── Segment controls ── */
.seg-status { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.seg-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.toggle-row {
  display: flex; flex-wrap: wrap; gap: 12px 20px;
  margin-top: 10px; font-size: .92rem;
}
.toggle-row label {
  display: flex; align-items: center; gap: 5px;
  cursor: pointer; user-select: none;
}

/* ── Lines ── */
.lines { display: flex; flex-direction: column; gap: 6px; }

.line {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.line:hover { border-color: var(--accent); }
.line.active {
  border-color: var(--accent); background: var(--card);
  box-shadow: inset 3px 0 0 var(--accent);
}
.line.learned { border-left: 3px solid var(--good); }

.line-header { display: flex; align-items: center; gap: 8px; }
.line-num { font-size: .75rem; color: var(--muted); min-width: 22px; text-align: center; }

.user-heard {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font: inherit; font-size: .95rem;
  padding: 6px 10px; outline: none; transition: border-color .15s;
}
.user-heard:focus { border-color: var(--accent); }
.user-heard::placeholder { color: var(--muted); opacity: .6; }

.orig-row { margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.orig-text { font-weight: 600; color: var(--accent2); }

.sub { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.sub.visible { max-height: 400px; }
.subCard { margin-top: 6px; padding: 8px 10px; background: var(--bg); border-radius: 6px; font-size: .9rem; }
.phon-author { color: var(--warn); }
.line-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ── Save indicator ── */
.save-indicator { font-size: 1.4rem; opacity: .3; transition: opacity .3s; }
.save-indicator.flash { opacity: 1; }

/* ── Page footer ── */
.page-footer { margin-top: 24px; padding: 16px 4px; text-align: center; }

/* ── Storage banner ── */
#storageBanner {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 12px 16px; display: flex; align-items: center;
  gap: 12px; flex-wrap: wrap; font-size: .85rem; z-index: 10000;
}
#storageBanner button {
  background: var(--accent); color: #fff; padding: 6px 16px;
  border-radius: 6px; white-space: nowrap;
}

/* ══════════════════════════════════════
   Spectrogram
   ══════════════════════════════════════ */
.spec-panel { padding: 8px 10px 10px; }

.spec-toolbar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px; flex-wrap: wrap;
}

.spec-zoom-btn {
  width: 44px; height: 44px; font-size: 22px; font-weight: 700;
  line-height: 1; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.spec-wrap {
  position: relative; width: 100%; height: 100px;
  border-radius: 8px; overflow: hidden;
  background: #0a0818; transition: height .25s ease;
}
.spec-wrap.collapsed { height: 0; overflow: hidden; }
.spec-wrap canvas { display: block; width: 100%; height: 100%; }

/* ══════════════════════════════════════
   Home / Catalog
   ══════════════════════════════════════ */
.catalog-bar {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.catalog-bar input,
.catalog-bar select {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 8px 12px;
  font: inherit; font-size: .95rem; outline: none;
}
.catalog-bar input:focus,
.catalog-bar select:focus { border-color: var(--accent); }
.catalog-bar input { flex: 1; min-width: 160px; }

.songCard {
  display: block; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px;
  color: var(--text); text-decoration: none; transition: border-color .15s;
}
.songCard:hover { border-color: var(--accent); text-decoration: none; }
.songTitle { font-weight: 600; font-size: 1.1rem; color: var(--accent2); }
.songMeta  { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.songSmall { font-size: .85rem; color: var(--muted); margin-top: 4px; }

/* ══════════════════════════════════════
   Keyboard shortcuts help
   ══════════════════════════════════════ */
.kbd-help {
  margin-top: 8px; padding: 8px 10px;
  background: var(--bg); border-radius: 6px;
  font-size: .78rem; color: var(--muted);
  line-height: 1.7;
}
.kbd-help kbd {
  display: inline-block;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px;
  font-family: monospace; font-size: .82rem; color: var(--text);
}

/* ══════════════════════════════════════
   RESPONSIVE: single column ≤ 800px
   ══════════════════════════════════════ */
   /* ══════════════════════════════════════
      RESPONSIVE: single column ≤ 800px
         Sticky прилипает к main-layout,
            который содержит и player, и lines
               ══════════════════════════════════════ */
               @media (max-width: 800px) {
                 body { max-width: 720px; }

                   .main-layout {
                       display: block;          /* не flex — один поток */
                           position: relative;      /* sticky-контекст */
                             }

                               .col-player {
                                   display: contents;       /* ← магия: убирает обёртку из потока */
                                     }

                                       .col-lines {
                                           width: 100%;
                                             }

                                               .sticky-block {
                                                   position: sticky;
                                                       top: 0;
                                                           z-index: 100;
                                                               background: var(--bg);
                                                                   padding-bottom: 4px;
                                                                     }

                                                                       /* seg-panel — просто идёт потоком между sticky и lines */
                                                                         .seg-panel {
                                                                             position: relative;
                                                                                 z-index: 50;
                                                                                   }
                                                                                   }

/* ══════════════════════════════════════
   MOBILE COMPACT  (max-width: 600px)
   ══════════════════════════════════════ */
@media (max-width: 600px) {

  button {
    padding: 5px 12px;
    font-size: 0.78rem;
    line-height: 1.2;
  }
  .tiny { font-size: 0.7rem; padding: 3px 7px; }
  .btn-reveal { font-size: 0.7rem; padding: 2px 7px; }
  .pill { padding: 1px 7px; font-size: 0.72rem; }

  #btnPlay { width: 34px; height: 34px; font-size: 17px; }

  .spec-zoom-btn { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }
  #specZoomLabel { font-size: 0.72rem; }

  .media-btns { gap: 5px; }
  #mediaName { font-size: 0.72rem; }

  .lamp { width: 8px; height: 8px; }

  .player-panel { padding: 6px; }
  .spec-panel   { padding: 5px 6px 6px; }
  .panel        { padding: 8px; margin-bottom: 6px; }

  .seg-status  { gap: 3px; margin-bottom: 4px; }
  .seg-buttons { gap: 4px; }

  .toggle-row { gap: 6px 12px; margin-top: 6px; font-size: 0.76rem; }
  .toggle-row label { font-size: 0.74rem; gap: 3px; }

  .line { padding: 7px 8px; }
  .line-header { gap: 5px; }
  .line-num { font-size: 0.68rem; min-width: 18px; }
  .user-heard { font-size: 0.84rem; padding: 4px 7px; }
  .orig-row { margin-top: 3px; gap: 5px; }
  .orig-text { font-size: 0.88rem; }
  .subCard { padding: 5px 7px; font-size: 0.8rem; margin-top: 3px; }
  .line-actions { gap: 3px; margin-top: 5px; }

  .song-header { padding: 10px 4px 5px; }
  .song-header h1 { font-size: 1.2rem; }
  .song-header p  { font-size: 0.85rem; }

  .spec-wrap { height: 80px; }
  .spec-toolbar { gap: 5px; margin-bottom: 3px; }

  .save-indicator { font-size: 1.1rem; }

  #storageBanner { padding: 8px 12px; font-size: 0.78rem; gap: 8px; }
  #storageBanner button { padding: 4px 12px; font-size: 0.78rem; }

  .kbd-help { font-size: .7rem; padding: 6px 8px; }
  .kbd-help kbd { font-size: .74rem; padding: 0px 4px; }
}

@media (min-width: 700px) {
  .spec-wrap { height: 130px; }
}

/* ══════════════════════════════════════
   Desktop two-column layout (≥ 900px)
   ══════════════════════════════════════ */
@media (min-width: 900px) {
  .main-layout {
    display: flex;
    align-items: flex-start;
  }
  .col-player {
    position: sticky;
    top: 0;
    flex-shrink: 0;
  }
  .sticky-block {
    position: static;
  }
}