:root {
    --bg: #0d1117;
    --surface: #151a23;
    --surface-alt: #1c2230;
    --border: #273044;
    --text: #e8edf5;
    --muted: #98a4bb;
    --accent: #5bd2c3;
    --accent-2: #5a8cff;
    --danger: #ff6b6b;
    --shadow: rgba(7, 10, 16, 0.45);
    --shadow-soft: rgba(7, 10, 16, 0.25);
    --glow: rgba(91, 210, 195, 0.22);
    --toast-bg: rgba(20, 24, 34, 0.95);
    --toast-text: #f3f6fc;
    --toast-border: rgba(255, 255, 255, 0.08);
    --toast-error-bg: rgba(56, 20, 20, 0.95);
    --toast-error-text: #fff1f1;
    --toast-error-border: rgba(255, 84, 84, 0.5);
}

/* Professional variants share geometry; only their semantic colors differ. */
body[data-theme="professional-light"] {
    color-scheme: light;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-alt: #f6f7f8;
    --border: #d5d9df;
    --text: #1f2937;
    --muted: #5b6573;
    --accent: #245da8;
    --accent-2: #245da8;
    --danger: #b4232d;
    --pro-primary: #245da8;
    --pro-primary-hover: #1b4a88;
    --pro-hover: #eaf0f7;
    --pro-selection: #dce8f7;
    --pro-danger-bg: #fff0f0;
    --pro-danger-border: #e1a5a9;
    --pro-overlay: rgba(31, 41, 55, 0.4);
    --pro-code-string: #21643a;
    --pro-code-number: #8a480e;
    --toast-bg: #ffffff;
    --toast-text: #1f2937;
    --toast-border: #d5d9df;
    --toast-error-bg: #fff0f0;
    --toast-error-text: #91212a;
    --toast-error-border: #e1a5a9;
}

body[data-theme="professional-dark"] {
    color-scheme: dark;
    --bg: #17191c;
    --surface: #202327;
    --surface-alt: #282c31;
    --border: #414750;
    --text: #e7e9ed;
    --muted: #adb5c0;
    --accent: #8db9ef;
    --accent-2: #8db9ef;
    --danger: #f5a0a6;
    --pro-primary: #3268ad;
    --pro-primary-hover: #3a74bc;
    --pro-hover: #2d3540;
    --pro-selection: #303f54;
    --pro-danger-bg: #39262a;
    --pro-danger-border: #88535b;
    --pro-overlay: rgba(0, 0, 0, 0.6);
    --pro-code-string: #a3cfad;
    --pro-code-number: #dfb889;
    --toast-bg: #282c31;
    --toast-text: #e7e9ed;
    --toast-border: #414750;
    --toast-error-bg: #39262a;
    --toast-error-text: #f5b7bb;
    --toast-error-border: #88535b;
}

body[data-theme="dark-modern"] {
    font-family: "Avenir Next", "Futura", "Trebuchet MS", sans-serif;
    background:
        radial-gradient(circle at 10% 15%, rgba(91, 210, 195, 0.18), transparent 45%),
        radial-gradient(circle at 85% 5%, rgba(90, 140, 255, 0.22), transparent 40%),
        radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.05), transparent 55%),
        var(--bg);
}

body[data-theme="light-modern"] {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-alt: #eef2f8;
    --border: #d6dce8;
    --text: #1c2533;
    --muted: #5c6678;
    --accent: #2db8db;
    --accent-2: #76eca1;
    --danger: #d9485f;
    --shadow: rgba(16, 24, 40, 0.12);
    --shadow-soft: rgba(16, 24, 40, 0.08);
    --glow: rgba(45, 156, 219, 0.2);
    --toast-bg: rgba(36, 42, 54, 0.96);
    --toast-text: #f7f9fd;
    --toast-border: rgba(28, 37, 51, 0.12);
    --toast-error-bg: rgba(92, 30, 36, 0.96);
    --toast-error-text: #fff4f4;
    --toast-error-border: rgba(217, 72, 95, 0.4);
    font-family: "Avenir Next", "Futura", "Trebuchet MS", sans-serif;
    background:
        radial-gradient(circle at 15% 10%, rgba(45, 156, 219, 0.2), transparent 40%),
        radial-gradient(circle at 85% 15%, rgba(242, 153, 74, 0.2), transparent 45%),
        #f5f7fb;
    .var-table th { background: rgb(164 164 164 / 90%); }
    #log { background: initial; color: initial; }
}

