/* Style glownego interfejsu: layout, zakladki, listy wideo i widok mobilny. */
:root {
    --bg: #f7f7f4;
    --panel: #ffffff;
    --ink: #1e2428;
    --muted: #66717a;
    --line: #dce0df;
    --accent: #0e7c6b;
    --accent-dark: #085e52;
    --warn: #a15c00;
    --bad: #a3323a;
    --good: #1c7b48;
    --soft: #eef4f2;
    --shadow: 0 18px 40px rgba(36, 43, 47, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: linear-gradient(180deg, #f0f3f1 0, var(--bg) 270px);
    color: var(--ink);
    font: 15px/1.45 "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    min-height: 40px;
    padding: 0 16px;
    font-weight: 650;
}

button:hover {
    background: var(--accent-dark);
}

button:disabled {
    cursor: wait;
    opacity: .58;
}

button.secondary {
    background: #eef2f0;
    color: #233033;
    border: 1px solid var(--line);
}

button.secondary:hover {
    background: #e1e8e5;
}

.icon-button {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 42px;
    min-width: 42px;
    min-height: 40px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
}

.link-form .icon-button {
    width: 46px;
    min-width: 46px;
    min-height: 46px;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 9px);
    z-index: 10000;
    transform: translateX(-50%) translateY(4px);
    pointer-events: none;
    white-space: nowrap;
    border-radius: 6px;
    background: #1e2428;
    color: #fff;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 650;
    opacity: 0;
    transition: opacity .12s ease, transform .12s ease;
}

[data-tooltip] {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
    user-select: none;
}

[data-tooltip]::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 4px);
    z-index: 10001;
    transform: translateX(-50%) translateY(4px);
    border: 5px solid transparent;
    border-top: 0;
    border-bottom-color: #1e2428;
    opacity: 0;
    transition: opacity .12s ease, transform .12s ease;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::after,
[data-tooltip]:focus-visible::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

body.touch-tooltip-mode [data-tooltip]::after,
body.touch-tooltip-mode [data-tooltip]::before,
.touch-tooltip-mode [data-tooltip]::after,
.touch-tooltip-mode [data-tooltip]::before {
    display: none !important;
}

@media (hover: none), (pointer: coarse) {
    [data-tooltip]::after,
    [data-tooltip]::before {
        display: none !important;
    }
}

.touch-tooltip-floating {
    position: fixed;
    z-index: 2147483647;
    max-width: min(260px, calc(100vw - 24px));
    border-radius: 6px;
    background: #1e2428;
    color: #fff;
    padding: 7px 9px;
    font-size: 12px;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .24);
}

.shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.topbar,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.topbar {
    margin-bottom: 22px;
}

.tabbar {
    position: relative;
    z-index: 5000;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .72);
    box-shadow: var(--shadow);
}

.tab-button {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 44px;
    min-width: 44px;
    min-height: 42px;
    padding: 0;
    border: 1px solid #cfd6d3;
    border-radius: 7px;
    background: #ecefed;
    color: #2f3a3f;
    font-size: 20px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .75) inset, 0 1px 2px rgba(36, 43, 47, .06);
}

.tab-button:hover {
    background: #e1e8e5;
    color: var(--accent-dark);
}

.tab-button.active {
    background: var(--accent);
    color: #fff;
}

.tab-view {
    display: none;
}

.tab-view.active {
    display: block;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: 34px;
    line-height: 1.1;
}

h2 {
    font-size: 22px;
    line-height: 1.2;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0;
    text-transform: uppercase;
}

.status-strip,
.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pill,
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

.pill.neutral,
.status-pill {
    background: #ecefed;
    color: #394348;
}

.pill.good,
.status-done {
    background: #e4f3ea;
    color: var(--good);
}

.pill.bad,
.status-error {
    background: #f7e7e8;
    color: var(--bad);
}

.status-downloading,
.status-queued {
    background: #e2f0ff;
    color: #155d96;
}

.add-panel,
.inspection,
.queue-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.add-panel {
    padding: 18px;
    margin-bottom: 18px;
}

