/* ----- Retro DOS player ----- */
:root {
    --dos-bg:     #0e1cad;
    --dos-bg2:    #0a14a0;
    --dos-fg:     #ffffff;
    --dos-dim:    rgba(255,255,255,.55);
    --dos-line:   rgba(255,255,255,.85);
    --dos-hover:  rgba(255,255,255,.10);
    --dos-active: rgba(255,255,255,.18);
    --dos-warn:   #ffd54a;
    --dos-err:    #ff5b6e;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background:
        radial-gradient(ellipse at center, #1226c8 0%, var(--dos-bg) 60%, #08106e 100%);
    color: var(--dos-fg);
    font-family: 'VT323', 'IBM Plex Mono', 'Courier New', ui-monospace, monospace;
    font-size: 22px;
    line-height: 1.1;
    letter-spacing: .02em;
    -webkit-font-smoothing: none;
    text-rendering: geometricPrecision;
    overflow: hidden;
}

/* subtelne scanlines + winieta dla CRT-feel */
body::before {
    content: '';
    position: fixed; inset: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(to bottom,
            rgba(0,0,0,0) 0px,
            rgba(0,0,0,0) 2px,
            rgba(0,0,0,.18) 3px,
            rgba(0,0,0,0) 4px);
    z-index: 10;
    mix-blend-mode: multiply;
}
body::after {
    content: '';
    position: fixed; inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.45) 100%);
    z-index: 11;
}

a { color: var(--dos-fg); }

/* ----- Main layout ----- */
.dos {
    max-width: 980px;
    margin: 0 auto;
    padding: 14px 18px 8px;
    height: 100vh;
    height: 100dvh; /* dvh: zawsze rzeczywista wysokość okna na mobilkach z dynamic toolbarami */
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.dos-titlebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--dos-line);
    padding: 2px 10px 6px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.dos-main {
    display: grid;
    grid-template-columns: 1fr 1.45fr;
    gap: 0;
    flex: 1;
    min-height: 0; /* żeby playlist mogła scrollować w obrębie flex parent */
    border-bottom: 2px solid var(--dos-line);
}

/* Linia rozdzielająca kolumny */
.dos-main > .dos-playlist {
    border-right: 2px solid var(--dos-line);
}

/* Sekcje */
.dos-section {
    padding: 8px 14px 10px;
}
.dos-section + .dos-section {
    border-top: 2px solid var(--dos-line);
}
.dos-sec-title {
    text-transform: uppercase;
    margin: 0 0 8px;
    font-weight: normal;
    font-size: inherit;
    letter-spacing: .04em;
}

.dos-marquee {
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}
.dos-marquee .inner {
    display: inline-block;
    padding-right: 2em;
}
.dos-marquee.scrolling .inner {
    padding-left: 100%;
    animation: dos-marquee var(--marquee-dur, 14s) linear infinite;
}
@keyframes dos-marquee {
    from { transform: translateX(0); }
    to   { transform: translateX(-100%); }
}

/* ----- Playlist ----- */
.dos-playlist { display: flex; flex-direction: column; min-height: 0; }
.dos-playlist .tracks {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--dos-line) transparent;
    scrollbar-gutter: stable;
}
.dos-playlist .tracks::-webkit-scrollbar { width: 8px; }
.dos-playlist .tracks::-webkit-scrollbar-thumb {
    background: var(--dos-line);
}
.dos-playlist .tracks::-webkit-scrollbar-track { background: transparent; }

