:root {
    --bg: #0d1a2e;
    --panel-bg: #1a2a45cc;
    --panel-border: #38bdf8;
    --header: #38bdf8;
    --text: #e0e6ed;
    --code-bg: #101c32;
    --error-bg: #2d1a1a;
    --error-border: #ef4444;
    --scrollbar: #38bdf8;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    width: 100vw;
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100vw;
    overflow-x: hidden;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin: 2rem 0 1.5rem 0;
    letter-spacing: 1px;
    text-shadow: 0 2px 16px #38bdf855;
}

.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 480px 400px;
    gap: 2rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    flex: 1 1 auto;
}

.panel {
    background: var(--panel-bg);
    border-radius: 1.2rem;
    border: 1.5px solid var(--panel-border);
    box-shadow: 0 0 24px 0 #38bdf833;
    display: flex;
    flex-direction: column;
    padding: 1.2rem 1.2rem 1rem 1.2rem;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.panel-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.7rem;
    letter-spacing: 0.5px;
}

.panel-content {
    background: var(--code-bg);
    border-radius: 0.7rem;
    flex: 1 1 0;
    overflow: auto;
    padding: 0.7rem 0.7rem 0.7rem 0.7rem;
    margin-bottom: 0.2rem;
    font-family: 'Fira Code', monospace;
    font-size: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar) #0002;
}

.panel-content::-webkit-scrollbar {
    width: 8px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar);
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-track {
    background: #0002;
    border-radius: 4px;
}

#codeInput {
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1 1 0;
    background: #101c32;
    color: #e0e6ed;
    border: 1.5px solid #38bdf8;
    border-radius: 0.7rem;
    font-family: 'Fira Code', monospace;
    font-size: 1rem;
    padding: 1rem;
    resize: none;
    margin-bottom: 1rem;
    outline: none;
    transition: border 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 0 0 #38bdf8;
}

#codeInput:focus {
    border: 1.5px solid #60a5fa;
    box-shadow: 0 0 0 2px #38bdf855;
}

#analyzeBtn {
    width: 100%;
    padding: 0.7rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 0.7rem;
    background: linear-gradient(90deg, #38bdf8 0%, #2563eb 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 12px 0 #38bdf855;
    transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
    margin-top: 0.2rem;
}

#analyzeBtn:hover:not(:disabled) {
    background: linear-gradient(90deg, #2563eb 0%, #38bdf8 100%);
    box-shadow: 0 4px 24px 0 #38bdf855;
}

#analyzeBtn:disabled {
    opacity: 0.7;
    cursor: wait;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.98rem;
}

th,
td {
    padding: 0.38rem 0.7rem;
    text-align: left;
    font-family: 'Fira Code', monospace;
}

th {
    color: #38bdf8;
    font-weight: 600;
    font-size: 1rem;
    border-bottom: 1.5px solid #38bdf8;
    background: transparent;
}

td {
    border-bottom: 1px solid #23304a;
    background: transparent;
}

.token-type {
    color: #38d9a9;
    font-weight: 600;
}

.token-value {
    color: #e0e6ed;
}

.scope-title {
    color: #38bdf8;
    font-weight: 600;
    font-size: 1.05rem;
    margin: 0.5rem 0 0.2rem 0;
}

.identifier {
    color: #f472b6;
}

.type {
    color: #facc15;
}

.tac-line {
    color: #e0e6ed;
    font-family: 'Fira Code', monospace;
    font-size: 1rem;
    white-space: pre;
}

.tac-lineno {
    color: #38bdf8;
    margin-right: 0.7em;
    font-weight: 600;
    font-size: 1rem;
    display: inline-block;
    width: 2.2em;
    text-align: right;
    opacity: 0.7;
}

#error-panel {
    display: none;
    grid-column: 1 / span 2;
    background: var(--error-bg);
    border: 2px solid var(--error-border);
    border-radius: 1.2rem;
    margin: 2rem auto 0 auto;
    max-width: 1400px;
    box-shadow: 0 0 24px 0 #ef444455;
    padding: 1.2rem 1.2rem 1rem 1.2rem;
}

#error-panel.visible {
    display: block;
}

.error-title {
    color: #ef4444;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.7rem;
}

.error-message {
    color: #f87171;
    background: #1a2a45;
    border-left: 4px solid #ef4444;
    border-radius: 0.5rem;
    padding: 0.7rem 1rem;
    margin-bottom: 0.5rem;
    font-family: 'Fira Code', monospace;
    font-size: 1rem;
}

@media (max-width: 1200px) {
    .main-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 480px 400px 480px 400px;
        gap: 1.2rem;
    }

    #error-panel {
        grid-column: 1 / span 1;
    }
}

@media (max-width: 700px) {
    h1 {
        font-size: 1.5rem;
    }

    .main-grid {
        gap: 0.7rem;
    }

    .panel {
        padding: 0.7rem;
    }

    .panel-content {
        padding: 0.4rem;
    }

    #error-panel {
        padding: 0.7rem;
    }
}