/* =========================================================================
   Content area: media library, playlists, playlist editor, schedules,
   schedule editor. Tokens from theme.css only — no raw colors.
   Shared primitives (cards, tables, badges, buttons, modal) live in app.css.
   ========================================================================= */

/* ------------------------------------------------------------- shared --- */
.field-error { color: var(--status-danger); font-size: var(--fs-xs); margin-top: var(--space-1); }
input.invalid, select.invalid { border-color: var(--status-danger) !important; box-shadow: 0 0 0 3px var(--status-danger-soft) !important; }
.err-text { color: var(--status-danger); font-size: var(--fs-xs); line-height: 1.4; margin: 4px 0 var(--space-2); max-width: 320px; }
.warn-ic { display: inline-grid; place-items: center; color: var(--status-warning); cursor: help; border-radius: 50%; }
.warn-ic .ic { width: 16px; height: 16px; }
.dirty-note { display: inline-flex; align-items: center; gap: var(--space-2); height: 22px; padding: 0 var(--space-3); border-radius: var(--radius-full); font-size: var(--fs-xs); color: var(--status-warning-strong); background: var(--status-warning-soft); border: 1px solid var(--status-warning-border); font-weight: 500; }
.dirty-note .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--status-warning-fill); }
.is-disabled > span { opacity: 0.55; }
.kind-tag { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-secondary); font-weight: 500; white-space: nowrap; }
.kind-tag .ic { width: 15px; height: 15px; color: var(--text-muted); }
.empty-actions { justify-content: center; flex-wrap: wrap; }
.kind-sm { display: none; }

/* in-use lists (delete flow) */
.usage-list { display: grid; grid-template-columns: 110px 1fr; gap: var(--space-2) var(--space-3); margin: 0; font-size: var(--fs-sm); }
.usage-list dt { color: var(--text-muted); padding-top: 3px; }
.usage-list dd { margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-1); }
.inuse-list { display: flex; flex-direction: column; gap: var(--space-3); max-height: 320px; overflow: auto; }
.inuse-item { border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: var(--space-3) 12px; }
.inuse-item .usage-list { margin-top: var(--space-2); }

/* ------------------------------------------------------- media library --- */
.media-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.folder-row { display: flex; flex-wrap: wrap; gap: var(--space-2); flex: 1; min-width: 0; }
.folder-chip { display: inline-flex; align-items: center; height: 34px; border: 1px solid var(--border-default); background: var(--bg-surface); border-radius: var(--radius-full); box-shadow: var(--shadow-xs); transition: border-color var(--dur-fast), background var(--dur-fast); }
.folder-chip:hover { border-color: var(--border-strong); }
.folder-chip.on { border-color: var(--accent-primary-border); background: var(--accent-primary-soft); }
.folder-chip .fc-main { display: inline-flex; align-items: center; gap: var(--space-2); height: 100%; border: 0; background: none; padding: 0 12px; cursor: pointer; font-weight: 500; font-size: var(--fs-sm); color: var(--text-secondary); border-radius: var(--radius-full); }
.folder-chip.on .fc-main { color: var(--accent-primary-text); font-weight: 600; }
.folder-chip .fc-main .ic { width: 15px; height: 15px; }
.folder-chip .fc-main:focus-visible, .folder-chip .fc-more:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.folder-chip .fc-count { background: var(--bg-surface-muted); color: var(--text-secondary); border-radius: var(--radius-full); padding: 0 var(--space-2); font-size: var(--fs-xs); font-weight: 500; line-height: 18px; }
.folder-chip.on .fc-count { background: var(--accent-primary-soft-strong); color: var(--accent-primary-text); }
.folder-chip .fc-more { border: 0; background: none; height: 100%; padding: 0 8px 0 0; cursor: pointer; color: var(--text-muted); display: inline-grid; place-items: center; border-radius: var(--radius-full); }
.folder-chip .fc-more .ic { width: 15px; height: 15px; }
.folder-chip .fc-more:hover { color: var(--text-primary); }

