:root {
    --bg-base: #09090b;
    --bg-glass: rgba(24, 24, 27, 0.6);
    --border-glass: rgba(255, 255, 255, 0.1);

    --primary: #3b82f6;
    --primary-hover: #2563eb;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-md: 8px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-ui);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.bg-blur {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.15), transparent 40%),
        radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.1), transparent 40%);
    z-index: -1;
    filter: blur(60px);
}

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.app-container {
    width: 100%;
    max-width: 1200px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-glass);
}

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

.logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.layout-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    border-right: 1px solid var(--border-glass);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    display: block;
}

.control-group {
    display: flex;
    flex-direction: column;
}

.input-area {
    width: 100%;
    height: 160px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    color: #FFF;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    color: #FFF;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.75rem;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    appearance: none;
}

.input:focus,
.input-area:focus {
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    outline: none;
    white-space: nowrap;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.w-full {
    width: 100%;
}

.btn-primary {
    background: var(--text-main);
    color: var(--bg-base);
}

.btn-primary:hover {
    background: #E2E8F0;
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-glass);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    padding: 0;
}

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

.actions {
    padding: 1.5rem;
    margin-top: auto;
}

/* Output Area */
.output-area {
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow: hidden;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.title {
    font-size: 1.2rem;
    font-weight: 500;
}

.export-actions {
    display: flex;
    gap: 0.75rem;
}

.heatmap-container {
    flex: 1;
    border: 1px dashed var(--border-glass);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 2rem;
    overflow: auto;
}

.scroll-x::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.scroll-x::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-x::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#svg-container {
    min-width: max-content;
}

#svg-container svg {
    outline: none;
    display: block;
    margin: 0 auto;
    user-select: none;
}

.rect-cell {
    transition: stroke-width 0.1s;
    cursor: crosshair;
}

.rect-cell:hover {
    stroke: #FFF !important;
    stroke-width: 1px !important;
}

/* Empty Default */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    opacity: 0.6;
}

.empty-icon {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

/* Legend Overlay Elements */
.legend-container {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-blocks {
    display: flex;
    gap: 4px;
}

.legend-block {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.hidden {
    display: none !important;
}

/* Tooltip floating absolute */
.tooltip {
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.85);
    color: #FFF;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 100;
    transform: translate(-50%, -120%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    opacity: 1;
    transition: opacity 0.15s;
}

.tooltip-val {
    font-weight: 600;
    margin-bottom: 0.1rem;
}

.tooltip-date {
    color: var(--text-muted);
    font-size: 0.75rem;
}

@media (max-width: 900px) {
    .layout-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        overflow: auto;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        overflow: visible;
    }

    body {
        padding: 0.5rem;
    }

    .app-container {
        height: auto;
        min-height: 95vh;
    }
}