.link-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.link-form input {
    width: 100%;
    min-height: 46px;
    border: 1px solid #cfd6d3;
    border-radius: 7px;
    padding: 0 14px;
    background: #fff;
    color: var(--ink);
}

.link-form input:focus,
select:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(14, 124, 107, .14);
}

.message,
.notice,
.queue-stats {
    color: var(--muted);
}

.message {
    margin-top: 10px;
    min-height: 22px;
}

.inspection,
.queue-panel {
    padding: 18px;
    margin-top: 18px;
}

.notice {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 7px;
    background: var(--soft);
}

.bulk-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
    color: var(--muted);
}

.bulk-left,
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bulk-actions {
    margin-left: auto;
    justify-content: flex-end;
}

.bulk-tools span {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 700;
}

.bulk-tools select {
    min-width: 142px;
}

.video-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.video-row {
    display: grid;
    grid-template-columns: 32px 154px 1fr minmax(210px, auto);
    gap: 14px;
    align-items: center;
    min-height: 104px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.compact .video-row {
    grid-template-columns: 32px 130px 1fr minmax(210px, auto);
}

.check-wrap {
    display: grid;
    place-items: center;
}

.row-check {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 6px;
    background: #d9ddda;
}

.thumb-link {
    display: block;
}

.video-main {
    min-width: 0;
}

.video-title {
    font-size: 15px;
    line-height: 1.32;
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

.video-meta {
    color: var(--muted);
    font-size: 13px;
}

.video-meta a,
.list-source-link {
    color: var(--accent-dark);
    font-weight: 700;
    text-decoration: none;
}

.video-meta a:hover,
.list-source-link:hover {
    text-decoration: underline;
}

.description-toggle {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: inherit;
    font-weight: 700;
    line-height: inherit;
    cursor: pointer;
}

.description-toggle:hover {
    background: transparent;
    color: var(--ink);
}

.note-icon {
    font-size: 11px;
    line-height: 1;
}

.video-description {
    flex-basis: 100%;
    max-height: 0;
    overflow: hidden;
    margin-top: 0;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    opacity: 0;
    white-space: pre-wrap;
    transition: max-height .22s ease, margin-top .22s ease, padding-top .22s ease, padding-bottom .22s ease, opacity .16s ease;
}

.video-description.expanded {
    margin-top: 8px;
    padding-top: 10px;
    padding-bottom: 10px;
    opacity: 1;
}

.meta-status {
    display: inline-flex;
    gap: 3px;
    white-space: nowrap;
}

.queued-quality {
    color: #1e6fb8;
    font-weight: 800;
}

.queued-quality-downloaded {
    color: var(--bad);
}

.video-meta a.downloaded-quality-link {
    color: #16824e;
    font-weight: 800;
}

.row-controls {
    display: grid;
    grid-template-columns: minmax(118px, 1fr);
    justify-items: stretch;
    gap: 8px;
}

.compact .row-controls {
    grid-template-columns: minmax(118px, 1fr) auto;
    align-items: center;
}

.quality-readonly {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #f7faf8;
    color: #2f3a3f;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 700;
}

.queue-row .row-controls {
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: end;
}

.readonly-row {
    grid-template-columns: 154px 1fr minmax(210px, auto);
}

.readonly-row .row-controls {
    grid-template-columns: minmax(118px, 1fr) auto;
    align-items: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.stat-card {
    min-height: 84px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 22px;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.stat-value.good {
    color: var(--good);
}

.stat-value.bad {
    color: var(--bad);
}

.stat-value.neutral {
    color: var(--muted);
}

.tools-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.tool-row {
    display: grid;
    grid-template-columns: max-content minmax(24px, 1fr) minmax(0, max-content);
    align-items: baseline;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.tool-label {
    color: var(--muted);
    font-weight: 750;
}

.tool-leader {
    border-bottom: 1px dotted #aebbb6;
    transform: translateY(-3px);
}

.tool-value {
    max-width: min(52vw, 620px);
    overflow-wrap: anywhere;
    text-align: right;
}

.tool-row small {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.app-log {
    min-height: 120px;
    max-height: 320px;
    overflow: auto;
    margin: 12px 0 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #111719;
    color: #d7ece7;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre;
    overflow-x: auto;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.settings-field,
.settings-check {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.settings-check {
    align-content: end;
    grid-template-columns: auto 1fr;
    align-items: center;
}

.settings-wide {
    grid-column: 1 / -1;
}

.settings-field textarea {
    min-height: 220px;
    resize: vertical;
    border: 1px solid #cfd6d3;
    border-radius: 7px;
    padding: 10px;
    color: var(--ink);
    font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.section-subhead {
    margin-top: 22px;
}

select {
    min-height: 38px;
    border: 1px solid #cfd6d3;
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 0 10px;
}

.progress-wrap {
    height: 8px;
    margin-top: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: #e7ece9;
}

.progress-bar {
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width .2s ease;
}

.log {
    max-height: 90px;
    overflow: auto;
    margin: 10px 0 0;
    padding: 8px;
    background: #111719;
    color: #d7ece7;
    border-radius: 6px;
    font-size: 12px;
}

.load-more-row {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

.hidden {
    display: none !important;
}

@media (max-width: 820px) {
    .shell {
        width: min(100vw - 20px, 1180px);
        padding-top: 18px;
    }

    .topbar,
    .section-head,
    .link-form {
        display: grid;
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    body {
        background: #f4f6f4;
    }

    .shell {
        width: min(100vw - 14px, 1180px);
        padding: 12px 0 36px;
    }

    .topbar {
        gap: 12px;
        margin-bottom: 12px;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 19px;
    }

    .status-strip,
    .actions,
    .bulk-tools {
        gap: 8px;
    }

    .tabbar {
        position: sticky;
        top: 0;
        z-index: 30;
        overflow-x: auto;
        margin-bottom: 12px;
        padding: 7px;
        scrollbar-width: none;
    }

    .tabbar::-webkit-scrollbar {
        display: none;
    }

    .tab-button {
        width: 46px;
        min-width: 46px;
        min-height: 44px;
    }

    .add-panel,
    .inspection,
    .queue-panel {
        padding: 12px;
        border-radius: 8px;
        box-shadow: 0 10px 24px rgba(36, 43, 47, .07);
    }

    .link-form {
        gap: 8px;
    }

    .link-form input {
        min-height: 44px;
    }

    .notice {
        margin-top: 10px;
    }

    .video-list {
        gap: 12px;
    }

    .video-row,
    .compact .video-row {
        position: relative;
        grid-template-columns: 1fr;
        gap: 10px;
        align-items: stretch;
        min-height: 0;
        padding: 10px;
    }

    .readonly-row {
        grid-template-columns: 1fr;
    }

    .check-wrap {
        position: absolute;
        top: 16px;
        left: 16px;
        z-index: 2;
        width: 34px;
        height: 34px;
        border-radius: 999px;
        background: rgba(255, 255, 255, .92);
        box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
    }

    .row-check {
        width: 20px;
        height: 20px;
    }

    .thumb-link {
        grid-column: 1;
        width: 100%;
    }

    .thumb {
        grid-column: 1;
        border-radius: 7px;
    }

    .video-main,
    .row-controls {
        grid-column: 1 / -1;
    }

    .video-title {
        font-size: 16px;
        line-height: 1.35;
        margin-bottom: 8px;
    }

    .video-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        font-size: 13px;
    }

    .row-controls {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        padding-top: 2px;
    }

    .queue-row .row-controls {
        grid-template-columns: 1fr auto;
    }

    .readonly-row .row-controls {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .row-controls select,
    .quality-readonly {
        min-width: 0;
        width: 100%;
    }

    .status-pill {
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        min-height: 76px;
        padding: 10px;
    }

    .stat-card strong {
        font-size: 18px;
    }
}

@media (max-width: 390px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .queue-row .row-controls {
        grid-template-columns: 1fr auto;
    }

    .queue-row .status-pill {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}