/* storage meter — same language as the dashboard Storage card */
.storage-mini { display: flex; align-items: center; gap: var(--space-3); width: 320px; max-width: 100%; flex: none; padding: var(--space-3) var(--space-4); background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); }
.storage-mini:empty { display: none; }
.storage-mini .sm-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.storage-mini .sm-line { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.storage-mini .sm-title { font-size: var(--fs-sm); font-weight: 600; }
.storage-mini .sm-val { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.storage-mini .sm-val b { font-weight: 600; }
.storage-mini .sm-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.storage-mini .sm-bar { display: flex; align-items: center; gap: var(--space-3); }
.storage-mini .sm-bar .progress { flex: 1; }
.storage-mini .pct { font-size: var(--fs-xs); color: var(--text-secondary); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }

.media-table td { vertical-align: middle; }
.media-name { min-width: 230px; }
.media-name .name-btn { display: block; max-width: 300px; text-align: left; color: var(--text-primary); }
.media-name .name-btn:hover { color: var(--accent-primary); text-decoration: underline; }
.media-name .cell-sub { white-space: nowrap; }
.props { min-width: 150px; line-height: 1.5; }
.pl-count { border-bottom: 1px dotted var(--text-muted); cursor: help; }
.status-cell { width: 230px; }
.status-cell .row { gap: var(--space-2); flex-wrap: wrap; }
.status-cell .err-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-width: 230px; }
.info-h { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: var(--space-5) 0 var(--space-2); }
.joblog { margin-top: var(--space-3); font-size: var(--fs-sm); }
.joblog summary { cursor: pointer; color: var(--text-link); font-weight: 500; }
.joblog pre { background: var(--bg-inverse); color: var(--bg-surface-muted); padding: var(--space-3) 12px; border-radius: var(--radius-md); font-size: var(--fs-xs); overflow: auto; max-height: 220px; white-space: pre-wrap; word-break: break-word; }
.modal-foot .grow { align-self: center; }

/* upload dialog */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: var(--space-8) var(--space-5); }
.dropzone:focus-visible { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--focus-ring); }
.dropzone .dz-ic { width: 44px; height: 44px; margin-bottom: var(--space-2); }
.dropzone .dz-ic .ic { width: 22px; height: 22px; color: inherit; }
.dz-title { font-weight: 600; color: var(--text-primary); font-size: var(--fs-lg); }
.dz-sub { font-size: var(--fs-xs); color: var(--text-muted); max-width: 460px; line-height: 1.5; }
.dz-types { justify-content: center; margin: var(--space-2) 0 2px; }
.uplist:empty { display: none; }
.upitem { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3); align-items: center; }
.upitem .up-main { min-width: 0; }
.upitem .up-name { font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); }
.upitem .up-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.upitem .up-bar { margin-top: var(--space-2); }
.upitem .up-bar .progress { height: 6px; }
.upitem .up-status { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 500; }
.upitem .up-status .ic { width: 15px; height: 15px; }
.upitem.up-done .up-status { color: var(--status-success); }
.upitem.up-done .progress > span { background: var(--status-success-fill); }
.upitem.up-failed { border-color: var(--status-danger-border); background: var(--status-danger-soft); }
.upitem.up-failed .up-status, .upitem .up-err { color: var(--status-danger-strong); }
.upitem.up-failed .up-sub { white-space: normal; }

