:root {
    --glitch-offset-1: 3px;
    --glitch-offset-2: -3px;
    --cyber-base: #050a0e;
    --cyber-green: #00ff41;
    --cyber-cyan: #00e5ff;
    --cyber-dark-green: #003b0f;
}

body {
    background-color: var(--cyber-base);
    color: var(--cyber-green);
    overflow-x: hidden;
    min-height: 100dvh;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    -webkit-font-smoothing: antialiased;
}

body.dashboard {
    overflow: hidden;
}

::selection {
    background: var(--cyber-cyan);
    color: var(--cyber-base);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--cyber-base) inset !important;
    -webkit-text-fill-color: var(--cyber-green) !important;
    transition: background-color 5000s ease-in-out 0s;
}

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--cyber-base);
}

::-webkit-scrollbar-thumb {
    background: var(--cyber-dark-green);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--cyber-green);
}

/* Ambient overlays — fixed so they cover the viewport even when the page scrolls */
#matrix-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 0.4;
    pointer-events: none;
}

.scanlines {
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.2) 50%,
        rgba(0, 0, 0, 0.2)
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 50;
    position: fixed;
    inset: 0;
    mix-blend-mode: overlay;
}

.screen-flicker {
    animation: flicker 0.15s infinite;
}

.vignette {
    background: radial-gradient(circle, rgba(5, 10, 14, 0) 40%, rgba(5, 10, 14, 0.9) 100%);
    pointer-events: none;
    z-index: 40;
    position: fixed;
    inset: 0;
}

/* Main layout */
.cyber-main {
    position: relative;
    z-index: 10;
    display: flex;
    min-height: 100dvh;
    width: 100%;
    align-items: center;
    justify-content: center;
    padding: 1rem 1rem 7rem;
}

/* Glass panel */
.cyber-panel {
    background: rgba(5, 10, 14, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 65, 0.2);
    box-shadow:
        0 0 30px rgba(0, 255, 65, 0.05),
        inset 0 0 20px rgba(0, 255, 65, 0.05);
    position: relative;
    width: 100%;
    max-width: 28rem;
    padding: 2rem;
    z-index: 20;
}

@media (min-width: 768px) {
    .cyber-panel {
        padding: 2.5rem;
    }
}

.cyber-panel::before,
.cyber-panel::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.cyber-panel::before {
    top: -1px;
    left: -1px;
    border-top-color: var(--cyber-green);
    border-left-color: var(--cyber-green);
}

.cyber-panel::after {
    bottom: -1px;
    right: -1px;
    border-bottom-color: var(--cyber-green);
    border-right-color: var(--cyber-green);
}

/* Header */
.cyber-header {
    margin-bottom: 2.5rem;
    text-align: center;
}

.cyber-header-top {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.cyber-header-top svg {
    margin-right: 0.75rem;
    opacity: 0.8;
}

.cyber-subtitle {
    color: var(--cyber-cyan);
    font-family: 'Share Tech Mono', monospace;
    font-weight: 700;
    letter-spacing: 0.2em;
    font-size: 0.75rem;
}

.cyber-title {
    font-family: 'Share Tech Mono', monospace;
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    text-transform: uppercase;
    color: var(--cyber-green);
}

@media (min-width: 768px) {
    .cyber-title {
        font-size: 3rem;
    }
}

.cyber-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(0, 255, 65, 0.5), transparent);
    margin: 1.5rem 0 0.5rem;
}

