@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap');

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

::selection {
    background: transparent;
    color: inherit;
}

/* ── Base (light fallback) ── */
:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --border: #d0d0d0;
    --border-heavy: #888;
    --text: #111;
    --muted: #111;
}

/* ── Themes ── */
html[data-theme="night"] {
    --bg: #000;
    --surface: #0a0a0a;
    --border: #333;
    --border-heavy: #555;
    --text: #fff;
    --muted: #fff;
    --run-bg: #000;
    --run-panel: #0a0a0a;
    --run-surface: #080808;
    --run-surface-alt: #0c0c0c;
    --run-elevated: #111;
    --run-elevated-strong: #1a1a1a;
    --run-hover: #222;
    --run-overlay: rgba(0, 0, 0, .9);
    --run-border-subtle: #333;
    --run-border-strong: #444;
    --run-border-quiet: #2a2a2a;
    --run-border-hover: #666;
    --run-text: #fff;
    --run-text-inverse: #000;
    --run-text-muted: #ccc;
    --run-text-soft: #999;
    --run-text-dim: #888;
    --run-text-offline: #666;
    --run-status-green: #fff;
    --run-status-yellow: #bdbdbd;
    --run-status-red: #444;
    --run-shadow-outline: 0 0 0 1px #000;
    --run-shadow-lg: 0 20px 50px rgba(0, 0, 0, 1);
    --run-shadow-glow: 0 0 10px #fff;
    --run-hint-bg: #333;
    --run-hint-fg: #fff;
    --run-offline-stripe: repeating-linear-gradient(135deg, rgba(255, 255, 255, .06) 0, rgba(255, 255, 255, .06) 5px, transparent 5px, transparent 14px);
}

html[data-theme="graphite"] {
    --bg: #0b0d10;
    --surface: #12151a;
    --border: #2d3440;
    --border-heavy: #3a4250;
    --text: #f4f7fb;
    --muted: #f4f7fb;
    --run-bg: #0b0d10;
    --run-panel: #12151a;
    --run-surface: #0f1216;
    --run-surface-alt: #171b21;
    --run-elevated: #171b21;
    --run-elevated-strong: #20252d;
    --run-hover: #262c35;
    --run-overlay: rgba(8, 10, 12, .9);
    --run-border-subtle: #2d3440;
    --run-border-strong: #3a4250;
    --run-border-quiet: #232830;
    --run-border-hover: #59677a;
    --run-text: #f4f7fb;
    --run-text-inverse: #050913;
    --run-text-muted: #d2d8e0;
    --run-text-soft: #a7b0bd;
    --run-text-dim: #93a0af;
    --run-text-offline: #788395;
    --run-status-green: #f4f7fb;
    --run-status-yellow: #c2cad4;
    --run-status-red: #4a5563;
    --run-shadow-outline: 0 0 0 1px #000;
    --run-shadow-lg: 0 20px 50px rgba(0, 0, 0, .75);
    --run-shadow-glow: 0 0 10px rgba(244, 247, 251, .95);
    --run-hint-bg: #2a313b;
    --run-hint-fg: #f4f7fb;
    --run-offline-stripe: repeating-linear-gradient(135deg, rgba(244, 247, 251, .05) 0, rgba(244, 247, 251, .05) 5px, transparent 5px, transparent 14px);
}

html[data-theme="midnight"] {
    --bg: #050913;
    --surface: #0c1220;
    --border: #27344c;
    --border-heavy: #384a67;
    --text: #f6f8ff;
    --muted: #f6f8ff;
    --run-bg: #050913;
    --run-panel: #0c1220;
    --run-surface: #090f1b;
    --run-surface-alt: #11192a;
    --run-elevated: #11192a;
    --run-elevated-strong: #18243a;
    --run-hover: #24304a;
    --run-overlay: rgba(5, 9, 19, .9);
    --run-border-subtle: #27344c;
    --run-border-strong: #384a67;
    --run-border-quiet: #1e2b40;
    --run-border-hover: #667a9d;
    --run-text: #f6f8ff;
    --run-text-inverse: #050913;
    --run-text-muted: #d5ddf2;
    --run-text-soft: #a6b4d1;
    --run-text-dim: #8fa0c2;
    --run-text-offline: #7282a3;
    --run-status-green: #f6f8ff;
    --run-status-yellow: #c6d0e8;
    --run-status-red: #4e5d7f;
    --run-shadow-outline: 0 0 0 1px #000;
    --run-shadow-lg: 0 20px 50px rgba(0, 0, 0, .78);
    --run-shadow-glow: 0 0 10px rgba(246, 248, 255, .95);
    --run-hint-bg: #2b3550;
    --run-hint-fg: #f6f8ff;
    --run-offline-stripe: repeating-linear-gradient(135deg, rgba(246, 248, 255, .05) 0, rgba(246, 248, 255, .05) 5px, transparent 5px, transparent 14px);
}

html[data-theme="forest"] {
    --bg: #08110d;
    --surface: #101b15;
    --border: #2a4537;
    --border-heavy: #39604b;
    --text: #f2fff6;
    --muted: #f2fff6;
    --run-bg: #08110d;
    --run-panel: #101b15;
    --run-surface: #0c1611;
    --run-surface-alt: #14211a;
    --run-elevated: #17261d;
    --run-elevated-strong: #1e3227;
    --run-hover: #294235;
    --run-overlay: rgba(5, 16, 11, .9);
    --run-border-subtle: #2a4537;
    --run-border-strong: #39604b;
    --run-border-quiet: #21352b;
    --run-border-hover: #58896d;
    --run-text: #f2fff6;
    --run-text-inverse: #07120c;
    --run-text-muted: #c8e2d1;
    --run-text-soft: #9ec4ad;
    --run-text-dim: #85ad97;
    --run-text-offline: #678b77;
    --run-status-green: #f2fff6;
    --run-status-yellow: #d2e7d9;
    --run-status-red: #4f6a5a;
    --run-shadow-outline: 0 0 0 1px #000;
    --run-shadow-lg: 0 20px 50px rgba(0, 0, 0, .78);
    --run-shadow-glow: 0 0 10px rgba(242, 255, 246, .95);
    --run-hint-bg: #2a4a3b;
    --run-hint-fg: #f2fff6;
    --run-offline-stripe: repeating-linear-gradient(135deg, rgba(242, 255, 246, .05) 0, rgba(242, 255, 246, .05) 5px, transparent 5px, transparent 14px);
}

html[data-theme="ember"] {
    --bg: #140b08;
    --surface: #1d110d;
    --border: #5a3529;
    --border-heavy: #744334;
    --text: #fff6f2;
    --muted: #fff6f2;
    --run-bg: #140b08;
    --run-panel: #1d110d;
    --run-surface: #180e0b;
    --run-surface-alt: #261612;
    --run-elevated: #2b1914;
    --run-elevated-strong: #3a221b;
    --run-hover: #513128;
    --run-overlay: rgba(20, 11, 8, .9);
    --run-border-subtle: #5a3529;
    --run-border-strong: #744334;
    --run-border-quiet: #472a21;
    --run-border-hover: #a6644f;
    --run-text: #fff6f2;
    --run-text-inverse: #1b0f0b;
    --run-text-muted: #f2d6ca;
    --run-text-soft: #ccaa9d;
    --run-text-dim: #b59387;
    --run-text-offline: #94756a;
    --run-status-green: #fff6f2;
    --run-status-yellow: #f0c9b9;
    --run-status-red: #765045;
    --run-shadow-outline: 0 0 0 1px #000;
    --run-shadow-lg: 0 20px 50px rgba(0, 0, 0, .78);
    --run-shadow-glow: 0 0 10px rgba(255, 246, 242, .95);
    --run-hint-bg: #623a2d;
    --run-hint-fg: #fff6f2;
    --run-offline-stripe: repeating-linear-gradient(135deg, rgba(255, 246, 242, .05) 0, rgba(255, 246, 242, .05) 5px, transparent 5px, transparent 14px);
}