/* media preview */
.mp-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); font-size: var(--fs-sm); }
.mp-props { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.mp-stage { position: relative; background: var(--bg-media); border-radius: var(--radius-lg); display: grid; place-items: center; min-height: 240px; overflow: hidden; }
.mp-stage img, .mp-stage video { max-width: 100%; max-height: 66vh; display: block; }
.mp-slides:focus-visible { outline-offset: 3px; }
.mp-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.mp-nav:hover { background: var(--bg-surface-subtle); }
.mp-nav.prev { left: 10px; }
.mp-nav.prev .ic { transform: rotate(90deg); }
.mp-nav.next { right: 10px; }
.mp-nav.next .ic { transform: rotate(-90deg); }
.mp-bar { margin: var(--space-3) 0 8px; }
.mp-strip { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: var(--space-1); }
.mp-thumb { position: relative; flex: none; width: 112px; aspect-ratio: 16 / 9; border: 2px solid transparent; border-radius: var(--radius-md); padding: 0; overflow: hidden; background: var(--bg-surface-muted); cursor: pointer; }
.mp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mp-thumb span { position: absolute; left: 4px; bottom: 4px; background: var(--bg-overlay); color: var(--text-on-accent); font-size: var(--fs-xs); font-weight: 600; border-radius: var(--radius-xs); padding: 0 var(--space-1); }
.mp-thumb.on { border-color: var(--accent-primary); }
.mp-error { text-align: center; padding: var(--space-10) var(--space-5); color: var(--text-muted); }
.mp-error .empty-ic { width: 48px; height: 48px; border-radius: var(--radius-xl); background: var(--status-danger-soft); color: var(--status-danger); display: grid; place-items: center; margin: 0 auto var(--space-4); }
.mp-error h3 { font-size: var(--fs-lg); margin-bottom: var(--space-2); }
.mp-error p { max-width: 460px; margin: 0 auto var(--space-4); line-height: 1.5; }
.mp-web { margin-top: 12px; background: var(--bg-surface); border: 1px solid var(--border-default); }

/* ------------------------------------------------------ playlists list --- */
.pl-name { min-width: 240px; }
.pl-title { gap: var(--space-2); flex-wrap: wrap; }
.pl-name .cell-title { color: var(--text-primary); }
.pl-name a.cell-title:hover { color: var(--accent-primary); }
.pl-name .badge { height: 20px; font-size: var(--fs-xs); padding: 0 var(--space-2); }
.pl-name .badge .ic { width: 12px; height: 12px; }

/* ------------------------------------------------------ playlist editor --- */
.pe .pe-main { min-width: 0; }
.pe-head { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: var(--space-3); }
.pe-head-row { display: flex; align-items: flex-start; gap: var(--space-2); flex-wrap: wrap; }
.pe-opts { align-items: center; gap: var(--space-5); }
.pe-opts .switch span { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); font-weight: 500; color: var(--text-secondary); }
.pe-opts .switch .ic { width: 15px; height: 15px; color: var(--text-muted); }
.pe-name-wrap { min-width: 200px; }
input.pe-name { height: var(--control-h-lg); font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.01em; }
.pe-order-h { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5) 0; }
.pe-order-h h3 { font-size: var(--fs-md); }
.items { padding: var(--space-3) var(--space-4) var(--space-4); gap: var(--space-2); }
.items.drop-into { outline: 2px dashed var(--accent-primary); outline-offset: -6px; border-radius: var(--radius-lg); }
.pe-empty { list-style: none; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: var(--space-10) var(--space-4); color: var(--text-muted); border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--bg-surface-subtle); }
.pe-empty b { color: var(--text-primary); font-size: var(--fs-lg); }
.pe-empty .empty-ic { width: 44px; height: 44px; border-radius: var(--radius-xl); background: var(--accent-primary-soft); color: var(--accent-primary); display: grid; place-items: center; margin-bottom: var(--space-2); }
.item { align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-1); transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.item:hover { border-color: var(--border-strong); }
.item:focus-within { border-color: var(--accent-primary-border); }
.item .handle { width: 24px; height: 36px; border-radius: var(--radius-sm); }
.item .handle .ic { width: 16px; height: 16px; }
.item .handle:hover { background: var(--bg-surface-muted); color: var(--text-primary); }
.item .handle:active { cursor: grabbing; }
.item .pos { width: 22px; height: 22px; line-height: 22px; border-radius: 50%; background: var(--bg-surface-muted); color: var(--text-secondary); font-variant-numeric: tabular-nums; flex: none; }
.item .thumb-btn { border: 0; padding: 0; background: none; cursor: zoom-in; border-radius: var(--radius-sm); flex: none; line-height: 0; }
.item .thumb-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.item .thumb-btn .thumb { width: 72px; height: 44px; }
.item-body { flex: 1; min-width: 0; }
.item-title { gap: var(--space-2); }
.item-title .badge { flex: none; }
input.item-name { height: 28px; border-color: transparent; box-shadow: none; font-weight: 600; font-size: var(--fs-md); padding: 0 var(--space-2); margin-left: -6px; background: transparent; min-width: 0; flex: 1; }
input.item-name:hover:not(:focus) { border-color: var(--border-default); background: var(--bg-surface); }
input.item-name:focus { background: var(--bg-surface); }
input.item-name::placeholder { color: var(--text-primary); opacity: 1; }
input.item-name:focus::placeholder { color: var(--text-muted); }
.item .meta { margin-top: 4px; }
.item .meta .kind-badge { height: 20px; padding: 0 var(--space-2); }
.item .meta .kind-badge .ic { width: 12px; height: 12px; }
.dur-wrap { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.dur-wrap .unit { margin-left: -2px; }
.dur-wrap .check { gap: var(--space-1); }
.dur-wrap .check input { width: 14px; height: 14px; }
.item .meta input.dur { width: 62px; }
.item-actions { display: flex; align-items: center; gap: 0; flex: none; }
.item-actions .icon-btn { width: 30px; height: 30px; }
.item-actions .icon-btn .ic { width: 16px; height: 16px; }
.item-actions .icon-btn:disabled { opacity: 0.3; cursor: default; background: none; }
.item-actions .icon-btn.off { color: var(--status-warning); }
.item-actions .danger-hover:hover { color: var(--status-danger); background: var(--status-danger-soft); }
.icon-spacer { display: inline-block; width: 30px; }
.item.notready { border-color: var(--status-warning-border); }
.item.hidden-item input.item-name::placeholder, .item.hidden-item input.item-name { color: var(--text-muted); text-decoration: line-through; }
.item.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: var(--accent-primary-soft); box-shadow: 0 0 0 2px var(--accent-primary-border); } 100% { background: var(--bg-surface); } }