body[data-theme="light-modern"] .topbar,
body[data-theme="light-modern"] .footer {
    background: rgba(255, 255, 255, 0.9);
}

body[data-theme="retro"] {
    --bg: #050805;
    --surface: #07120a;
    --surface-alt: #0c1b12;
    --border: #1f3d2b;
    --text: #9cffc5;
    --muted: #5da37b;
    --accent: #2fff8f;
    --accent-2: #6effc8;
    --danger: #ff4d6d;
    --shadow: rgba(0, 0, 0, 0.6);
    --shadow-soft: rgba(0, 0, 0, 0.35);
    --glow: rgba(47, 255, 143, 0.18);
    --toast-bg: rgba(7, 18, 10, 0.96);
    --toast-text: #9cffc5;
    --toast-border: rgba(47, 255, 143, 0.2);
    --toast-error-bg: rgba(58, 10, 20, 0.96);
    --toast-error-text: #ffd3dc;
    --toast-error-border: rgba(255, 77, 109, 0.45);
    font-family: "Courier New", "Lucida Console", monospace;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3) 1px, transparent 1px, transparent 3px),
        radial-gradient(circle at 30% 10%, rgba(47, 255, 143, 0.18), transparent 50%),
        #050805;
    #log { font-family: "Courier New", "Courier", monospace; }
}

body[data-theme="retro"] .topbar,
body[data-theme="retro"] .footer {
    background: rgba(5, 14, 8, 0.9);
}

body[data-theme="retro"] .panel,
body[data-theme="retro"] .panel-header,
body[data-theme="retro"] .panel-body {
    border-radius: 0;
}

body[data-theme="retro"] .btn {
    font-family: inherit;
    border-radius: 2px;
}

body[data-theme="retro"] .panel,
body[data-theme="retro"] .panel-header,
body[data-theme="retro"] .panel-body,
body[data-theme="retro"] .modal-card,
body[data-theme="retro"] .btn,
body[data-theme="retro"] .info-card,
body[data-theme="retro"] .log,
body[data-theme="retro"] #screenshotCanvas,
body[data-theme="retro"] .dropzone,
body[data-theme="retro"] .dropzone input[type="file"],
body[data-theme="retro"] .dropzone input[type="file"]::file-selector-button,
body[data-theme="retro"] .splash-card,
body[data-theme="retro"] .progress-bar,
body[data-theme="retro"] .progress-bar-fill,
body[data-theme="retro"] .brand-mark,
body[data-theme="retro"] .brand-beta {
    border-radius: 0;
}

/* Minimal theme: flat graphite surfaces, one muted accent, no gradients/glow/blur, no emoji. */
body[data-theme="minimal"] {
    --bg: #121316;
    --surface: #1a1b1f;
    --surface-alt: #202126;
    --border: #2c2d33;
    --text: #e7e7ea;
    --muted: #8c8f98;
    --accent: #8fa8c4;
    --accent-2: #8fa8c4;
    --danger: #c1786f;
    --shadow: rgba(0, 0, 0, 0.28);
    --shadow-soft: rgba(255, 255, 255, 0.06);
    --glow: transparent;
    --toast-bg: #1c1d21;
    --toast-text: #e7e7ea;
    --toast-border: #33343a;
    --toast-error-bg: #241c1b;
    --toast-error-text: #f2e6e3;
    --toast-error-border: rgba(193, 120, 111, 0.4);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
}

body[data-theme="minimal"] .topbar,
body[data-theme="minimal"] .footer {
    background: var(--surface);
    backdrop-filter: none;
}

body[data-theme="minimal"] .brand-mark {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: none;
    border-radius: 8px;
}

body[data-theme="minimal"] .brand-mark > span.brand-beta {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: none;
}

body[data-theme="minimal"] .settings-update-dot {
    background: var(--danger);
    box-shadow: 0 0 0 2px var(--surface);
}

body[data-theme="minimal"] .status-dot.is-active {
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(143, 168, 196, 0.2);
}

body[data-theme="minimal"] .splash-card,
body[data-theme="minimal"] .panel,
body[data-theme="minimal"] .modal-card {
    box-shadow: none;
    border-radius: 8px;
}

body[data-theme="minimal"] .info-card,
body[data-theme="minimal"] .table-wrap,
body[data-theme="minimal"] .settings-offline,
body[data-theme="minimal"] .modal-overlay-card {
    border-radius: 8px;
}

