/* The table shares the normal page scroll and preserves the rest of the app. */
body.table-layout { overflow-x: clip; }
.table-layout .movies-section { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px 20px; align-items: center; }
.table-layout .library-tabs { grid-column: 1; grid-row: 1; margin: 0; }
.table-layout .section-header { grid-column: 2; grid-row: 1; margin: 0; padding: 0; gap: 12px; }
.table-layout .library-tabs:not(.hidden) + .section-header #grid-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.table-layout .mt-panel, .table-layout .movies-grid, .table-layout .empty-state { grid-column: 1 / -1; }
/* Only the table extends beyond the app's centered desktop column. */
.table-layout .mt-panel { width: calc(var(--mt-workspace-width, 100vw) - 3rem); margin-inline: calc((100% - var(--mt-workspace-width, 100vw)) / 2 + 1.5rem); }
.library-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; flex-wrap: wrap; }
#gallery-sort-controls[hidden], #library-table-panel[hidden], .mt-columns-control[hidden], .mt-column-menu[hidden], .mt-column-choice[hidden], .mt-column-options fieldset[hidden], .mt-no-columns[hidden] { display: none; }
#movies-grid[hidden] { display: none; }
.mt-view-controls { display: flex; align-items: center; gap: .6rem; }
.mt-view-controls button, .mt-table button { font-family: var(--font-body); cursor: pointer; }
.mt-layout-toggle { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--border-color); border-radius: 9px; background: var(--input-bg); }
.mt-layout-toggle button { display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 32px; padding: 0 .65rem; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary); font-size: .76rem; font-weight: 500; transition: color 120ms, background 120ms; }
.mt-layout-toggle button[aria-pressed="true"] { color: var(--text-primary); background: var(--bg-card-solid); box-shadow: 0 1px 4px #0002; }
.mt-layout-toggle button[aria-pressed="true"] svg { color: var(--accent); }
.mt-view-controls svg { width: 15px; height: 15px; flex: 0 0 auto; }
.mt-columns-control { position: relative; }
.mt-columns-button { display: flex; align-items: center; gap: .45rem; min-height: 38px; padding: 0 .8rem; border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-secondary); background: var(--bg-surface-solid); font-size: .76rem; font-weight: 500; }
.mt-columns-button:hover, .mt-columns-button[aria-expanded="true"] { color: var(--text-primary); border-color: var(--border-hover); }
.mt-column-count { border-radius: 4px; background: var(--input-bg); padding: 2px 5px; color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: .68rem; }
.mt-column-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 25; width: 330px; padding: 16px; border: 1px solid var(--border-hover); border-radius: 14px; background: var(--bg-surface-solid); box-shadow: 0 18px 50px #0004; text-align: left; }
.mt-menu-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.mt-menu-heading strong { color: var(--text-primary); font-size: .88rem; font-weight: 600; }
.mt-menu-heading p { color: var(--text-muted); font-size: .72rem; margin-top: 5px; line-height: 1.5; }
.mt-reset { padding: 3px 0; border: 0; background: none; color: var(--accent); font-size: .73rem; }
.mt-presets { display: flex; gap: 5px; margin: 14px 0; }
.mt-presets button { flex: 1; min-height: 32px; font-size: .73rem; color: var(--text-secondary); background: var(--input-bg); border: 1px solid var(--border-color); border-radius: 6px; }
.mt-presets button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.mt-search-label { display: block; }
.mt-column-search { width: 100%; height: 36px; border: 1px solid var(--border-color); border-radius: 7px; background: var(--input-bg); color: var(--text-primary); font: inherit; font-size: .76rem; padding: 0 10px; }
.mt-column-search::placeholder { color: var(--text-muted); }
.mt-column-options { max-height: min(340px, 40dvh); overflow-y: auto; overscroll-behavior: contain; margin-top: 12px; scrollbar-width: thin; }
.mt-column-options fieldset { border: 0; margin: 0 0 12px; padding: 0; }
.mt-column-options legend { font-size: .64rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; padding: 0 6px; }
.mt-column-choice { display: flex; align-items: center; gap: 10px; min-height: 33px; padding: 5px 6px; border-radius: 5px; color: var(--text-secondary); cursor: pointer; font-size: .76rem; }
.mt-column-choice:hover { background: var(--input-bg); color: var(--text-primary); }
.mt-column-choice input { width: 14px; height: 14px; accent-color: var(--accent); }
.mt-column-choice small { margin-left: auto; font-size: .65rem; color: var(--text-muted); }
.mt-no-columns { padding: 15px 6px; color: var(--text-secondary); font-size: .8rem; }
.mt-density { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--border-color); }
.mt-density > span { color: var(--text-secondary); font-size: .73rem; }
.mt-density > div { display: flex; padding: 3px; border: 1px solid var(--border-color); border-radius: 6px; }
.mt-density button { padding: 6px 8px; border: 0; border-radius: 4px; background: transparent; color: var(--text-secondary); font-size: .67rem; }
.mt-density button[aria-pressed="true"] { color: var(--text-primary); background: var(--bg-card-solid); }
.mt-panel { --mt-row-height: 44px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-surface-solid); }
.mt-panel[data-density="comfortable"] { --mt-row-height: 60px; }
.mt-heading-viewport { position: sticky; top: 0; z-index: 6; overflow: hidden; border-radius: 11px 11px 0 0; background: var(--bg-card-solid); }
.mt-viewport { height: var(--mt-body-height); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; position: relative; }
.mt-viewport::-webkit-scrollbar { display: none; }
.mt-data-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.mt-footer-dock { position: sticky; bottom: 0; z-index: 6; border-top: 1px solid var(--border-color); border-radius: 0 0 11px 11px; background: var(--bg-surface-solid); }
.mt-horizontal-scroll { height: 17px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--border-hover) transparent; }
.mt-horizontal-scroll[hidden] { display: none; }
.mt-horizontal-track { height: 1px; }
.mt-table { table-layout: fixed; border-collapse: separate; border-spacing: 0; min-width: 100%; color: var(--text-secondary); font-size: .78rem; font-variant-numeric: tabular-nums; }
.mt-table th { position: sticky; top: 0; z-index: 3; height: 40px; padding: 0; text-align: left; background: var(--bg-card-solid); border-bottom: 1px solid var(--border-hover); font-weight: 500; }
.mt-table th button { display: flex; align-items: center; gap: 7px; width: 100%; height: 39px; padding: 0 14px; border: 0; background: transparent; color: var(--text-muted); font-size: .7rem; font-weight: 500; white-space: nowrap; overflow: hidden; }
.mt-table th button > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.mt-table th button:hover, .mt-table th[aria-sort="ascending"] button, .mt-table th[aria-sort="descending"] button { color: var(--text-primary); }
.mt-sort-icon { display: flex; opacity: 0; flex: 0 0 13px; }
.mt-sort-icon svg { width: 13px; height: 13px; }
.mt-table th:hover .mt-sort-icon { opacity: .5; }
.mt-sort-icon.is-sorted { opacity: 1; color: var(--accent); }
.mt-sort-icon.is-desc { transform: rotate(180deg); }
.mt-resize { position: absolute; right: -4px; top: 0; width: 9px; height: 100%; cursor: col-resize; z-index: 4; touch-action: none; }
.mt-resize::after { content: ''; position: absolute; top: 10px; bottom: 10px; left: 4px; width: 1px; background: var(--border-color); }
.mt-resize:hover::after, .mt-resize:focus-visible::after { width: 2px; background: var(--accent); }
.mt-row { height: var(--mt-row-height); cursor: pointer; }
.mt-row td { height: var(--mt-row-height); padding: 0 14px; border-bottom: 1px solid var(--border-color); background: var(--bg-surface-solid); white-space: nowrap; }
.mt-row:nth-child(even) td { background: color-mix(in srgb, var(--bg-surface-solid) 97%, var(--text-primary)); }
.mt-row:hover td, .mt-row:focus-within td { background: color-mix(in srgb, var(--bg-surface-solid) 94%, var(--accent)); }
.mt-table .mt-pinned { position: sticky; left: 0; z-index: 2; border-right: 1px solid var(--border-color); }
.mt-table th.mt-pinned { z-index: 5; }
.mt-scrolled .mt-pinned { box-shadow: 5px 0 8px -6px #0008; }
.mt-row td.mt-pinned { padding: 0 12px; }
.mt-film { display: flex; align-items: center; gap: 10px; width: 100%; height: calc(var(--mt-row-height) - 1px); background: none; border: 0; color: var(--text-primary); text-align: left; font-size: .78rem; font-weight: 500; }
.mt-film-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-thumbnail { flex: 0 0 22px; height: 32px; border-radius: 3px; overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--text-muted); background: var(--input-bg); font-size: .75rem; }
.mt-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.mt-film-open { margin-left: auto; opacity: 0; color: var(--text-muted); display: flex; }
.mt-film-open svg { width: 13px; height: 13px; }
.mt-row:hover .mt-film-open, .mt-film:focus-visible .mt-film-open { opacity: 1; }
.mt-cell { overflow: hidden; text-overflow: ellipsis; }
.mt-table .mt-numeric { text-align: right; }
.mt-table th.mt-numeric button { justify-content: flex-end; }
.mt-status { display: inline-flex; align-items: center; gap: 5px; font-size: .73rem; font-weight: 500; }
.mt-status svg { width: 12px; height: 12px; }
.mt-green { color: #62cfa3; }
.mt-violet { color: #b99afa; }
.mt-cyan { color: #69cbdc; }
.mt-amber { color: #e5bb71; }
.light-theme .mt-green { color: #197551; }
.light-theme .mt-violet { color: #6d28d9; }
.light-theme .mt-cyan { color: #11768b; }
.light-theme .mt-amber { color: #936515; }
.mt-no, .mt-missing { color: var(--text-muted); }
.mt-no-dot { width: 5px; height: 5px; margin: 0 4px; border: 1px solid currentColor; border-radius: 50%; opacity: .7; }
.mt-score { font-weight: 600; }
.mt-scale { color: var(--text-muted); font-size: .65rem; }
.mt-personal-star { color: var(--accent); }
.mt-spacer, .mt-spacer td { padding: 0; border: 0; height: 0; line-height: 0; }
.mt-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 35px; padding: 8px 14px; color: var(--text-muted); font-size: .66rem; font-variant-numeric: tabular-nums; }
.mt-range { color: var(--text-secondary); }
.mt-resizing, .mt-resizing * { cursor: col-resize !important; user-select: none; }
.mt-announcement, .mt-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mt-view-controls button:focus-visible, .mt-view-controls input:focus-visible, .mt-table button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mt-viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mt-horizontal-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 720px) {
    .table-layout .mt-panel { width: auto; margin-inline: 0; }
    .table-layout .movies-section { display: block; }
    .table-layout .library-tabs { margin-bottom: .75rem; }
    .table-layout .section-header { flex-direction: row; align-items: center; flex-wrap: wrap; gap: .65rem; margin-bottom: .8rem; }
    .library-header-actions { gap: .5rem; }
    .mt-layout-toggle button { padding: 0 .5rem; }
    .mt-layout-toggle button span { display: none; }
    .mt-column-menu { position: fixed; top: auto; bottom: 12px; left: 16px; right: 16px; width: auto; max-height: calc(100dvh - 24px); }
    .mt-footer { font-size: .61rem; }
    .mt-footer #mt-table-help { max-width: 180px; text-align: right; }
}
@media (prefers-reduced-motion: reduce) { .mt-layout-toggle button { transition: none; } }
