/* Media Manager styles. High contrast, visible focus, no information by colour alone. */
:root {
  --bg: #ffffff; --fg: #1a1a1a; --muted: #4a4a4a; --line: #8a8a8a; --soft: #f2f4f7;
  --accent: #0b5cad; --accent-fg: #ffffff; --focus: #c2410c; --ok: #116b2b; --warn: #8a5300; --err: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121417; --fg: #f1f1f1; --muted: #c4c4c4; --line: #8f8f8f; --soft: #1f242b;
          --accent: #7fb8ff; --accent-fg: #0b1220; --focus: #ffb366; --ok: #6fd48a; --warn: #ffcc66; --err: #ff8a80; }
}
* { box-sizing: border-box; }
html { font-size: 100%; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; line-height: 1.5; background: var(--bg); color: var(--fg); }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pm-skip { position: absolute; left: -10000px; top: 0; background: var(--accent); color: var(--accent-fg); padding: .5rem 1rem; z-index: 100; }
.pm-skip:focus { left: .5rem; }
.pm-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
header.pm-banner { background: var(--soft); border-bottom: 1px solid var(--line); padding: .5rem 1rem; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; }
.pm-appname { font-weight: 700; font-size: 1.15rem; color: var(--fg); text-decoration: none; }
nav.pm-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
nav.pm-nav a[aria-current="page"] { font-weight: 700; text-decoration-thickness: 3px; }
form.pm-search { display: flex; gap: .4rem; margin-left: auto; }
main { padding: 1rem 1.25rem 3rem; max-width: 110rem; }
footer.pm-footer { border-top: 1px solid var(--line); padding: .75rem 1.25rem; color: var(--muted); font-size: .9rem; }
h1 { font-size: 1.6rem; margin: .4rem 0 .8rem; }
h2 { font-size: 1.3rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1.1rem; margin: 1.1rem 0 .5rem; }
nav.pm-breadcrumb ol { list-style: none; padding: 0; margin: 0 0 .3rem; display: flex; flex-wrap: wrap; }
nav.pm-breadcrumb li + li { margin-left: .6rem; padding-left: .6rem; border-left: 1px solid var(--muted); }
button, .pm-button, input[type=submit] {
  font: inherit; padding: .35rem .8rem; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg);
  border-radius: 4px; cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.4;
}
button.pm-secondary, .pm-button.pm-secondary { background: var(--bg); color: var(--accent); }
button.pm-danger { background: #a31b14; border-color: #a31b14; color: #fff; }
button[aria-disabled="true"] { opacity: .65; }
button.pm-sort { background: none; border: none; color: inherit; font-weight: 700; padding: 0; text-decoration: underline; }
th[aria-sort="ascending"] .pm-sort::after { content: "";display:inline-block;margin-left:.4em;border-left:.3em solid transparent;border-right:.3em solid transparent;border-bottom:.4em solid currentColor; }
th[aria-sort="descending"] .pm-sort::after { content: "";display:inline-block;margin-left:.4em;border-left:.3em solid transparent;border-right:.3em solid transparent;border-top:.4em solid currentColor; }
input, select, textarea { font: inherit; padding: .3rem .45rem; border: 1px solid var(--line); border-radius: 3px; background: var(--bg); color: var(--fg); max-width: 100%; }
textarea { width: 100%; min-height: 6rem; }
label { font-weight: 600; }
.pm-field { margin: .6rem 0; }
.pm-field label, .pm-field .pm-label { display: block; }
/* A checkbox or radio sits on the same line as its label, aligned with it. */
.pm-field input[type=checkbox] + label, .pm-field input[type=radio] + label { display: inline; }
input[type=checkbox], input[type=radio] { vertical-align: middle; margin: 0 .35rem 0 0; width: 1.1rem; height: 1.1rem; }
.pm-field-inline { display: inline-flex; gap: .4rem; align-items: center; margin-right: 1rem; }
.pm-hint { color: var(--muted); font-size: .92rem; margin: .15rem 0; }
.pm-error-text { color: var(--err); font-weight: 600; }
fieldset { border: 1px solid var(--line); padding: .6rem .9rem; margin: .8rem 0; }
legend { font-weight: 700; padding: 0 .3rem; }
table { border-collapse: collapse; width: 100%; margin: .5rem 0 1rem; }
caption { text-align: left; font-weight: 700; padding: .3rem 0; }
th, td { border-bottom: 1px solid var(--line); padding: .35rem .5rem; text-align: left; vertical-align: top; }
th { background: var(--soft); }
td.pm-num, th.pm-num { text-align: right; font-variant-numeric: tabular-nums; }
.pm-thumb { width: 72px; height: 72px; object-fit: cover; background: var(--soft); display: block; }
.pm-actions-cell { white-space: nowrap; }
.pm-menu-wrap { position: relative; display: inline-block; }
[role="menu"] { position: absolute; z-index: 50; min-width: 15rem; max-width: 24rem; list-style: none; margin: .15rem 0 0; padding: .25rem 0;
  background: var(--bg); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.25); left: 0; top: 100%; }