html[data-theme="polar"] {
    --bg: #eef3f8;
    --surface: #fff;
    --border: #bcc9dc;
    --border-heavy: #9fb0cb;
    --text: #152033;
    --muted: #152033;
    --run-bg: #eef3f8;
    --run-panel: #fff;
    --run-surface: #f7faff;
    --run-surface-alt: #eef4fb;
    --run-elevated: #edf3fb;
    --run-elevated-strong: #e3ebf7;
    --run-hover: #dce7f5;
    --run-overlay: rgba(22, 33, 48, .35);
    --run-border-subtle: #bcc9dc;
    --run-border-strong: #9fb0cb;
    --run-border-quiet: #d3ddec;
    --run-border-hover: #6f86ab;
    --run-text: #152033;
    --run-text-inverse: #f4f8ff;
    --run-text-muted: #2d3d57;
    --run-text-soft: #4a5d7a;
    --run-text-dim: #617492;
    --run-text-offline: #7a8da9;
    --run-status-green: #152033;
    --run-status-yellow: #425f8e;
    --run-status-red: #7d90ab;
    --run-shadow-outline: 0 0 0 1px rgba(128, 150, 182, .3);
    --run-shadow-lg: 0 20px 50px rgba(34, 52, 78, .16);
    --run-shadow-glow: 0 0 10px rgba(90, 118, 160, .45);
    --run-hint-bg: #d8e3f2;
    --run-hint-fg: #152033;
    --run-offline-stripe: repeating-linear-gradient(135deg, rgba(21, 32, 51, .08) 0, rgba(21, 32, 51, .08) 5px, transparent 5px, transparent 14px);
}

/* ── Layout ── */
body {
    font-family: 'Space Grotesk', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: background-color .24s ease, color .24s ease;
}

header {
    border-bottom: 1px solid var(--border-heavy);
    padding: 0 24px;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    min-height: 44px;
    height: 44px;
    box-sizing: border-box;
    flex-shrink: 0;
    overflow: visible;
    transition: background-color .24s, color .24s, border-color .24s, opacity .24s;
}

.header-left {
    display: flex;
    align-items: stretch;
    min-width: 0;
    overflow: visible;
}

.header-right {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
}

/* ── Brand ── */
.brand {
    font-size: 13px;
    font-weight: bold;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 0 16px 0 0;
    display: inline-flex;
    align-items: center;
    border-right: 1px solid var(--border-heavy);
    cursor: pointer;
    gap: 6px;
    white-space: nowrap;
    transition: opacity .18s;
}

.brand:hover {
    opacity: .65;
}

/* Smooth label animation for mode switch */
#brandMode {
    display: inline-block;
    transition: transform .22s ease, opacity .18s ease;
    will-change: transform, opacity;
}

.brand-mode-fade {
    opacity: 0;
    transform: translateY(-6px);
}

/* ── Shared dropdown wrapper ── */
.folder-dropdown-wrap,
.file-dropdown-wrap,
.run-connect-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
    overflow: visible;
}

.folder-dropdown-wrap {
    border-right: 1px solid var(--border);
    z-index: 50;
}

.file-dropdown-wrap {
    border-left: 1px solid var(--border);
    z-index: 40;
}

.run-connect-wrap,
.run-access-logs-wrap {
    border-right: 1px solid var(--border);
    z-index: 50;
    display: none;
}

.run-client-wrap {
    border-right: 1px solid var(--border);
    z-index: 50;
    display: none;
    align-items: stretch;
    overflow: visible;
}

.run-client-name {
    cursor: default;
    pointer-events: none;
    color: var(--run-text-muted, var(--text));
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#actionTargetWrap .run-client-name {
    pointer-events: auto;
    cursor: pointer;
}

#actionTargetWrap .dropdown-menu {
    min-width: 160px;
    max-width: 260px;
}

/* ── Shared button base for header ── */
.folder-btn,
.file-btn {
    font-family: inherit;
    font-size: 13px;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    letter-spacing: .05em;
    display: flex;
    align-items: center;
    border-radius: 0;
    white-space: nowrap;
    height: 44px;
    box-sizing: border-box;
}

.folder-btn {
    padding: 0 14px;
}

.file-btn {
    padding: 0 14px;
}

.folder-btn:hover,
.file-btn:hover {
    background: var(--border);
}

/* ── Header icon button/link ── */
.header-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text);
    padding: 0 8px;
    height: 44px;
    box-sizing: border-box;
    text-decoration: none;
    cursor: pointer;
    opacity: .7;
    transition: opacity .15s;
}

.header-icon-link:hover {
    opacity: 1;
    background: none;
}

.header-icon-link svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    display: block;
}

.folder-btn:disabled,
.file-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.folder-btn:disabled:hover,
.file-btn:disabled:hover {
    background: none;
}

#fpsWrap .file-btn:hover {
    background: none;
}

/* ── Dropdown menus ── */
.dropdown-menu,
.file-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: -1px;
    right: -1px;
    background: var(--surface);
    border: 1px solid var(--border-heavy);
    border-top: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
}

.dropdown-menu {
    max-height: 280px;
    overflow-y: auto;
}

.dropdown-menu.open,
.file-dropdown-menu.open {
    display: block;
}

#fpsWrap .file-dropdown-menu {
    top: auto;
    bottom: calc(100% + 2px);
    border-top: 1px solid var(--border-heavy);
    border-bottom: none;
}

.slider-wrap.auto-locked {
    opacity: .55;
    cursor: not-allowed;
}

.slider-wrap.auto-locked input[type=range] {
    cursor: not-allowed;
}

.dropdown-item,
.file-dropdown-item {
    font-family: inherit;
    font-size: 13px;
    height: 34px;
    min-height: 34px;
    box-sizing: border-box;
    padding: 0 14px;
    cursor: pointer;
    letter-spacing: .04em;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    white-space: nowrap;
}

#fpsWrap .file-dropdown-item {
    height: 30px;
    min-height: 30px;
    padding: 0 10px;
}

.dropdown-item:last-child,
.file-dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover,
.file-dropdown-item:hover {
    background: var(--border);
}

.dropdown-item.active,
.file-dropdown-item.active {
    background: var(--text);
    color: var(--bg);
}

/* ── Folder measure (invisible sizing helper) ── */
.folder-measure {
    position: absolute;
    left: -9999px;
    top: -9999px;
    visibility: hidden;
    pointer-events: none;
    white-space: nowrap;
}

/* ── Frames view ── */
#view-frames {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.image-area {
    flex: 1;
    min-height: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
}

.image-area.dragging {
    cursor: grabbing;
}

.image-area img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    max-height: none;
    transform-origin: 0 0;
    display: none;
    pointer-events: none;
    will-change: transform;
}

.zoom-hint {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 13px;
    color: var(--muted);
    letter-spacing: .04em;
    opacity: .6;
    pointer-events: none;
    z-index: 5;
}

.zoom-level {
    position: absolute;
    bottom: 10px;
    left: 10px;
    font-size: 13px;
    color: var(--muted);
    letter-spacing: .04em;
    opacity: 0;
    pointer-events: none;
    z-index: 5;
    transition: opacity .4s;
}

.zoom-level.visible {
    opacity: .8;
}

#frames-status-msg {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    padding: 40px 20px;
    letter-spacing: .05em;
    position: absolute;
}

.progress-bar-wrap {
    height: 6px;
    background: var(--border);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    cursor: pointer;
}

.progress-bar {
    height: 100%;
    background: var(--border-heavy);
    width: 0%;
    transition: width .1s linear;
}

/* ── Controls row (frames) ── */
.controls-row {
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: none;
    align-items: center;
    gap: 16px;
    min-height: 48px;
    flex-shrink: 0;
}

.btn {
    font-family: inherit;
    font-size: 13px;
    background: none;
    border: 1px solid var(--border-heavy);
    color: var(--text);
    padding: 0 12px;
    cursor: pointer;
    letter-spacing: .05em;
    text-transform: uppercase;
    border-radius: 0;
    min-width: 90px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    transition: background-color .24s, color .24s, border-color .24s, opacity .24s;
}

.btn:hover {
    background: var(--text);
    color: var(--bg);
}

.btn:active {
    opacity: .7;
}

.btn.active {
    background: var(--text);
    color: var(--bg);
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn:disabled:hover {
    background: none;
    color: var(--text);
}

.slider-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 10px 0;
    cursor: pointer;
}

input[type=range] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-heavy);
    outline: none;
    cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--text);
    cursor: pointer;
    border-radius: 0;
}

input[type=range]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--text);
    cursor: pointer;
    border-radius: 0;
    border: none;
}

