/* CSS Variables: Modern Dark Theme */
:root {
    --bg-base: #050505;
    --bg-surface: #0f0f0f;
    --bg-elevated: #1a1a1a;
    --text-main: #f4f4f5;
    --text-muted: #8b8b90;
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.15);
    --border: #222222;
    --border-hover: #333333;
    --danger: #ef4444;

    /* Typography Stack: Monospace for Eng/Num, Malgun Gothic for Korean */
    --font-mono: 'Consolas', 'Courier New', Courier, monospace;
    --font-kor: '맑은 고딕', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Combines both requirements: English uses mono, Korean falls back to Malgun Gothic */
    font-family: var(--font-mono), var(--font-kor);
    letter-spacing: -0.02em;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(16, 185, 129, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(16, 185, 129, 0.45);
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(16, 185, 129, 0.2) transparent;
}

/* Global Reset (Mobile-First Default) */
body {
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    background-image: linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: center center;
}

/* Animations */
@keyframes revealUp {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@keyframes slideInRight {
    0% {
        opacity: 0;
        transform: translateX(-10px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.anim-reveal {
    opacity: 0;
    animation: revealUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-1 {
    animation-delay: 0.1s;
}

.delay-2 {
    animation-delay: 0.2s;
}

.delay-3 {
    animation-delay: 0.3s;
}

/* Layout Structure: Navigation & Aside (Mobile-First Default) */
aside {
    width: 100%;
    height: auto;
    position: relative;
    background: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

aside .brand-header {
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: default;
    text-align: center;
}

aside .brand-title {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit;
    width: 100%;
    gap: 8px;
}

aside .brand-logo {
    width: 24px !important;
    height: 24px !important;
}

aside .brand-title p {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-main);
    letter-spacing: 0.05em;
    align-self: center;
}

aside .brand-subtitle {
    display: none;
}

aside .nav-menu {
    display: none;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.8rem 1.5rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    position: relative;
    text-decoration: none;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background-color: var(--accent);
    transform: scaleY(0);
    transition: transform 0.3s ease;
    transform-origin: center;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: var(--bg-surface);
}

.nav-item.active {
    color: var(--accent);
    background-color: var(--accent-glow);
}

.nav-item.active::before {
    transform: scaleY(1);
}

/* Mobile Command Menu Trigger */
.mobile-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    z-index: 10000;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.05);
    position: absolute;
    right: 10px;
}

.mobile-menu-trigger:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.cursor-prompt {
    animation: blink-cursor 1s infinite step-end;
}

@keyframes blink-cursor {
    from, to { color: transparent }
    50% { color: var(--accent) }
}

/* Active State: Mobile Terminal Command Menu Overlay */
aside.menu-open {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 5, 5, 0.98);
    backdrop-filter: blur(15px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 1rem;
    border-bottom: none;
    overflow-y: auto;
}

aside.menu-open .brand-header {
    width: 100%;
    padding: 0 0 1rem 0;
    border-bottom: 1px dashed var(--border);
}

aside.menu-open .nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 2rem;
    padding: 0;
}

aside.menu-open .nav-item {
    opacity: 0;
    padding: 1rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    text-decoration: none;
    animation: revealUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Replace desktop vertical bar highlight with a CLI prompt prefix */
aside.menu-open .nav-item::before {
    content: '>';
    color: var(--accent);
    position: static;
    width: auto;
    height: auto;
    background-color: transparent;
    transform: none;
    display: inline;
    margin-right: 0.8rem;
    font-weight: bold;
    transition: transform 0.2s ease;
}

aside.menu-open .nav-item:hover::before,
aside.menu-open .nav-item.active::before {
    transform: translateX(4px);
}

aside.menu-open .nav-item:hover,
aside.menu-open .nav-item.active {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.12);
}

/* Staggered entry animation delay for menu items */
aside.menu-open .nav-item:nth-child(1) { animation-delay: 0.05s; }
aside.menu-open .nav-item:nth-child(2) { animation-delay: 0.1s; }
aside.menu-open .nav-item:nth-child(3) { animation-delay: 0.15s; }
aside.menu-open .nav-item:nth-child(4) { animation-delay: 0.2s; }
aside.menu-open .nav-item:nth-child(5) { animation-delay: 0.25s; }
aside.menu-open .nav-item:nth-child(6) { animation-delay: 0.3s; }
aside.menu-open .nav-item:nth-child(7) { animation-delay: 0.35s; }

/* Main Area & Container (Mobile-First Default) */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 60px - 120px);
    background: radial-gradient(circle at top right, rgba(16, 185, 129, 0.03), transparent 50%);
}