/* Prawa kolumna: now + viz + controls — wszystkie nie-rosnące */
.dos-right { display: flex; flex-direction: column; min-height: 0; }
.dos-playlist .tr {
    display: grid;
    grid-template-columns: 1.2em 1fr auto;
    align-items: baseline;
    padding: 2px 12px 2px 4px;  /* zarezerwowane miejsce po prawej na scrollbar */
    cursor: pointer;
    text-transform: uppercase;
}
.dos-playlist .tr:hover { background: var(--dos-hover); }
.dos-playlist .tr.active {
    background: var(--dos-fg);
    color: var(--dos-bg);
}
.dos-playlist .tr.active .marker::before { content: '\25B6'; } /* ▶ */
.dos-playlist .marker { width: 1.2em; }
.dos-playlist .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.dos-playlist .time  { font-variant-numeric: tabular-nums; }
.dos-playlist .dl-btn {
    display: inline-block;
    color: var(--dos-dim);
    text-decoration: none;
    font-size: .75em;
    padding: 0 4px;
    flex-shrink: 0;
    line-height: 1;
    opacity: 0;
    transition: opacity .15s;
}
.dos-playlist .tr:hover .dl-btn { opacity: 1; }
.dos-playlist .dl-btn:hover { color: var(--dos-fg); }

.dos-dl-album {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    text-decoration: none;
    font-size: .85em;
    width: auto;
}

/* ----- Now playing ----- */
.dos-now {
    display: flex; flex-direction: column; gap: 4px;
}
.dos-now .marquee {
    display: grid;
    grid-template-columns: 1.2em 1fr auto;
    margin-bottom: 6px;
}
.dos-now .marquee .title {
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 12px;
}
.dos-now .row {
    display: flex;
    justify-content: space-between;
    text-transform: uppercase;
}
.dos-now .row .lbl { color: var(--dos-dim); }
.dos-now .row .val { font-variant-numeric: tabular-nums; }

/* ----- Visualization ----- */
.dos-section-viz {
    display: flex;
    align-items: stretch;
    gap: 12px;
}
.dos-section-viz .dos-viz-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.dos-section-viz .dos-vis-bars { flex: 0 0 auto; }
.dos-vis-head-box {
    flex: 0 0 auto;
    align-self: flex-end;     /* przyklejona do dolnej krawędzi sekcji */
    /* wysokość = tytuł "VISUALIZATION" (font-size+margin-bottom 8px) + bars 80px */
    height: calc(1em + 8px + 80px);
    aspect-ratio: 1 / 1;
    display: block;
}
.dos-vis-head {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
    pointer-events: none;
    display: block;
}
.dos-vis-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 80px;
    padding: 6px 0 4px;
    overflow: hidden;
}
.dos-vis-bars .bar {
    flex: 1;
    min-height: 2px;
    max-height: 100%;
    background:
        repeating-linear-gradient(
            to bottom,
            var(--dos-fg) 0 6px,
            transparent 6px 8px
        );
    transition: height .08s linear;
}

/* ----- Controls ----- */
.dos-controls {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    padding-top: 6px;
}
.dos-btn {
    background: transparent;
    color: var(--dos-fg);
    border: 2px solid var(--dos-fg);
    padding: 6px 4px 4px;
    text-align: center;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-transform: uppercase;
    line-height: 1;
}
.dos-btn:hover, .dos-btn:focus { background: var(--dos-fg); color: var(--dos-bg); outline: none; }
.dos-btn:disabled { opacity: .35; cursor: not-allowed; }
.dos-btn .glyph {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    line-height: 1;
    margin-bottom: 2px;
    white-space: nowrap;
    letter-spacing: -0.05em;
    font-variant-emoji: text;
    font-family: 'VT323', 'IBM Plex Mono', 'Courier New', ui-monospace, monospace;
}
.dos-btn .glyph svg {
    width: 1.2em;
    height: 1.2em;
    fill: currentColor;
    display: block;
}
.dos-btn[data-active="true"] {
    background: var(--dos-fg);
    color: var(--dos-bg);
}

