:root {
    --bg: #000000;
    --fg: #ffffff;
    --accent: #ff0000;
    --dim: #333333;
    --border: 1px solid var(--fg);
}

body.theme-light {
    --bg: #ffffff;
    --fg: #000000;
    --accent: #ff0000;
    --dim: #cccccc;
    --border: 1px solid var(--fg);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: 'Space Mono', monospace;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Grid background */
body::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: linear-gradient(var(--dim) 1px, transparent 1px);
    background-size: 100% 50px;
    opacity: 0.2;
    pointer-events: none;
    z-index: 0;
}

/* --- WRAPPER --- */
.terminal-wrapper {
    position: relative;
    z-index: 10;
    width: 85vw;
    max-width: 1400px;
    height: 90vh;
    max-height: 900px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* --- TABS --- */
.nav-cluster {
    display: flex;
    justify-content: flex-start;
    flex-shrink: 0;
    margin-bottom: -1px;
    z-index: 20;
}

.nav-item {
    text-decoration: none;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--fg);
    border-bottom: none;
    padding: 10px 24px;
    font-size: 11px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: -1px;
    white-space: nowrap;
}

.nav-item:hover { background: var(--fg); color: var(--bg); }
.nav-item[data-pos="5"] { border-color: var(--accent); color: var(--accent); }
.nav-item[data-pos="5"]:hover { background: var(--accent); color: var(--bg); }

.nav-bottom { display: none; }

/* --- CONTENT WINDOW --- */
.content-frame {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--fg);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-frame::after {
    content: " ";
    position: absolute;
    top: 0; right: -20px;
    width: 10px; height: 100px;
    background: repeating-linear-gradient(to bottom, var(--fg), var(--fg) 2px, transparent 2px, transparent 4px);
    opacity: 0.5;
}

#home-view {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: left;
    overflow: hidden;
}

h1 {
    font-size: 8vw;
    font-weight: 400;
    line-height: 0.8;
    margin: 0;
    letter-spacing: -4px;
    color: var(--fg);
}

.manifesto {
    margin-top: 40px;
    font-size: 12px;
    line-height: 1.6;
    max-width: 500px;
    border-left: 1px solid var(--accent);
    padding-left: 20px;
    color: var(--fg);
    min-height: 6em;
}

.system-badge {
    display: inline-block;
    background: var(--fg);
    color: var(--bg);
    padding: 0 5px;
    animation: pulse 2s step-end infinite;
}

@keyframes pulse { 0%, 80%, 100% { opacity: 1; } 40% { opacity: 0.3; } }

.load-counter { font-size: 12px; opacity: 0.5; display: inline; }
.meta-data { position: absolute; bottom: 20px; left: 20px; font-size: 9px; opacity: 0.6; }

.poem-data {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 9px;
    opacity: 0;
    max-width: 340px;
    line-height: 1.8;
    text-align: left;
    transition: opacity 1.2s ease;
}

.poem-fn {
    display: block;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 2px;
}

.poem-body {
    display: block;
    color: var(--fg);
    word-break: break-word;
}
.barcode-strip { position: absolute; top: 20px; right: 20px; font-size: 9px; text-align: right; line-height: 1.2; }

iframe#frame-view { width: 100%; height: 100%; border: none; display: none; }

/* --- FOOTER --- */
footer {
    flex-shrink: 0;
    margin-top: 12px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--dim);
    padding-top: 10px;
    font-size: 10px;
    gap: 12px;
}

.audio-trigger {
    background: transparent;
    border: 1px solid var(--fg);
    color: var(--fg);
    padding: 5px 15px;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 10px;
    font-family: 'Space Mono', monospace;
    white-space: nowrap;
}

.audio-trigger:hover { background: var(--fg); color: var(--bg); }
.footer-track { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.running-text { color: var(--accent); }
.running-text a { color: inherit; text-decoration: none; }

/* ===================== MEDIA QUERIES ===================== */

@media (max-width: 1024px) {
    .terminal-wrapper { width: 94vw; height: 94dvh; }
    .content-frame::after { display: none; }
}

@media (max-width: 768px) {
    .nav-cluster { flex-wrap: nowrap; }
    .nav-item[data-pos="4"], .nav-item[data-pos="5"] { display: none; }
    .nav-item { padding: 8px 10px; font-size: 9px; flex: 1; text-align: center; }

    .nav-bottom {
        display: flex; justify-content: flex-end;
        margin-top: -1px; z-index: 20; flex-shrink: 0;
    }
    .nav-bottom-item {
        text-decoration: none; color: var(--fg); background: var(--bg);
        border: 1px solid var(--fg); border-top: none;
        padding: 8px 12px; font-size: 9px; margin-left: -1px;
        text-transform: uppercase;
    }
    .nav-bottom-item.accent { border-color: var(--accent); color: var(--accent); }
  footer { margin-top: 8px; padding-top: 8px; }
    .poem-data { display: none; }
    h1 { font-size: 14vw; letter-spacing: -2px; }
    .manifesto { font-size: 10px; margin-top: 15px; }
    footer { margin-top: 8px; padding-top: 8px; }
}

@media (max-height: 500px) and (orientation: landscape) {
    body { align-items: flex-start; padding-top: 5px; }
    .terminal-wrapper { width: 98vw; height: 96vh; justify-content: flex-start; }
    .content-frame { flex: 1; margin-bottom: 2px; }
    .nav-item[data-pos="4"], .nav-item[data-pos="5"] { display: block; }
    .nav-item { padding: 5px 6px; font-size: 8px; flex: 1; text-align: center; }
    .nav-bottom { display: none; }
    h1 { font-size: 8vw; }
    .manifesto { margin-top: 5px; font-size: 9px; min-height: 0; border: none; padding-left: 0; text-align: center; }
    .meta-data, .barcode-strip { display: none; }\n    .poem-data { display: none; }
    footer { margin-top: 2px; padding-top: 2px; border: none; justify-content: center; gap: 5px; }
    .footer-track { display: none; }
}