/* summary side panel */
.pe-side { display: flex; flex-direction: column; gap: var(--space-4); }
.pe-side .card-head .btn { flex: none; }
.sum-total { padding-bottom: var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); padding-top: var(--space-4); }
.sum-label { font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.sum-value { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.sum-value.big { font-size: var(--fs-kpi); letter-spacing: -0.03em; line-height: 1.1; margin-bottom: 4px; }
.sum-comp { margin-top: var(--space-4); }
.sum-ratio { margin-top: var(--space-3); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.sum-alerts:not(:empty) { margin-top: var(--space-4); }
.sum-used { display: flex; gap: var(--space-2); align-items: flex-start; margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); color: var(--text-secondary); line-height: 1.45; }
.sum-used .ic { width: 16px; height: 16px; margin-top: 1px; color: var(--text-muted); }

/* media library picker */
.pe-lib { min-width: 0; margin-top: var(--space-4); }
.pe-lib-head { flex-wrap: wrap; }
.pe-lib-tools { flex-wrap: wrap; justify-content: flex-end; }
.pe-lib-tools .search { width: 220px; max-width: 100%; }
.pe-lib-tools select { width: auto; }
.pe-tabs { padding: 0 var(--space-4); margin-bottom: 0; }
.pe-tabs .count-pill { height: 18px; min-width: 20px; }
.pe-lib-hint { padding: var(--space-3) var(--space-5) 0; }
.lib-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: var(--space-3); padding: var(--space-4) var(--space-5) var(--space-5); max-height: 460px; }
.lib-card { position: relative; box-shadow: var(--shadow-xs); transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.lib-card:not(:disabled):hover { border-color: var(--accent-primary-border); box-shadow: var(--shadow-md); }
.lib-card:focus-visible { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--focus-ring); }
.lib-card .thumb { height: auto; aspect-ratio: 16 / 9; }
.lib-card .lib-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 8px var(--space-3); }
.lib-card .lib-name { display: block; }
.lib-card .lib-in { position: absolute; top: 6px; right: 6px; display: inline-flex; align-items: center; gap: 2px; background: var(--status-success); color: var(--text-on-accent); border-radius: var(--radius-full); padding: 1px var(--space-2); font-size: var(--fs-xs); font-weight: 600; }
.lib-card .lib-in .ic { width: 12px; height: 12px; }
.lib-card .err-inline { color: var(--status-danger); }
.lib-empty { grid-column: 1 / -1; padding: var(--space-8) var(--space-4); }