.counter {
    font-size: 13px;
    color: var(--muted);
    min-width: 92px;
    text-align: right;
    letter-spacing: .05em;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.speed-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    border: 1px solid var(--border-heavy);
    min-width: 90px;
    height: 32px;
    padding: 0 8px;
    position: relative;
    overflow: visible;
    cursor: pointer;
    transition: background-color .24s, color .24s, border-color .24s, opacity .24s;
}

.speed-wrap:hover,
.speed-wrap:focus-within {
    background: var(--text);
    color: var(--bg);
}

.speed-wrap:hover .speed-label,
.speed-wrap:focus-within .speed-label,
.speed-wrap:hover .file-btn,
.speed-wrap:focus-within .file-btn {
    color: var(--bg);
}

.speed-label {
    font-size: 13px;
    color: var(--muted);
    letter-spacing: .04em;
    white-space: nowrap;
}

.speed-wrap .file-btn {
    height: 26px;
    padding: 0 10px;
}

/* ── Loading/dim states ── */
body.is-loading header .header-left> :not(.brand),
body.is-loading header .header-right,
body.is-loading .controls-row {
    pointer-events: none;
    opacity: .4;
}

body.is-loading .speed-wrap {
    opacity: .45;
}

body.view-frames.frames-dim header .header-left> :not(.brand),
body.view-frames.frames-dim header .header-right {
    opacity: .4;
}

body.view-frames.frames-menu-disabled #hamburgerBtn {
    pointer-events: none;
    opacity: .4;
}

/* ── Run view ── */
#view-run {
    display: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--run-bg, var(--bg));
    height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-heavy) transparent;
}

#view-run::-webkit-scrollbar {
    width: 6px;
}

#view-run::-webkit-scrollbar-track {
    background: transparent;
}

#view-run::-webkit-scrollbar-thumb {
    background: var(--border-heavy);
}

.run-panel {
    margin: 0 auto;
    max-width: 1600px;
    padding: 2rem;
}

.run-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ── User cards ── */
.user-card {
    background: var(--run-panel, var(--surface));
    border: 1px solid var(--run-border-subtle, var(--border));
    border-radius: 4px;
    cursor: default;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow: hidden;
    padding: 1rem;
    position: relative;
    transition: transform 240ms cubic-bezier(.2, .8, .2, 1),
        background-color 240ms ease, border-color 240ms ease, box-shadow 240ms ease;
    will-change: transform;
}

.user-card.card-enter {
    animation: card-enter 300ms cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.985);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .user-card.card-enter {
        animation: none;
    }
}

.user-card.offline {
    background: var(--run-surface, var(--surface));
}

.user-card.offline .card-header {
    position: relative;
    z-index: 1;
}

.user-card.offline .card-actions {
    position: relative;
    z-index: 2;
}

.user-card.offline .card-btn {
    background: var(--run-surface-alt, var(--bg));
    border-color: var(--run-border-quiet, var(--border));
    color: var(--run-text-offline, var(--muted));
    position: relative;
    z-index: 2;
}

.user-card.offline .card-btn.primary {
    background: var(--run-elevated, var(--surface)) !important;
    border-color: var(--run-border-quiet, var(--border)) !important;
    color: var(--run-text-offline, var(--muted)) !important;
}

.user-card.offline .card-btn[data-action="output"] {
    background: var(--run-elevated, var(--surface));
    border-color: var(--run-border-subtle, var(--border));
    box-shadow: none;
    color: var(--run-text-muted, var(--text));
    opacity: 1;
    z-index: 3;
}

.user-card.offline .card-ts {
    color: var(--run-text-offline, var(--muted));
}

.user-card.offline::before {
    background: var(--run-offline-stripe, none);
    content: '';
    inset: 0;
    opacity: .35;
    pointer-events: none;
    position: absolute;
}

.user-card.selected {
    background: var(--run-elevated-strong, var(--surface)) !important;
    border-color: var(--run-text, var(--text)) !important;
    box-shadow: 0 0 0 1px var(--run-text, var(--text)), 0 4px 16px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
}

body:not(.kb-mode) .user-card:hover {
    background: var(--run-elevated, var(--surface));
    border-color: var(--run-border-hover, var(--border-heavy));
    transform: translateY(-2px);
}

body.kb-mode .user-card.selected {
    border-color: var(--run-text, var(--text)) !important;
    box-shadow: 0 0 0 2px var(--run-text, var(--text)), 0 0 12px rgba(255, 255, 255, 0.2);
}

.user-card.windows-user {
    overflow: hidden;
}

.user-card.windows-user>* {
    position: relative;
    z-index: 1;
}

.os-logo {
    color: var(--run-text, var(--text));
    font-size: 1.45rem;
    line-height: 1;
    opacity: 0.35;
    flex-shrink: 0;
    transition: opacity 240ms ease;
    margin-top: 2px;
}

body:not(.kb-mode) .user-card:hover .os-logo {
    opacity: 0.65;
}

.user-card.offline .os-logo {
    opacity: 0.18;
}

.card-header {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.card-ts {
    color: var(--run-text-soft, var(--muted));
    font-size: 13px;
    height: 18px;
}

.card-username {
    color: var(--run-text, var(--text));
    flex: 1;
    font-size: 16px;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-username.offline {
    color: var(--run-text-offline, var(--muted));
    font-weight: normal;
}

.card-actions {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
}

.card-btn {
    background: var(--run-elevated, var(--surface));
    border: 1px solid var(--run-border-subtle, var(--border));
    border-radius: 2px;
    color: var(--run-text-muted, var(--text));
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    height: 35px;
    position: relative;
    text-align: center;
    transition: transform 160ms cubic-bezier(.2, .8, .2, 1),
        background-color 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.card-btn.disabled {
    opacity: .3;
    pointer-events: none;
}

.card-btn.primary {
    background: var(--run-elevated-strong, var(--surface)) !important;
    border-color: var(--run-border-strong, var(--border-heavy)) !important;
    color: var(--run-text, var(--text)) !important;
}

body:not(.kb-mode) .card-btn:hover,
body:not(.kb-mode) .card-btn.primary:hover {
    background: var(--run-hover, var(--border)) !important;
    border-color: var(--run-text, var(--text)) !important;
    color: var(--run-text, var(--text)) !important;
}

body:not(.kb-mode) .user-card.offline .card-btn[data-action="output"]:hover {
    background: var(--run-hover, var(--border));
    border-color: var(--run-text, var(--text));
    color: var(--run-text, var(--text));
}

/* ── Hint badges ── */
.btn-hint {
    background: var(--run-hint-bg, #333);
    border-radius: 2px;
    color: var(--run-hint-fg, #fff);
    font-size: 12px;
    padding: 2px 5px;
}

.card-btn .btn-hint {
    font-size: 12px;
    line-height: 1;
    padding: 1px 4px;
    pointer-events: none;
    position: absolute;
    right: 3px;
    top: 3px;
}

/* ── Empty state ── */
.empty {
    font-size: 13px;
    color: var(--run-text-dim, var(--muted));
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 40px 20px;
    text-align: center;
    grid-column: 1 / -1;
    min-height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Action view (replaces popup overlay) ── */
#view-action {
    display: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--run-bg, var(--bg));
    scrollbar-width: thin;
    scrollbar-color: var(--border-heavy) transparent;
}

#view-action::-webkit-scrollbar {
    width: 6px;
}

#view-action::-webkit-scrollbar-track {
    background: transparent;
}

#view-action::-webkit-scrollbar-thumb {
    background: var(--border-heavy);
}

.action-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.action-back-btn {
    color: var(--run-text-dim, var(--muted));
    padding-left: 10px;
}

.action-back-btn:hover {
    background: var(--run-hover, var(--border));
    border-color: var(--run-text, var(--text));
    color: var(--run-text, var(--text));
}

.action-back-btn svg {
    flex-shrink: 0;
}

/* ── Action mode dropdown (header) ── */
.action-mode-wrap {
    display: none;
}

#action-mode-btn {
    min-width: 140px;
}

.action-placeholder-body,
.action-scripts-body {
    display: none;
    flex-direction: column;
    gap: 8px;
    color: var(--run-text-dim, var(--muted));
    font-size: 14px;
}

.script-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: var(--run-elevated, var(--surface));
    border: 1px solid var(--run-border-subtle, var(--border));
    border-radius: 4px;
    width: 100%;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s, transform 0.15s;
    position: relative;
}

