body {
    margin: 0;
    padding: 0;
    background: #050505;
    color: #eee;
    font-family: 'Segoe UI', sans-serif;
    overflow-x: hidden;
}

#matrix {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -10;
    pointer-events: none;
}

.lang-switch {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.lang-switch button {
    background: transparent;
    border: 2px solid cyan;
    color: cyan;
    padding: 6px 12px;
    margin-left: 10px;
    cursor: pointer;
    transition: 0.3s;
}

.lang-switch button:hover {
    background: cyan;
    color: #000;
    box-shadow: 0 0 15px cyan;
}

/* HEADER */
.ag-header {
    text-align: center;
    padding-top: 10vh;
}

.ag-header h1 {
    font-family: 'Bruno Ace SC', sans-serif;
    font-size: 5rem;
    letter-spacing: 5px;
    color: #cfffff;
    -webkit-text-stroke: 0.3px #cfffff;
    text-shadow:
        0 0 6px rgba(200,255,255,0.5),
        0 0 12px rgba(200,255,255,0.3);
}

@keyframes glow {
    from { text-shadow: 0 0 10px cyan; }
    to   { text-shadow: 0 0 30px cyan; }
}

/* MAIN CONTAINER */
.ag-container {
    max-width: 1100px;
    margin: auto;
    padding: 20px;
}

/* PRESETS */
.ag-presets {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.preset {
    padding: 10px 20px;
    border: 1px solid cyan;
    background: rgba(0,0,0,0.4);
    color: cyan;
    cursor: pointer;
    transition: 0.3s;
}

.preset:hover {
    background: cyan;
    color: black;
    box-shadow: 0 0 20px cyan;
}

/* PANEL */
.ag-panel textarea,
.ag-panel input {
    width: 100%;
    background: rgba(0,0,0,0.6);
    border: 1px solid cyan;
    color: cyan;
    padding: 10px;
    margin-bottom: 10px;
    box-sizing: border-box;
}

/* DESKTOP — 4 kolumny */
.ag-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)); /* KLUCZOWA POPRAWKA */
    gap: 15px;
}

.ag-controls label {
    display: flex;
    flex-direction: column;
    font-size: 14px;
    min-width: 0;
}

.ag-controls input {
    min-width: 0; /* zapobiega nachodzeniu */
    width: 100%;
    box-sizing: border-box;
}

/* TABLET — 2 kolumny */
@media (max-width: 900px) {
    .ag-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* MOBILE — 1 kolumna */
@media (max-width: 500px) {
    .ag-controls {
        grid-template-columns: 1fr;
    }

    .ag-controls label {
        font-size: 16px;
    }

    .ag-controls input {
        padding: 12px;
        font-size: 16px;
    }
}

.ag-generate {
    width: 100%;
    padding: 15px;
    border: 2px solid cyan;
    background: transparent;
    color: cyan;
    cursor: pointer;
    transition: 0.3s;
    font-size: 18px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.ag-generate:hover {
    background: cyan;
    color: black;
    box-shadow: 0 0 25px cyan;
}

/* LOADER */
.ag-loader {
    display: none;
    text-align: center;
    margin-top: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* OUTPUT */
.ag-output img[src=""] {
    display: none;
}

/* EFFECTS */
.flash {
    animation: flash 0.3s ease-out;
}

@keyframes flash {
    0% { box-shadow: 0 0 0px cyan; }
    50% { box-shadow: 0 0 20px cyan; }
    100% { box-shadow: 0 0 0px cyan; }
}

.reveal {
    animation: reveal 0.6s ease-out;
}

@keyframes reveal {
    from { opacity: 0; filter: blur(10px); }
    to { opacity: 1; filter: blur(0); }
}

.ag-progress {
    width: 100%;
    height: 8px;
    background: rgba(0,255,255,0.15);
    border: 1px solid cyan;
    box-shadow: 0 0 10px cyan;
    margin-top: 20px;
    overflow: hidden;
    display: none; /* domyślnie ukryty */
}

.ag-progress-bar {
    height: 100%;
    width: 0%;
    background: cyan;
    box-shadow: 0 0 20px cyan;
    transition: width 0.15s linear;
}

/* Wyłączenie natywnych strzałek w input type=number */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

/* FULLSCREEN VIEWER */
.ag-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.92);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.ag-viewer img {
    max-width: 95%;
    max-height: 90%;
    border: 1px solid cyan;
    box-shadow: 0 0 25px cyan;
    border-radius: 6px;
    transition: transform 0.3s ease;
}

.ag-viewer img:hover {
    transform: scale(1.02);
}

.ag-viewer-close {
    position: absolute;
    top: 25px;
    right: 35px;
    font-size: 48px;
    color: cyan;
    cursor: pointer;
    text-shadow: 0 0 15px cyan;
    transition: 0.2s;
}

.ag-viewer-close:hover {
    color: white;
    text-shadow: 0 0 25px cyan;
}

/* MOBILE */
@media (max-width: 600px) {
    .ag-viewer-close {
        font-size: 38px;
        right: 20px;
    }
}

/* HISTORIA MINIATUR — SCROLL PREMIUM */
.ag-history {
    width: 100%;
    margin-top: 20px;
    overflow: hidden; /* kontener bez paska */
}

.ag-history-list {
    display: flex;
    gap: 12px;
    padding: 10px 20px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
}

.ag-history-list::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.ag-history-list img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border: 1px solid cyan;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 0 12px rgba(0,255,255,0.35);
}

.ag-history-list img:hover {
    transform: scale(1.08);
    box-shadow: 0 0 20px cyan;
}

/* MOBILE */
@media (max-width: 600px) {
    .ag-history-list img {
        width: 70px;
        height: 70px;
    }
}