main {
    flex: 1;
    padding: 2rem 1rem;
    overflow-y: visible; /* Let body handle scrolling on mobile */
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.content-wrapper {
    width: 100%;
    max-width: 960px;
    position: relative;
    padding-bottom: 20px; /* Mobile/Tablet base spacer */
}

/* Module Content Styles */
.module-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background-color: var(--accent-glow);
    color: var(--accent);
    font-size: 0.7rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.module-title {
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 2rem;
    font-weight: 300;
}

/* Information Cards */
.info-card {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.info-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.05);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-desc {
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Details & Summary Collapsible UI */
details {
    margin-bottom: 1.5rem;
}

summary, summary.card-title {
    list-style: none;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0;
    padding: 1rem 1.5rem;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.2s ease;
    user-select: none;
}

summary::-webkit-details-marker {
    display: none;
}

summary::before {
    content: "▶";
    font-size: 0.8rem;
    color: var(--accent);
    transition: transform 0.2s ease;
}

details[open] summary {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: 1px dashed var(--border);
}

details[open] summary::before {
    transform: rotate(90deg);
}

.collapse-content {
    background-color: rgba(26, 26, 26, 0.5);
    border: 1px solid var(--border);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    padding: 1.5rem;
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
}

.card-title.accent {
    color: var(--accent);
}

.card-title.danger {
    color: var(--danger);
}

.card-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
    font-family: var(--font-kor);
}

/* Bottom Control Bar */
.control-bar {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-prev {
    color: var(--text-muted);
    border-color: transparent;
}

.btn-prev:hover:not(:disabled) {
    color: var(--text-main);
    background-color: var(--bg-surface);
}

.btn-next {
    background-color: var(--text-main);
    color: #000;
    border-color: var(--text-main);
}

.btn-next:hover:not(:disabled) {
    transform: translateX(3px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.btn-finish {
    background-color: var(--bg-elevated);
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-finish.ready {
    background-color: var(--accent);
    color: #000;
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Radar Canvas Aspect Ratio (Mobile-First Default) */
#vigfoot-map {
    height: 300px !important;
    min-height: 220px !important;
    margin-top: 10px !important;
}

/* Autopilot & Telemetry Panels (Mobile-First Default) */
.anim-reveal.delay-3 {
    flex-direction: column;
}

#autopilot-panel {
    width: 100% !important;
    min-width: 100% !important;
    border-right: none !important;
    border-bottom: 1px dashed var(--border) !important;
}

#telemetry-panel {
    width: 100% !important;
}

/* Logger Bar (Mobile-First Default) */
.logger-bar {
    position: relative;
    width: 100%;
    flex: none;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border);
    border-radius: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    gap: 0.5rem;
    margin-top: 0;
    height: 180px;
    overflow: hidden;
}

#logger-feed {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

#vigfoot-map {
    position: relative;
}

#vessel-stowage-hud {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 140px;
    background: rgba(10, 15, 20, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px 4px 24px 24px;
    padding: 8px 8px 12px 8px;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

#vessel-stowage-hud > div[style*="grid-template-columns"] {
    grid-template-columns: repeat(6, 14%) !important;
    gap: 3px;
    padding: 0;
}

.compact-title {
    font-size: 0.95rem !important;
}

@keyframes alert-blink {
    0% { background-color: rgba(239, 68, 68, 0.1); color: #fca5a5; }
    50% { background-color: rgba(239, 68, 68, 0.4); color: #fff; }
    100% { background-color: rgba(239, 68, 68, 0.1); color: #fca5a5; }
}

.alert-danger {
    animation: alert-blink 0.8s infinite;
    border-color: #ef4444 !important;
}

.log-entry {
    display: flex;
    gap: 0.8rem;
    animation: fadeIn 0.2s ease-out forwards;
}

.log-time {
    color: #52525b;
    flex-shrink: 0;
}

.log-msg {
    color: var(--text-muted);
}

.log-msg.highlight {
    color: var(--accent);
}

/* Highlight only the latest log for better readability */
.log-entry:last-child .log-msg {
    color: var(--text-main);
}

/* Live Telemetry Wave Visualizer */
.live-wave {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--accent);
    background: transparent;
    padding: 0.5rem 0 0 0;
    margin-top: 0.5rem;
    width: max-content;
    pointer-events: none;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
    animation: pulse-dot-anim 1.5s infinite;
}

@keyframes pulse-dot-anim {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.4);
        opacity: 0.4;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.wave-svg {
    width: 50px;
    height: 10px;
}

.wave-path {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: wave-move 4s linear infinite;
}

@keyframes wave-move {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* --- Desktop Layout overrides (min-width: 1200px) --- */
@media (min-width: 1200px) {
    body {
        flex-direction: row;
        height: 100vh;
        margin: 0;
    }

    /* CRT Scanline & Phosphor Flicker Overlay (Desktop Only) */
    body::after {
        content: " ";
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%);
        background-size: 100% 4px;
        z-index: 99999;
        pointer-events: none;
        opacity: 0.3;
        animation: screen-flicker 0.15s infinite;
    }

    @keyframes screen-flicker {
        0% {
            opacity: 0.28;
        }
        50% {
            opacity: 0.32;
        }
        100% {
            opacity: 0.28;
        }
    }

    aside {
        width: 280px;
        height: 100vh;
        border-bottom: none;
        border-right: 1px solid var(--border);
    }

    aside .brand-header {
        padding: 1.2rem 1rem;
        border-bottom: 1px solid var(--border);
        text-align: center;
    }

    aside .brand-title {
        width: 100%;
        justify-content: center;
        flex-direction: row;
        flex-wrap: nowrap;
    }

    aside .brand-logo {
        width: auto !important;
        height: auto !important;
    }

    aside .brand-title p {
        font-size: 1.2rem;
    }

    aside .brand-subtitle {
        display: block;
        font-size: 0.8rem;
        color: var(--text-muted);
        text-align: center;
        width: 100%;
        margin-top: 4px;
    }

    .desktop-text {
        display: inline !important;
    }

    aside .nav-menu {
        display: flex;
        flex: 1;
        padding: 1.5rem 0;
        flex-direction: column;
        gap: 0.25rem;
    }

    .mobile-menu-trigger {
        display: none;
    }

    .main-container {
        height: 100vh;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    main {
        padding: 10px;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .content-wrapper {
        padding-bottom: 0;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    
    #module-content {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    
    .layout-responsive {
        flex-direction: row;
        flex: 1;
        min-height: 0;
        margin: 0 !important;
        gap: 10px;
    }

    .layout-left, .layout-right {
        flex: 1;
        width: 50%;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /* Desktop Editor Wrapper */
    #vigfoot-map {
        flex: 1 !important;
        min-height: 0 !important;
        height: auto !important;
    }

    /* Desktop Telemetry & Autopilot Row Layout */
    .anim-reveal.delay-3 {
        flex-direction: column !important; /* Ensure it stays column if it was row */
    }

    #autopilot-panel {
        flex: 1 !important;
        min-height: 0 !important;
        border-right: none !important;
        border-bottom: none !important;
    }

    /* Desktop Logger Bar Normal Layout (Not fixed, attached to bottom of main-container) */
    .logger-bar {
        position: relative !important;
        width: 100% !important;
        left: 0 !important;
        bottom: 0 !important;
        height: 120px !important;
        min-height: 120px !important;
        flex: none !important; /* Do not shrink or grow */
        flex-direction: row !important;
        border: none !important;
        border-top: 1px solid var(--border) !important;
        border-radius: 0 !important;
        padding: 1rem 1.5rem !important;
        gap: 0.3rem !important;
        margin-top: 0 !important;
    }

}
/* Tagify Custom Styles */
.tagify {
    --tags-border-color: var(--border);
    --tags-hover-border-color: var(--accent);
    --tags-focus-border-color: var(--accent);
    --tag-bg: var(--accent-glow);
    --tag-hover: var(--accent);
    --tag-text-color: var(--text-main);
    --tag-text-color--edit: var(--text-main);
    --tag-remove-bg: var(--danger);
    --tag-remove-btn-color: var(--text-main);
    --tag-remove-btn-bg--hover: var(--danger);
    --input-color: var(--text-main);
    --placeholder-color: var(--text-muted);
    font-family: var(--font-mono);
    border-radius: 4px;
    background: var(--bg-surface);
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    height: 40px;
    font-size: 0.8rem;
    overflow: hidden;
    align-items: center;
}

.tagify__input {
    white-space: nowrap;
    overflow: hidden;
}

.tagify__dropdown {
    font-family: var(--font-mono);
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-main) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}
.tagify__dropdown__wrapper {
    background: var(--bg-surface) !important;
    border: none !important;
}
.tagify__dropdown__item {
    color: var(--text-main) !important;
    padding: 0.5em 1em !important;
    transition: background 0.2s ease, color 0.2s ease !important;
}
.tagify__dropdown__item--active,
.tagify__dropdown__item:hover {
    background: var(--accent-glow) !important;
    color: var(--accent) !important;
}

/* Algorithm List Styles */
.algo-group {
    margin-bottom: 1.5rem;
}
summary.algo-group-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    border-bottom: 1px dashed var(--border);
    border-radius: 0;
    padding: 0 0 0.3rem 0;
    background-color: transparent;
}

details[open] summary.algo-group-title {
    border-bottom: 1px dashed var(--border);
}
.algo-item {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}
.algo-item-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.algo-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
.algo-item.active {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: bold;
}
.algo-bullet {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    display: inline-block;
}
.algo-item.active .algo-bullet {
    background: var(--accent);
    box-shadow: 0 0 5px var(--accent);
}
/* --- New Simplified Layout (Vigfoot Simulator) --- */
body {
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent body scroll, everything is flex */
    height: 100vh;
}

#master-layout {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: 100vw;
}

#sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

#algo-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex overflow */
}

#workspace {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

#editor-section {
    flex: 2;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg-base);
    min-width: 0;
}

