:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(17, 21, 27, 0.92);
    --panel-border: rgba(80, 90, 104, 0.95);
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent-primary: #58a6ff;
    --accent-primary-hover: #3182ce;
    --accent-secondary: #238636;
    --accent-secondary-hover: #2ea043;
    --danger: #f85149;
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'Fira Code', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(88, 166, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(35, 134, 54, 0.05) 0%, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: flex-start;
}

.app-container {
    width: 100%;
    max-width: none;
    padding: 1.25rem 1.5rem 1.5rem 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--panel-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0;
    color: var(--text-primary);
    padding-left: 0.35rem;
}

.title-block {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

h1 {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

.byline {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.byline a {
    color: var(--accent-primary);
    text-decoration: none;
}

.byline a:hover {
    text-decoration: underline;
}

.discord-user {
    color: var(--text-primary);
    font-weight: 600;
}

.header-links {
    display: flex;
    gap: 0.5rem;
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--panel-border);
    background: rgba(13, 17, 23, 0.6);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
}

.header-link:hover {
    background: rgba(255, 255, 255, 0.08);
}

.header-link-icon {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
}

.main-content {
    display: flex;
    flex: 1;
    gap: 1rem;
    min-height: 0;
}

.ops-section {
    flex: 0 0 335px;
    padding: 1.5rem 1rem 1.5rem 0.9rem;
    min-height: 0;
    overflow: hidden;
    border-radius: 0 12px 12px 0;
    border-left: none;
    position: relative;
    z-index: 1;
}

.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 7px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
    display: flex;
    flex-direction: column;
}

.input-section {
    flex: 1;
    padding: 1.5rem;
    gap: 1rem;
    min-height: 0;
    overflow: visible;
    position: relative;
    z-index: 20;
}

.results-section {
    flex: 1.35;
    padding: 1.5rem;
    overflow: hidden;
}

h2 {
    font-size: 1.22rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

textarea {
    width: 100%;
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    padding: 1rem;
    resize: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

#input-text {
    flex: 1 1 auto;
    min-height: 140px;
}

.controls-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.magic-options-row {
    align-items: flex-end;
    flex-wrap: nowrap;
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.92rem;
    color: var(--text-secondary);
}

input[type="text"],
input[type="number"],
.select-box {
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    color: var(--text-primary);
    padding: 0.625rem 1rem;
    font-size: 0.92rem;
}

.select-box {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.advanced-options {
    background: rgba(13, 17, 23, 0.5);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 1rem;
    flex: 0 0 auto;
    position: relative;
    overflow: visible;
    z-index: 25;
}

.crazy-mode-row {
    margin-top: 0.8rem;
    padding-top: 0.75rem;
    border-top: 1px dashed rgba(139, 148, 158, 0.28);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.crazy-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    font-size: 0.86rem;
    color: #ffcc66;
    cursor: pointer;
    user-select: none;
}

.compression-info-icon {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
}

.compression-info-icon .info-icon {
    color: #9aa7ff;
    font-size: 0.8rem;
}

.op-label-text {
    flex: 1 1 auto;
    min-width: 0;
}

input[type="number"] {
    font-family: var(--font-mono);
    font-weight: 500;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    filter: invert(0.85) contrast(1.2);
}

::placeholder {
    color: rgba(139, 148, 158, 0.55);
    opacity: 1;
}

.operations-toggles {
    margin-top: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 100%;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.section-label {
    width: 100%;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    font-weight: 500;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.4rem 0.55rem;
    border-radius: 3px;
    border: 1px solid var(--panel-border);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s, border-color 0.2s;
}

.sequence-input-group {
    flex: 1 1 0;
    min-width: 0;
}

.depth-group {
    flex: 0 0 132px;
}

.sequence-popover-anchor {
    position: relative;
}

.sequence-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    color: var(--text-primary);
    padding: 0.625rem 0.78rem;
    font-size: 0.88rem;
    text-align: left;
}

.sequence-trigger:hover {
    border-color: rgba(88, 166, 255, 0.42);
    background: rgba(19, 27, 38, 0.92);
}

.sequence-trigger-summary {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sequence-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 3.7rem;
    padding: 0.18rem 0.42rem;
    border-radius: 999px;
    border: 1px solid rgba(88, 166, 255, 0.28);
    background: rgba(88, 166, 255, 0.12);
    color: #cfe7ff;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
}

.sequence-count-badge.is-empty {
    border-color: rgba(139, 148, 158, 0.25);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.sequence-trigger-caret {
    color: var(--text-secondary);
    font-size: 0.75rem;
    flex: 0 0 auto;
}

.sequence-builder {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 0.85rem;
    background: rgba(8, 12, 18, 0.94);
    border: 1px solid rgba(88, 166, 255, 0.28);
    border-radius: 8px;
}

.sequence-builder-popover {
    position: absolute;
    bottom: calc(100% + 0.65rem);
    z-index: 30;
    max-height: min(55vh, 420px);
    overflow-y: auto;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

.sequence-builder-section {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-width: 0;
}

.sequence-builder-section:first-child .sequence-chip-list {
    min-height: 76px;
}

.sequence-builder-section:last-child .sequence-dropzone {
    min-height: 56px;
}

.sequence-builder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sequence-builder-title {
    color: var(--text-primary);
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.sequence-builder-title-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.sequence-builder-hint {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.sequence-clear-btn,
.sequence-block-btn,
.sequence-chip {
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transition: background 0.18s, border-color 0.18s, transform 0.18s;
}

.sequence-clear-btn,
.sequence-block-btn {
    padding: 0.32rem 0.55rem;
    font-size: 0.78rem;
}

.sequence-clear-btn:hover,
.sequence-block-btn:hover,
.sequence-chip:hover {
    background: rgba(88, 166, 255, 0.12);
    border-color: rgba(88, 166, 255, 0.42);
}

.sequence-block-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sequence-block-btn.danger:hover {
    background: rgba(248, 81, 73, 0.16);
    border-color: rgba(248, 81, 73, 0.42);
}

.sequence-dropzone {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11.25rem, 1fr));
    gap: 0.6rem;
    min-height: 48px;
    align-items: stretch;
    padding: 0.55rem;
    border: 1px dashed rgba(139, 148, 158, 0.34);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.sequence-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    min-height: 48px;
    align-items: flex-start;
}

.sequence-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 8.5rem;
    padding: 0.46rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sequence-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
    padding: 0.42rem 0.42rem 0.42rem 0.62rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.2), rgba(33, 139, 255, 0.08));
    border: 1px solid rgba(88, 166, 255, 0.34);
    cursor: grab;
    user-select: none;
}

.sequence-block-label {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text-primary);
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sequence-step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.45rem;
    height: 1.45rem;
    padding: 0 0.32rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #cfe7ff;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1;
    flex: 0 0 auto;
}

.sequence-block-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.18rem;
}

