* {
    box-sizing: border-box;
}

:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #1f2937;
    background: #f3f4f6;
}

body {
    margin: 0;
}

a {
    color: #b45309;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.topbar nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.layout,
.admin-layout {
    width: min(1200px, calc(100% - 2rem));
    margin: 1rem auto;
}

.layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.admin-layout {
    display: grid;
    gap: 1rem;
}

.narrow {
    width: min(520px, calc(100% - 2rem));
    margin: 3rem auto;
}

.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 1.1rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
}

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

.private {
    border-color: #f59e0b;
}

h1,
h2 {
    margin-top: 0;
}

label {
    display: grid;
    gap: 0.35rem;
    margin: 0 0 1rem;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    font: inherit;
}

textarea {
    resize: vertical;
}

button,
.button {
    display: inline-block;
    border: 0;
    border-radius: 10px;
    padding: 0.7rem 1rem;
    background: #f59e0b;
    color: #111827;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button.danger {
    background: #dc2626;
    color: #fff;
}

.time-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.time-tabs button {
    white-space: nowrap;
    background: #f3f4f6;
}

.time-tabs button.active {
    background: #f59e0b;
}

.message {
    padding: 0.8rem;
    border-radius: 10px;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}

.message.success {
    background: #dcfce7;
    color: #166534;
}

.muted {
    color: #64748b;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
}

.form-actions {
    grid-column: 1 / -1;
}

.user-list {
    display: grid;
    gap: 1rem;
}

.user-card {
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.user-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.badge {
    align-self: flex-start;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: #fef3c7;
    font-size: 0.85rem;
    font-weight: 700;
}

.user-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
    color: #64748b;
    font-size: 0.9rem;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(180px, 320px) auto;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 0.8rem;
}

fieldset {
    margin: 0 0 1.2rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

legend {
    padding: 0 0.4rem;
    font-weight: 700;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.7rem;
}

.check-row:last-child {
    margin-bottom: 0;
}

.check-row input {
    width: auto;
    margin: 0;
}

.settings-page {
    margin-top: 1.5rem;
}

.card-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.small-link {
    font-size: 0.9rem;
}

/* Počasí */

.weather-location {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.8rem;
}

.weather-location strong {
    font-size: 1.15rem;
}

.weather-location span {
    color: #64748b;
    font-size: 0.85rem;
}

.weather-current {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.weather-icon {
    font-size: 4rem;
    line-height: 1;
}

.weather-temperature {
    font-size: 2.5rem;
    font-weight: 750;
    line-height: 1;
}

.weather-description {
    margin-top: 0.35rem;
    color: #475569;
}

.weather-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    margin-bottom: 1rem;
    padding: 0.8rem;
    border-radius: 12px;
    background: #f8fafc;
}

.weather-details span {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    color: #64748b;
}

.weather-details strong {
    color: #1f2937;
}

.weather-days {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.4rem;
}

.weather-day {
    display: grid;
    justify-items: center;
    gap: 0.25rem;
    padding: 0.55rem 0.25rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    text-align: center;
}

.weather-day-icon {
    font-size: 1.5rem;
}

.weather-day small {
    color: #64748b;
}

.weather-footer {
    margin-top: 0.7rem;
    color: #94a3b8;
    font-size: 0.75rem;
    text-align: right;
}

/* RSS */

.rss-list {
    display: grid;
}

.rss-item {
    padding: 0.9rem 0;
    border-top: 1px solid #e5e7eb;
}

.rss-item:first-child {
    border-top: 0;
    padding-top: 0.2rem;
}

.rss-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: #64748b;
    font-size: 0.82rem;
}

.rss-item h3 {
    margin: 0.25rem 0 0;
    font-size: 1.05rem;
    line-height: 1.35;
}

.rss-item h3 a {
    color: #1f2937;
    text-decoration: none;
}

.rss-item h3 a:hover {
    color: #b45309;
    text-decoration: underline;
}

.rss-item p {
    margin: 0.35rem 0 0;
    color: #475569;
    line-height: 1.45;
}

.rss-errors {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 10px;
    background: #fff7ed;
    color: #9a3412;
}

.rss-errors summary {
    cursor: pointer;
    font-weight: 700;
}

.rss-errors ul {
    padding-left: 1.2rem;
    overflow-wrap: anywhere;
}

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

    .wide {
        grid-column: auto;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .form-actions {
        grid-column: auto;
    }

    .inline-form {
        grid-template-columns: 1fr;
    }

    .weather-days {
        grid-template-columns: repeat(5, minmax(72px, 1fr));
        overflow-x: auto;
        padding-bottom: 0.35rem;
    }
}