.script-card:hover {
    border-color: var(--run-border-hover, var(--border-heavy));
    background: var(--run-elevated-strong, var(--surface));
}

.script-card:active {
    transform: scale(0.995);
}

.script-card.active {
    border-color: var(--run-text, var(--text));
    background: var(--run-hover, var(--border));
    box-shadow: 0 0 0 1px var(--run-text, var(--text)), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.script-card.danger:hover {
    border-color: rgba(229, 115, 115, 0.6);
    background: rgba(229, 115, 115, 0.08);
}

.script-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: var(--run-surface-alt, var(--bg));
    border: 1px solid var(--run-border-quiet, var(--border));
    color: var(--run-text, var(--text));
    font-size: 15px;
    flex-shrink: 0;
    transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.script-card.active .script-icon-wrap {
    background: var(--run-text, var(--text));
    color: var(--run-text-inverse, var(--bg));
    border-color: var(--run-text, var(--text));
}

.script-icon-wrap.danger {
    color: #e57373;
    border-color: rgba(229, 115, 115, 0.3);
    background: rgba(229, 115, 115, 0.08);
}

.script-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.script-title {
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--run-text, var(--text));
    line-height: 1.2;
}

.script-desc {
    font-family: inherit;
    font-size: 11.5px;
    letter-spacing: .01em;
    color: var(--run-text-soft, var(--muted));
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.script-status-pill {
    font-family: inherit;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: .08em;
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid var(--run-border-strong, var(--border-heavy));
    color: var(--run-text-soft, var(--muted));
    margin-left: auto;
    flex-shrink: 0;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.script-card.active .script-status-pill {
    border-color: var(--run-text, var(--text));
    background: var(--run-text, var(--text));
    color: var(--run-text-inverse, var(--bg));
}

.action-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 4px;
}

.popup-btn {
    font-family: inherit;
    font-size: 15px;
    background: none;
    border: 1px solid var(--run-border-strong, var(--border-heavy));
    color: var(--run-text, var(--text));
    padding: 8px 16px;
    cursor: pointer;
    letter-spacing: .05em;
    text-transform: uppercase;
    border-radius: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 160ms, border-color 160ms, color 160ms;
}

.popup-btn.confirm {
    background: var(--run-text, var(--text));
    border-color: var(--run-text, var(--text));
    color: var(--run-text-inverse, var(--bg));
}

body:not(.kb-mode) .popup-btn:hover {
    background: var(--run-hover, var(--border));
    border-color: var(--run-text, var(--text));
    color: var(--run-text, var(--text));
}

.popup-btn.confirm:hover {
    background: var(--run-text-muted, var(--muted));
    border-color: var(--run-text, var(--text));
    color: var(--run-text-inverse, var(--bg));
}

.popup-input {
    background: var(--run-bg, var(--bg));
    border: 1px solid var(--run-border-strong, var(--border-heavy));
    border-radius: 2px;
    color: var(--run-text, var(--text));
    font-family: inherit;
    font-size: 16px;
    height: 8.5rem;
    min-height: 8.5rem;
    max-height: 8.5rem;
    outline: none;
    padding: 12px;
    resize: none;
    overflow-y: auto;
    overflow-x: hidden;
    transition: border-color 160ms;
    width: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--run-border-strong, var(--border-heavy)) transparent;
}

.popup-input::-webkit-scrollbar {
    width: 4px;
}

.popup-input::-webkit-scrollbar-track {
    background: transparent;
}

.popup-input::-webkit-scrollbar-thumb {
    background: var(--run-border-strong, var(--border-heavy));
}

.popup-input:focus {
    border-color: var(--run-text-dim, var(--muted));
}

/* ── Option buttons ── */
.opt-btn {
    background: var(--run-elevated, var(--surface));
    border: 1px solid var(--run-border-subtle, var(--border));
    color: var(--run-text-dim, var(--muted));
    cursor: pointer;
    flex: 1;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    padding: 8px;
    text-transform: uppercase;
    transition: background-color 260ms, border-color 260ms, color 260ms, box-shadow 260ms,
        transform 160ms cubic-bezier(.2, .8, .2, 1);
}

.opt-btn.active {
    background: var(--run-hover, var(--border));
    border-color: var(--run-text, var(--text));
    color: var(--run-text, var(--text));
}

body:not(.kb-mode) .opt-btn:hover {
    background: var(--run-hover, var(--border));
    border-color: var(--run-text, var(--text));
    color: var(--run-text, var(--text));
}

.option-row {
    align-items: center;
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.option-row .btn-hint {
    margin-left: 2px;
    white-space: nowrap;
}

/* ── Collapsible sections ── */
.collapsible-section {
    border: 1px solid var(--run-border-subtle, var(--border));
    margin-bottom: 15px;
    overflow: hidden;
}

.collapsible-summary {
    align-items: center;
    background: var(--run-elevated, var(--surface));
    color: var(--run-text, var(--text));
    cursor: pointer;
    display: flex;
    font-size: 13px;
    font-weight: bold;
    gap: 8px;
    justify-content: space-between;
    list-style: none;
    min-height: 30px;
    padding: 6px 12px;
    text-transform: uppercase;
    user-select: none;
}

.collapsible-summary::-webkit-details-marker {
    display: none;
}

body:not(.kb-mode) .collapsible-summary:hover {
    background: var(--run-hover, var(--border));
}

.collapsible-meta {
    color: var(--run-text-dim, var(--muted));
    font-size: 12px;
    font-weight: normal;
    letter-spacing: .08em;
}

.collapsible-meta-shell {
    align-items: center;
    display: flex;
    gap: 10px;
    text-wrap: nowrap;
}

.collapsible-meta-pill {
    color: var(--run-text-dim, var(--muted));
    transition: color 160ms, text-shadow 160ms;
}

.collapsible-meta-pill.active {
    color: var(--run-text, var(--text));
    text-decoration: underline;
    text-decoration-color: var(--run-text, var(--text));
    text-underline-offset: 2px;
}

.collapsible-body {
    background: var(--run-panel, var(--surface));
    border-top: 1px solid var(--run-border-subtle, var(--border));
    display: grid;
    gap: 12px;
    padding: 12px;
}

/* ── SPK controls ── */
.spk-row {
    display: grid;
    gap: 8px;
}

.spk-row-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.spk-row label {
    color: var(--run-text, var(--text));
    font-size: 13px;
    font-weight: bold;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.spk-value {
    color: var(--run-text-dim, var(--muted));
    font-size: 13px;
    font-weight: bold;
    min-width: 44px;
    text-align: right;
}

.spk-slider {
    accent-color: var(--run-text-dim, var(--muted));
    width: 100%;
}

#shell-section .collapsible-body {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#shell-section .opt-btn {
    min-width: 58px;
}

/* ── Textarea + tab hints ── */
.textarea-wrap {
    margin-bottom: 15px;
    position: relative;
}

.textarea-wrap.show-hint .tab-hint {
    display: flex;
}

.tab-hint {
    align-items: flex-end;
    bottom: 15px;
    color: var(--run-text-offline, var(--muted));
    display: none;
    flex-direction: column;
    font-family: inherit;
    font-size: 12px;
    gap: 4px;
    pointer-events: none;
    position: absolute;
    right: 15px;
}

.tab-hint-row {
    align-items: center;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    display: flex;
    font: inherit;
    gap: 5px;
    padding: 0;
    pointer-events: auto;
}

/* ── Imager Mode Upload Section ── */
.imager-upload-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
    width: 100%;
}

.imager-card {
    position: relative;
    cursor: pointer;
    border: 1px dashed var(--run-border-strong, var(--border-heavy));
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
}

.imager-card.has-file {
    border-style: solid;
    border-color: var(--run-border-hover, var(--border-heavy));
    background: var(--run-elevated-strong, var(--surface));
}

.imager-card.dragover {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.08);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
    transform: scale(1.005);
}

.imager-card .imager-remove-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: #fb7185;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.imager-card .imager-remove-btn:hover {
    background: rgba(244, 63, 94, 0.2);
    color: #fda4af;
    transform: scale(1.15);
}

.imager-caption-wrap {
    width: 100%;
}

.imager-caption-input {
    width: 100%;
    background: var(--run-bg, var(--bg));
    border: 1px solid var(--run-border-strong, var(--border-heavy));
    border-radius: 2px;
    color: var(--run-text, var(--text));
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.15s ease;
}

