/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0d1117;
    --text: #c9d1d9;
    --border: #30363d;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --surface: #161b22;
    --surface-hover: #1c2129;
    --panel-width: 220px;
    --header-height: 48px;
    --action-bar-height: 48px;
}

html, body {
    height: 100%;
    height: 100svh;
    overflow: hidden;
}

body {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.hidden { display: none !important; }
.hidden-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

/* === Header === */
.site-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text);
}

/* === Main 3-Column Layout === */
.main-layout {
    display: flex;
    height: calc(100vh - var(--header-height) - var(--action-bar-height));
    height: calc(100svh - var(--header-height) - var(--action-bar-height));
}

/* === Panels === */
.panel {
    width: var(--panel-width);
    min-width: var(--panel-width);
    padding: 1rem;
    overflow-y: auto;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.panel-left {
    border-right: 1px solid var(--border);
}

.panel-right {
    border-left: 1px solid var(--border);
}

.panel-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

/* === Controls === */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text);
}

.control-label span {
    font-weight: 600;
}

.control-input {
    width: 68px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--accent);
    font-family: inherit;
    font-size: 0.7rem;
    padding: 2px 6px;
    text-align: right;
}

.control-input:focus {
    outline: 1px solid var(--accent);
    border-color: var(--accent);
}

/* Range slider */
.control-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.control-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    cursor: pointer;
    transition: transform 0.1s;
}

.control-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.control-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    cursor: pointer;
}

/* === Comparator === */
.comparator {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #000;
    cursor: ew-resize;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-x;
}

.comparator-half {
    position: absolute;
    top: 0;
    height: 100%;
    overflow: hidden;
}

.half-left {
    left: 0;
    width: 50%;
}

.half-right {
    left: 50%;
    width: 50%;
}

.comp-image {
    position: absolute;
    transform-origin: center center;
    display: none;
}

/* Drop placeholder */
.drop-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border);
    border-radius: 8px;
    margin: 1rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    z-index: 5;
}

.drop-placeholder:hover {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
}

.drop-placeholder.drag-over {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.1);
    border-width: 3px;
}

.drop-placeholder p {
    font-size: 0.85rem;
    color: var(--text);
}

.drop-hint {
    font-size: 0.7rem !important;
    color: #484f58 !important;
    margin-top: 0.25rem;
}

/* Slider */
.slider-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: white;
    z-index: 20;
    box-shadow: 0 0 8px rgba(0,0,0,0.5);
    pointer-events: none;
    transform: translateX(-50%);
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    z-index: 21;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: transform 0.15s ease;
}

.comparator:active .slider-handle {
    transform: translate(-50%, -50%) scale(1.1);
}

.comp-label {
    position: absolute;
    top: 12px;
    z-index: 15;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: none;
}

.label-a { left: 12px; }
.label-b { right: 12px; }

/* === Action Bar === */
.action-bar {
    height: var(--action-bar-height);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.15s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
}

/* Share links */
.share-links {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

.share-label {
    font-size: 0.7rem;
    color: #484f58;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.share-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.65rem;
    padding: 3px 8px;
    width: 260px;
    cursor: pointer;
}

.share-input:focus {
    outline: 1px solid var(--accent);
}

/* === Mobile Drawers === */
.drawer {
    position: fixed;
    bottom: var(--action-bar-height);
    width: 240px;
    max-height: 55vh;
    max-height: 55svh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: none;
    z-index: 50;
    transition: transform 0.3s ease, width 0.3s ease;
    overflow-y: hidden;
}

.drawer-left {
    left: 0;
    border-left: none;
    border-radius: 0 12px 0 0;
}

.drawer-right {
    right: 0;
    border-right: none;
    border-radius: 12px 0 0 0;
}

.drawer.collapsed {
    transform: translateY(100%);
    width: 44px;
}

.drawer-toggle {
    width: 100%;
    height: 36px;
    background: var(--surface);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.08em;
}

.drawer-toggle:hover {
    background: var(--surface-hover);
}

.drawer-content {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    max-height: calc(55vh - 36px);
    max-height: calc(55svh - 36px);
}

/* === Responsive: Mobile === */
@media (max-width: 768px) {
    .panel {
        display: none;
    }

    .main-layout {
        height: calc(100vh - var(--header-height) - var(--action-bar-height));
    height: calc(100svh - var(--header-height) - var(--action-bar-height));
    }

    .action-bar {
        flex-wrap: wrap;
        height: auto;
        min-height: var(--action-bar-height);
        padding: 0.5rem;
        justify-content: center;
    }

    .share-links {
        flex-direction: column;
        gap: 0.4rem;
        width: 100%;
    }

    .share-input {
        width: 100%;
    }
}

@media (min-width: 769px) {
    .drawer {
        display: none !important;
    }
}