.sequence-placeholder {
    color: var(--text-secondary);
    font-size: 0.82rem;
    align-self: center;
}


@media (max-width: 680px) {
    .magic-options-row {
        flex-wrap: wrap;
    }

    .sequence-builder-popover {
        max-width: calc(100vw - 16px);
    }

    .sequence-trigger {
        flex-wrap: wrap;
    }

    .sequence-trigger-caret {
        margin-left: auto;
    }
}

.sequence-block.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.sequence-block.drag-target {
    border-color: rgba(255, 203, 107, 0.72);
    background: linear-gradient(135deg, rgba(255, 203, 107, 0.24), rgba(88, 166, 255, 0.14));
}

.toggle-label:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Special XOR Toggle */
.xor-inline-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-color: rgba(227, 179, 65, 0.4);
    background: rgba(227, 179, 65, 0.05);
    color: #e3b341;
    margin-top: 0;
    position: relative;
    border-radius: 4px;
    border: 1px solid rgba(227, 179, 65, 0.4);
    font-size: 0.9rem;
}

.xor-inline-container:hover {
    background: rgba(227, 179, 65, 0.15);
    z-index: 10;
}

.xor-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-weight: 500;
}

.xor-checkbox-label input[type="checkbox"] {
    accent-color: #e3b341;
    cursor: pointer;
}

/* Hide inputs when checkbox is unchecked by using the :has pseudo-class */
.xor-inline-container:not(:has(input[type="checkbox"]:checked)) .xor-compact-input,
.xor-inline-container:not(:has(input[type="checkbox"]:checked)) .xor-compact-select {
    display: none;
}