.editor-container {
    flex: 1;
    position: relative;
    overflow: auto; /* Allow code to scroll */
}

#variables-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    min-width: 0;
}

#variables-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.panel-header {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-weight: bold;
    color: var(--accent);
    background: var(--bg-elevated);
    font-size: 0.85rem;
}

#logger-bar {
    height: 250px;
    min-height: 250px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 10px;
}

#logger-feed {
    flex: 1;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

#floating-editor-ui {
    display: flex;
    padding: 10px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    gap: 8px;
}

.btn-primary { background: var(--accent); color: #000; border: none; padding: 6px 12px; font-weight: bold; cursor: pointer; border-radius: 4px;}
.btn-secondary { background: transparent; color: var(--text-main); border: 1px solid var(--border); padding: 6px 12px; cursor: pointer; border-radius: 4px;}
.btn-danger { background: var(--danger); color: #fff; border: none; padding: 6px 12px; font-weight: bold; cursor: pointer; border-radius: 4px;}

/* --- Editor Styling --- */
.editor-container {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1e1e1e;
}

#java-editor, #highlighting {
    margin: 0 !important;
    padding: 15px !important;
    border: 0 !important;
    width: 100%;
    height: 100%;
    font-family: var(--font-mono) !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    position: absolute;
    top: 0;
    left: 0;
    white-space: pre !important;
    overflow-wrap: normal;
    box-sizing: border-box;
    tab-size: 4;
}

#java-editor {
    color: transparent !important;
    background: transparent !important;
    caret-color: white;
    z-index: 1;
    resize: none;
    outline: none;
    overflow: auto;
}