@media (max-width: 430px) {
    .weather-details {
        grid-template-columns: 1fr;
    }

    .weather-icon {
        font-size: 3.3rem;
    }

    .weather-temperature {
        font-size: 2.1rem;
    }

    .rss-meta {
        flex-direction: column;
        gap: 0.15rem;
    }
}


/* TV program */

.tv-card {
    grid-column: 1 / -1;
}

.tv-time-tabs {
    margin: 0.2rem 0 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.tv-time-tabs a {
    display: inline-block;
    min-width: 66px;
    padding: 0.55rem 0.7rem;
    border-radius: 8px 8px 0 0;
    color: #1f2937;
    font-weight: 650;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
}

.tv-time-tabs a.active {
    background: #f59e0b;
    color: #111827;
}

.tv-list {
    display: grid;
}

.tv-row {
    display: grid;
    grid-template-columns: 165px minmax(0, 1fr) 78px;
    gap: 0.75rem;
    align-items: center;
    min-height: 42px;
    padding: 0.35rem 0;
    border-bottom: 1px solid #eef0f3;
}

.tv-row:last-child {
    border-bottom: 0;
}

.tv-time-block {
    display: grid;
    grid-template-columns: 42px minmax(45px, 1fr) 42px;
    gap: 0.45rem;
    align-items: center;
    color: #64748b;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.tv-progress {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #eceff2;
}

.tv-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #f59e0b;
}

.tv-title {
    min-width: 0;
    line-height: 1.25;
}

.tv-title a {
    color: #dc2626;
    text-decoration: none;
}

.tv-title a:hover {
    text-decoration: underline;
}

.tv-title small {
    margin-left: 0.4rem;
    color: #94a3b8;
}

.tv-station,
.tv-setting-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 850;
    letter-spacing: -0.03em;
}

.tv-station {
    min-height: 28px;
    padding: 0.25rem 0.4rem;
    border-radius: 8px;
    color: currentColor;
    font-size: 0.76rem;
    text-decoration: none;
}

.tv-setting-badge {
    min-width: 58px;
    padding: 0.2rem 0.35rem;
    border-radius: 7px;
    font-size: 0.72rem;
}