[role="menu"].pm-menu-left { left: auto; right: 0; }
[role="menu"].pm-menu-up { top: auto; bottom: 100%; }
[role="menu"] li { margin: 0; }
[role="menuitem"] { display: block; width: 100%; text-align: left; background: none; color: var(--fg); border: none; border-radius: 0; padding: .4rem .9rem; text-decoration: none; }
[role="menuitem"]:hover, [role="menuitem"]:focus { background: var(--accent); color: var(--accent-fg); outline: none; }
[role="separator"] { border-top: 1px solid var(--line); margin: .25rem 0; }
[role="tablist"] { display: flex; flex-wrap: wrap; gap: .2rem; border-bottom: 2px solid var(--line); margin: 1rem 0 0; }
[role="tab"] { background: var(--soft); color: var(--fg); border: 1px solid var(--line); border-bottom: none; border-radius: 4px 4px 0 0; }
[role="tab"][aria-selected="true"] { background: var(--accent); color: var(--accent-fg); font-weight: 700; }
[role="tabpanel"] { padding: .5rem 0; }
dialog { border: 2px solid var(--line); border-radius: 6px; padding: 0; max-width: min(46rem, 95vw); width: 100%; background: var(--bg); color: var(--fg); }
dialog::backdrop { background: rgba(0,0,0,.5); }
.pm-dialog-head { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1rem; border-bottom: 1px solid var(--line); background: var(--soft); }
.pm-dialog-head h2 { margin: 0; font-size: 1.2rem; }
.pm-dialog-body { padding: .6rem 1rem; max-height: 70vh; overflow: auto; }
.pm-dialog-foot { padding: .6rem 1rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; flex-wrap: wrap; }
.pm-flash { border: 2px solid var(--ok); padding: .5rem .8rem; margin: .5rem 0; background: var(--soft); }
.pm-flash-error { border-color: var(--err); }
.pm-flash-warning { border-color: var(--warn); }
.pm-badge { display: inline-block; border: 1px solid var(--line); border-radius: 3px; padding: 0 .35rem; font-size: .85rem; }
.pm-badge-warn { border-color: var(--warn); color: var(--warn); }
.pm-badge-err { border-color: var(--err); color: var(--err); }
.pm-selection-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .4rem .6rem; border: 1px solid var(--line); background: var(--soft); margin: .5rem 0; }
.pm-filter-panel { border: 1px solid var(--line); padding: .6rem 1rem; margin: .5rem 0; background: var(--soft); }
.pm-filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .3rem 1rem; }
.pm-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 1rem; }
.pm-card { border: 1px solid var(--line); padding: .4rem; display: flex; flex-direction: column; gap: .3rem; }
.pm-card img { width: 100%; height: 11rem; object-fit: cover; background: var(--soft); }
.pm-pager ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: center; }
.pm-media-view img.pm-full { max-width: 100%; max-height: 80vh; height: auto; }
.pm-media-view video { max-width: 100%; max-height: 70vh; }
.pm-transcript ol { padding-left: 0; list-style: none; }
.pm-transcript li { margin: .2rem 0; }
.pm-transcript button { background: var(--bg); color: var(--accent); text-align: left; }
.pm-text-item { border-left: 4px solid var(--line); padding: .3rem .8rem; margin: .7rem 0; }
.pm-text-item.pm-ai { border-left-color: var(--warn); }
dl.pm-facts { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; }
dl.pm-facts dt { font-weight: 700; }
dl.pm-facts dd { margin: 0; }
.pm-row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
[dir="rtl"] { text-align: right; }