#highlighting {
    z-index: 0;
    pointer-events: none;
}

#highlighting-content {
    font-family: var(--font-mono) !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
}

.sidebar-search {
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

/* --- Tagify Dark Mode --- */
.tagify {
    --tags-border-color: var(--border);
    --tags-hover-border-color: var(--accent);
    --tags-focus-border-color: var(--accent);
    --tag-bg: transparent;
    --tag-hover: transparent;
    --tag-text-color: var(--text-main);
    --tag-text-color--edit: var(--text-main);
    --tag-pad: 0.5em 0.5em;
    --tag-inset-shadow-size: 1.1em;
    --tag-invalid-color: var(--danger);
    --tag-invalid-bg: rgba(239, 68, 68, 0.5);
    --tag-remove-bg: rgba(239, 68, 68, 0.3);
    --tag-remove-btn-color: var(--text-main);
    --tag-remove-btn-bg--hover: var(--danger);
    --input-color: var(--text-main);
    --placeholder-color: var(--text-muted);
    border-radius: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 0;
    transition: border-color 0.15s ease;
}

.tagify:hover {
    border-color: var(--accent);
}

.tagify__input {
    color: var(--text-main) !important;
    font-family: var(--font-mono);
}

.tagify__input::before {
    color: var(--text-muted) !important;
}

.tagify__dropdown {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-main) !important;
    font-family: var(--font-mono);
}