.cyber-status-text {
    color: rgba(0, 255, 65, 0.6);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.cyber-status-text .pulse {
    color: var(--cyber-cyan);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Form */
.cyber-form {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.cyber-field {
    position: relative;
    display: flex;
    flex-direction: column-reverse;
}

.input-field {
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(0, 255, 65, 0.4);
    color: var(--cyber-green);
    transition: all 0.2s ease;
    width: 100%;
    padding: 0.5rem 0.25rem;
    font-size: 1.125rem;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.05em;
}

.input-field:focus {
    outline: none;
    border-bottom-color: var(--cyber-cyan);
    box-shadow: 0 5px 15px -10px var(--cyber-cyan);
    background: rgba(0, 229, 255, 0.03);
    color: var(--cyber-cyan);
}

.input-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(0, 255, 65, 0.7);
    margin-bottom: 0.25rem;
    transition: color 0.2s ease;
}

.input-field:focus + .input-label {
    color: var(--cyber-cyan);
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

.field-marker {
    position: absolute;
    right: 0;
    bottom: 0.75rem;
    width: 0.5rem;
    height: 0.5rem;
    background: rgba(0, 255, 65, 0.2);
    transition: background-color 0.2s ease;
}

.cyber-field:focus-within .field-marker {
    background: rgba(0, 229, 255, 0.5);
}

.required {
    color: #ef4444;
}

.auth-error {
    border: 1px solid rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: 'Share Tech Mono', monospace;
    text-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.auth-error[hidden] {
    display: none;
}

/* Actions */
.cyber-actions {
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.btn-cyber {
    position: relative;
    background: rgba(0, 255, 65, 0.1);
    border: 1px solid var(--cyber-green);
    color: var(--cyber-green);
    transition: all 0.2s ease;
    text-transform: uppercase;
    overflow: hidden;
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

@media (min-width: 768px) {
    .btn-cyber {
        font-size: 1rem;
    }
}

.btn-cyber:hover:not(:disabled) {
    background: rgba(0, 255, 65, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
    text-shadow: 0 0 5px var(--cyber-green);
}

.btn-cyber:active:not(:disabled) {
    transform: scale(0.98);
    background: var(--cyber-green);
    color: var(--cyber-base);
}

.btn-cyber:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.btn-cyber .btn-bracket {
    color: rgba(0, 255, 65, 0.5);
    transition: color 0.2s ease;
}

.btn-cyber:hover:not(:disabled) .btn-bracket {
    color: var(--cyber-green);
}

.btn-cyber .btn-glow-line {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: var(--cyber-cyan);
    transition: width 0.3s ease;
}

.btn-cyber:hover:not(:disabled) .btn-glow-line {
    width: 100%;
}

.btn-cyber.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.forgot-link {
    font-size: 0.75rem;
    color: rgba(0, 255, 65, 0.4);
    text-decoration: none;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-bottom: 1px solid transparent;
    padding-bottom: 0.25rem;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.forgot-link:hover {
    color: var(--cyber-cyan);
    border-bottom-color: var(--cyber-cyan);
}

/* Glitch text */
.glitch-text {
    position: relative;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

.glitch-text::before {
    left: var(--glitch-offset-1);
    text-shadow: -2px 0 red;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    animation: glitch-anim 3s infinite linear alternate-reverse;
}

.glitch-text::after {
    left: var(--glitch-offset-2);
    text-shadow: -2px 0 blue;
    clip-path: polygon(0 80%, 100% 20%, 100% 100%, 0 100%);
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { clip-path: inset(20% 0 80% 0); transform: translate(-2px, 1px); }
    10% { clip-path: inset(50% 0 10% 0); transform: translate(1px, -1px); }
    20% { clip-path: inset(80% 0 5% 0); transform: translate(-1px, 2px); }
    30% { clip-path: inset(10% 0 60% 0); transform: translate(2px, -2px); }
    40% { clip-path: inset(30% 0 20% 0); transform: translate(1px, 1px); }
    50% { clip-path: inset(90% 0 5% 0); transform: translate(-2px, 1px); }
    60% { clip-path: inset(0% 0 90% 0); transform: translate(2px, -1px); }
    70% { clip-path: inset(40% 0 30% 0); transform: translate(-1px, -2px); }
    80% { clip-path: inset(60% 0 20% 0); transform: translate(1px, 2px); }
    90% { clip-path: inset(15% 0 70% 0); transform: translate(-2px, -1px); }
    100% { clip-path: inset(85% 0 10% 0); transform: translate(2px, 1px); }
}

@keyframes flicker {
    0% { opacity: 0.98; }
    50% { opacity: 0.95; }
    100% { opacity: 0.99; }
}

@keyframes blink {
    50% { opacity: 0; }
}

.cursor-blink {
    animation: blink 1s step-start infinite;
    display: inline-block;
    width: 8px;
    height: 1.2em;
    background-color: var(--cyber-green);
    vertical-align: middle;
    margin-left: 4px;
}

/* Terminal status bar */
.cyber-terminal {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(3, 6, 8, 0.9);
    border-top: 1px solid rgba(0, 255, 65, 0.2);
    padding: 0.5rem;
    z-index: 30;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(0, 255, 65, 0.7);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    backdrop-filter: blur(4px);
}

@media (min-width: 768px) {
    .cyber-terminal {
        font-size: 0.75rem;
    }
}

.terminal-output {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 66.666667%;
    height: 4.5rem;
    overflow: hidden;
    justify-content: flex-end;
}

.terminal-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.terminal-meta .node-id {
    color: rgba(0, 229, 255, 0.6);
}

.terminal-meta .version {
    color: rgba(0, 255, 65, 0.4);
    margin-top: 0.25rem;
}

.status-line {
    opacity: 0;
    transform: translateY(5px);
    animation: fadeUp 0.3s ease forwards;
}

.status-line.delay-1 { animation-delay: 200ms; }
.status-line.delay-2 { animation-delay: 500ms; }

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.text-cyan { color: var(--cyber-cyan); }
.text-red { color: #ef4444; }
.font-bold { font-weight: 700; }


/* ============================================================
   MOBILE ADAPTATION
   ============================================================ */

/* Tablets and below */
@media (max-width: 640px) {
    .cyber-main {
        padding: 0.85rem 0.85rem 5.5rem;
    }

    .cyber-panel {
        padding: 1.5rem 1.15rem;
        max-width: 100%;
    }

    .cyber-header {
        margin-bottom: 1.75rem;
    }

    .cyber-title {
        font-size: 1.95rem;
        letter-spacing: -0.03em;
    }

    .cyber-form {
        gap: 1.5rem;
    }

    .input-field {
        font-size: 1rem;
        padding: 0.55rem 0.25rem;
    }

    .input-label {
        font-size: 0.7rem;
    }

    .btn-cyber {
        padding: 0.9rem 1rem;
        letter-spacing: 0.15em;
        min-height: 48px;
    }

    .cyber-actions { gap: 1rem; }

    .forgot-link {
        padding: 0.5rem 0.75rem;
        min-height: 32px;
    }

    .auth-error {
        font-size: 0.7rem;
        padding: 0.55rem 0.65rem;
    }

    /* Trim glitch overflow on small screens */
    :root {
        --glitch-offset-1: 2px;
        --glitch-offset-2: -2px;
    }

    .cyber-terminal {
        font-size: 9px;
        padding: 0.4rem 0.55rem;
        gap: 0.5rem;
    }

    .terminal-output {
        width: 60%;
        height: 3.2rem;
        gap: 0.15rem;
    }

    .terminal-meta {
        font-size: 9px;
    }
}

/* Phones */
@media (max-width: 420px) {
    .cyber-panel {
        padding: 1.25rem 0.95rem;
    }

    .cyber-title {
        font-size: 1.6rem;
    }

    .cyber-subtitle {
        font-size: 0.65rem;
        letter-spacing: 0.15em;
    }

    .cyber-header-top svg {
        width: 18px;
        height: 18px;
        margin-right: 0.5rem;
    }

    .cyber-form {
        gap: 1.25rem;
    }

    .cyber-divider {
        margin: 1rem 0 0.5rem;
    }

    .cyber-status-text {
        font-size: 0.65rem;
    }
}

/* Very small phones — stack the terminal bar vertically */
@media (max-width: 360px) {
    .cyber-main {
        padding-bottom: 6rem;
    }

    .cyber-terminal {
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
    }

    .terminal-output {
        width: 100%;
        height: 2.4rem;
    }

    .terminal-meta {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }

    .terminal-meta .version {
        margin-top: 0;
    }
}

/* Short viewport (landscape phones) — hide the terminal bar to free space */
@media (max-height: 520px) and (max-width: 900px) {
    .cyber-terminal {
        display: none;
    }
    .cyber-main {
        padding-bottom: 1rem;
    }
}