.xor-inline-inputs {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.xor-compact-input,
.xor-compact-select {
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    height: 24px;
}

.xor-compact-input {
    width: 80px;
}

.xor-compact-select {
    width: 65px;
    padding-right: 1.2rem;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.2rem center;
}

.xor-compact-input:focus,
.xor-compact-select:focus {
    outline: none;
    border-color: #e3b341;
    box-shadow: 0 0 0 2px rgba(227, 179, 65, 0.2);
}

/* Inline Info Tooltip */
.info-icon-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    margin-left: 0.2rem;
}

.info-icon-wrapper .info-icon {
    color: var(--accent-primary);
    font-size: 1rem;
    font-weight: bold;
}

/* Global JS-Driven Tooltip */
.global-tooltip {
    position: fixed;
    width: 260px;
    padding: 0.75rem;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid rgba(88, 166, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 0 15px rgba(88, 166, 255, 0.15);
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-secondary);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    z-index: 99999;
}

.global-tooltip.visible {
    opacity: 1;
}

.global-tooltip.glowing-blue strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.3rem;
}

.toggle-label input[type="checkbox"] {
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.button-group {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 0.75rem;
    flex-shrink: 0;
    background: transparent;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.72rem 1.35rem;
    font-size: 0.92rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent-primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--panel-border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.results-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.6rem;
    padding-bottom: 0.5rem;
}

.progress-wrap {
    padding-bottom: 0.75rem;
}

.progress-wrap.hidden {
    display: none;
}

.progress-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--panel-border);
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width 0.18s ease;
}