.tagify__dropdown__item {
    color: var(--text-main) !important;
    padding: 8px 12px;
}

.tagify__dropdown__item--active {
    background: var(--accent-glow) !important;
    color: var(--accent) !important;
}

.tagify__tag {
    color: var(--text-main) !important;
    margin: 0 !important;
}

.tagify__tag > div::before {
    box-shadow: none !important;
}

.tagify__tag > div > span {
    color: var(--text-main) !important;
}

/* --- IntelliJ Custom Editor --- */
.intellij-editor {
    width: 100%;
    height: 100%;
    background: #2b2b2b;
    color: #a9b7c6;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    overflow: auto;
    padding: 10px 0;
}

.editor-line {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-width: max-content;
}

.editor-line:hover {
    background: #323232;
}

.editor-line.has-breakpoint {
    background: rgba(239, 68, 68, 0.15) !important;
}

.editor-line.highlight-exec {
    background: rgba(45, 106, 79, 0.4);
    border-left: 3px solid #10b981;
}

/* IntelliJ Inline Debugger Hint */
.inline-debugger-hint {
    margin-left: 20px;
    color: #7a7a7a;
    font-style: italic;
    font-size: 12px;
    pointer-events: none;
    user-select: none;
}

.editor-line-number {
    width: 45px;
    min-width: 45px;
    text-align: right;
    padding-right: 12px;
    color: #606366;
    user-select: none;
    border-right: 1px solid #313335;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    transition: color 0.15s;
}

.editor-line-number:hover {
    color: #a9b7c6;
}

.editor-line-number::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 10px;
    height: 10px;
    background-color: #ef4444; /* Red circle */
    border-radius: 50%;
    transition: transform 0.15s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    opacity: 0.8;
}

.editor-line-number:hover::before {
    transform: translateY(-50%) scale(0.6);
    opacity: 0.4;
}

.editor-line-number.has-breakpoint::before {
    transform: translateY(-50%) scale(1);
    opacity: 1;
}

.editor-line-number.has-breakpoint {
    color: #ef4444;
}

.editor-line-content {
    padding-left: 10px;
    white-space: pre;
    flex: 1;
}

.inline-var-input {
    background: rgba(0,0,0,0.15);
    border: none;
    border-bottom: 1px dashed #606366;
    color: #cc7832; /* Variable/Number color in Darcula */
    font-family: inherit;
    font-size: inherit;
    text-align: center;
    padding: 0 4px;
    margin: 0 4px;
    outline: none;
    transition: all 0.2s;
    min-width: 40px;
    border-radius: 2px;
}

.inline-var-input:focus {
    background: rgba(16, 185, 129, 0.1);
    border-bottom: 1px solid #10b981;
    color: #10b981;
}

/* --- Mobile Responsive Layout (max-width: 1200px) --- */
@media (max-width: 1200px) {
    #master-layout {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }
    aside#sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    #mobile-menu-btn {
        display: flex !important;
    }
    aside#sidebar:not(.menu-open) .sidebar-search, 
    aside#sidebar:not(.menu-open) #algo-list-container {
        display: none;
    }
    aside#sidebar.menu-open {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        height: 100vh;
        z-index: 9999;
        background: rgba(5, 5, 5, 0.98);
        padding: 1rem;
        display: flex;
        flex-direction: column;
    }
    aside#sidebar.menu-open .sidebar-search,
    aside#sidebar.menu-open #algo-list-container {
        display: block;
    }
    aside#sidebar.menu-open #algo-list-container {
        flex: 1;
        overflow-y: auto;
        margin-top: 1rem;
    }
    main#main-content {
        width: 100%;
        padding: 0;
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }
    #workspace {
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }
    #editor-section, #variables-section {
        width: 100%;
        border-right: none;
    }
    #editor-section {
        flex: 1;
        min-height: 0;
    }
    #variables-section {
        border-top: 1px solid var(--border);
        min-height: 120px;
    }
    #floating-editor-ui {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    #editor-container {
        flex: 1;
        min-height: 0;
        height: auto;
        max-height: none;
    }
    #logger-bar {
        border-left: none;
        border-top: 1px solid var(--border);
        height: 60px;
        min-height: 60px;
        max-height: 60px;
        padding: 4px 8px;
        flex: none;
    }
    .panel-header {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}

