:root,
[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f8f7;
    --surface: #ffffff;
    --surface-soft: #eef3f0;
    --text: #18201c;
    --muted: #627069;
    --line: #d7e0db;
    --accent: #167a55;
    --accent-strong: #0f5b40;
    --danger: #c84949;
    --danger-text: #ffffff;
    --shadow: 0 14px 38px rgba(38, 54, 47, 0.13);
    --media-bg: #111614;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1311;
    --surface: #181f1c;
    --surface-soft: #202923;
    --text: #f4f7f2;
    --muted: #aeb8ad;
    --line: #35443c;
    --accent: #7ccf8b;
    --accent-strong: #a8e0b1;
    --danger: #e36b6b;
    --danger-text: #160606;
    --shadow: 0 16px 44px rgba(0, 0, 0, 0.35);
    --media-bg: #050706;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.mobile-filter-open {
    overflow: hidden;
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    padding: 0 18px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.topnav {
    display: inline-flex;
    gap: 10px;
    align-items: center;
}

.mobile-nav-toggle {
    display: none;
}

.topnav a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.user-pill {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    font-weight: 700;
}

.brand {
    display: inline-flex;
    gap: 11px;
    align-items: center;
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}

.brand-mark {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--accent-strong) 82%, #ffffff), color-mix(in srgb, var(--accent) 72%, #000000));
    border: 1px solid color-mix(in srgb, var(--accent) 70%, var(--line));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 10px 24px rgba(22, 122, 85, 0.24);
    overflow: hidden;
}

.brand-mark::before {
    content: "";
    position: absolute;
    inset: 7px 9px 8px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 8px 8px 10px 10px;
    clip-path: polygon(50% 0, 100% 14%, 100% 62%, 50% 100%, 0 62%, 0 14%);
}

.brand-mark::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 9px;
    height: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
}

.brand-lens {
    position: relative;
    z-index: 1;
    width: 17px;
    height: 17px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent-strong) 55%, #000000);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.16), 0 0 16px rgba(255, 255, 255, 0.18);
}

.brand-lens::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 3px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
}

.brand-text {
    display: grid;
    gap: 1px;
    line-height: 1.05;
}

.brand-text strong {
    font-size: 18px;
}

.brand-text small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
}

.theme-toggle {
    min-width: 76px;
    background: var(--surface-soft);
    border-color: var(--line);
    color: var(--text);
}

.page {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 22px 18px 28px;
}