.imager-caption-input:focus {
    border-color: var(--run-text, #fff);
}

/* ── Audio Mode Upload Section ── */
.audio-upload-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
    width: 100%;
}

.audio-card .audio-preview-btn {
    margin-left: auto;
    margin-right: 6px;
    background: var(--run-elevated, rgba(255, 255, 255, 0.08));
    border: 1px solid var(--run-border-strong, rgba(255, 255, 255, 0.15));
    color: var(--run-text, #fff);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.audio-card .audio-preview-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    color: #38bdf8;
    transform: scale(1.08);
}

.audio-card .audio-preview-btn.playing {
    background: rgba(245, 158, 11, 0.25);
    border-color: #fbbf24;
    color: #fbbf24;
    animation: audio-pulse 1.2s infinite alternate;
}

@keyframes audio-pulse {
    from {
        box-shadow: 0 0 4px rgba(245, 158, 11, 0.3);
    }
    to {
        box-shadow: 0 0 12px rgba(245, 158, 11, 0.7);
    }
}

/* ── View switching ── */
body.view-frames #view-frames {
    display: flex;
}

body.view-frames #view-run,
body.view-frames #view-action {
    display: none;
}

body.view-frames .frames-header-right {
    display: flex !important;
}

body.view-frames #folderWrap {
    display: flex;
}

body.view-frames .run-connect-wrap,
body.view-frames .run-access-logs-wrap,
body.view-frames .run-client-wrap,
body.view-frames .run-theme-wrap,
body.view-frames .action-mode-wrap,
body.view-frames #actionTargetWrap {
    display: none !important;
}

body.view-frames .sidebar-run-section {
    display: none;
}

body.view-frames .sidebar-frames-section {
    display: block;
}

body.view-run #view-frames,
body.view-run #view-action {
    display: none;
}

body.view-run #view-run {
    display: block;
    height: auto;
}

body.view-run .frames-header-right {
    display: none !important;
}

body.view-run #folderWrap {
    display: none;
}

body.view-run .run-connect-wrap,
body.view-run .run-theme-wrap {
    display: flex !important;
}

body.view-run #actionTargetWrap,
body.view-run .action-mode-wrap {
    display: none !important;
}

body.view-run .sidebar-run-section {
    display: block;
}

body.view-run .sidebar-frames-section {
    display: none;
}

body.view-action #view-frames,
body.view-action #view-run {
    display: none;
}

body.view-action #view-action {
    display: block;
}

body.view-action .frames-header-right,
body.view-action #folderWrap,
body.view-action .run-connect-wrap,
body.view-action .run-access-logs-wrap,
body.view-action .run-client-wrap,
body.view-action .run-theme-wrap {
    display: none !important;
}

body.view-action #actionTargetWrap,
body.view-action .action-mode-wrap {
    display: flex !important;
}

body.view-action .sidebar-frames-section {
    display: none;
}

body.view-action .sidebar-run-section {
    display: block;
}

.sidebar-action-section {
    display: none;
}