[hidden] { display: none !important; }
.pm-command-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem 1rem; margin: .75rem 0; }
form.pm-search { flex: 1 1 32rem; max-width: 55rem; }
.pm-search input { min-width: 8rem; width: 100%; }
main { max-width: none; }
th, td { padding: .6rem .5rem; overflow-wrap: normal; }
td:has(time), td.pm-num, .pm-date-widget { white-space: nowrap; }
button:disabled { opacity: .6; cursor: default; }
.pm-actions-cell { white-space: normal; }
[role="menu"] { max-width: min(24rem, 95vw); max-height: 80vh; overflow-y: auto; }
[role="menuitem"] { white-space: normal; }
[role="menuitem"]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
@media (max-width: 60rem) {
  .pm-search { margin-left: 0; }
  th, td { padding: .45rem; }
  table { display: block; overflow-x: auto; }
  dl.pm-facts { grid-template-columns: minmax(6rem, 1fr) minmax(0, 2fr); }
}

.able-modal-header h2 { font-size: 1.2rem; margin: 0; }

table[data-sort-url] tbody th[scope="row"], td[dir="auto"] { overflow-wrap: anywhere; }
table[data-sort-url] tbody th[scope="row"] { min-width: 8rem; max-width: 24rem; }
.pm-actions-cell button, #selection-button { white-space: nowrap; overflow-wrap: normal; }

button.pm-link { border: 0; padding: 0; background: none; color: var(--accent); text-decoration: underline; text-align: left; }
#pm-remote { max-width: min(90rem,96vw); }
.pm-compare-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(22rem,100%),1fr)); gap: 1rem; }
.pm-compare-card { border: 1px solid var(--line); padding: .8rem; min-width: 0; }
.pm-compare-card img,.pm-compare-card video { max-width: 100%; max-height: 26rem; object-fit: contain; }