/* Seek (transport bar) */
.dos-seek-wrap {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 0 0;
}
.dos-seek-wrap .t { font-variant-numeric: tabular-nums; }
.dos-seek {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 16px;
    background: transparent;
    margin: 0;
}
.dos-seek::-webkit-slider-runnable-track {
    height: 14px;
    background:
        repeating-linear-gradient(to right,
            var(--dos-fg) 0 6px,
            transparent 6px 8px);
    border: 1px solid var(--dos-fg);
}
.dos-seek::-moz-range-track {
    height: 14px;
    background:
        repeating-linear-gradient(to right,
            var(--dos-fg) 0 6px,
            transparent 6px 8px);
    border: 1px solid var(--dos-fg);
}
.dos-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px; height: 22px;
    background: var(--dos-fg);
    border: 2px solid var(--dos-bg);
    margin-top: -4px;
}
.dos-seek::-moz-range-thumb {
    width: 14px; height: 22px;
    background: var(--dos-fg);
    border: 2px solid var(--dos-bg);
    border-radius: 0;
}

/* ----- Status bar ----- */
.dos-statusbar {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px 0;
    text-transform: uppercase;
    color: var(--dos-fg);
    flex-shrink: 0;
}
.dos-statusbar kbd {
    background: transparent;
    color: var(--dos-fg);
    font-family: inherit;
    font-size: inherit;
    padding: 0;
}

/* ----- Error screen (token problemy) ----- */
.dos-error {
    margin: 40px auto;
    max-width: 520px;
    border: 2px solid var(--dos-fg);
    padding: 18px 22px;
}
.dos-error h1 {
    margin: 0 0 10px;
    font-size: 1.2em;
    text-transform: uppercase;
    border-bottom: 2px solid var(--dos-fg);
    padding-bottom: 6px;
}
.dos-error p { margin: 6px 0; }
.dos-error .blink {
    animation: dos-blink 1s steps(2) infinite;
}
@keyframes dos-blink { 50% { opacity: 0; } }

/* ----- Legal footer ----- */
.dos-legal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: .55em;
    color: var(--dos-dim);
    padding: 4px 16px;
    background: var(--dos-bg2);
    border-top: 1px solid rgba(255,255,255,.15);
    z-index: 20;
    letter-spacing: .04em;
}
.dos-legal a { color: var(--dos-dim); text-decoration: none; }
.dos-legal a:hover { color: var(--dos-fg); }

/* Strony prawne (regulamin, polityka prywatności) */
body.legal-page { overflow: auto; }
.dos-page {
    max-width: 820px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}
.dos-page .back {
    display: inline-block;
    margin-bottom: 18px;
    font-size: .68em;
    color: var(--dos-dim);
    text-decoration: none;
}
.dos-page .back:hover { color: var(--dos-fg); }
.dos-page h1 {
    font-size: 1.15em;
    border-bottom: 2px solid var(--dos-fg);
    padding-bottom: 6px;
    margin: 0 0 18px;
}
.dos-page h2 {
    font-size: .95em;
    color: var(--dos-warn);
    margin: 22px 0 6px;
}
.dos-page p,
.dos-page li {
    font-size: .7em;
    line-height: 1.75;
    color: rgba(255,255,255,.85);
    margin: 4px 0;
}
.dos-page ul, .dos-page ol { padding-left: 22px; }
.dos-page a { color: var(--dos-warn); }

/* ----- Install prompt (PWA) ----- */
.dos-install-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
    padding: 8px 12px 6px;
    background: var(--dos-fg);
    color: var(--dos-bg);
    border: none;
    font-family: inherit;
    font-size: 1em;
    text-transform: uppercase;
    cursor: pointer;
    letter-spacing: .04em;
    flex-shrink: 0;
}
.dos-install-btn:active { opacity: 0.85; }
.dos-install-btn .glyph {
    display: inline-block;
    border: 2px solid var(--dos-bg);
    padding: 0 6px;
    font-weight: bold;
    line-height: 1;
}

