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

:root
{
    --bg:       #111110;
    --surface:  #1c1c18;
    --border:   #38362e;
    --accent:   #c8860a;
    --accent-h: #e09c20;
    --text:     #d8d4be;
    --muted:    #7a7868;
    --active-bg:#2c2210;
}

html, body
{
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Courier New', 'Lucida Console', monospace;
    font-size: 14px;
    line-height: 1.5;
}

/* APP CONTAINER ****************************************************************/

.app
{
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* TOP BAR **********************************************************************/

.topbar
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 48px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.topbar h1
{
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    text-shadow: 0 0 12px rgba(200, 134, 10, 0.5);
}

/* MAIN SECTION *****************************************************************/

.main-layout
{
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* SIDE BAR / CONTROLS **********************************************************/

.sidebar
{
    width: 200px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-scroll
{
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-track { background: var(--bg); }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

/* SIDE BAR PANELS */

.panel
{
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.panel h2
{
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 8px;
}

.panel.disabled
{
    opacity: 0.4;
    pointer-events: none;
}

/* FILE SELECTION CONTROLS */

.file-button
{
    display: inline-block;
    padding: 6px 14px;
    background: var(--accent);
    color: #0a0a08;
    border-radius: 2px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.04em;
    transition: background 0.1s;
    user-select: none;
    text-align: center;
}

.file-button.full-width
{
    display: block;
    width: 100%;
}

.load-panel
{
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.select-full
{
    width: 100%;
    padding: 5px 8px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

.select-full:focus
{
    outline: none;
    border-color: var(--accent);
}

.file-button:hover  { background: var(--accent-h); }
.file-button:active { transform: translateY(1px); }

.file-button input[type="file"]
{
    display: none;
}

/* ANIMATION CONTROLS */

.controls-panel .control-row
{
    margin-bottom: 10px;
}

.controls-panel label
{
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
}

.controls-panel input[type="range"]
{
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.controls-panel span
{
    color: var(--text);
    font-weight: 700;
    font-size: 12px;
}

.button
{
    width: 100%;
    padding: 7px 0;
    background: var(--accent);
    color: #0a0a08;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.04em;
    transition: background 0.1s;
}

.button:hover   { background: var(--accent-h); }
.button:active  { transform: translateY(1px); }
.button:disabled { opacity: 0.35; cursor: default; }

.frame-display
{
    font-size: 11px;
    color: var(--muted);
    text-align: center;
}

.hint
{
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
}

/* ANIMATION LIST */

.animation-list
{
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.animation-list li
{
    padding: 5px 8px;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.animation-list li:hover  { background: var(--border); }
.animation-list li.active
{
    background: var(--active-bg);
    color: var(--accent);
    text-shadow: 0 0 6px rgba(200, 134, 10, 0.4);
}

/* BOTTOM BAR / CONSOLE *********************************************************/

.console-panel
{
    flex-shrink: 0;
    height: 140px;
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border);
    background: #0a0a08;
}

.console-header
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    flex-shrink: 0;
}

.console-clear
{
    background: none;
    border: none;
    color: var(--muted);
    font-size: 10px;
    font-family: inherit;
    cursor: pointer;
    padding: 1px 4px;
    border-radius: 2px;
    letter-spacing: 0.04em;
}

.console-clear:hover { color: var(--text); background: var(--border); }

.console-body
{
    flex: 1;
    overflow-y: auto;
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: 'Courier New', 'Lucida Console', monospace;
    font-size: 11px;
}

.console-body::-webkit-scrollbar { width: 4px; }
.console-body::-webkit-scrollbar-track { background: #0a0a08; }
.console-body::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

.console-body > div
{
    display: flex;
    gap: 6px;
    line-height: 1.4;
    word-break: break-word;
}

.log-time
{
    color: var(--muted);
    flex-shrink: 0;
}

.log-info  .log-text { color: #b8c89a; text-shadow: 0 0 4px rgba(184, 200, 154, 0.45); }
.log-error .log-text { color: #f47c4a; }

/* WEBGL CANVAS & RETRO EFFECTS *************************************************/

/* CANVAS CONTAINER */
.canvas-wrap
{
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #0e0e0b;
}

/* VIGNETTE */
.canvas-wrap::before
{
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center,
        transparent 55%,
        rgba(0, 0, 0, 0.55) 100%);
    pointer-events: none;
    z-index: 1;
}

/* SCANLINES */
.canvas-wrap::after
{
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(0, 0, 0, 0.18) 1px,
        rgba(0, 0, 0, 0.18) 2px
    );
    pointer-events: none;
    z-index: 2;
}

/* CANVAS */
#glCanvas
{
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
}

#glCanvas:active
{
    cursor: grabbing;
}
