:root {
    --bg: #0e1016;
    --panel: #161922;
    --panel-2: #1d212c;
    --border: #2a2f3a;
    --text: #e7e9ee;
    --muted: #8b93a3;
    --accent: #7b42bc;        /* Terraform purple */
    --accent-2: #9a63d6;
    --tofu: #ffda18;          /* OpenTofu yellow */
    --error: #ff6b6b;
    --ok: #7ee2a8;
    --ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--ui);
    -webkit-font-smoothing: antialiased;
}
body.engine-tofu { --accent: #b8950f; --accent-2: var(--tofu); }

a { color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 1.1rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.brand-mark {
    font-family: var(--mono); font-weight: 500; color: var(--bg);
    background: var(--accent-2); border-radius: 6px; padding: 0.15rem 0.4rem; font-size: 0.95rem;
}
.brand-name { font-weight: 700; letter-spacing: -0.01em; }

.controls { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.engine-toggle { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.engine-btn {
    border: none; background: transparent; color: var(--muted);
    font-family: var(--ui); font-size: 0.85rem; font-weight: 600; cursor: pointer;
    padding: 0.35rem 0.7rem; border-radius: 6px;
}
.engine-btn.is-active { background: var(--accent); color: #fff; }

select#versionSelect, .ghost-btn {
    background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; padding: 0.4rem 0.6rem; font-family: var(--ui); font-size: 0.85rem; cursor: pointer;
}
select#versionSelect:focus, .ghost-btn:focus { outline: 2px solid var(--accent); }

.menu { position: relative; }
.menu-list {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 20;
    list-style: none; margin: 0; padding: 6px; min-width: 180px;
    background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 16px 40px -12px rgba(0,0,0,0.6);
}
.menu-list button {
    width: 100%; text-align: left; background: transparent; border: none; color: var(--text);
    font-family: var(--ui); font-size: 0.85rem; padding: 0.45rem 0.55rem; border-radius: 6px; cursor: pointer;
}
.menu-list button:hover { background: var(--accent); color: #fff; }

.run-btn {
    background: var(--accent); color: #fff; border: none; border-radius: 8px;
    font-family: var(--ui); font-weight: 700; font-size: 0.9rem; padding: 0.45rem 1rem; cursor: pointer;
    transition: transform 0.1s, background 0.15s;
}
.run-btn:hover:not(:disabled) { background: var(--accent-2); }
.run-btn:disabled { opacity: 0.6; cursor: progress; }

.github-link { color: var(--muted); display: inline-flex; }
.github-link:hover { color: var(--text); }

/* ---------- Workspace ---------- */
.workspace { flex: 1; display: grid; grid-template-columns: 1fr 6px 1fr; min-height: 0; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.splitter { background: var(--border); cursor: col-resize; transition: background 0.15s; }
.splitter:hover, .splitter.dragging { background: var(--accent); }
.pane-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--muted); padding: 0.6rem 0.9rem; background: var(--panel); border-bottom: 1px solid var(--border);
}
#editor { flex: 1; min-height: 0; }

.copy-btn {
    background: transparent; border: 1px solid var(--border); color: var(--muted);
    font-size: 0.7rem; border-radius: 5px; padding: 0.15rem 0.5rem; cursor: pointer; letter-spacing: 0;
    text-transform: none;
}
.copy-btn:hover { color: var(--text); border-color: var(--muted); }

.output-meta {
    font-family: var(--mono); font-size: 0.72rem; color: var(--muted);
    padding: 0.4rem 1.1rem; border-bottom: 1px solid var(--border); background: var(--panel);
}
.output-meta.is-error { color: var(--error); }
.output-meta[hidden] { display: none; }

.output {
    flex: 1; margin: 0; padding: 1rem 1.1rem; overflow: auto; min-height: 0;
    font-family: var(--mono); font-size: 0.85rem; line-height: 1.55; color: var(--text);
    white-space: pre-wrap; word-break: break-word; background: #0c0e13;
}
.output.is-error { color: var(--error); }
.output .muted { color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: 0.6rem 1.1rem; font-size: 0.78rem; color: var(--muted);
    background: var(--panel); border-top: 1px solid var(--border);
}
.site-footer a { color: var(--accent-2); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer code { font-family: var(--mono); color: var(--text); }

/* ---------- Old-school visitor counter ---------- */
.hit-counter {
    display: inline-flex; align-items: center; gap: 0.45rem;
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted);
}
.hit-digits { display: inline-flex; gap: 2px; padding: 2px; background: #000; border: 1px solid #2a2f3a; border-radius: 3px; }
.hit-digits .d {
    font-family: var(--mono); font-weight: 700; font-size: 0.9rem; line-height: 1;
    color: #39ff7a; background: #0a0d0a; padding: 2px 3px; border-radius: 2px;
    min-width: 0.7em; text-align: center; text-shadow: 0 0 5px #39ff7a;
}

/* ---------- About page ---------- */
.about {
    max-width: 760px; margin: 0 auto; padding: 3rem 1.4rem 4rem; line-height: 1.7;
}
.about h1 { font-size: 2.2rem; margin: 0 0 0.6rem; letter-spacing: -0.02em; }
.about h2 { font-size: 1.15rem; margin: 2.2rem 0 0.5rem; color: var(--accent-2); }
.about .lead { font-size: 1.2rem; color: var(--text); }
.about p, .about li { color: #c7ccd6; }
.about ul { padding-left: 1.2rem; }
.about li { margin-bottom: 0.5rem; }
.about code { font-family: var(--mono); background: var(--panel-2); padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.9em; }
.about strong { color: var(--text); }
.about a { color: var(--accent-2); }
.about-code {
    font-family: var(--mono); font-size: 0.85rem; background: #0c0e13; color: var(--text);
    border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.1rem; overflow-x: auto;
}
.about .credit { margin-top: 2.5rem; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 820px) {
    .workspace { grid-template-columns: 1fr !important; grid-template-rows: 1fr 1fr; }
    .splitter { display: none; }
    .editor-pane { border-bottom: 1px solid var(--border); }
    .topbar { gap: 0.5rem; }
    .brand-name { display: none; }
}