.dos-install-help {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 60;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
/* Atrybut hidden ma zostać silniejszy niż display: flex/inline-block powyżej */
.dos-install-help[hidden],
.dos-install-btn[hidden] { display: none !important; }
.dos-install-box {
    background: var(--dos-bg);
    color: var(--dos-fg);
    border: 2px solid var(--dos-fg);
    padding: 18px 22px;
    max-width: 460px;
    width: 100%;
}
.dos-install-box h3 {
    margin: 0 0 12px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--dos-fg);
    padding-bottom: 6px;
    font-weight: normal;
    font-size: 1.1em;
    letter-spacing: .04em;
}
.dos-install-box ol { padding-left: 20px; margin: 0 0 10px; }
.dos-install-box li { margin: 6px 0; }
.dos-install-box .ios-share {
    display: inline-block;
    font-size: 1.4em;
    line-height: 1;
    vertical-align: -3px;
}
.dos-install-box .hint {
    margin: 6px 0 14px;
    color: var(--dos-dim);
    font-size: 0.9em;
}
.dos-install-box .dos-btn { width: 100%; padding: 8px; }

/* ----- Responsive ----- */
@media (max-width: 760px) {
    body { font-size: 17px; }
    .dos { padding: 8px 10px 4px; }
    .dos-statusbar { display: none; }
    .dos-main { border-bottom: none; }
    .dos-section { padding: 6px 10px 8px; }
    .dos-sec-title { margin-bottom: 4px; }

    .dos-main {
        grid-template-columns: 1fr;
        /* prawa kolumna (now+viz+controls) — auto; playlist na końcu, rośnie i scrolluje */
        grid-template-rows: auto 1fr;
    }
    .dos-main > .dos-right       { order: 1; border-bottom: 2px solid var(--dos-line); }
    .dos-main > .dos-playlist {
        order: 2;
        border-right: none;
        min-height: 0;
    }

    /* Na mobile: zostawiamy tylko tytuł utworu + elapsed */
    .dos-now .row-bitrate,
    .dos-now .row-status { display: none; }

    .dos-vis-bars { height: 56px; }
    /* tytuł na mobile ma margin-bottom 4px (z .dos-sec-title override) + bars 56 */
    .dos-vis-head-box { height: calc(1em + 4px + 56px); }

    .dos-controls { grid-template-columns: repeat(5, 1fr); gap: 6px; }
    .dos-controls .dos-btn:nth-child(6),
    .dos-controls .dos-btn:nth-child(7) { display: none; }
    .dos-btn { padding: 4px 2px 3px; }
    .dos-btn .glyph { font-size: 1.3em; }
}

/* ----- Resume prompt (Android Chrome autoplay block) ----- */
.dos-resume-prompt {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 9999;
    background: var(--dos-bg);
    color: var(--dos-fg);
    border: 2px solid var(--dos-fg);
    padding: 12px 22px;
    font-family: inherit;
    font-size: 1em;
    letter-spacing: .1em;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,.6);
    text-transform: uppercase;
}
.dos-resume-prompt:hover { background: var(--dos-fg); color: var(--dos-bg); }
.dos-resume-prompt[hidden] { display: none !important; }
.dos-resume-prompt .glyph { font-size: 1.2em; margin-right: 6px; }

/* ----- Browser compatibility banner ----- */
.compat-banner {
    position: relative;
    z-index: 9998;
    background: #ffd60a;
    color: #000;
    border-bottom: 3px solid #000;
    padding: 14px 18px;
    text-align: center;
    font-family: 'VT323', 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 1em;
    line-height: 1.35;
    letter-spacing: .03em;
}
.compat-banner-hard {
    background: #ff453a;
    color: #fff;
    border-color: #fff;
}
.compat-banner strong { display: inline-block; margin-bottom: 4px; }
.compat-btn {
    display: inline-block;
    margin: 8px 6px 0;
    background: #000;
    color: #ffd60a;
    border: 2px solid #000;
    padding: 6px 14px;
    font-family: inherit;
    font-size: .9em;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.compat-banner-hard .compat-btn { background: #fff; color: #ff453a; border-color: #fff; }
.compat-btn:hover { background: #fff; color: #000; }