/* --------------------------------------------------------- schedules --- */
.sc-content { min-width: 140px; }
.sc-table td { vertical-align: middle; }
.wpw { margin-top: var(--space-4); }
.wpw-rules { margin-bottom: var(--space-4); }
.wpw-rules .label { margin-bottom: var(--space-2); }
.wpw-order { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); counter-reset: wpw; }
.wpw-order li { counter-increment: wpw; display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px 0 var(--space-2); border-radius: var(--radius-full); background: var(--bg-surface-muted); color: var(--text-secondary); font-size: var(--fs-sm); }
.wpw-order li::before { content: counter(wpw); width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-surface); color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 600; }
.wpw-order li:first-child { background: var(--accent-primary-soft); color: var(--accent-primary-text); }
.wpw-order li:first-child::before { background: var(--accent-primary); color: var(--text-on-accent); }
.wpw-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: var(--space-3); }
.wpw-form .field { width: 260px; max-width: 100%; }
.wpw-out { margin-top: var(--space-4); }
.wpw-out:empty { display: none; }
.wpw-at { margin-bottom: var(--space-2); }
.table-wrap.bordered { border: 1px solid var(--border-default); border-radius: var(--radius-lg); }
.badge.src-schedule { background: var(--accent-primary-soft); color: var(--accent-primary-text); border-color: var(--accent-primary-border); }
.badge.src-screen { background: var(--status-info-soft); color: var(--status-info-strong); border-color: var(--status-info-border); }
.badge.src-group { background: var(--bg-surface-muted); color: var(--text-secondary); border-color: var(--border-default); }
.badge.src-fallback { background: var(--status-warning-soft); color: var(--status-warning-strong); border-color: var(--status-warning-border); }
.badge.src-none { background: var(--status-neutral-soft); color: var(--status-neutral-strong); border-color: var(--status-neutral-border); }