body[data-theme="minimal"] .btn,
body[data-theme="minimal"] .form-input,
body[data-theme="minimal"] .search,
body[data-theme="minimal"] .dropzone {
    border-radius: 6px;
}

body[data-theme="minimal"] .toast {
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow);
}

body[data-theme="minimal"] .progress-bar {
    background: var(--surface-alt);
}

body[data-theme="minimal"] .progress-bar-fill {
    background: var(--accent);
}

body[data-theme="minimal"] .dropzone {
    border: 1px dashed var(--border);
    background: var(--surface-alt);
}

body[data-theme="minimal"] .dropzone.drag-over {
    border-color: var(--accent);
    background: var(--surface-alt);
    box-shadow: none;
}

body[data-theme="minimal"] .dropzone input[type="file"] {
    background: var(--surface);
}

body[data-theme="minimal"] .btn.primary {
    background: var(--accent);
    color: #12141a;
    box-shadow: none;
}

body[data-theme="minimal"] .btn.danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

body[data-theme="minimal"] .var-table th {
    background: var(--surface-alt);
}

body[data-theme="minimal"] .var-table tr:hover {
    background: var(--surface-alt);
}

body[data-theme="minimal"] .var-table tr.drop-target {
    background: var(--surface-alt);
    outline: 1px dashed var(--accent);
}

body[data-theme="minimal"] .modal {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: none;
}

body[data-theme="minimal"] .modal-overlay {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: none;
}

body[data-theme="minimal"] #screenshotCanvas {
    outline: 1px solid var(--border);
}

body[data-theme="minimal"] .log-error {
    color: #d99b93;
}

body[data-theme="minimal"] :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Avenir Next", "Futura", "Trebuchet MS", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 15%, rgba(91, 210, 195, 0.18), transparent 45%),
        radial-gradient(circle at 85% 5%, rgba(90, 140, 255, 0.22), transparent 40%),
        radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.05), transparent 55%),
        var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.splash {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.splash-card {
    max-width: 520px;
    padding: 36px 40px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 20px 50px var(--shadow);
}

.splash h1 {
    margin: 0 0 10px;
    font-size: 24px;
}

.splash p {
    text-wrap: balance;
    margin: 0 0 22px;
    color: var(--muted);
}

/* Show startup progress before scripts load and while isolation may reload the page. */
.initialization-screen {
    display: none;
}

body.initializing {
    overflow: hidden;
}

body.initializing > :not(.initialization-screen) {
    visibility: hidden;
}

body.initializing .initialization-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.initialization-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    text-align: center;
}

.initialization-card p {
    margin: 0;
    color: var(--muted);
}

.initialization-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    .initialization-spinner {
        animation: none;
    }
}

.splash-warning {
    margin: 16px 0 22px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 107, 107, 0.12);
    color: var(--text);
}

.splash-warning p {
    margin: 0 0 6px;
}

.splash-warning p:last-child {
    margin-bottom: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 14, 20, 0.82);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0b0f14;
    font-weight: 700;
    letter-spacing: 0;
    box-shadow: 0 10px 24px rgba(90, 140, 255, 0.18);
    position: relative;
    line-height: 14px;
    text-align: center;
}

.brand-mark > span {
    position: relative;
    top: 1px;
    left: .5px;
}

.brand-mark > span.brand-beta {
    position: absolute;
    top: -7px;
    left: initial;
    right: -10px;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(13, 17, 23, 0.85);
    color: #fff;
    padding: 0 5px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.brand-build {
    display: none;
}

.brand-title {
    font-size: 18px;
    font-weight: 600;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--muted);
}

.settings-offline {
    margin-top: 16px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--muted);
    font-size: 12px;
}

.settings-offline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-offline-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--muted);
}

.settings-button {
    position: relative;
}

.settings-update-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4d4d;
    box-shadow: 0 0 0 2px rgba(10, 14, 20, 0.8);
}

.progress-indicator {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 200px;
    flex: 1 1 240px;
    max-width: 260px;
    max-height: min-content;
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-label {
    font-size: 12px;
    color: var(--muted);
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--muted);
}

.progress-percent,
.progress-rate {
    white-space: nowrap;
}

.progress-bar {
    position: relative;
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(90, 140, 255, 0.2);
}

.progress-bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 45%;
    background: linear-gradient(90deg, rgba(91, 210, 195, 0.3), var(--accent-2), var(--accent));
    animation: progress-slide 1.2s ease-in-out infinite;
}