body[data-theme="light"] { --bg:#fff;--fg:#1a1a1a;--muted:#4a4a4a;--line:#8a8a8a;--soft:#f2f4f7;--accent:#0b5cad;--accent-fg:#fff;--focus:#c2410c;--ok:#116b2b;--warn:#8a5300;--err:#b3261e; }
body[data-theme="dark"] { --bg:#121417;--fg:#f1f1f1;--muted:#c4c4c4;--line:#8f8f8f;--soft:#1f242b;--accent:#7fb8ff;--accent-fg:#0b1220;--focus:#ffb366;--ok:#6fd48a;--warn:#ffcc66;--err:#ff8a80; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }

.pm-search {position:relative}
#global-suggestions {position:absolute;top:100%;left:0;right:0;z-index:2000;list-style:none;margin:0;padding:.3rem;max-height:60vh;overflow:auto;background:var(--bg);color:var(--fg);border:2px solid currentColor;box-shadow:0 4px 10px #0005}
#global-suggestions[hidden]{display:none}
#global-suggestions [role=option]{padding:.65rem;overflow-wrap:anywhere;cursor:pointer;border-bottom:1px solid #8886}
#global-suggestions [aria-selected=true]{outline:3px solid currentColor;outline-offset:-3px;background:var(--soft)}
.pm-search-reason{display:block;font-size:.9em}
.pm-command-bar{gap:.65rem;align-items:center}

/* Single-record properties retain native table/row-header semantics at every width. */
table.pm-properties{width:100%;table-layout:fixed}
.pm-properties th[scope=row]{width:30%;vertical-align:top;white-space:normal}
.pm-properties td{white-space:normal;overflow-wrap:anywhere;vertical-align:top}

.able-controller .pm-player-primary,.able-controller .pm-player-secondary .pm-command-bar{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;margin:.4rem 0}
.able-controller .pm-player-primary{position:relative}
.able-controller .pm-player-primary button{color:var(--fg);background:var(--bg);font:inherit;border:1px solid var(--line)}
.able-controller .pm-player-secondary[hidden]{display:none!important}
.able-controller .able-volume-slider{z-index:4}
.able-wrapper video{max-width:100%;height:auto}

/* Viewer layout controls never hide the navigation/restore commands. */
#viewer-orientation { margin:.4rem 0 .8rem; overflow-wrap:anywhere; }
#viewer-details[hidden] { display:none !important; }
[data-shortcut-capture] { width:min(100%,25rem); cursor:pointer; }
[data-shortcut-capture][data-capturing="true"] { outline:3px solid var(--focus); outline-offset:2px; }
.pm-media-max main { max-width:none; padding:.5rem; }
.pm-media-max main > h1 { font-size:1.05rem; margin:0 0 .25rem; }
.pm-media-max #viewer-orientation { margin:.25rem 0; }
.pm-media-max .pm-media-view { margin:.25rem 0; }
.pm-media-max .pm-full,.pm-media-max video { max-height:calc(100dvh - 12rem); width:auto; max-width:100%; object-fit:contain; }
.pm-media-max .able-wrapper { max-width:100%; }
body[data-viewer-mode="window"] main { padding:.5rem; }
[data-location-field="progress"] { display:block; }

/* ---- Phase 1 normalization (1.0.6) ---- */
/* Toggle buttons: off = outlined, on = filled with a drawn check mark (no text content, so nothing extra is spoken). */
button[aria-pressed="false"] { background: var(--bg); color: var(--accent); }
button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); font-weight: 700; box-shadow: inset 0 -3px 0 var(--fg); }
button[aria-pressed="true"]::before { content: ""; display: inline-block; width: .35em; height: .7em; margin: 0 .45em .1em 0; border: solid currentColor; border-width: 0 .14em .14em 0; transform: rotate(45deg); }
/* Menus float above media players and other content; separators set destructive commands apart. */
.pm-menu-wrap { z-index: auto; }
[role="menu"] { z-index: 3000; }
.pm-menu-wrap:has([aria-expanded="true"]) { z-index: 3000; }
li.pm-menu-sep, [role="menu"] [role="separator"] { border-top: 2px solid var(--line); margin: .35rem .5rem; list-style: none; }
/* Selection count, then Bulk Actions. */
.pm-selection-bar { border: 0; background: none; padding: 0; margin: .5rem 0; }
/* Cards (PM2 card pattern): a list of equal-height cards in a responsive grid, each an article named by its heading. */
.pm-grid-tools { margin: .5rem 0; }
.pm-card-grid { list-style: none; padding: 0; margin: .5rem 0 1.5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr)); grid-auto-rows: 1fr; gap: .75rem; }
.pm-card-grid > li { display: flex; min-width: 0; }
.pm-card { flex: 1; display: flex; flex-direction: column; gap: .35rem; border: 1px solid var(--line); border-radius: .45rem; padding: .6rem; min-width: 0; background: var(--bg); }
.pm-card-media { display: block; width: 100%; aspect-ratio: 4 / 3; height: auto; object-fit: cover; background: var(--soft); border-radius: .3rem; }
.pm-card-icon { display: flex; align-items: center; justify-content: center; font-size: 3rem; color: var(--muted); }
.pm-card-title { font-size: 1.02rem; line-height: 1.3; margin: .2rem 0 0; overflow-wrap: anywhere; }
.pm-card-meta { margin: 0; color: var(--muted); font-size: .92rem; }
.pm-card-meta .pm-badge { margin-right: .3rem; }
.pm-card-actions { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding-top: .35rem; }
.pm-card-actions label { font-weight: 400; }
/* Pager: Previous | 26–50 of 600 | Next */
.pm-pager { display: flex; justify-content: center; align-items: center; gap: .5rem; margin: 1rem 0; flex-wrap: wrap; }
.pm-pager-range { min-width: 10rem; font-variant-numeric: tabular-nums; }
dialog.pm-dialog-small { max-width: min(24rem, 95vw); }
/* Dialogs: one scroll area at most; choices list stays compact. */
.pm-dialog-body { max-height: 65vh; }
.pm-choices { max-height: 16rem; overflow: auto; margin: .4rem 0; }
.pm-choices > div { padding: .15rem 0; }
.pm-choices label { font-weight: 400; }
/* Transcript: readable in light and dark themes (Able Player paints a white panel). */
.able-transcript-area, .able-transcript, .able-transcript-container, .able-window-toolbar { background: var(--bg) !important; color: var(--fg) !important; }
.able-transcript .able-transcript-seekpoint, .able-transcript span { color: var(--fg); }
.able-transcript .able-highlight { background: var(--accent) !important; color: var(--accent-fg) !important; }
.pm-transcript button, .pm-transcript li { color: var(--fg); }
.pm-transcript li[aria-current="true"] { background: var(--soft); outline: 2px solid var(--accent); }
/* Able Player uses z-index 5000–9500 internally; isolate it so open menus always appear above the player. */
.pm-media-view, .pm-compare-card, .able-wrapper { position: relative; z-index: 0; isolation: isolate; }
.pm-menu-wrap { position: relative; }
.pm-menu-wrap:has(> [aria-expanded="true"]) { z-index: 3000; }