/* --- Clean UI Extracted Classes --- */
.floating-editor-ui {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controls-container {
    display: flex;
    gap: 8px;
}

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

.editor-algo-title {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: bold;
    font-size: 13px;
}

.btn-reset-code {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-reset-code:hover {
    color: var(--text-main);
}

.editor-empty-state {
    padding: 20px;
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--font-mono);
}

.brand-title-text {
    margin: 0;
    text-align: start;
}

.algo-group-title {
    padding: 8px;
    color: var(--accent);
    font-weight: bold;
    cursor: pointer;
}

.algo-group-items {
    padding-left: 16px;
}

.algo-item {
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.algo-item:hover {
    color: var(--text-main);
}

/* --- Brand Title Acronym --- */
.highlight-acronym {
    color: var(--accent);
    font-weight: 800;
}
.desktop-text {
    display: none;
}

/* --- Educational Info Panel (Floating Accordion) --- */
#editor-section {
    position: relative;
}

.editor-algo-info {
    position: absolute;
    top: 55px;
    right: 15px;
    width: 500px;
    max-width: calc(100vw - 30px);
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 16px 20px;
    overflow-y: auto;
    max-height: 50vh;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top right;
    opacity: 1;
    transform: translateY(0) scaleY(1);
}

.editor-algo-info.accordion-closed {
    opacity: 0;
    transform: translateY(-10px) scaleY(0.95);
    pointer-events: none;
    visibility: hidden;
}

.btn-toggle-info {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-toggle-info:hover {
    background: rgba(16, 185, 129, 0.2);
}

.btn-close-info {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-close-info:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.editor-algo-info h2.info-title {
    margin: 0 0 12px 0;
    color: var(--accent);
    font-size: 1.4rem;
    font-weight: 800;
}

.desc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

@media (min-width: 768px) {
    .desc-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.desc-card {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
}

.desc-card h4 {
    margin: 0 0 8px 0;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.desc-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.desc-section {
    margin-bottom: 16px;
}

.desc-section:last-child {
    margin-bottom: 0;
}

.desc-title {
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.desc-section p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.desc-section ol {
    margin: 0;
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.desc-section ol li {
    margin-bottom: 4px;
}

.desc-highlight {
    background: rgba(16, 185, 129, 0.05);
    border-left: 3px solid var(--accent);
    padding: 12px;
    border-radius: 0 4px 4px 0;
}

.desc-highlight .desc-title {
    color: var(--accent);
}

/* --- README Empty State --- */
.editor-readme {
    padding: 30px;
    color: #a9b7c6;
    font-family: var(--font-main, sans-serif);
    line-height: 1.6;
    max-width: 900px;
    margin: 0 auto;
}

.readme-title {
    font-size: 2em;
    color: var(--accent);
    margin-bottom: 10px;
    border-bottom: 1px solid #4d4d4d;
    padding-bottom: 10px;
}

.readme-subtitle {
    font-size: 1.5em;
    color: #cc7832;
    margin-top: 30px;
    margin-bottom: 15px;
    border-bottom: 1px dashed #4d4d4d;
    padding-bottom: 5px;
}

.readme-desc {
    font-size: 1.1em;
    margin-bottom: 20px;
}

.readme-list {
    margin-left: 20px;
    margin-bottom: 20px;
}

.readme-list li {
    margin-bottom: 8px;
}

.readme-columns {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.readme-group-title {
    font-size: 1.2em;
    color: #9876aa;
    margin-bottom: 10px;
}

.readme-link {
    color: #6897bb;
    text-decoration: none;
    transition: color 0.2s;
}

.readme-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* --- Control Buttons Icons & Mobile Override --- */
.btn-primary, .btn-secondary, .btn-danger, .btn-toggle-info, .btn-reset-code {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

@media (max-width: 1200px) {
    .btn-text {
        display: none;
    }
    #variables-section {
        flex: none !important;
        height: 180px !important;
        min-height: 180px !important;
        max-height: 180px !important;
    }
    #variables-container {
        padding: 5px 15px !important;
    }
}