.tv-station--seznam { color: #ef1717; }
.tv-station--ct1 { color: #e31c31; }
.tv-station--ct2 { color: #f59e0b; }
.tv-station--nova { color: #174a8b; }
.tv-station--prima { color: #ef4d23; }
.tv-station--nova-cinema { color: #7384ff; }
.tv-station--nova-fun { color: #2ee6a6; }
.tv-station--nova-action { color: #f3b31b; }
.tv-station--prima-krimi { color: #b89c72; }
.tv-station--nova-lady { color: #ef6f75; }
.tv-station--prima-cool { color: #21c44b; }
.tv-station--barrandov-kino { color: #b99116; }
.tv-station--amc { color: #db1c28; }
.tv-station--prima-love { color: #8147e6; }
.tv-station--prima-zoom { color: #1689c9; }
.tv-station--ct-sport { color: #61be24; }

.tv-toggle {
    display: block;
    margin: 0.7rem auto 0;
    padding: 0.35rem 0.8rem;
    background: transparent;
    color: #b45309;
    font-size: 0.88rem;
}

.tv-errors {
    margin-top: 0.8rem;
    padding: 0.7rem;
    border-radius: 10px;
    background: #fff7ed;
    color: #9a3412;
}

.tv-errors summary {
    cursor: pointer;
    font-weight: 700;
}

.tv-errors ul {
    overflow-wrap: anywhere;
}

.tv-footer {
    margin-top: 0.65rem;
    color: #94a3b8;
    font-size: 0.72rem;
    text-align: right;
}

.tv-channel-settings {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
}

.field-help {
    margin-top: 0;
}

html[data-theme="dark"] .tv-time-tabs {
    border-bottom-color: #303b48;
}

html[data-theme="dark"] .tv-time-tabs a {
    color: #e7edf4;
}

html[data-theme="dark"] .tv-row {
    border-bottom-color: #303b48;
}

html[data-theme="dark"] .tv-progress {
    background: #303b48;
}

html[data-theme="dark"] .tv-title a {
    color: #ff7373;
}

html[data-theme="dark"] .tv-toggle {
    color: #f3a83b;
}

html[data-theme="dark"] .tv-errors {
    background: #352419;
    color: #fdba74;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .tv-time-tabs {
        border-bottom-color: #303b48;
    }

    html[data-theme="system"] .tv-time-tabs a {
        color: #e7edf4;
    }

    html[data-theme="system"] .tv-row {
        border-bottom-color: #303b48;
    }

    html[data-theme="system"] .tv-progress {
        background: #303b48;
    }

    html[data-theme="system"] .tv-title a {
        color: #ff7373;
    }

    html[data-theme="system"] .tv-toggle {
        color: #f3a83b;
    }

    html[data-theme="system"] .tv-errors {
        background: #352419;
        color: #fdba74;
    }
}

@media (max-width: 720px) {
    .tv-card {
        grid-column: auto;
    }

    .tv-row {
        grid-template-columns: minmax(0, 1fr) 64px;
        gap: 0.4rem 0.65rem;
        padding: 0.55rem 0;
    }

    .tv-time-block {
        grid-column: 1 / -1;
        grid-template-columns: 42px minmax(70px, 1fr) 42px;
        order: 2;
    }

    .tv-title {
        order: 1;
    }

    .tv-station {
        order: 1;
    }

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


.tv-settings-tools {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    gap: 0.7rem;
    align-items: center;
    margin-bottom: 0.9rem;
}

.tv-settings-buttons {
    display: flex;
    gap: 0.45rem;
}

.tv-settings-buttons button {
    padding: 0.55rem 0.7rem;
    font-size: 0.85rem;
}

.tv-channel-settings {
    max-height: 520px;
    overflow-y: auto;
    padding: 0.2rem 0.5rem 0.2rem 0;
    scrollbar-gutter: stable;
}

.tv-channel-settings .check-row[hidden] {
    display: none;
}

@media (max-width: 620px) {
    .tv-settings-tools {
        grid-template-columns: 1fr;
    }

    .tv-settings-buttons {
        flex-wrap: wrap;
    }
}


/* Vlastní pořadí televizních stanic */

.tv-channel-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 0.45rem;
    align-items: center;
    min-height: 44px;
    padding: 0.25rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.tv-channel-row:last-child {
    border-bottom: 0;
}

.tv-channel-row.is-dragging {
    opacity: 0.45;
}

.tv-drag-handle,
.tv-order-buttons button {
    padding: 0.35rem 0.45rem;
    border: 1px solid #cbd5e1;
    background: #f3f4f6;
    color: #475569;
    line-height: 1;
}

.tv-drag-handle {
    cursor: grab;
    touch-action: none;
}

.tv-drag-handle:active {
    cursor: grabbing;
}

.tv-channel-check {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 0.55rem;
    margin: 0;
    cursor: pointer;
}

.tv-channel-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-order-buttons {
    display: flex;
    gap: 0.25rem;
}

.tv-order-buttons button {
    min-width: 31px;
    cursor: pointer;
}

html[data-theme="dark"] .tv-channel-row {
    border-bottom-color: #303b48;
}

html[data-theme="dark"] .tv-drag-handle,
html[data-theme="dark"] .tv-order-buttons button {
    border-color: #445263;
    background: #222b36;
    color: #c4cfdb;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .tv-channel-row {
        border-bottom-color: #303b48;
    }

    html[data-theme="system"] .tv-drag-handle,
    html[data-theme="system"] .tv-order-buttons button {
        border-color: #445263;
        background: #222b36;
        color: #c4cfdb;
    }
}

@media (max-width: 520px) {
    .tv-channel-row {
        grid-template-columns: 32px minmax(0, 1fr) auto;
        gap: 0.3rem;
    }

    .tv-setting-badge {
        min-width: 48px;
    }

    .tv-order-buttons {
        flex-direction: column;
    }

    .tv-order-buttons button {
        padding: 0.25rem 0.4rem;
    }
}


/* Lokální PNG loga TV stanic */

.tv-station.has-logo,
.tv-setting-badge.has-logo {
    background: #111;
    color: transparent;
}

.tv-station.has-logo {
    width: 72px;
    height: 32px;
    padding: 3px 5px;
}

.tv-logo-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tv-setting-badge.has-logo {
    width: 64px;
    height: 30px;
    padding: 3px 5px;
}

.tv-setting-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@media (max-width: 720px) {
    .tv-station.has-logo {
        width: 62px;
        height: 30px;
    }

    .tv-setting-badge.has-logo {
        width: 56px;
        height: 28px;
    }
}