.sidebar-action-target {
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    letter-spacing: .04em;
    padding: 9px 14px;
    border: 1px solid var(--border-heavy);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.run-connect-wrap .folder-btn.connected {
    color: var(--run-status-yellow, #bdbdbd);
}

/* ── Hamburger / Sidebar ── */
.hamburger-btn {
    display: none;
    font-size: 18px;
    background: none;
    border: none;
    border-left: 1px solid var(--border);
    color: var(--text);
    padding: 0 14px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background-color .18s;
}

.hamburger-btn:hover {
    background: var(--border);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 300;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.open {
    display: block;
}

.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 240px;
    background: var(--surface);
    border-left: 1px solid var(--border-heavy);
    z-index: 400;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 260ms cubic-bezier(.2, .8, .2, 1);
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    min-height: 44px;
    border-bottom: 1px solid var(--border-heavy);
    flex-shrink: 0;
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-title {
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    opacity: .7;
    transition: opacity .15s;
}

.sidebar-close:hover {
    opacity: 1;
}

.sidebar-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    color: var(--text);
    opacity: .7;
    transition: opacity .15s;
    text-decoration: none;
}

.sidebar-icon-link:hover {
    opacity: 1;
}

.sidebar-icon-link svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-folder-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-folder-btn.active {
    background: var(--text);
    color: var(--bg);
}

.sidebar-file-name {
    color: var(--text);
    font-size: 12px;
    letter-spacing: .04em;
    padding: 8px 10px;
    border: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 8px;
}

.sidebar-section-label {
    font-family: inherit;
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text);
    opacity: .45;
    margin-top: 8px;
    margin-bottom: 2px;
}

.sidebar-section-label:first-child {
    margin-top: 0;
}

/* ── Shared sidebar button base ── */
.sidebar-row-btn,
.sidebar-theme-btn,
.sidebar-fps-btn,
.sidebar-play-btn {
    font-family: inherit;
    font-size: 13px;
    background: none;
    color: var(--text);
    cursor: pointer;
    letter-spacing: .04em;
    text-align: left;
    width: 100%;
    transition: background-color .18s;
}

.sidebar-row-btn {
    border: 1px solid var(--border-heavy);
    padding: 9px 14px;
    letter-spacing: .05em;
}

.sidebar-theme-btn,
.sidebar-fps-btn,
.sidebar-play-btn {
    border: 1px solid var(--border);
    padding: 8px 14px;
    display: block;
    border-bottom: none;
}

.sidebar-theme-btn:last-child,
.sidebar-fps-btn:last-child,
.sidebar-play-btn:last-child {
    border-bottom: 1px solid var(--border);
}

.sidebar-row-btn:hover,
.sidebar-theme-btn:hover,
.sidebar-fps-btn:hover,
.sidebar-play-btn:hover {
    background: var(--border);
}

.sidebar-row-btn.connected {
    color: var(--run-status-yellow, #bdbdbd);
}

.sidebar-theme-btn.active,
.sidebar-fps-btn.active,
.sidebar-play-btn.active {
    background: var(--text);
    color: var(--bg);
}

/* ── Responsive ── */
@media (max-width: 600px) {

    /* Header */
    header {
        padding: 0 12px;
        min-height: 40px;
        height: 40px;
    }

    .brand,
    .folder-btn,
    .file-btn {
        height: 40px;
        min-height: 40px;
    }

    .dropdown-item,
    .file-dropdown-item {
        height: 34px;
        min-height: 34px;
    }

    .brand {
        font-size: 11px;
        padding: 0 10px 0 0;
        letter-spacing: .06em;
        gap: 4px;
    }

    .folder-btn {
        font-size: 11px;
        padding: 0 8px;
        overflow: hidden;
    }

    .folder-btn span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
    }

    .file-btn {
        font-size: 11px;
        padding: 0 10px;
    }

    #fileName {
        display: none !important;
    }

    .file-btn::after {
        content: 'FILE';
        font-family: inherit;
        font-size: 11px;
        letter-spacing: .05em;
    }

    .frames-header-right {
        display: flex;
        align-items: stretch;
        min-width: 0;
        overflow: hidden;
    }

    .file-dropdown-wrap {
        min-width: 0;
        overflow: visible;
    }

    /* Visibility toggles */
    .hamburger-btn {
        display: flex;
    }

    .header-github-link {
        display: none !important;
    }

    body.view-run .run-connect-wrap,
    body.view-run .run-access-logs-wrap,
    body.view-run .run-theme-wrap,
    body.view-frames .frames-header-right,
    body.view-run .frames-header-right,
    body.view-frames #folderWrap {
        display: none !important;
    }

    body.view-action #actionTargetWrap,
    body.view-action .action-mode-wrap {
        display: none !important;
    }

    body.view-action .sidebar-action-section {
        display: block;
    }

    body.view-action .sidebar-run-section {
        display: none;
    }

    #fpsWrap {
        display: none;
    }

    /* Controls row */
    .controls-row {
        padding: 0 10px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        gap: 8px;
        min-height: 44px;
        flex-wrap: wrap;
        display: none;
        overflow: visible;
        position: sticky;
        bottom: 0;
        background: var(--surface);
        z-index: 20;
    }

    .controls-row[style*="flex"] {
        display: flex !important;
    }

    .slider-wrap {
        order: -1;
        flex: 0 0 100%;
        padding: 6px 0 0;
    }

    .btn {
        min-width: 60px;
        font-size: 11px;
        height: 30px;
        padding: 0 8px;
        flex: 1;
    }

    .speed-wrap {
        min-width: 74px;
        height: 30px;
        padding: 0 6px;
        flex-shrink: 0;
    }

    .speed-label {
        font-size: 11px;
    }

    .counter {
        font-size: 11px;
        min-width: 0;
        width: calc((100% - 24px) / 4);
        flex: 0 0 calc((100% - 24px) / 4);
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .zoom-hint {
        display: none;
    }

    /* Run grid / cards */
    .run-panel {
        padding: 0.75rem;
    }

    .run-grid {
        gap: 8px;
        grid-template-columns: repeat(2, 1fr);
    }

    .user-card {
        gap: 10px;
        padding: 0.75rem;
    }

    .card-username {
        font-size: 12px;
        line-height: 1.3;
    }

    .os-logo {
        font-size: 1.15rem;
    }

    .card-ts {
        font-size: 9px;
        color: var(--run-text-offline, var(--muted));
        min-height: 1.3em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .card-actions {
        gap: 5px;
        grid-template-columns: repeat(2, 1fr);
    }

    .card-btn {
        border-radius: 3px;
        font-size: 13px;
        height: 36px;
        touch-action: manipulation;
    }

    .btn-hint {
        display: none;
    }

    /* Action page */
    .action-page {
        padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
    }

    .popup-btn {
        font-size: 14px;
        min-height: 44px;
        padding: 12px 20px;
    }

    .popup-input {
        font-size: 16px;
    }

    .opt-btn {
        font-size: 12px;
        padding: 12px 8px;
    }

    #shell-section .opt-btn {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (min-width: 601px) and (max-width: 900px) {
    .run-grid {
        gap: 14px;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    .run-panel {
        padding: 1.25rem;
    }

    .controls-row {
        padding: 0 16px;
        gap: 10px;
    }

    .btn {
        min-width: 72px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   FTP FILE BROWSER MODAL & CONTROLS
   ═══════════════════════════════════════════════════════════════ */

@keyframes ftpPopIn {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes ftpSpin {
    to {
        transform: rotate(360deg);
    }
}

.ftp-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.ftp-window {
    background: var(--run-panel, #0a0a0a);
    border: 1px solid var(--run-border-strong, #333);
    border-radius: 6px;
    box-shadow: var(--run-shadow-lg, 0 24px 60px rgba(0, 0, 0, 0.85));
    width: 100%;
    max-width: 980px;
    height: 86vh;
    max-height: 740px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: ftpPopIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.ftp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--run-border-subtle, #252525);
    background: var(--run-surface-alt, #0e0e0e);
    flex-shrink: 0;
}

.ftp-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ftp-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: var(--run-elevated, #161616);
    border: 1px solid var(--run-border-quiet, #2a2a2a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--run-text, #fff);
    flex-shrink: 0;
}

.ftp-header-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ftp-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--run-text, #fff);
}

.ftp-subtitle {
    font-size: 11px;
    letter-spacing: .02em;
    color: var(--run-text-soft, #888);
}

.ftp-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ftp-icon-btn {
    background: transparent;
    border: 1px solid var(--run-border-quiet, #2a2a2a);
    color: var(--run-text-soft, #aaa);
    border-radius: 4px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
}

.ftp-icon-btn:hover {
    background: var(--run-hover, #222);
    border-color: var(--run-border-hover, #555);
    color: var(--run-text, #fff);
}

.ftp-close-btn:hover {
    border-color: rgba(229, 115, 115, 0.5);
    color: #e57373;
    background: rgba(229, 115, 115, 0.08);
}

.ftp-drives-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--run-border-quiet, #1a1a1a);
    background: var(--run-surface, #080808);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}

.ftp-drives-bar::-webkit-scrollbar {
    display: none;
}

.ftp-drive-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    background: var(--run-elevated, #141414);
    border: 1px solid var(--run-border-quiet, #282828);
    color: var(--run-text-soft, #bbb);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    font-family: inherit;
}

.ftp-drive-chip:hover {
    background: var(--run-hover, #222);
    color: var(--run-text, #fff);
    border-color: var(--run-border-hover, #555);
}

.ftp-drive-chip.active {
    background: var(--run-hover, #262626);
    color: var(--run-text, #fff);
    border-color: var(--run-text, #fff);
    box-shadow: 0 0 0 1px var(--run-text, #fff);
}

.ftp-nav-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--run-border-subtle, #222);
    background: var(--run-surface-alt, #0c0c0c);
    flex-shrink: 0;
}

.ftp-nav-btn {
    background: var(--run-elevated, #141414);
    border: 1px solid var(--run-border-quiet, #282828);
    color: var(--run-text, #fff);
    border-radius: 4px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
    flex-shrink: 0;
}

.ftp-nav-btn:hover:not(:disabled) {
    background: var(--run-hover, #222);
    border-color: var(--run-border-hover, #555);
}

.ftp-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.ftp-breadcrumb-trail {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    font-size: 12px;
}

.ftp-breadcrumb-trail::-webkit-scrollbar {
    display: none;
}

.ftp-crumb-item {
    color: var(--run-text-soft, #999);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    transition: all 0.15s;
}

.ftp-crumb-item:hover {
    color: var(--run-text, #fff);
    background: var(--run-hover, #222);
}

.ftp-crumb-item.active {
    color: var(--run-text, #fff);
    font-weight: 600;
    cursor: default;
    background: transparent;
}

.ftp-crumb-sep {
    color: var(--run-border-hover, #555);
    font-size: 10px;
    flex-shrink: 0;
    user-select: none;
}

.ftp-search-wrap {
    position: relative;
    width: 190px;
    flex-shrink: 0;
}

.ftp-search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--run-text-soft, #777);
    pointer-events: none;
}

.ftp-filter-input {
    width: 100%;
    background: var(--run-elevated, #141414);
    border: 1px solid var(--run-border-quiet, #282828);
    border-radius: 4px;
    padding: 5px 26px 5px 26px;
    color: var(--run-text, #fff);
    font-size: 11.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.ftp-filter-input:focus {
    border-color: var(--run-text, #fff);
}

.ftp-filter-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--run-text-soft, #777);
    cursor: pointer;
    padding: 2px;
    font-size: 13px;
}

.ftp-main-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: var(--run-bg, #000);
}

.ftp-file-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    height: 100%;
}

.ftp-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.ftp-table-header {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 90px 140px 60px;
    padding: 7px 18px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--run-text-soft, #777);
    border-bottom: 1px solid var(--run-border-quiet, #1a1a1a);
    background: var(--run-surface, #080808);
    user-select: none;
    flex-shrink: 0;
}

.ftp-col-actions {
    display: flex;
    justify-content: flex-end;
}

.ftp-file-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 10px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ftp-file-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 90px 140px 60px;
    padding: 6px 8px;
    border-radius: 4px;
    align-items: center;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    font-size: 12.5px;
    color: var(--run-text, #eee);
    user-select: none;
    border: 1px solid transparent;
}

.ftp-file-row:hover {
    background: var(--run-hover, #1a1a1a);
    color: var(--run-text, #fff);
}

.ftp-file-row.selected {
    background: var(--run-elevated-strong, #222);
    border-color: var(--run-border-hover, #555);
    color: var(--run-text, #fff);
}

.ftp-row-name {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ftp-row-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ftp-row-size {
    font-family: inherit;
    font-size: 11.5px;
    color: var(--run-text-soft, #888);
}

.ftp-row-date {
    font-size: 11px;
    color: var(--run-text-soft, #777);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ftp-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
}

.ftp-row-action-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--run-text-soft, #777);
    border-radius: 3px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.12s;
    font-size: 12px;
}

.ftp-row-action-btn:hover {
    background: var(--run-hover, #222);
    border-color: var(--run-border-hover, #555);
    color: var(--run-text, #fff);
}

.ftp-row-action-btn.danger:hover {
    border-color: rgba(229, 115, 115, 0.5);
    color: #e57373;
    background: rgba(229, 115, 115, 0.1);
}

.ftp-row-icon {
    font-size: 15px;
    flex-shrink: 0;
}

.ftp-row-icon.dir {
    color: #e0b040;
}

.ftp-row-icon.file {
    color: #88a0b8;
}

.ftp-row-icon.code {
    color: #72c080;
}

.ftp-row-icon.media {
    color: #d070b0;
}

.ftp-row-icon.binary {
    color: #a080d0;
}

.ftp-drives-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    padding: 16px;
}

.ftp-drive-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    background: var(--run-elevated, #121212);
    border: 1px solid var(--run-border-subtle, #282828);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.ftp-drive-card:hover {
    background: var(--run-hover, #1c1c1c);
    border-color: var(--run-border-hover, #666);
    transform: translateY(-1px);
}

.ftp-drive-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ftp-drive-icon {
    font-size: 20px;
    color: var(--run-text, #fff);
}

.ftp-drive-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--run-text, #fff);
}

.ftp-drive-sub {
    font-size: 11px;
    color: var(--run-text-soft, #888);
}

.ftp-drive-bar-wrap {
    width: 100%;
    height: 5px;
    background: var(--run-surface-alt, #222);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.ftp-drive-bar-fill {
    height: 100%;
    background: var(--run-text, #fff);
    transition: width 0.3s;
}

.ftp-drive-usage {
    font-size: 10.5px;
    color: var(--run-text-soft, #888);
    display: flex;
    justify-content: space-between;
}

.ftp-preview-drawer {
    width: 400px;
    max-width: 50%;
    border-left: 1px solid var(--run-border-subtle, #252525);
    background: var(--run-surface-alt, #0c0c0c);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.ftp-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--run-border-quiet, #222);
    background: var(--run-surface, #080808);
}

.ftp-preview-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ftp-preview-icon {
    font-size: 16px;
    color: var(--run-text, #fff);
    flex-shrink: 0;
}

.ftp-preview-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ftp-preview-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--run-text, #fff);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ftp-preview-size {
    font-size: 10px;
    color: var(--run-text-soft, #777);
}

.ftp-preview-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ftp-save-btn {
    color: #81c784 !important;
    border-color: rgba(129, 199, 132, 0.4) !important;
}

.ftp-save-btn:hover {
    background: rgba(129, 199, 132, 0.15) !important;
    border-color: #81c784 !important;
}

.ftp-preview-body {
    flex: 1;
    overflow: auto;
    padding: 12px;
    background: var(--run-bg, #000);
    display: flex;
    flex-direction: column;
}

.ftp-preview-code {
    margin: 0;
    font-family: 'Consolas', 'Cascadia Code', 'Fira Code', monospace;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--run-text-muted, #ccc);
    white-space: pre-wrap;
    word-break: break-all;
}

.ftp-preview-editor {
    width: 100%;
    flex: 1;
    min-height: 250px;
    background: transparent;
    color: var(--run-text, #fff);
    font-family: 'Consolas', 'Cascadia Code', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.55;
    border: 1px solid var(--run-border-quiet, #222);
    border-radius: 4px;
    padding: 10px;
    outline: none;
    resize: none;
    tab-size: 4;
}

.ftp-preview-editor:focus {
    border-color: var(--run-border-hover, #666);
}

.ftp-preview-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 16px;
}

.ftp-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid var(--run-border-quiet, #222);
}

.ftp-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 18px;
    border-top: 1px solid var(--run-border-subtle, #222);
    background: var(--run-surface-alt, #0c0c0c);
    font-size: 11px;
    color: var(--run-text-soft, #777);
    flex-shrink: 0;
}

/* ── Inline Dialog Overlay ── */
.ftp-dialog-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: ftpPopIn 0.15s ease;
}

.ftp-dialog {
    background: var(--run-panel, #0c0c0c);
    border: 1px solid var(--run-border-strong, #333);
    border-radius: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85);
    width: 100%;
    max-width: 380px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ftp-dialog-title {
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--run-text, #fff);
}

.ftp-dialog-msg {
    font-size: 12px;
    color: var(--run-text-soft, #aaa);
    line-height: 1.45;
}

.ftp-dialog-input {
    width: 100%;
    background: var(--run-elevated, #161616);
    border: 1px solid var(--run-border-subtle, #333);
    border-radius: 4px;
    padding: 7px 10px;
    color: var(--run-text, #fff);
    font-size: 12.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.ftp-dialog-input:focus {
    border-color: var(--run-text, #fff);
}

.ftp-dialog-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.ftp-dialog-btn {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--run-border-subtle, #333);
    color: var(--run-text-soft, #ccc);
    font-family: inherit;
    transition: all 0.12s;
}

.ftp-dialog-btn:hover {
    background: var(--run-hover, #222);
    color: var(--run-text, #fff);
}

.ftp-dialog-btn.primary {
    background: var(--run-text, #fff);
    color: var(--run-text-inverse, #000);
    border-color: var(--run-text, #fff);
}

.ftp-dialog-btn.primary:hover {
    opacity: 0.9;
}

.ftp-dialog-btn.danger {
    background: #e57373;
    color: #fff;
    border-color: #e57373;
}

.ftp-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    gap: 10px;
    color: var(--run-text-soft, #777);
    text-align: center;
    margin: auto;
}

.ftp-empty-icon {
    font-size: 32px;
    color: var(--run-border-hover, #555);
}

.ftp-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 12px;
    color: #e57373;
    text-align: center;
    margin: auto;
}

.ftp-loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px;
    color: var(--run-text-soft, #888);
    font-size: 13px;
    margin: auto;
}

.ftp-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--run-border-hover, #555);
    border-top-color: var(--run-text, #fff);
    border-radius: 50%;
    animation: ftpSpin 0.7s linear infinite;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE & TOUCH HANDLING
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 650px) {
    .ftp-modal-overlay {
        padding: 0;
    }

    .ftp-window {
        height: 100dvh;
        max-height: 100dvh;
        width: 100vw;
        border-radius: 0;
        border: none;
    }

    .ftp-header {
        padding: 8px 12px;
    }

    .ftp-brand-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .ftp-title {
        font-size: 12px;
    }

    .ftp-subtitle {
        font-size: 10px;
    }

    .ftp-drives-bar {
        padding: 6px 12px;
        gap: 6px;
    }

    .ftp-drive-chip {
        padding: 3px 8px;
        font-size: 11px;
    }

    .ftp-nav-toolbar {
        padding: 6px 12px;
        gap: 6px;
        flex-wrap: wrap;
    }

    .ftp-breadcrumb-trail {
        order: 1;
        flex: 1 1 auto;
        min-width: 0;
        max-width: calc(100% - 130px);
    }

    .ftp-toolbar-actions {
        order: 2;
        margin-left: auto;
    }

    .ftp-search-wrap {
        order: 3;
        width: 100%;
        margin-top: 4px;
    }

    .ftp-table-header {
        grid-template-columns: minmax(130px, 1fr) 60px 60px;
        padding: 6px 10px;
        font-size: 10px;
    }

    .ftp-col-date,
    .ftp-row-date {
        display: none;
    }

    .ftp-file-row {
        grid-template-columns: minmax(130px, 1fr) 60px 60px;
        min-height: 44px;
        padding: 8px 10px;
    }

    .ftp-row-actions {
        opacity: 1;
    }

    .ftp-row-action-btn {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }

    .ftp-preview-drawer {
        position: absolute;
        inset: 0;
        width: 100%;
        max-width: 100%;
        z-index: 30;
    }

    .ftp-drives-grid {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 10px;
    }

    .logs-window {
        height: 94vh;
        max-height: 94vh;
    }

    .logs-toolbar {
        padding: 8px 12px;
        gap: 8px;
    }

    .logs-search-wrap {
        max-width: 100%;
        min-width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════
   OPERATION LOGS MODAL
   ═══════════════════════════════════════════════════════════════ */

.logs-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.logs-window {
    background: var(--run-panel, #0a0a0a);
    border: 1px solid var(--run-border-strong, #333);
    border-radius: 6px;
    box-shadow: var(--run-shadow-lg, 0 24px 60px rgba(0, 0, 0, 0.85));
    width: 100%;
    max-width: 920px;
    height: 84vh;
    max-height: 720px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: ftpPopIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.logs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--run-border-subtle, #252525);
    background: var(--run-surface-alt, #0e0e0e);
    flex-shrink: 0;
}

.logs-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logs-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: var(--run-elevated, #161616);
    border: 1px solid var(--run-border-quiet, #2a2a2a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--run-text, #fff);
    flex-shrink: 0;
}

.logs-header-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logs-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--run-text, #fff);
}

.logs-subtitle {
    font-size: 11px;
    letter-spacing: .02em;
    color: var(--run-text-soft, #888);
}

.logs-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logs-icon-btn {
    background: transparent;
    border: 1px solid var(--run-border-quiet, #2a2a2a);
    color: var(--run-text-soft, #aaa);
    border-radius: 4px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
}

.logs-icon-btn:hover {
    background: var(--run-hover, #222);
    border-color: var(--run-border-hover, #555);
    color: var(--run-text, #fff);
}

.logs-icon-btn.danger:hover {
    border-color: rgba(229, 115, 115, 0.5);
    color: #e57373;
    background: rgba(229, 115, 115, 0.08);
}

.logs-close-btn:hover {
    border-color: rgba(229, 115, 115, 0.5);
    color: #e57373;
    background: rgba(229, 115, 115, 0.08);
}

.logs-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--run-border-subtle, #252525);
    background: var(--run-surface, #0c0c0c);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.logs-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 180px;
    max-width: 300px;
}

.logs-search-icon {
    position: absolute;
    left: 9px;
    font-size: 12px;
    color: var(--run-text-soft, #777);
    pointer-events: none;
}

.logs-filter-input {
    width: 100%;
    background: var(--run-elevated, #161616);
    border: 1px solid var(--run-border-quiet, #2a2a2a);
    border-radius: 4px;
    padding: 6px 28px 6px 28px;
    font-size: 12px;
    color: var(--run-text, #fff);
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

.logs-filter-input:focus {
    border-color: var(--run-border-hover, #666);
}

.logs-filter-clear {
    position: absolute;
    right: 6px;
    background: transparent;
    border: none;
    color: var(--run-text-soft, #777);
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
}

.logs-filter-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.logs-pill {
    background: var(--run-elevated, #141414);
    border: 1px solid var(--run-border-quiet, #282828);
    color: var(--run-text-soft, #aaa);
    border-radius: 3px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.logs-pill:hover {
    background: var(--run-hover, #222);
    color: var(--run-text, #fff);
}

.logs-pill.active {
    background: var(--run-text, #fff);
    border-color: var(--run-text, #fff);
    color: var(--run-bg, #000);
}

.logs-counter {
    margin-left: auto;
    font-size: 11px;
    color: var(--run-text-soft, #777);
    white-space: nowrap;
}

.logs-list-container {
    flex: 1;
    overflow-y: auto;
    background: var(--run-bg, #060606);
    padding: 12px 18px;
}

.logs-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.log-entry {
    background: var(--run-surface, #0e0e0e);
    border: 1px solid var(--run-border-quiet, #1f1f1f);
    border-radius: 4px;
    padding: 8px 14px;
    display: grid;
    grid-template-columns: 140px 1fr auto;
    grid-template-areas: "time content tag";
    align-items: center;
    column-gap: 14px;
    row-gap: 6px;
    transition: border-color 0.15s, background 0.15s;
}

.log-entry:hover {
    border-color: var(--run-border-hover, #444);
    background: var(--run-surface-alt, #141414);
}

.log-time {
    grid-area: time;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 11px;
    color: var(--run-text-soft, #777);
    white-space: nowrap;
}

.log-type-tag {
    grid-area: tag;
    font-family: 'Space Grotesk', -apple-system, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    padding: 2px 7px;
    border-radius: 3px;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
    justify-self: end;
}

.log-type-COMMAND {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
}

.log-type-SPEAK {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.35);
}

.log-type-MESSAGE {
    background: rgba(20, 184, 166, 0.15);
    color: #2dd4bf;
    border: 1px solid rgba(20, 184, 166, 0.35);
}

.log-type-IMAGER {
    background: rgba(244, 63, 94, 0.15);
    color: #fb7185;
    border: 1px solid rgba(244, 63, 94, 0.35);
}

.log-type-AUDIO {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.log-type-SCREENSHOT {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.log-type-UPDATE {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.log-type-DEVICE {
    background: rgba(236, 72, 153, 0.15);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.35);
}

.log-type-FTP {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.35);
}

.log-type-SYSTEM {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.log-type-VISIBILITY {
    background: rgba(120, 113, 108, 0.15);
    color: #a8a29e;
    border: 1px solid rgba(120, 113, 108, 0.35);
}

.log-content {
    grid-area: content;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.log-detail-text {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 12px;
    color: var(--run-text, #eee);
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    line-height: 1.45;
}

/* ═══════════════════════════════════════════════════════════════
   ACCESS VERIFICATION LOGS
   ═══════════════════════════════════════════════════════════════ */

.access-logs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.access-log-entry {
    background: var(--run-surface, #0e0e0e);
    border: 1px solid var(--run-border-quiet, #1f1f1f);
    border-radius: 5px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.15s, background 0.15s;
}

.access-log-entry:hover {
    border-color: var(--run-border-hover, #444);
    background: var(--run-surface-alt, #141414);
}

.access-log-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.access-log-ip-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--run-text, #fff);
}

.access-log-location {
    font-size: 12px;
    color: var(--run-text-muted, #ccc);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.access-log-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--run-text-soft, #888);
}

.access-log-status-SUCCESS {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.35);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 3px;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.access-log-status-FAILED {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 3px;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.access-log-status-BLOCKED {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 3px;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.access-log-device-badge {
    background: var(--run-elevated, #1a1a1a);
    border: 1px solid var(--run-border-quiet, #2a2a2a);
    color: var(--run-text-dim, #aaa);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.access-log-gps-badge {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 3px;
    letter-spacing: .04em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
}

.access-log-maps-btn {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.35);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 3px;
    letter-spacing: .04em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.access-log-maps-btn:hover {
    background: rgba(56, 189, 248, 0.28);
    border-color: #38bdf8;
    color: #bae6fd;
}

.access-log-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 6px 14px;
    padding-top: 8px;
    border-top: 1px solid var(--run-border-quiet, #1a1a1a);
    font-size: 11px;
}

.access-log-spec-item {
    display: flex;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.access-log-spec-label {
    color: var(--run-text-soft, #777);
    flex-shrink: 0;
}

.access-log-spec-val {
    color: var(--run-text-muted, #ddd);
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 10.5px;
}

.access-log-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--run-text-soft, #666);
    font-size: 13px;
}



/* ── Mobile Responsive Operations Logs ── */
@media (max-width: 768px) {
    .logs-modal-overlay {
        padding: 8px 6px;
    }

    .logs-window {
        width: 100%;
        height: 94vh;
        max-height: 96vh;
        border-radius: 6px;
    }

    .logs-header {
        padding: 10px 14px;
    }

    .logs-title {
        font-size: 12px;
    }

    .logs-toolbar {
        padding: 8px 12px;
        gap: 8px;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "search search"
            "pills counter";
        align-items: center;
    }

    .logs-search-wrap {
        grid-area: search;
        min-width: 100%;
        max-width: 100%;
    }

    .logs-filter-pills {
        grid-area: pills;
        display: flex;
        align-items: center;
        gap: 6px;
        overflow-x: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        min-width: 0;
        padding-bottom: 2px;
    }

    .logs-filter-pills::-webkit-scrollbar {
        display: none;
    }

    .logs-pill {
        flex-shrink: 0;
        padding: 4px 9px;
        font-size: 11px;
    }

    .logs-counter {
        grid-area: counter;
        margin-left: 8px;
        font-size: 10.5px;
        white-space: nowrap;
    }

    .logs-list-container {
        padding: 8px 10px;
    }

    .log-entry {
        padding: 8px 12px;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "time tag"
            "content content";
        column-gap: 8px;
        row-gap: 6px;
        align-items: center;
    }

    .log-time {
        font-size: 10.5px;
        padding-top: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .log-type-tag {
        font-size: 9.5px;
        padding: 2px 6px;
        justify-self: end;
    }

    .log-content {
        width: 100%;
        padding-top: 2px;
    }

    .log-detail-text {
        font-size: 11.5px;
        line-height: 1.4;
    }
}

.logs-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 280px;
    color: var(--run-text-soft, #666);
    text-align: center;
}

.logs-empty-icon {
    font-size: 38px;
    opacity: 0.4;
}

/* Disabled script card state (e.g. Screenshot Capture while streaming) */
.script-card.disabled {
    opacity: 0.42;
    filter: grayscale(0.4);
    cursor: not-allowed;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}