:root {
    --bg: #050505;
    --fg: #e9edf2;
    --muted: rgba(233, 237, 242, 0.7);
    --card: rgba(12, 12, 12, 0.4);
    --stroke: rgba(255, 255, 255, 0.08);
    --accent: #55ffe0;
    --accent-2: #ffaa40;
    --danger: #ff4d67;
    --radius: 20px;
    --font-heading: 'Syne', 'Space Grotesk', sans-serif;
    --font-body: 'Space Grotesk', system-ui, sans-serif;
    --noise: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="160" height="160" viewBox="0 0 160 160"%3E%3Cfilter id="n" x="0" y="0" width="1" height="1"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23n)" opacity="0.42"/%3E%3C/svg%3E');
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    background: #050505;
    color: var(--fg);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--noise);
    opacity: 0.25;
    pointer-events: none;
    mix-blend-mode: screen;
    z-index: 9999;
}

.noise-layer {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 10% 20%, rgba(85, 255, 224, 0.08), transparent 45%),
        radial-gradient(circle at 90% 80%, rgba(255, 170, 64, 0.06), transparent 40%);
    filter: blur(120px);
    opacity: 0.6;
    pointer-events: none;
    z-index: -1;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 2.5rem 2rem;
    border-right: 1px solid var(--stroke);
    background: rgba(5, 5, 5, 0.5);
    backdrop-filter: blur(24px);
    display: flex;
    flex-direction: column;
}

.sidebar h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin: 0 0 3rem;
    background: linear-gradient(120deg, #fff, rgba(255,255,255,0.5));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.nav a {
    padding: 0.85rem 1.25rem;
    border-radius: 99px;
    color: var(--muted);
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.03);
}

.nav a.active {
    background: rgba(85, 255, 224, 0.1);
    color: var(--accent);
    border-color: rgba(85, 255, 224, 0.2);
    font-weight: 500;
}

.nav a.logout {
    margin-top: auto;
    color: var(--danger);
}

.content {
    padding: 4rem clamp(2rem, 5vw, 4rem);
    max-width: 1400px;
}

h1, h2, h3 {
    font-family: var(--font-heading);
    margin-top: 0;
}

.card {
    background: var(--card);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.cards-grid .card p:first-of-type {
    margin: 0 0 0.5rem;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    text-align: left;
    padding: 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    border-bottom: 1px solid var(--stroke);
}

.table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--stroke);
}

.table tr:last-child td {
    border-bottom: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    color: #050505;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--stroke);
    color: var(--fg);
}

.btn-danger {
    background: rgba(255, 77, 103, 0.15);
    color: var(--danger);
    border: 1px solid rgba(255, 77, 103, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 600px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--muted);
}

input, textarea, select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--stroke);
    border-radius: 12px;
    padding: 0.85rem 1.1rem;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(85, 255, 224, 0.15);
}

textarea {
    min-height: 120px;
    line-height: 1.5;
}

/* Login Page overrides */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.flash {
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.flash.success { background: rgba(85, 255, 224, 0.1); color: var(--accent); border: 1px solid rgba(85, 255, 224, 0.2); }
.flash.error { background: rgba(255, 77, 103, 0.1); color: var(--danger); border: 1px solid rgba(255, 77, 103, 0.2); }

/* Code Editor enhancements */
textarea[name^='preview_'] {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    background: #0d0d0d;
    color: #a8b3cf;
    border-color: #333;
}

textarea[name='preview_html'] { color: #e3a063; }
textarea[name='preview_css'] { color: #6db6ff; }
textarea[name='preview_js'] { color: #d19a66; }
