/* Shared styling for the divided ATEM Config Explorer tools (Macro
   Viewer, Audio Mapping, Labels, ...). One file so the card-loading row
   and the macro-card/chip/tab pieces look identical everywhere they're
   used, instead of drifting across hand-copied <style> blocks per page.
   Loaded via a plain <link> tag from each tool page. */

.atemx { max-width: 1100px; margin: 0 auto; }
.atemx h3 { margin-top: 32px; }
.atemx-article-spacing { margin-top: 40px; }

/* --- Top row: 5 cards (drag & drop / code / 3 recent) --- */
.atemx-card-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}
@media (max-width: 820px) {
    .atemx-card-row { grid-template-columns: repeat(2, 1fr); }
}
.atemx-card {
    border: var(--border-width) solid var(--border-color);
    background: var(--surface-color);
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s;
    position: relative;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    color: var(--text-main);
}
.atemx-card:hover { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--border-color); }
.atemx-card-icon { font-size: 1.6rem; margin-bottom: 4px; }
.atemx-card-title { font-weight: bold; font-size: 0.9rem; }
.atemx-card-sub { color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }
.atemx-card-drop.atemx-dropzone-active { border-color: var(--primary); background: var(--surface-alt); }
.atemx-card-code.active { background: var(--primary); color: #1a1a1a; }
.atemx-card-code.active .atemx-card-sub { color: #1a1a1a; }
.atemx-card-empty { cursor: default; border-style: dashed; color: var(--text-muted); }
.atemx-card-empty:hover { transform: none; box-shadow: none; }
.atemx-card-filled .atemx-card-title { word-break: break-word; }
.atemx-card-remove {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
}
.atemx-card-remove:hover { color: var(--text-main); }
#atemxFileInput { display: none; }
label.btn { display: inline-block; text-decoration: none; }

.atemx-tool-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0 20px;
}
.atemx-tool-link {
    display: inline-block;
    font-family: monospace;
    font-size: 0.8rem;
    text-transform: uppercase;
    text-decoration: none;
    background: var(--surface-alt);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
}
.atemx-tool-link:hover { background: var(--surface-color); }
.atemx-tool-link-current {
    background: var(--primary);
    color: #1a1a1a;
    font-weight: bold;
    cursor: default;
}
.atemx-tool-link-disabled {
    opacity: 0.4;
    pointer-events: none;
}
.atemx-tool-clear {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: monospace;
    font-size: 0.8rem;
    text-transform: uppercase;
    padding: 6px 12px;
    cursor: pointer;
}
.atemx-tool-clear:hover { color: var(--text-main); background: var(--surface-alt); }

.atemx-code-box { margin-bottom: 24px; }
.atemx-code-box textarea {
    width: 100%;
    box-sizing: border-box;
    height: 200px;
    font-family: monospace;
    resize: vertical;
}

.atemx-active-label {
    font-family: monospace;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0 0 16px;
}

.atem-empty { color: var(--text-muted); }
.atem-warnings { margin-bottom: 20px; }
.atem-warning { font-family: monospace; color: #f59e0b; margin-bottom: 4px; }
.atem-size-warning { font-family: monospace; color: #f59e0b; margin-bottom: 12px; }
.atem-menu-filter { width: 100%; box-sizing: border-box; }

/* --- Macros: list on the left, detail on the right --- */
.atemx-macro-split { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
@media (max-width: 700px) {
    .atemx-macro-split { grid-template-columns: 1fr; }
}
.atemx-macro-list-panel {
    border: var(--border-width) solid var(--border-color);
    background: var(--surface-color);
    padding: 10px;
}
.atemx-macro-list-panel .atem-menu-filter { margin-bottom: 8px; }
.atemx-macro-list { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow-y: auto; }
.atem-macro-list-item {
    text-align: left; background: none; border: none; color: var(--text-main);
    font-family: monospace; font-size: 0.85rem; padding: 6px 8px; cursor: pointer; text-transform: none;
}
.atem-macro-list-item:hover, .atem-macro-list-item:focus-visible { background: var(--surface-alt); }
.atem-macro-list-item.active { background: var(--primary); color: #1a1a1a; font-weight: bold; }
.atemx-macro-detail { min-width: 0; }

/* --- Macro cards --- */
.atem-macro-card {
    border: var(--border-width) solid var(--border-color);
    padding: 16px 20px;
    scroll-margin-top: 12px;
}
@keyframes atem-flash-fade { from { background: var(--primary); } to { background: transparent; } }
.atem-macro-card.atem-flash { animation: atem-flash-fade 1s ease-out; }
.atem-macro-header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.atem-macro-name { font-weight: bold; font-size: 1.05rem; }
.atem-macro-meta { color: var(--text-muted); font-family: monospace; font-size: 0.8rem; margin-left: auto; }
.atem-macro-description {
    font-style: italic; color: var(--text-muted); border-left: 3px solid var(--primary);
    margin: 0 0 10px; padding: 2px 0 2px 12px;
}
.atem-macro-headline { font-weight: bold; margin: 0 0 12px; }
.atem-chip {
    display: inline-block; font-family: monospace; font-weight: bold; font-size: 0.75rem;
    background: var(--surface-alt); border: 1px solid var(--border-color); padding: 2px 8px; white-space: nowrap;
}
.atem-chip-index { background: var(--primary); color: #1a1a1a; }
.atem-chip-clickable { cursor: pointer; }
.atem-chip-clickable:hover, .atem-chip-open { background: var(--primary); color: #1a1a1a; }
.atem-group-list { display: flex; flex-direction: column; gap: 6px; }
.atem-group-row { display: flex; gap: 10px; align-items: baseline; }
.atem-group-phrase { color: var(--text-main); }
.atem-group-ops {
    margin: 4px 0 2px;
}

/* --- Op lines: coloured like a VS Code editor (Dark+ token colours),
   independent of the site's own light/dark theme, since the colours
   only read correctly against a dark background. --- */
.atem-op-list {
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    padding: 8px 10px;
    overflow-x: auto;
}
.atem-op-line { color: #d4d4d4; word-break: break-all; }
.atem-op-line-num {
    display: inline-block;
    min-width: 3.5em;
    color: #6e7681;
    user-select: none;
}
.atem-op-token-tag { color: #569cd6; font-weight: bold; }
.atem-op-token-key { color: #9cdcfe; }
.atem-op-token-value { color: #ce9178; }
.atem-layout-toggle-btn {
    margin-top: 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: monospace;
    font-size: 0.8rem;
    text-transform: uppercase;
    padding: 6px 12px;
    cursor: pointer;
}
.atem-layout-toggle-btn:hover { background: var(--surface-color); }
.atem-inline-layout { margin-top: 12px; }
.atem-svg-canvas {
    width: 100%; max-width: 640px; height: auto;
    background: var(--bg-color); border: var(--border-width) solid var(--border-color);
}

.atem-macro-tabs {
    font-family: monospace; font-size: 0.85rem; margin-top: 14px;
    border-top: 1px solid var(--border-color); padding-top: 10px;
}
.atem-macro-tab-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin-bottom: 10px; }
.atem-macro-tab-btn {
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--text-muted); font-family: monospace; font-size: 0.8rem;
    text-transform: uppercase; padding: 6px 4px; cursor: pointer; margin-bottom: -1px;
}
.atem-macro-tab-btn:hover { color: var(--text-main); }
.atem-macro-tab-btn.active { color: var(--text-main); border-bottom-color: var(--primary); font-weight: bold; }

/* --- Audio Mapping (reuses /atemaudio's own scripts) --- */
#xmlArea { height: 160px; font-family: monospace; resize: vertical; width: 100%; box-sizing: border-box; }
.filter-container { margin-bottom: 20px; }
.output-block { margin: 0 0 10px 0; display: flex; align-items: center; gap: 10px; font-family: monospace; }

/* --- Labels: input list ---
   Newspaper-style CSS columns instead of one long flexbox column, so a
   large input count (40+, common on bigger switchers) fills the width
   with several columns of short rows instead of one tall scrolling list
   — closer to how ATEM Software Control's own input list stays dense by
   going wide rather than tall. break-inside: avoid keeps a single row
   from being split across two columns. */
.atemx-label-list {
    column-width: 230px;
    column-gap: 0;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
}
.atemx-label-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 3px 6px;
    border-bottom: 1px solid var(--border-color);
    break-inside: avoid;
    font-size: 0.8rem;
}
.atemx-label-row:hover { background: var(--surface-alt); }
.atemx-label-row-nondefault {
    border-left: 3px solid var(--primary);
    padding-left: 3px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.atemx-label-row-id { font-family: monospace; font-size: 0.7rem; color: var(--text-muted); flex-shrink: 0; width: 2em; }
.atemx-label-row-short { font-family: monospace; font-size: 0.7rem; color: var(--text-muted); flex-shrink: 0; }
.atemx-label-row-port {
    font-family: monospace;
    font-size: 0.6rem;
    text-transform: uppercase;
    background: var(--surface-alt);
    border: 1px solid var(--border-color);
    padding: 0 4px;
    flex-shrink: 0;
}
.atemx-label-row-name {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

/* --- Labels: multiview layout grid --- */
.atemx-mv-grid-wrap {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px 24px;
}
@media (max-width: 700px) {
    .atemx-mv-grid-wrap { grid-template-columns: 1fr; }
}
.atemx-mv-block { min-width: 0; }
.atemx-mv-heading { font-family: monospace; font-weight: bold; font-size: 0.85rem; margin: 16px 0 6px; }
.atemx-mv-frame {
    display: grid;
    gap: 1px;
    background: #000;
    border: 2px solid var(--border-color);
    max-width: 640px;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    margin-bottom: 4px;
}
.atemx-mv-tile {
    background: #1a1a1a;
    display: flex;
    align-items: flex-end;
    padding: 2px 4px;
    min-width: 0;
    overflow: hidden;
}
.atemx-mv-tile-label {
    font-family: monospace;
    font-size: 0.6rem;
    color: #e8e8e8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.atemx-mv-tile-empty { background: #101010; }