/* 1.0.7 player: one wrapping row of standard controls in reading order. */
.pm-player { max-width: none; }
.pm-player video { display: block; max-width: min(100%, 960px); height: auto; }
.pm-player audio { display: none; }
.pm-player-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: .5rem 0; }
.pm-player-field { display: inline-flex; align-items: center; gap: .35rem; }
.pm-player-volume input { width: 6rem; }
.pm-player-seek { flex: 0 1 14rem; }
.pm-player-seek input { flex: 1 1 auto; min-width: 8rem; }
.pm-player-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pm-player input[type=range] { accent-color: var(--accent, #1a5fb4); min-height: 1.5rem; }
.pm-caption-line { min-height: 1.6em; padding: .4rem .6rem; background: #000; color: #fff; border-radius: 4px; font-size: 1.15rem; }
.pm-caption-line:empty { display: none; }
.pm-cap-small video::cue, .pm-cap-small .pm-caption-line { font-size: 90%; }
.pm-cap-large video::cue, .pm-cap-large .pm-caption-line { font-size: 140%; }
.pm-cap-xlarge video::cue, .pm-cap-xlarge .pm-caption-line { font-size: 180%; }
.pm-player:fullscreen { background: #000; color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 1rem; max-width: none; }
.pm-player:fullscreen video { max-height: calc(100vh - 6rem); max-width: 100%; margin: 0 auto; }
.pm-player-transcript { border: 1px solid var(--border, #888); border-radius: 4px; padding: .5rem; margin: .5rem 0; max-width: 960px; }
.pm-player-lines { max-height: 16rem; overflow-y: auto; position: relative; }
.pm-player-lines ol { margin: 0; padding-left: 1.5rem; }
.pm-player-lines li[aria-current="true"] { background: var(--highlight-bg, #fff3b0); color: var(--highlight-fg, #000); outline: 2px solid currentColor; }
/* Details: Media Actions on the left, tablist on the right; reading order is the same. */
.pm-details-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .75rem; }
.pm-details-bar [role=tablist] { margin-left: auto; }
.pm-inline { display: inline; }

.pm-viewer-desc { max-width: 960px; margin: .5rem 0; }
.pm-viewer-desc p { margin: .35rem 0; white-space: pre-line; }

/* Phase 2: section links (Activity, Admin), inline forms, spam trap, review and share pages */
.pm-tablinks { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; padding: 0; margin: 0 0 1rem; border-bottom: 1px solid var(--line); }
.pm-tablinks a { display: inline-block; padding: .45rem .8rem; text-decoration: none; border: 1px solid transparent; border-bottom: 0; border-radius: .35rem .35rem 0 0; }
.pm-tablinks a[aria-current="page"] { border-color: var(--line); background: var(--soft); font-weight: 600; }
.pm-inline { display: inline; }
.pm-position { padding: 0 .5rem; align-self: center; }
.pm-honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.pm-comment { border-top: 1px solid var(--line); padding: .4rem 0; }
.pm-comment h3 { font-size: 1rem; margin: 0; }