.status-indicator {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-indicator.loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--text-secondary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.status-indicator.error {
    color: var(--danger);
    font-weight: 500;
}

.hidden {
    display: none !important;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.output-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.5rem;
}

.results-tabs {
    display: flex;
    gap: 0.45rem;
    margin-bottom: 0.5rem;
}

.results-tab {
    border: 1px solid var(--panel-border);
    background: rgba(13, 17, 23, 0.6);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
}

.results-tab.active {
    color: var(--text-primary);
    border-color: rgba(88, 166, 255, 0.5);
    background: rgba(88, 166, 255, 0.16);
}

.visualizer-panel {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(4, 8, 14, 0.72);
    backdrop-filter: blur(6px);
    animation: visualizerOverlayIn 0.18s ease-out;
}

.visualizer-shell {
    width: min(1500px, 100%);
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1rem;
    border: 1px solid rgba(132, 197, 255, 0.18);
    background: rgba(9, 14, 22, 0.96);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    transform-origin: center top;
    animation: visualizerShellIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes visualizerOverlayIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes visualizerShellIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.visualizer-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.visualizer-toolbar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.visualizer-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.visualizer-close-btn {
    border: none;
    background: transparent;
    color: #ff7b72;
    font-size: 2rem;
    line-height: 1;
    padding: 0 0.1rem;
    cursor: pointer;
    transition: color 0.16s ease, transform 0.16s ease;
}

.visualizer-close-btn:hover,
.visualizer-close-btn:focus-visible {
    color: #ffb3ad;
    transform: scale(1.08);
    outline: none;
}

.visualizer-stats {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.visualizer-btn {
    border: 1px solid var(--panel-border);
    background: rgba(13, 17, 23, 0.8);
    color: var(--text-primary);
    font-size: 0.73rem;
    font-weight: 600;
    padding: 0.24rem 0.48rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.visualizer-btn:hover,
.visualizer-btn:focus-visible {
    background: rgba(88, 166, 255, 0.2);
    border-color: rgba(88, 166, 255, 0.6);
    transform: translateY(-1px);
    outline: none;
}

.visualizer-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 0.35rem;
}

.visualizer-search-input {
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    font-size: 0.75rem;
    padding: 0.28rem 0.5rem;
    min-width: 0;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.visualizer-search-input:focus {
    outline: none;
    border-color: rgba(88, 166, 255, 0.6);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.14);
    background: rgba(17, 25, 37, 0.96);
}

.visualizer-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(420px, 1.2fr) minmax(0, 1.2fr);
    gap: 0.65rem;
}

.visualizer-branch-panel,
.visualizer-detail-panel {
    min-height: 0;
    border: 1px solid var(--panel-border);
    background: rgba(13, 17, 23, 0.36);
}

.visualizer-branch-panel {
    overflow: hidden;
}

.visualizer-branch-list {
    height: 100%;
    overflow: auto;
    padding: 0.45rem;
    display: block;
}

.visualizer-empty,
.visualizer-list-note {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 0.5rem;
}

.visualizer-branch-item {
    appearance: none;
    width: 100%;
    border: 1px solid rgba(88, 166, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    padding: 0.52rem 0.6rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    overflow: hidden;
    margin-bottom: 0.45rem;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.visualizer-branch-item:hover,
.visualizer-branch-item.active {
    border-color: rgba(132, 197, 255, 0.58);
    background: rgba(88, 166, 255, 0.12);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(20, 42, 64, 0.24);
}

.visualizer-branch-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.visualizer-branch-rank,
.visualizer-branch-score {
    font-size: 0.7rem;
    color: #d8efff;
    font-family: var(--font-mono);
}

.visualizer-branch-path {
    font-size: 0.77rem;
    color: var(--text-primary);
    line-height: 1.35;
    word-break: break-word;
}

.visualizer-branch-section {
    display: flex;
    flex-direction: column;
    gap: 0.14rem;
    min-width: 0;
}

.visualizer-branch-label {
    font-size: 0.64rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #88a6c0;
}

.visualizer-branch-sequence {
    font-size: 0.78rem;
    color: var(--text-primary);
    line-height: 1.35;
    min-width: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    line-clamp: 4;
    word-break: break-word;
}

.visualizer-branch-preview {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.35;
    min-width: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    line-clamp: 6;
    white-space: normal;
    text-overflow: ellipsis;
    word-break: break-word;
}

.visualizer-crib-match {
    background: rgba(255, 203, 107, 0.24);
    color: #ffe5a6;
    padding: 0 0.08rem;
}

.visualizer-detail-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 0.55rem;
    padding: 0.55rem;
}

.visualizer-selection-meta {
    font-size: 0.76rem;
    color: var(--text-secondary);
}

.visualizer-selection-path {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 1.9rem;
}

.visualizer-path-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.45rem;
    border: 1px solid rgba(132, 197, 255, 0.26);
    background: rgba(88, 166, 255, 0.1);
    color: #e3f3ff;
    font-size: 0.72rem;
}

.visualizer-viewport {
    flex: 1;
    min-height: 220px;
    border: 1px solid var(--panel-border);
    background: rgba(13, 17, 23, 0.45);
    overflow: hidden;
    cursor: grab;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.visualizer-viewport.dragging {
    cursor: grabbing;
}

.visualizer-viewport:hover {
    border-color: rgba(88, 166, 255, 0.38);
    box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.08);
}

.visualizer-svg {
    width: 100%;
    height: 100%;
    display: block;
    user-select: none;
}

.vis-edge {
    stroke: rgba(132, 197, 255, 0.56);
    stroke-width: 1.25;
    shape-rendering: optimizeSpeed;
}

.vis-edge-dim {
    opacity: 0.16;
}

.vis-edge-match {
    stroke: rgba(165, 218, 255, 0.92);
    stroke-width: 1.75;
}

.vis-edge-focus {
    stroke: rgba(214, 240, 255, 0.95);
    stroke-width: 1.9;
}

.vis-node {
    stroke: rgba(186, 226, 255, 0.95);
    stroke-width: 1.35;
    shape-rendering: optimizeSpeed;
    filter: drop-shadow(0 0 7px rgba(104, 185, 255, 0.45)) drop-shadow(0 0 14px rgba(64, 156, 255, 0.22));
    transition: stroke 0.18s ease, stroke-width 0.18s ease, filter 0.18s ease, transform 0.18s ease;
}

.vis-node:hover {
    stroke: #eef8ff;
    stroke-width: 1.8;
    filter: drop-shadow(0 0 10px rgba(138, 206, 255, 0.72)) drop-shadow(0 0 20px rgba(88, 166, 255, 0.38));
}

.vis-node-dim {
    opacity: 0.18;
}

.vis-node-match {
    stroke: #f2fbff;
    stroke-width: 2.3;
    filter: drop-shadow(0 0 12px rgba(180, 228, 255, 0.9)) drop-shadow(0 0 24px rgba(88, 166, 255, 0.5));
}

.vis-node-focus {
    stroke: #f5fbff;
    stroke-width: 2.2;
    filter: drop-shadow(0 0 12px rgba(188, 229, 255, 0.92)) drop-shadow(0 0 24px rgba(88, 166, 255, 0.52));
}

/* Filtering mode: dim non-matching elements */
.vis-filtering .vis-node:not(.vis-node-match) {
    opacity: 0.18;
}

.vis-filtering .vis-label:not(.vis-label-match) {
    opacity: 0.18;
}

.vis-filtering .vis-edge:not(.vis-edge-match) {
    opacity: 0.18;
}

.vis-label {
    fill: rgba(230, 237, 243, 0.9);
    font-size: 9px;
    font-family: var(--font-mono);
    pointer-events: none;
    text-rendering: optimizeSpeed;
}

.vis-label-match {
    fill: #ffffff;
    font-weight: bold;
}

.vis-label-focus {
    fill: #ffffff;
    font-weight: 700;
}

.vis-label-dim {
    opacity: 0.2;
}

@media (max-width: 980px) {
    .visualizer-body {
        grid-template-columns: 1fr;
    }

    .visualizer-detail-panel {
        grid-template-rows: auto auto minmax(220px, 1fr);
    }

    .visualizer-search {
        grid-template-columns: 1fr;
    }
}

body.visualizer-popout-open {
    overflow: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.empty-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-style: italic;
    border: 1px dashed var(--panel-border);
    border-radius: 5px;
}

.result-card {
    background: rgba(22, 27, 34, 0.8);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-path-row {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    min-width: 0;
}

.use-sequence-btn {
    border: 1px solid rgba(88, 166, 255, 0.28);
    background: rgba(88, 166, 255, 0.08);
    color: #cfe7ff;
    font-size: 0.76rem;
    line-height: 1;
    padding: 0.28rem 0.38rem;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.use-sequence-btn:hover,
.use-sequence-btn:focus-visible {
    background: rgba(88, 166, 255, 0.16);
    border-color: rgba(88, 166, 255, 0.5);
    transform: translateX(-1px);
    outline: none;
}

.path-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    min-width: 0;
}

.path-badge {
    background: rgba(88, 166, 255, 0.14);
    color: var(--accent-primary);
    border: 1px solid rgba(88, 166, 255, 0.35);
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 5px;
    font-family: var(--font-mono);
}

@media (prefers-reduced-motion: reduce) {
    .visualizer-panel,
    .visualizer-shell,
    .visualizer-close-btn,
    .visualizer-btn,
    .visualizer-search-input,
    .visualizer-branch-item,
    .visualizer-path-chip,
    .visualizer-viewport,
    .vis-node,
    .result-card,
    .use-sequence-btn,
    .path-badge {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
}

.path-arrow {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.metrics {
    display: flex;
    gap: 0.5rem;
}

.score-badge {
    background: rgba(35, 134, 54, 0.16);
    color: var(--accent-secondary);
    border: 1px solid rgba(35, 134, 54, 0.35);
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    font-weight: 500;
}

.score-badge.high {
    background: rgba(35, 134, 54, 0.2);
    color: #3fb950;
    border-color: #3fb950;
}

.score-badge.low {
    background: rgba(248, 81, 73, 0.1);
    color: var(--danger);
    border-color: rgba(248, 81, 73, 0.2);
}

.result-card textarea {
    min-height: 96px;
    background: rgba(13, 17, 23, 0.5);
    border: 1px solid transparent;
}

.result-card textarea:focus {
    border-color: var(--panel-border);
    box-shadow: none;
}

.result-text-wrap {
    position: relative;
}

.copy-result-btn {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    z-index: 2;
    border: 1px solid var(--panel-border);
    background: rgba(13, 17, 23, 0.9);
    color: var(--text-primary);
    width: 1.9rem;
    height: 1.9rem;
    padding: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease;
}

.copy-result-btn svg {
    width: 0.95rem;
    height: 0.95rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.result-text-wrap:hover .copy-result-btn,
.result-text-wrap:focus-within .copy-result-btn {
    opacity: 1;
    pointer-events: auto;
}

.copy-result-btn:hover,
.copy-result-btn:focus-visible {
    background: rgba(88, 166, 255, 0.2);
    border-color: var(--accent-primary);
    outline: none;
}

/* Animations and responsiveness */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }

    .header-links {
        width: 100%;
        flex-wrap: wrap;
    }

    .ops-section,
    .input-section,
    .results-section {
        flex: none;
        height: auto;
    }

    body {
        align-items: flex-start;
    }

    .app-container {
        height: auto;
    }

    .operations-toggles {
        max-height: 180px;
    }

    .results-header {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .status-indicator {
        justify-content: flex-start;
    }
}

/* Global hard-edge mode: no rounded corners anywhere */
*,
*::before,
*::after {
    border-radius: 0 !important;
}