.scroll-top {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 5;
    width: 46px;
    height: 46px;
    min-height: 46px;
    padding: 0;
    border-radius: 8px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.scroll-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.mobile-filter-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    padding: 64px 10px max(18px, env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.mobile-filter-overlay.open {
    display: block;
}

.mobile-filter-panel {
    max-height: calc(100dvh - 82px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    box-shadow: var(--shadow);
}

.mobile-filter-panel > header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.mobile-filter-panel > header strong {
    font-size: 18px;
}

.mobile-filter-panel > header button {
    min-height: 36px;
}

.mobile-filter-content {
    display: grid;
    gap: 10px;
    padding: 10px 10px 28px;
}

.mobile-filter-content .sidebar {
    position: static;
    display: block;
    max-height: none;
    overflow: visible;
}

.mobile-filter-content .toolbar {
    margin-bottom: 0;
}

.mobile-filter-content .filters {
    padding-bottom: 0;
}

.shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.shell.tree-collapsed {
    grid-template-columns: minmax(0, 1fr);
}

.content {
    min-width: 0;
}

.overview-menu-bar,
.overview-menu-toggle {
    display: none;
}

.folder-toggle {
    display: inline-flex;
    flex: 0 0 auto;
}

.tree-close {
    min-height: 32px;
    padding: 0 10px;
    background: var(--surface-soft);
    border-color: var(--line);
    color: var(--text);
}

.sidebar {
    position: sticky;
    top: 78px;
    max-height: calc(100vh - 100px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.sidebar-title {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    font-weight: 800;
}

.sidebar.collapsed .tree {
    display: none;
}

.sidebar.collapsed {
    display: none;
    overflow: hidden;
}

.tree {
    padding: 8px;
}

.tree details {
    margin: 2px 0;
}

.tree summary {
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text);
    font-weight: 700;
    list-style-position: inside;
}

.tree summary:hover,
.tree-days a:hover {
    background: var(--surface-soft);
}

.tree details details {
    margin-left: 10px;
}

.tree-days {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 4px 0 8px 18px;
}

.tree-days a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
}

.tree-days a.active {
    background: var(--accent);
    color: #ffffff;
    font-weight: 800;
}

.calendar-panel {
    display: grid;
    gap: 14px;
    padding: 14px;
}

.calendar-summary {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.calendar-summary span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.calendar-summary strong {
    color: var(--text);
    font-size: 24px;
    line-height: 1.1;
}

.calendar-nav {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 8px;
    align-items: center;
}

.calendar-nav a {
    width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 20px;
    font-weight: 900;
    line-height: 1;
    text-decoration: none;
}

.calendar-nav a:hover {
    border-color: var(--accent);
    background: var(--surface);
    color: var(--accent-strong);
}

.calendar-nav strong {
    min-width: 0;
    text-align: center;
    font-size: 17px;
    overflow-wrap: anywhere;
}

.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.calendar-weekdays span {
    display: grid;
    place-items: center;
    min-height: 24px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.calendar-empty,
.calendar-day {
    min-width: 0;
}

.calendar-day {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--muted);
    font-weight: 800;
    text-decoration: none;
}

.calendar-day span {
    line-height: 1;
}

.calendar-day small {
    display: none;
}

.calendar-day:hover {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--text);
}

.calendar-day.has-media {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
}

.calendar-day.has-media small {
    display: block;
    width: min(46px, calc(100% - 6px));
    overflow: hidden;
    color: var(--accent-strong);
    font-size: 9px;
    font-weight: 900;
    line-height: 1;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-day.today {
    border-color: var(--accent);
}

.calendar-day.today::before {
    content: "Heute";
    position: absolute;
    top: -9px;
    left: 50%;
    padding: 1px 5px;
    border-radius: 999px;
    background: var(--accent);
    color: #ffffff;
    font-size: 9px;
    font-weight: 900;
    transform: translateX(-50%);
}

.calendar-day.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.calendar-day.active.today::before {
    background: #ffffff;
    color: var(--accent);
}

.calendar-legend {
    display: block;
    padding-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}

.toolbar,
.viewer-head,
.actions {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.toolbar {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.flash {
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 16%, var(--surface));
    color: var(--text);
    font-weight: 800;
}

.date-form,
.actions form,
.searchbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.protect-inline-form input[type="text"] {
    min-width: 220px;
}

.refresh-control {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 40px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text);
    font-weight: 700;
}

.refresh-control select {
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.searchbar {
    margin-bottom: 14px;
}

.searchbar input[type="search"] {
    flex: 1 1 auto;
    min-width: 180px;
}

input,
button,
.button,
textarea {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text);
    padding: 0 12px;
    font: inherit;
    text-decoration: none;
}

textarea {
    display: block;
    align-items: initial;
    justify-content: initial;
    width: 100%;
    min-height: 120px;
    padding: 10px 12px;
    resize: vertical;
}

.button.secondary {
    background: var(--surface-soft);
    border-color: var(--line);
    color: var(--text);
}

button,
.button {
    cursor: pointer;
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    font-weight: 700;
}

button,
.button,
.days a,
.filters a,
.theme-toggle,
.tile {
    transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

button:hover,
.button:hover,
.tile:hover {
    transform: translateY(-1px);
}

.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--danger-text);
}

.safe-action {
    background: var(--surface-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
}

.secondary-action {
    background: var(--surface-soft);
    border-color: var(--line);
    color: var(--text);
}

.stats,
.meta span,
.viewer-head p,
.empty p {
    color: var(--muted);
}

.stats {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    font-weight: 700;
}

.home-stats {
    display: inline-flex;
    gap: 10px;
    align-items: center;
}

.storage-card {
    min-height: 40px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}

.storage-card strong {
    color: var(--text);
}

.days {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 0 16px;
    margin-bottom: 2px;
}

.days a {
    flex: 0 0 auto;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    text-decoration: none;
}

.days a.active {
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
}

.filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 0 14px;
}

.filters a {
    flex: 0 0 auto;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}

.filters a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.type-filters {
    padding-bottom: 4px;
}

.timeline {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.timeline-head {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.timeline-head span {
    color: var(--muted);
    font-weight: 700;
}

.timeline-hours {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
    gap: 8px;
}

.timeline-hours a {
    display: grid;
    gap: 2px;
    min-height: 46px;
    align-content: center;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text);
    text-decoration: none;
}

.timeline-hours a:hover {
    border-color: var(--accent);
}

.timeline-hours span {
    color: var(--muted);
    font-size: 13px;
}

.timeline-hours strong {
    font-size: 17px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.grid[data-grid-size="2"],
.grid[data-grid-size="3"],
.grid[data-grid-size="4"],
.grid[data-grid-size="5"],
.grid[data-grid-size="6"] {
    grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
}

.bulk-form {
    display: grid;
    gap: 14px;
}

.selectionbar {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.switch {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.slider {
    position: relative;
    width: 46px;
    height: 24px;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
}

.slider::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 140ms ease, background-color 140ms ease;
}

.switch input:checked + .slider {
    background: var(--accent);
    border-color: var(--accent);
}

.switch input:checked + .slider::after {
    transform: translateX(22px);
    background: #ffffff;
}

.bulkbar {
    position: sticky;
    top: 72px;
    z-index: 1;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.bulk-form:not(.selection-enabled) .bulkbar,
.bulk-form:not(.selection-enabled) .pick {
    display: none;
}

.select-all,
.pick {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--text);
    font-weight: 700;
}

.selection-count {
    color: var(--muted);
    margin-right: auto;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
}

.tile {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.hour-anchor {
    position: absolute;
    top: -84px;
    left: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    scroll-margin-top: 84px;
}

.tile-link {
    display: block;
    text-decoration: none;
}

.tile:hover {
    border-color: var(--accent);
}

.thumb {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 9;
    background: var(--media-bg);
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-badge {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.72);
    color: #ffffff;
    font-size: 13px;
    font-weight: 800;
}

.protected-badge {
    position: absolute;
    left: 10px;
    bottom: 10px;
    padding: 5px 8px;
    border-radius: 6px;
    background: var(--danger);
    color: var(--danger-text);
    font-size: 13px;
    font-weight: 900;
}

.pick {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    padding: 7px 9px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.pick input,
.select-all input {
    min-height: auto;
    width: 18px;
    height: 18px;
    padding: 0;
}

.list {
    display: grid;
    gap: 10px;
}

.list-row {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.row-actions {
    display: inline-flex;
    gap: 10px;
    align-items: center;
}

.list-row p,
.toolbar-note {
    margin: 4px 0 0;
    color: var(--muted);
}

.meta {
    display: grid;
    gap: 4px;
    padding: 13px;
}

.meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-head {
    align-items: flex-start;
    justify-content: flex-start;
}

.viewer-head > div {
    min-width: 0;
    flex: 1 1 auto;
}

.back-button {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
}

.media-nav {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}

.nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
}

.nav-button.disabled {
    opacity: 0.35;
}

.viewer-head h1 {
    margin: 0 0 4px;
    overflow-wrap: anywhere;
}

.viewer-head p {
    margin: 0;
    overflow-wrap: anywhere;
}

.viewer {
    display: grid;
    place-items: center;
    min-height: 40vh;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--media-bg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.notice {
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    background: var(--surface-soft);
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}

.viewer video,
.viewer img {
    display: block;
    width: 100%;
    max-height: calc(100vh - 220px);
    object-fit: contain;
}

.empty {
    padding: 42px 0;
}

.empty h1 {
    margin: 0 0 8px;
}

.portal {
    min-height: calc(100vh - 130px);
    display: grid;
    align-content: center;
    gap: 22px;
}

.portal-head {
    display: grid;
    gap: 6px;
    text-align: center;
}

.portal-head strong {
    color: var(--accent-strong);
    font-size: 16px;
}

.portal-head h1 {
    margin: 0;
    font-size: 32px;
}

.portal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 360px));
    gap: 14px;
    justify-content: center;
}

.portal-card {
    display: grid;
    gap: 8px;
    min-height: 160px;
    align-content: center;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    text-decoration: none;
}

.portal-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.portal-card span {
    color: var(--muted);
    font-weight: 800;
}

.portal-card strong {
    font-size: 24px;
}

.portal-card p {
    margin: 0;
    color: var(--muted);
}

code {
    color: var(--accent-strong);
}

.login-shell {
    min-height: calc(100vh - 120px);
    display: grid;
    gap: 14px;
    place-items: center;
    align-content: center;
}

.login-box {
    width: min(420px, 100%);
    display: grid;
    gap: 14px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 13px;
    padding: 4px 0 6px;
}

.login-brand .brand-mark {
    width: 54px;
    height: 54px;
}

.login-brand .brand-mark::before {
    inset: 9px 11px 10px;
    border-width: 3px;
}

.login-brand .brand-mark::after {
    left: 13px;
    right: 13px;
    bottom: 11px;
    width: auto;
    height: 3px;
}

.login-brand .brand-lens {
    width: 19px;
    height: 19px;
}

.login-brand .brand-text strong {
    font-size: 27px;
}

.login-brand .brand-text small {
    font-size: 13px;
}

.login-intro {
    margin: 0;
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

.login-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.login-section-title::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

.guest-login-box {
    background: var(--surface-soft);
}

.pin-input {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 0;
    text-align: center;
}

.login-box label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
}

.remember {
    display: inline-flex;
    grid-template-columns: auto 1fr;
    align-items: center;
}

.remember input {
    min-height: auto;
    width: 18px;
    height: 18px;
    padding: 0;
}

.login-error {
    margin: 0;
    padding: 10px;
    border: 1px solid var(--danger);
    border-radius: 6px;
    color: var(--danger);
}

.settings-warning {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
    padding: 14px;
    border: 1px solid color-mix(in srgb, var(--danger) 70%, var(--line));
    border-radius: 8px;
    background: color-mix(in srgb, var(--danger) 10%, var(--surface));
    color: var(--text);
}

.settings-warning strong {
    color: var(--danger);
}

.settings-warning p {
    margin: 0;
    color: var(--muted);
}

.settings-warning button {
    justify-self: start;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.account-grid {
    display: grid;
    grid-template-columns: minmax(280px, 440px);
}

.system-overview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.system-card {
    display: grid;
    gap: 5px;
    align-content: start;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.system-overview-polished {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.system-overview-polished .system-card {
    min-height: 132px;
    position: relative;
    overflow: hidden;
}

.system-overview-polished .system-card::after {
    content: "";
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 34px;
    height: 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 42%, transparent);
}

.system-card-button {
    width: 100%;
    min-height: 132px;
    text-align: left;
    cursor: pointer;
    color: var(--text);
    font: inherit;
    justify-content: stretch;
}

.system-card-button:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.system-card-link {
    color: inherit;
    text-decoration: none;
}

.system-card-link:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.system-card span,
.system-card p,
.status-list dt,
.maintenance-list p {
    color: var(--muted);
}

.system-card strong {
    font-size: 24px;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.system-card p {
    margin: 0;
    overflow-wrap: anywhere;
}

.system-settings-stack {
    display: grid;
    gap: 12px;
}

.system-foldout {
    padding: 0;
    overflow: hidden;
}

.system-foldout summary {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 14px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 900;
    list-style: none;
}

.system-foldout summary::-webkit-details-marker {
    display: none;
}

.system-foldout summary::before {
    content: "+";
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--accent-strong);
}

.system-foldout[open] summary::before {
    content: "-";
}

.system-foldout > :not(summary) {
    margin: 0 14px 14px;
}

.system-dialog {
    width: min(1120px, calc(100vw - 28px));
    max-height: min(86vh, 900px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    opacity: 1;
}

.system-dialog::backdrop {
    background: rgba(0, 0, 0, 0.76);
    backdrop-filter: blur(2px);
}

.system-dialog-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.system-dialog .admin-box,
.system-dialog .user-card,
.system-dialog .share-row,
.system-dialog .protected-row,
.system-dialog .list-row,
.system-dialog .job-row {
    background: var(--surface-soft);
}

.system-dialog .admin-action-box {
    background: var(--surface);
}

.system-dialog-head strong {
    display: block;
    font-size: 22px;
}

.system-dialog-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.system-dialog > .share-list,
.system-dialog > .protected-list,
.system-dialog > .system-dialog-list,
.system-dialog > .muted-text,
.system-dialog > .system-dialog-grid,
.system-dialog > .system-dialog-panel,
.system-dialog > .system-dialog-toolbar {
    margin: 16px;
}

.system-dialog-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.system-dialog-grid {
    align-items: start;
}

.system-dialog-panel {
    box-shadow: none;
}

.media-view-dialog {
    width: min(1180px, calc(100vw - 24px));
    max-height: min(92vh, 980px);
}

.media-dialog-content {
    padding: 16px;
}

.media-dialog-content .viewer-head .back-button[href] {
    display: none;
}

.media-dialog-close-inline {
    margin-bottom: 12px;
}

.media-view-dialog .viewer {
    min-height: 48vh;
}

.media-view-dialog .viewer video,
.media-view-dialog .viewer img {
    max-height: calc(92vh - 260px);
}

.media-dialog-loading {
    min-height: 220px;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 800;
}

.system-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.75fr);
    gap: 14px;
    margin-bottom: 14px;
}

.status-list {
    display: grid;
    gap: 8px;
    margin: 0;
}

.status-list div {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}

.status-list div:last-child {
    border-bottom: 0;
}

.status-list dt,
.status-list dd {
    margin: 0;
}

.status-list dd {
    color: var(--text);
    font-weight: 800;
}

.maintenance-list {
    display: grid;
    gap: 8px;
}

.maintenance-list p {
    margin: 0;
}

.cleanup-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px) minmax(180px, 240px) auto;
    gap: 10px;
    align-items: end;
}

.cleanup-form label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.cleanup-form .checkline {
    align-self: center;
}

.cleanup-preview {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.cleanup-preview p,
.cleanup-preview ul {
    margin: 0;
    color: var(--muted);
}

.cleanup-preview ul {
    display: grid;
    gap: 4px;
    padding-left: 20px;
}

.cleanup-last-run {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.cleanup-last-run dl {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.cleanup-last-run div {
    display: grid;
    gap: 3px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
}

.cleanup-last-run dt,
.cleanup-last-run p {
    margin: 0;
    color: var(--muted);
}

.cleanup-last-run dd {
    margin: 0;
    color: var(--text);
    font-weight: 800;
}

.job-detail {
    margin-bottom: 14px;
}

.job-progress {
    height: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.job-progress span {
    display: block;
    min-width: 4px;
    height: 100%;
    background: var(--accent);
    transition: width 160ms ease;
}

.job-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.job-stats div {
    display: grid;
    gap: 3px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
}

.job-stats dt,
.job-summary {
    margin: 0;
    color: var(--muted);
}

.job-stats dd {
    margin: 0;
    color: var(--text);
    font-weight: 800;
}

.job-list {
    display: grid;
    gap: 8px;
}

.job-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    text-decoration: none;
}

.compact-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
}


.job-row span:first-child {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.job-row small {
    color: var(--muted);
    font-weight: 700;
}

.muted-text {
    margin: 0;
    color: var(--muted);
}

.share-create-box {
    margin-top: 18px;
}

.share-result {
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.share-result p {
    margin: 0;
    color: var(--muted);
}

.share-create-form {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(180px, 240px) minmax(220px, 1fr) auto auto;
    gap: 10px;
    align-items: end;
}

.share-download-check {
    min-height: 40px;
    align-self: end;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
}

.share-result-wide {
    margin-bottom: 14px;
}

.share-builder {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.share-options {
    position: sticky;
    top: 78px;
}

.share-preview-list {
    display: grid;
    gap: 10px;
}

.share-preview-list article {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.share-preview-list article.active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.share-preview-list .thumb {
    border-radius: 6px;
    overflow: hidden;
    text-decoration: none;
}

.share-preview-list strong {
    display: block;
    overflow-wrap: anywhere;
}

.share-preview-list p {
    margin: 4px 0 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.shared-collection {
    margin-top: 18px;
}

.share-public-list .row-actions {
    margin-top: 10px;
}

.share-panel {
    margin-bottom: 14px;
}

.protected-panel {
    margin-bottom: 14px;
}

.protected-list {
    display: grid;
    gap: 8px;
}

.protected-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.protected-row p {
    margin: 4px 0 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.protected-note {
    display: block;
    margin: -6px 0 18px;
}

.protected-note-form {
    grid-column: 1 / -1;
    display: grid;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.protected-note-form label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.protected-list-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
}

.maintenance-panel {
    margin-bottom: 14px;
}

.settings-form {
    display: grid;
    gap: 10px;
}

.settings-form label,
.live-settings-form label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.settings-form input,
.live-settings-form input {
    width: 100%;
}

.live-settings-panel {
    margin-bottom: 14px;
}

.live-settings-form {
    display: grid;
    gap: 10px;
}

.live-toolbar {
    margin-bottom: 14px;
}

.live-station {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.live-picker,
.live-player {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.live-picker {
    position: sticky;
    top: 78px;
    display: grid;
    gap: 10px;
    padding: 12px;
}

.live-picker > strong {
    font-size: 18px;
}

.live-picker nav {
    display: grid;
    gap: 8px;
}

.live-picker a {
    display: grid;
    gap: 3px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text);
    text-decoration: none;
}

.live-picker a.active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 16%, var(--surface));
}

.live-picker a:first-child {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.live-picker span,
.live-picker small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-picker span {
    font-weight: 800;
}

.live-picker small {
    color: var(--muted);
    font-weight: 700;
}

.live-player header {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}

.live-modes {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}

.live-modes a {
    flex: 0 0 auto;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    font-weight: 800;
    text-decoration: none;
}

.live-modes a.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.live-player header div {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.live-player strong,
.live-player span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-player span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.live-player iframe {
    display: block;
    width: 100%;
    height: min(72vh, 720px);
    min-height: 420px;
    border: 0;
    background: var(--media-bg);
}

.live-grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
    gap: 14px;
    padding: 14px;
    background: #000000;
}

.live-grid-tile {
    position: relative;
    display: block;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #000000;
    color: #ffffff;
    text-decoration: none;
    aspect-ratio: 16 / 9;
}

.live-grid-tile iframe {
    width: 100%;
    height: 100%;
    min-height: 0;
    pointer-events: none;
}

.live-grid-tile span {
    position: absolute;
    left: 8px;
    bottom: 8px;
    max-width: calc(100% - 16px);
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.72);
    color: #ffffff;
    font-size: 13px;
    font-weight: 900;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-empty {
    display: grid;
    gap: 10px;
    justify-items: start;
}

.share-list {
    display: grid;
    gap: 10px;
}

.share-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.share-main {
    min-width: 0;
    display: grid;
    gap: 5px;
}

.share-main p {
    margin: 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.share-link {
    width: 100%;
    min-width: 0;
    font-size: 14px;
}

.share-meta {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.system-users {
    margin-top: 0;
}

.admin-box {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.admin-box-head {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.admin-box h2 {
    margin: 0;
}

.admin-box label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.admin-box input,
.admin-box select {
    width: 100%;
}

.badge-row {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.badge {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.badge.ok {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.badge.off {
    border-color: var(--danger);
    color: var(--danger);
}

.user-list {
    display: grid;
    gap: 12px;
}

.user-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.user-card-head {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    justify-content: space-between;
}

.user-card-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.admin-actions {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(180px, 0.7fr);
    gap: 10px;
}

.guest-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.6fr);
    gap: 10px;
}

.admin-action-box {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.delete-user-box p {
    margin: 0;
    color: var(--muted);
}

.pin-chip {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 0 10px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent-strong);
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0;
}

.checkline {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.checkline input {
    min-height: auto;
    width: 18px;
    height: 18px;
}

@media (max-width: 1100px) {
    .shell {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .shell.tree-collapsed {
        grid-template-columns: 1fr;
    }

    .overview-menu-bar {
        position: sticky;
        top: 62px;
        z-index: 2;
        display: block;
        padding: 8px 0;
        margin-bottom: 4px;
        background: var(--bg);
    }

    .overview-menu-toggle {
        position: relative;
        z-index: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        width: 100%;
        min-height: 48px;
        background: linear-gradient(135deg, var(--accent), var(--accent-strong));
        border-color: var(--accent);
        color: #ffffff;
        box-shadow: var(--shadow);
        font-size: 15px;
        letter-spacing: 0;
    }

    .overview-menu-toggle::before {
        content: "";
        flex: 0 0 auto;
        width: 20px;
        height: 14px;
        background:
            linear-gradient(currentColor, currentColor) 0 0 / 20px 2px no-repeat,
            linear-gradient(currentColor, currentColor) 0 6px / 20px 2px no-repeat,
            linear-gradient(currentColor, currentColor) 0 12px / 20px 2px no-repeat;
        border-radius: 2px;
    }


    .shell:not(.overview-controls-open) .sidebar,
    .shell:not(.overview-controls-open) .toolbar,
    .shell:not(.overview-controls-open) .searchbar,
    .shell:not(.overview-controls-open) .filters,
    .shell:not(.overview-controls-open) .selectionbar,
    .shell:not(.overview-controls-open) .timeline,
    .shell:not(.overview-controls-open) .bulkbar,
    .shell:not(.overview-controls-open) .pick {
        display: none;
    }

    .shell.overview-controls-open .sidebar {
        display: block;
        position: static;
        max-height: none;
        margin-bottom: 0;
        border-radius: 8px;
        box-shadow: var(--shadow);
    }

    .shell.overview-controls-open .content {
        display: contents;
    }

    .tree-close,
    .folder-toggle {
        display: none;
    }

    .sidebar-title {
        padding: 12px 14px;
        justify-content: center;
        background: var(--surface-soft);
        font-size: 15px;
    }

    .tree {
        padding: 10px;
    }

    .tree > details {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        overflow: hidden;
    }

    .tree > details + details {
        margin-top: 8px;
    }

    .tree summary {
        min-height: 38px;
        display: flex;
        align-items: center;
        padding: 8px 10px;
        border-radius: 0;
    }

    .tree details details {
        margin-left: 0;
        border-top: 1px solid var(--line);
    }

    .shell.overview-controls-open .toolbar,
    .shell.overview-controls-open .timeline {
        display: grid;
    }

    .shell.overview-controls-open .searchbar,
    .shell.overview-controls-open .filters {
        display: flex;
    }

    .shell.overview-controls-open .selectionbar {
        display: flex;
    }

    .searchbar,
    .selectionbar,
    .timeline {
        display: none !important;
    }

    .tree-days {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 6px;
        padding: 8px;
    }

    .tree-days a {
        min-height: 36px;
        background: var(--surface-soft);
        font-weight: 700;
    }

    .calendar-panel {
        padding: 12px;
    }

    .calendar-nav {
        grid-template-columns: 44px minmax(0, 1fr) 44px;
    }

    .calendar-nav a {
        min-height: 44px;
    }

    .calendar-weekdays,
    .calendar-grid {
        gap: 7px;
    }

    .calendar-day {
        min-height: 40px;
    }

    .shell:not(.overview-controls-open) .content {
        padding-top: 8px;
    }
}

@media (max-width: 680px) {
    .topbar {
        min-height: 54px;
        padding: 8px 10px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .brand {
        min-width: 0;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
    }

    .brand-mark::before {
        inset: 6px 8px 8px;
    }

    .brand-mark::after {
        left: 9px;
        right: 9px;
        bottom: 8px;
        width: auto;
    }

    .brand-lens {
        width: 14px;
        height: 14px;
        border-width: 2px;
    }

    .brand-text strong {
        font-size: 16px;
    }

    .brand-text small {
        font-size: 11px;
    }

    .mobile-nav-toggle {
        order: 2;
        display: inline-flex;
        min-height: 36px;
        margin-left: auto;
        padding: 0 10px;
        background: var(--surface-soft);
        border-color: var(--line);
        color: var(--text);
        font-size: 14px;
    }

    .topbar.has-overview-menu .mobile-nav-toggle {
        margin-left: 0;
    }

    .topbar .overview-menu-bar {
        order: 1;
        display: inline-flex;
        position: static;
        width: auto;
        padding: 0;
        margin: 0 0 0 auto;
        background: transparent;
    }

    .topbar .overview-menu-toggle {
        width: auto;
        min-height: 36px;
        padding: 0 10px;
        gap: 7px;
        box-shadow: none;
        font-size: 14px;
    }

    .topbar .overview-menu-toggle::before {
        width: 16px;
        height: 12px;
        background:
            linear-gradient(currentColor, currentColor) 0 0 / 16px 2px no-repeat,
            linear-gradient(currentColor, currentColor) 0 5px / 16px 2px no-repeat,
            linear-gradient(currentColor, currentColor) 0 10px / 16px 2px no-repeat;
    }

    .topnav {
        order: 3;
        width: 100%;
        display: none;
        grid-template-columns: 1fr;
        gap: 6px;
        padding-top: 6px;
    }

    .topnav.open {
        display: grid;
    }

    .topnav a,
    .topnav button,
    .theme-toggle {
        width: 100%;
        justify-content: flex-start;
        min-height: 36px;
        padding: 0 9px;
        font-size: 14px;
    }

    .theme-toggle {
        margin-left: 0;
    }

    .page {
        padding: 8px;
    }

    .scroll-top {
        right: 12px;
        bottom: 12px;
        width: 44px;
        height: 44px;
        min-height: 44px;
    }

    .toolbar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 12px;
        margin-bottom: 0;
        border-radius: 8px;
    }

    .folder-toggle {
        width: 100%;
    }

    .stats {
        min-height: 36px;
        justify-content: center;
        padding: 0 8px;
        white-space: nowrap;
    }

    .home-stats {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .storage-card {
        min-height: 36px;
        justify-content: center;
        white-space: normal;
        text-align: center;
    }

    .date-form {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 8px;
    }

    .date-form label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .date-form input {
        width: 100%;
    }

    .refresh-control {
        grid-column: 1 / -1;
        justify-content: space-between;
        width: 100%;
    }

    .grid-control {
        display: none;
    }

    .actions,
    .bulkbar,
    .searchbar {
        align-items: stretch;
        flex-direction: column;
    }

    .searchbar {
        display: flex;
        gap: 8px;
        margin-bottom: 0;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        box-shadow: var(--shadow);
    }

    .actions form,
    .actions button,
    .actions .button,
    .searchbar input,
    .searchbar button,
    .searchbar .button,
    .media-nav,
    .bulkbar button,
    .topnav a,
    .topnav button {
        width: 100%;
    }

    .row-actions,
    .selectionbar,
    .list-row {
        align-items: stretch;
        flex-direction: column;
    }

    .user-pill {
        width: 100%;
        justify-content: center;
    }

    .filters {
        margin: 0;
        padding: 10px;
        gap: 6px;
        scroll-padding: 8px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        box-shadow: var(--shadow);
    }

    .filters a {
        padding: 8px 10px;
        font-size: 14px;
    }

    .timeline {
        padding: 10px;
        box-shadow: var(--shadow);
    }

    .timeline-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .timeline-hours {
        display: flex;
        overflow-x: auto;
        gap: 6px;
    }

    .timeline-hours a {
        flex: 0 0 76px;
    }

    .selectionbar {
        align-items: stretch;
        gap: 8px;
        padding: 10px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        box-shadow: var(--shadow);
    }

    .switch {
        justify-content: space-between;
        width: 100%;
        padding: 9px 10px;
    }

    .bulkbar {
        position: static;
        padding: 10px;
    }

    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .grid[data-grid-size="2"],
    .grid[data-grid-size="3"],
    .grid[data-grid-size="4"],
    .grid[data-grid-size="5"],
    .grid[data-grid-size="6"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .meta {
        padding: 9px;
        gap: 2px;
    }

    .meta strong {
        font-size: 13px;
    }

    .meta span {
        font-size: 12px;
        line-height: 1.25;
    }

    .video-badge {
        right: 6px;
        bottom: 6px;
        padding: 4px 6px;
        font-size: 12px;
    }

    .protected-badge {
        left: 6px;
        bottom: 6px;
        padding: 4px 6px;
        font-size: 12px;
    }

    .pick {
        top: 6px;
        left: 6px;
        padding: 6px;
    }

    .pick span {
        display: none;
    }

    .viewer-head {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr);
        align-items: start;
        gap: 8px;
        margin-bottom: 10px;
    }

    .viewer-head h1 {
        font-size: 18px;
        line-height: 1.2;
    }

    .viewer-head p {
        font-size: 13px;
        line-height: 1.35;
    }

    .media-nav {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
        margin-left: 0;
    }

    .nav-button {
        width: 100%;
    }

    .viewer {
        min-height: 30vh;
        margin-bottom: 12px;
    }

    .viewer video,
    .viewer img {
        max-height: calc(100vh - 250px);
    }

    .actions {
        gap: 8px;
    }

    .portal {
        min-height: calc(100vh - 120px);
        align-content: start;
        padding-top: 34px;
    }

    .portal-head h1 {
        font-size: 24px;
    }

    .portal-actions {
        grid-template-columns: 1fr;
    }

    .portal-card {
        min-height: 132px;
    }

    .system-dialog {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
    }

    .media-view-dialog {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: 0;
    }

    .media-dialog-content {
        min-height: 100dvh;
        display: grid;
        grid-template-rows: auto auto minmax(0, 1fr) auto;
        gap: 10px;
        padding: 0;
        background: var(--background);
    }

    .media-dialog-close-inline {
        position: sticky;
        top: 0;
        z-index: 3;
        width: 100%;
        margin: 0;
        min-height: 46px;
        border-radius: 0;
    }

    .media-view-dialog .viewer-head {
        padding: 0 10px;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
        margin-bottom: 0;
    }

    .media-view-dialog .viewer-head h1 {
        font-size: 15px;
        line-height: 1.2;
    }

    .media-view-dialog .viewer-head p {
        display: none;
    }

    .media-view-dialog .media-nav {
        grid-column: auto;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-left: 0;
    }

    .media-view-dialog .viewer {
        min-height: 0;
        height: 100%;
        padding: 0;
        margin-bottom: 0;
        background: #000000;
        border-radius: 0;
    }

    .media-view-dialog .viewer video,
    .media-view-dialog .viewer img {
        height: 100%;
        max-height: calc(100dvh - 260px);
        background: #000000;
    }

    .media-view-dialog .actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 10px;
        border-top: 1px solid var(--line);
        background: var(--surface);
    }

    .media-view-dialog .actions form,
    .media-view-dialog .actions .protect-inline-form {
        grid-column: 1 / -1;
        width: 100%;
    }

    .media-view-dialog .share-create-box {
        margin: 0 10px 10px;
        padding: 10px;
        gap: 10px;
    }

    .media-view-dialog .share-create-box .admin-box-head {
        display: flex;
        flex-direction: row;
        align-items: center;
    }

    .media-view-dialog .share-create-box h2 {
        font-size: 16px;
    }

    .media-view-dialog .share-create-form {
        grid-template-columns: 1fr;
    }

    .media-view-dialog .share-result {
        padding: 10px;
    }

    .media-view-dialog .protected-note {
        display: none;
    }

    .system-dialog-head {
        flex-direction: column;
    }

    .system-dialog-head button {
        width: 100%;
    }

    .list-row {
        padding: 10px;
    }

    .admin-grid,
    .account-grid,
    .system-grid,
    .system-overview,
    .share-builder,
    .share-create-form,
    .share-row,
    .share-preview-list article,
    .protected-row,
    .cleanup-form,
    .cleanup-last-run dl,
    .job-stats,
    .job-row,
    .admin-actions,
    .guest-actions,
    .user-card-head,
    .admin-box-head {
        grid-template-columns: 1fr;
        align-items: stretch;
        flex-direction: column;
    }

    .share-options {
        position: static;
    }

    .badge-row {
        justify-content: flex-start;
    }

    .live-station {
        grid-template-columns: 1fr;
    }

    .live-picker {
        position: static;
    }

    .live-picker nav {
        display: grid;
        gap: 8px;
        max-height: 260px;
        overflow-y: auto;
    }

    .live-picker a {
        min-height: 52px;
    }

    .live-player iframe {
        height: 260px;
        min-height: 260px;
    }

    .live-grid-view {
        grid-template-columns: 1fr;
    }

    .live-grid-tile iframe {
        height: 100%;
        min-height: 0;
    }
}

@media (max-width: 380px) {
    .brand-text small {
        display: none;
    }

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

    .grid[data-grid-size="2"],
    .grid[data-grid-size="3"],
    .grid[data-grid-size="4"],
    .grid[data-grid-size="5"],
    .grid[data-grid-size="6"] {
        grid-template-columns: 1fr;
    }
}