/* ---------------------------------------------------- schedule editor --- */
.se-form { padding: 0 var(--space-6) var(--space-2); min-width: 0; }
.se-errors .form-error { margin: var(--space-4) 0 0; }
.se-form > .form-error { margin: var(--space-4) 0 0; }
.se-sec { border: 0; border-bottom: 1px solid var(--border-subtle); margin: 0; padding: var(--space-5) 0; min-width: 0; }
.se-sec:last-child { border-bottom: 0; }
.se-sec legend { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: var(--fs-lg); padding: 0; margin-bottom: var(--space-1); float: left; width: 100%; }
.se-sec legend + * { clear: both; }
.se-num { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-primary-soft); color: var(--accent-primary-text); display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 600; flex: none; }
.se-desc { margin: 0 0 var(--space-4) 33px; font-size: var(--fs-sm); color: var(--text-muted); }
.se-sec .check { font-weight: 500; font-size: var(--fs-sm); }
.se-sec .stack > .check { display: flex; }
.se-sec .row-between > .link-btn { margin-bottom: var(--space-2); display: inline-flex; align-items: center; gap: 4px; }
.se-sec .row-between > .link-btn .ic { width: 14px; height: 14px; }
.daychips-wrap { margin: var(--space-4) 0 var(--space-1); }
.daychips { flex-wrap: wrap; }
.daychips label { width: 44px; height: var(--control-h); transition: border-color var(--dur-fast), background var(--dur-fast); }
.daychips label:hover { border-color: var(--text-faint); }
.daychips label:has(input:checked):hover { border-color: var(--accent-primary-hover); background: var(--accent-primary-hover); }
.daychips label:focus-within { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
.se-when { margin-top: var(--space-4); }
.se-window { margin-top: var(--space-4); }
.se-window-row { flex-wrap: wrap; align-items: flex-end; }
.se-window-row > span { padding-bottom: var(--space-3); }
.se-window-row .field > span { display: block; }
.se-window-row > div { min-width: 140px; }
.se-sem { margin-top: var(--space-3); background: var(--bg-surface-subtle); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); line-height: 1.5; }
.se-adv summary { cursor: pointer; display: flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: var(--fs-lg); border-radius: var(--radius-sm); }
.se-adv summary .ic { width: 16px; height: 16px; color: var(--text-muted); }
.se-adv summary:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 3px; }
.se-side { display: flex; flex-direction: column; gap: var(--space-4); }
.se-summary { margin: 0; line-height: 1.65; color: var(--text-secondary); font-size: var(--fs-md); }
.se-summary b { color: var(--text-primary); font-weight: 600; }
.se-up { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.se-up-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--fs-sm); }
.se-up-list li { display: flex; align-items: flex-start; gap: var(--space-2); }
.se-up-list .ic { width: 15px; height: 15px; margin-top: 2px; color: var(--accent-primary); }
.se-up-list .up-when { font-weight: 500; font-variant-numeric: tabular-nums; }
.se-up-list .up-until { display: block; font-weight: 400; font-size: var(--fs-xs); color: var(--text-muted); }
.se-actions { display: flex; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.se-actions .btn-primary { flex: 1; }
.se-side .dirty-note { display: flex; width: fit-content; margin: var(--space-3) 0 0 auto; }
.se-side .dirty-note[hidden] { display: none; }

/* ------------------------------------------------------ desktop layout --- */
@media (min-width: 1101px) {
  .editor.pe, .editor.se { grid-template-columns: minmax(0, 1fr) 340px; }
  .pe-side, .se-side { position: sticky; top: calc(var(--topbar-h) + var(--space-4)); }
}

/* ------------------------------------------------- tablet: rail layout --- */
@media (max-width: 1199px) {
  .media-table th:nth-child(3), .media-table td.td-type, .media-table th:nth-child(4), .media-table td.td-up { display: none; }
  .kind-sm { display: inline; }
  .status-cell { width: 190px; }
  .status-cell .err-text { max-width: 190px; }
  .media-name { min-width: 200px; }
  .media-name .name-btn { max-width: 220px; }
}

/* ------------------------------------------- mobile: tables → card rows --- */
@media (max-width: 760px) {
  .toolbar .search { width: 100%; }
  .toolbar select { flex: 1; min-width: 0; }
  .media-top { flex-direction: column; align-items: stretch; }
  .storage-mini { width: auto; }
  .kind-sm { display: inline; }

  .media-table, .media-table tbody, .pl-table, .pl-table tbody, .sc-table, .sc-table tbody { display: block; }
  .media-table thead, .pl-table thead, .sc-table thead { display: none; }
  .media-table tr, .pl-table tr, .sc-table tr { display: grid; gap: var(--space-2) var(--space-3); padding: var(--space-3); border: 1px solid var(--border-default); border-radius: var(--radius-lg); margin: var(--space-2) var(--space-3); }
  .media-table td, .pl-table td, .sc-table td { display: block; padding: 0; border: 0; background: none !important; min-width: 0; }
  .media-table tr.selected { border-color: var(--accent-primary-border); background: var(--accent-primary-soft); }
  .media-table .media-name, .pl-name { min-width: 0; }
  .media-name .name-btn { max-width: 100%; }
  .media-name .cell-sub { white-space: normal; }

  .media-table tr { grid-template-columns: 24px minmax(0, 1fr) auto; }
  .media-table td.td-check { grid-column: 1; grid-row: 1; align-self: start; padding-top: 4px; width: auto; }
  .media-table td.td-name { grid-column: 2; grid-row: 1; }
  .media-table td.td-act { grid-column: 3; grid-row: 1; align-self: start; width: auto; }
  .media-table td.td-status { grid-column: 2 / -1; grid-row: 2; width: auto; }
  .media-table td.td-props { grid-column: 2 / -1; grid-row: 3; min-width: 0; }
  .media-table td.td-type, .media-table td.td-up, .media-table td.td-pl { display: none; }
  .status-cell .err-text { max-width: none; }

  .pl-table tr { grid-template-columns: minmax(0, 1fr) auto; }
  .pl-table td.td-name { grid-column: 1; grid-row: 1; }
  .pl-table td.td-act { grid-column: 2; grid-row: 1; align-self: start; width: auto; }
  .pl-table td.td-used { grid-column: 1; grid-row: 2; }
  .pl-table td.td-dur { grid-column: 2; grid-row: 2; justify-self: end; color: var(--text-muted); }
  .pl-table td.td-items, .pl-table td.td-upd { display: none; }

  .sc-table tr { grid-template-columns: minmax(0, 1fr) auto; }
  .sc-table td.td-name { grid-column: 1; grid-row: 1; }
  .sc-table td.td-act { grid-column: 2; grid-row: 1; align-self: start; width: auto; }
  .sc-table td.td-status { grid-column: 1 / -1; grid-row: 2; white-space: normal; }
  .sc-table td.td-runs { grid-column: 1 / -1; grid-row: 3; font-size: var(--fs-xs); color: var(--text-secondary); }
  .sc-table td.td-runs > div { display: inline; }
  .sc-table td.td-runs .cell-sub { margin: 0; font-size: inherit; color: inherit; }
  .sc-table td.td-runs .cell-sub::before { content: ' · '; }
  .sc-table td.td-content, .sc-table td.td-targets { grid-column: 1 / -1; font-size: var(--fs-xs); color: var(--text-muted); min-width: 0; }
  .sc-table td.td-content::before { content: 'Plays: '; }
  .sc-table td.td-targets::before { content: 'On: '; }
  .sc-table td.td-targets > div { display: inline; }
  .sc-table td.td-targets > div + div::before { content: ' · '; }
  .sc-table td.td-targets .cell-sub { margin: 0; font-size: inherit; }
  .table-foot { flex-wrap: wrap; gap: var(--space-1) var(--space-3); }

  .wpw-form .field { width: 100%; }
  .wpw-form .btn { flex: 1; }
  .wpw-table th:nth-child(3), .wpw-table td:nth-child(3) { min-width: 180px; }

  /* playlist editor */
  .pe-head { padding: var(--space-4); }
  .pe-head-row .pe-name-wrap { flex-basis: 100%; }
  .pe-head-row:first-child { justify-content: flex-end; }
  .pe-head-row:first-child .pe-name-wrap { order: -1; }
  .pe-opts { gap: var(--space-4); }
  .items { padding: var(--space-3); }
  .item { flex-wrap: wrap; padding: var(--space-3); row-gap: var(--space-2); }
  .item .pos { display: none; }
  .item .handle { width: 22px; }
  .item-body { flex: 1 1 calc(100% - 140px); }
  .item-actions { width: 100%; justify-content: flex-end; border-top: 1px solid var(--border-subtle); padding-top: var(--space-1); }
  .lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: var(--space-3); }
  .pe-lib-tools, .pe-lib-tools .search { width: 100%; }
  .pe-lib-tools select { flex: 1; min-width: 0; }
  .pe-lib-hint { padding: var(--space-3) var(--space-4) 0; }

  /* schedule editor */
  .se-form { padding: 0 var(--space-4) var(--space-2); }
  .se-desc { margin-left: 0; }
  .usage-list { grid-template-columns: 1fr; }
  .mp-thumb { width: 84px; }
  .se-window-row > div { min-width: 120px; flex: 1; }
  .se-actions .btn { flex: 1; }
}

/* toolbar filters wrap evenly on phones */
@media (max-width: 640px) {
  .toolbar.tb2 > .search { flex: 1 1 100%; }
  .toolbar.tb2 > select { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .toolbar.tb2 > .grow { display: none; }
  .toolbar.tb2 > .btn { flex: 1 1 auto; }
}