.progress-bar-fill.determinate {
    animation: none;
    transition: width 0.2s ease;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #586178;
    box-shadow: 0 0 0 4px rgba(88, 97, 120, 0.2);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.status-dot.is-active {
    background: #4fd3b4;
    box-shadow: 0 0 0 4px rgba(79, 211, 180, 0.2);
}

.actions {
    display: flex;
    gap: 12px;
}

.layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
    padding: 24px 28px 60px;
    flex: 1;
    min-width: 80%;
    max-width: 1400px;
    place-self: center;
}

.panel {
    grid-column: span 6;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 16px 40px var(--shadow);
    overflow: hidden;
    min-width: 0;
}

.panel.wide {
    grid-column: span 12;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    gap: 12px;
}

.panel-header h2 {
    margin: 0;
    font-size: 16px;
    letter-spacing: 0.3px;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.panel-body {
    padding: 18px 20px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}

.info-card {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.info-card .label {
    font-size: 11px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--muted);
}

.info-card .value {
    margin-top: 6px;
    font-size: 15px;
    font-weight: 600;
}

.device-model-secondary {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.note {
    margin-top: 14px;
    font-size: 13px;
    color: var(--muted);
}

.info-list {
    margin-top: 16px;
    display: grid;
    border: 1px solid var(--border);
    border-bottom: none;
}

.info-row {
    display: grid;
    grid-template-columns: minmax(140px, 250px) 1fr;
    gap: 10px;
    padding: 1px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.info-row .key {
    color: var(--muted);
    font-weight: 600;
}

.info-row .hash-value {
    font-family: monospace;
    overflow: hidden;
}

.transfer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.dropzone {
    border: 1px dashed rgba(79, 211, 180, 0.5);
    border-radius: 14px;
    padding: 18px;
    display: grid;
    gap: 12px;
    background: rgba(91, 210, 195, 0.05);
}

.dropzone.drag-over {
    border-color: rgba(79, 211, 180, 0.9);
    background: rgba(79, 211, 180, 0.12);
    box-shadow: 0 0 0 3px rgba(79, 211, 180, 0.18);
}

.dropzone input[type="file"] {
    width: 100%;
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(9, 12, 18, 0.25);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.dropzone input[type="file"]::file-selector-button {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    padding: 8px 12px;
    font-weight: 600;
    margin-right: 12px;
    cursor: pointer;
}

.dropzone-text .title {
    font-size: 15px;
    font-weight: 600;
}

.dropzone-text .subtitle {
    font-size: 12px;
    color: var(--muted);
}

.quick-actions {
    display: grid;
    gap: 10px;
}

.keypad {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}

.keypad .btn {
    min-height: 40px;
    text-align: center;
}

.key-quick {
    font-size: 12px;
    padding: 8px 10px;
}

.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
    position: relative;
    min-height: 40px;
    text-align: left;
}

.btn.mini {
    padding: 4px 10px;
    font-size: 11px;
    min-height: 26px;
    border-radius: 8px;
    white-space: nowrap;
}

/* Icon glyphs used by the Minimal theme in place of emoji (see app.js setIconLabel/iconMarkup). */
.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: -0.15em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.btn:not(.hidden):has(.icon) {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-inline:not(.hidden):has(.icon) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.folder-icon:has(.icon) {
    vertical-align: -0.2em;
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0c0f14;
    box-shadow: 0 10px 18px rgba(91, 210, 195, 0.24), 0 0 0 1px rgba(91, 210, 195, 0.2);
}

.btn.ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn.subtle {
    background: var(--surface);
    color: var(--muted);
    border-color: var(--border);
}

.btn.danger {
    background: rgba(255, 107, 107, 0.12);
    color: #ff9b9b;
    border-color: rgba(255, 107, 107, 0.3);
}

.btn.send-idle {
    background: var(--surface);
    color: var(--muted);
    border-color: var(--border);
    box-shadow: none;
    padding: 8px 12px;
    font-size: 12px;
    min-height: 36px;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn:not(:disabled):hover {
    transform: translateY(-1px);
    background-color: var(--shadow-soft);
}

.btn.loading::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes progress-slide {
    0% { transform: translateX(-70%); }
    50% { transform: translateX(30%); }
    100% { transform: translateX(140%); }
}

.search {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    min-height: 40px;
    font-size: 13px;
    font-weight: 600;
}

.table-wrap {
    max-height: 360px;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(9, 12, 18, 0.2);
    position: relative;
}

.var-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.var-table th,
.var-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.var-table th {
    background: rgba(31, 35, 48);
    position: sticky;
    top: 0;
    z-index: 1;
    cursor: pointer;
}

.var-table td:first-of-type
{
    width: 45px;
}

.folder-sticky {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    pointer-events: none;
}

.folder-sticky.hidden {
    visibility: hidden;
    opacity: 0;
}

.folder-sticky table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.folder-sticky td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-weight: 600;
    color: var(--text);
    background: var(--surface-alt);
}

.folder-sticky tr:last-child td {
    border-bottom: 1px solid var(--border);
}

.folder-sticky.hide-location td:nth-child(5),
.folder-sticky.hide-kind td:nth-child(7) {
    display: none;
}

.var-table tr:hover {
    background: rgba(79, 211, 180, 0.08);
}

.var-table tr.drop-target {
    background: rgba(79, 211, 180, 0.18);
    outline: 1px dashed rgba(79, 211, 180, 0.6);
}

.var-table tr[data-is-folder='1'] > td > span {
    font-weight: bold;
}

.var-table.hide-location th[data-sort="location"],
.var-table.hide-location td:nth-child(5) {
    display: none;
}

.var-table th.sorted-asc::after,
.var-table th.sorted-desc::after {
    content: '';
    border: 5px solid transparent;
    border-bottom-color: var(--muted);
    display: inline-block;
    margin-left: 6px;
}

.var-table th.sorted-desc::after {
    border-bottom-color: transparent;
    border-top-color: var(--muted);
}

.hidden {
    display: none;
}

.modal.hidden {
    display: none;
}


.var-table.hide-kind th:nth-child(7),
.var-table.hide-kind td:nth-child(7) {
    display: none;
}

.row-actions {
    display: inline-flex;
    gap: 6px;
    margin-left: auto;
    opacity: 0;
    transform: translateY(-1px);
    transition: opacity 120ms ease;
    pointer-events: none;
}

.name-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.name-left {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.name-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.integrity-warning {
    display: inline-block;
    margin-left: 0.45rem;
    color: #d29922;
    font-size: 0.78em;
    font-weight: 700;
    white-space: nowrap;
}

tr.integrity-invalid {
    box-shadow: inset 3px 0 0 #d29922;
}

.folder-toggle {
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    margin-right: 2px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    width: 0.75em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.folder-toggle:focus {
    outline: 1px solid rgba(255, 255, 255, 0.45);
    outline-offset: 2px;
    border-radius: 4px;
}

.folder-icon {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.folder-summary {
    opacity: 0.75;
    font-style: italic;
    white-space: nowrap;
    margin-left: 10px;
}

.folder-size {
    font-style: italic;
    color: lightslategrey;
}

.indent-bars {
    display: inline-flex;
    align-items: stretch;
    gap: 16px;
    margin-right: 2px;
    left: 2px;
    position: relative;
    height: 20px;
}

.indent-bar {
    width: 16px;
    border-left: 1px dotted rgba(255, 255, 255, 0.16);
    height: 100%;
}

.row-actions .btn-inline {
    padding: 2px 6px;
    font-size: 12px;
    line-height: 1;
    min-height: auto;
}

tr:hover .row-actions,
tr:focus-within .row-actions {
    opacity: 1;
    pointer-events: auto;
}

@media (hover: none) {
    .row-actions {
        opacity: 0;
        pointer-events: none;
    }
    tr.is-active .row-actions {
        opacity: 1;
        pointer-events: auto;
    }
    .folder-sticky td {
        padding-top: 10px;
        padding-bottom: 10px;
    }
}

#screenshotCanvas {
    display: block;
    width: auto;
    height: auto;
    image-rendering: pixelated;
    outline: 4px solid grey;
    margin: 8px auto;
    border-radius: 2px;
    max-width: min(640px, 100%);
    background: rgba(6, 8, 12, 0.4);
}

#screenshotCanvas.filled {
    background: grey;
}

.log {
    height: 485px;
    background: #0b0d12;
    color: #c7d0e0;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 12px;
    overflow: auto;
    margin: 0;
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
    font-size: 12px;
}

.log-error {
    color: #ff7b7b;
}

.footer {
    border-top: 1px solid var(--border);
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    background: rgba(15, 17, 23, 0.75);
    justify-content: center;
    text-align: center;
    text-wrap: balance;
}

.modal-footer-split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-footer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-footer.modal-footer-split > .modal-footer-actions:last-child {
    margin-left: auto;
}

a {
    color: var(--accent-2);
}

.footer a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.footer a:hover {
    border-bottom-color: var(--accent);
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(7, 9, 14, 0.75);
    backdrop-filter: blur(6px);
    z-index: 50;
}

.modal-card {
    width: min(720px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 40px var(--shadow);
    overflow: hidden;
}

.modal-card.modal-wide {
    width: min(980px, 100%);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.modal-body {
    padding: 18px 20px 10px;
    position: relative;
}

.modal-footer {
    padding: 12px 20px 18px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border);
    background: rgba(15, 17, 23, 0.6);
}

.modal-footer.modal-footer-split {
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.modal-footer-actions.hidden {
    display: none;
}

.preview-meta {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.preview-body {
    display: grid;
    gap: 14px;
    max-height: min(70vh, 720px);
    overflow: auto;
}

.preview-controls {
    display: flex;
    align-items: center;
    min-height: 30px;
}

.preview-controls.hidden {
    display: none;
}

.preview-download-split {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-download-split.hidden {
    display: none;
}

.preview-download-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.preview-download-choices {
    display: inline-flex;
}

.preview-download-choices .btn {
    border-radius: 0;
    padding-inline: 10px;
}

.preview-download-choices .btn:first-child {
    border-radius: 8px 0 0 8px;
}

.preview-download-choices .btn:last-child {
    margin-left: -1px;
    border-radius: 0 8px 8px 0;
}

.preview-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.preview-image {
    max-width: 100%;
    max-height: 420px;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    image-rendering: pixelated;
}

.preview-content {
    min-height: 120px;
    margin: 0;
    padding: 14px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #0b0d12;
    color: #c7d0e0;
    font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.preview-content .hljs-comment {
    color: #7f8c98;
    font-style: italic;
}

.preview-content .hljs-keyword {
    color: #66aaff;
    font-weight: 700;
}

.preview-content .hljs-built_in,
.preview-content .hljs-class .hljs-title,
.preview-content .hljs-function .hljs-title {
    color: #ff9696;
}

.preview-content .hljs-string {
    color: #7bd88f;
}

.preview-content .hljs-attribute {
    color: #8be9fd;
}

.preview-content .hljs-number,
.preview-content .hljs-symbol,
.preview-content .hljs-title {
    color: #ffb86b;
}

.preview-content .hljs-literal {
    color: #67e8f9;
}

.preview-content .hljs-variable,
.preview-content .hljs-params {
    color: #c3e88d;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 9, 14, 0.78);
    backdrop-filter: blur(3px);
    z-index: 2;
}

.modal-overlay.hidden {
    display: none;
}

.modal-overlay-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 30px var(--shadow);
    font-size: 13px;
}

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.transfer-table th,
.transfer-table td {
    vertical-align: middle;
    padding: 6px 10px;
}

.transfer-select {
    width: 40px;
    text-align: center;
}

.transfer-type {
    width: 120px;
    white-space: nowrap;
    text-transform: capitalize;
}

.transfer-size {
    width: 90px;
    white-space: nowrap;
    text-align: right;
}

.transfer-table input,
.transfer-table select {
    width: 100%;
}

.transfer-select input {
    width: auto;
}

.transfer-table .form-input {
    padding: 4px 8px;
    min-height: 28px;
    height: 28px;
    font-size: 12px;
    border-radius: 8px;
}

.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 260px;
    max-width: 420px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--toast-bg);
    color: var(--toast-text);
    border: 1px solid var(--toast-border);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    font-size: 13px;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    border-color: var(--toast-error-border);
    background: var(--toast-error-bg);
    color: var(--toast-error-text);
}

.toast-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.form-field {
    display: grid;
    gap: 6px;
}

.form-field label {
    font-size: 12px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}

.form-field .form-option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
}

.form-field.disabled .form-option {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    min-height: 40px;
    font-size: 13px;
    font-weight: 600;
}

.form-hint {
    font-size: 12px;
    color: var(--muted);
}

.form-note {
    margin-top: 12px;
    font-size: 12px;
    color: var(--muted);
}

@media (max-width: 1200px) {
    .layout {
        grid-template-columns: repeat(8, 1fr);
    }
    .panel,
    .panel.wide {
        grid-column: span 8;
    }
    .transfer-grid {
        grid-template-columns: 1fr;
    }
    .topbar {
        flex-wrap: wrap;
        gap: 16px;
    }
    .actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .progress-indicator {
        width: 100%;
    }
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: repeat(4, 1fr);
    }
    .panel,
    .panel.wide {
        grid-column: span 4;
    }
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .panel-actions {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
    }
    .layout {
        padding: 16px;
        grid-template-columns: repeat(1, 1fr);
    }
    .panel-actions .btn,
    .panel-actions .search {
        flex: 1 1 auto;
    }
    .status {
        order: 3;
        width: 100%;
    }
    .progress-indicator {
        order: 4;
        width: 100%;
    }
    .info-grid {
        grid-template-columns: 1fr;
    }
    .var-table th:nth-child(4),
    .var-table td:nth-child(4),
    .var-table th:nth-child(5),
    .var-table td:nth-child(5),
    .var-table th:nth-child(6),
    .var-table td:nth-child(6) {
        display: none;
    }
    .log {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .brand {
        align-items: flex-start;
    }
    .brand-mark {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }
    .panel-body {
        padding: 14px;
    }
    .dropzone {
        padding: 14px;
    }
    #btnIsReady {
        display: none;
    }
    .info-row {
        grid-template-columns: 145px 1fr;
    }
    .info-row .key {
        max-width: 150px;
    }
    .var-table th:nth-child(3),
    .var-table td:nth-child(3),
    .var-table th:nth-child(4),
    .var-table td:nth-child(4) {
        display: none;
    }
}

/* Flat, compact utility UI, scoped to the two Professional themes. */
body:is([data-theme="professional-light"], [data-theme="professional-dark"]) {
    --shadow: transparent;
    --shadow-soft: transparent;
    --glow: transparent;
    background: var(--bg);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    line-height: 1.45;
    accent-color: var(--accent);

    .topbar, .footer, .panel-header, .modal-header, .modal-footer {
        background: var(--surface);
        backdrop-filter: none;
    }
    .topbar { padding: 14px 24px; gap: 20px; }
    .brand-title { font-size: 17px; font-weight: 650; }
    .brand-mark {
        border-radius: 4px;
        background: var(--pro-primary);
        color: #fff;
        box-shadow: none;
        font-size: 13px;
    }
    .brand-mark > span.brand-beta {
        background: var(--surface-alt);
        color: var(--text);
        border-color: var(--border);
        border-radius: 2px;
        box-shadow: none;
    }
    /* setStatus writes an inline glow for the original themes. */
    .status-dot { box-shadow: none !important; }
    .layout {
        width: 100%;
        min-width: 0;
        max-width: 1600px;
        padding: 20px 24px 28px;
        gap: 16px;
        align-content: start;
    }
    .panel, .modal-card, .splash-card, .modal-overlay-card {
        border-radius: 4px;
        box-shadow: none;
    }
    .panel-header { padding: 12px 16px; flex-wrap: wrap; }
    .panel-header h2, .modal-header h3 {
        font-size: 14px;
        font-weight: 600;
        letter-spacing: 0;
    }
    .panel-body { padding: 16px; }
    .panel-actions, .actions, .quick-actions { gap: 8px; }
    .quick-actions { align-content: start; }
    .info-grid { grid-template-columns: 1fr; gap: 0; }
    .info-card {
        display: grid;
        grid-template-columns: minmax(110px, 35%) minmax(0, 1fr);
        align-items: baseline;
        gap: 12px;
        padding: 10px 0;
        border: 0;
        border-bottom: 1px solid var(--border);
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }
    .info-card .label, .form-field label {
        font-size: 12px;
        text-transform: none;
        letter-spacing: 0;
    }
    .info-card .value { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
    .info-row { grid-template-columns: minmax(110px, 35%) minmax(0, 1fr); }
    .info-row > * { min-width: 0; overflow-wrap: anywhere; }
    .btn, .search, .form-input, input[type="file"]::file-selector-button {
        font-family: inherit;
        font-size: 13px;
        font-weight: 500;
        line-height: 1.4;
        border-radius: 4px;
        min-height: 34px;
        padding: 7px 10px;
        box-shadow: none;
    }
    .btn { transition: background-color 120ms ease, border-color 120ms ease; }
    .btn.subtle { color: var(--text); }
    .btn:not(:disabled):hover { transform: none; background: var(--pro-hover); }
    .btn.primary { background: var(--pro-primary); color: #fff; border-color: var(--pro-primary); }
    .btn.primary:not(:disabled):hover { background: var(--pro-primary-hover); }
    .btn.danger {
        color: var(--danger);
        background: var(--pro-danger-bg);
        border-color: var(--pro-danger-border);
    }
    .btn.danger:not(:disabled):hover { background: var(--pro-danger-bg); border-color: var(--danger); }
    .btn.mini { min-height: 26px; padding: 3px 7px; font-size: 12px; }
    :is(button, input, select, a, .folder-toggle):focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
    .search, .form-input { min-width: 0; max-width: 100%; }
    .search::placeholder, .form-input::placeholder { color: var(--muted); opacity: 1; }
    .dropzone {
        padding: 14px;
        border-color: var(--border);
        border-radius: 4px;
        background: var(--surface-alt);
    }
    .dropzone.drag-over { background: var(--pro-selection); border-color: var(--accent); box-shadow: none; }
    .dropzone input[type="file"] {
        min-width: 0;
        border-radius: 4px;
        background: var(--surface);
        font-family: inherit;
        font-size: 12px;
    }
    .dropzone input[type="file"]::file-selector-button { background: var(--surface-alt); color: var(--text); }
    .dropzone-text .title { font-size: 14px; }
    #keysPanel { border: 0; border-top: 1px solid var(--border); border-radius: 0; }
    #keysPanel .panel-header { border: 0; padding: 12px 0 8px; }
    #keysPanel .panel-body { padding: 0; }
    .table-wrap { border-radius: 4px; background: var(--surface); }
    .var-table th { background: var(--surface-alt); font-weight: 600; }
    .var-table :is(th, td) { padding: 8px 10px; }
    .var-table tr:hover { background: var(--pro-hover); }
    .var-table tr.drop-target { background: var(--pro-selection); outline-color: var(--accent); }
    .indent-bar { border-color: var(--border); }
    .log, .preview-content {
        border-radius: 4px;
        background: var(--surface-alt);
        color: var(--text);
        line-height: 1.6;
    }
    .log { height: 240px; }
    .log-error { color: var(--danger); }
    .preview-content .hljs-comment { color: var(--muted); }
    .preview-content :is(.hljs-keyword, .hljs-attribute, .hljs-literal) { color: var(--accent); }
    .preview-content :is(.hljs-built_in, .hljs-class .hljs-title, .hljs-function .hljs-title) { color: var(--danger); }
    .preview-content :is(.hljs-string, .hljs-variable, .hljs-params) { color: var(--pro-code-string); }
    .preview-content :is(.hljs-number, .hljs-symbol, .hljs-title) { color: var(--pro-code-number); }
    .progress-bar { background: var(--surface-alt); border-radius: 2px; }
    .progress-bar-fill { background: var(--pro-primary); border-radius: 2px; }
    .modal, .modal-overlay { background: var(--pro-overlay); backdrop-filter: none; }
    .modal-card { max-height: calc(100dvh - 48px); display: flex; flex-direction: column; }
    .modal-body { overflow-y: auto; min-height: 0; padding-bottom: 16px; }
    .modal-header, .modal-footer { flex-shrink: 0; }
    .modal-footer-actions { flex-wrap: wrap; }
    .settings-grid { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
    .toast { border-radius: 4px; box-shadow: 0 4px 16px var(--pro-overlay); }
    .spinner { border-color: var(--border); border-top-color: var(--accent); }
    .splash-card { padding: 32px; text-align: left; }
    .splash h1 { font-size: 22px; font-weight: 600; }
    .splash p { text-wrap: initial; line-height: 1.6; }
    .splash-warning { border-radius: 4px; border-color: var(--pro-danger-border); background: var(--pro-danger-bg); }
    .footer { line-height: 1.6; }

    @media (max-width: 640px) {
        .topbar { position: static; padding: 16px; gap: 12px; }
        .layout { padding: 16px; }
        .panel, .panel.wide { grid-column: 1 / -1; }
        .panel-header, .panel-body { padding: 12px; }
        .btn, .search, .form-input { min-height: 40px; }
        .btn.mini { min-height: 32px; }
        .modal { padding: 12px; }
        .modal-card { max-height: calc(100dvh - 24px); }
        .modal-header, .modal-body, .modal-footer { padding: 12px; }
        .splash { padding: 24px 16px; }
        .splash-card { padding: 24px; }
        .keypad { grid-template-columns: minmax(0, 1fr); }
    }
    @media (prefers-reduced-motion: reduce) {
        .btn { transition: none; }
    }
}
