:root {
    --card-bg: rgba(18, 16, 43, 0.85);
    --input-bg: rgba(28, 24, 61, 0.9);
    --input-border: #4f46e5;
    --input-focus: #6366f1;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-green: #22c55e;
    --accent-blue: #3b82f6;
    
    /* Proměnné pro language picker */
    --li4-color-primary-hsl: 250, 84%, 54%;
    --li4-color-bg-hsl: 13, 7%, 38%;
    --li4-color-contrast-high-hsl: 210, 40%, 98%;
    --li4-color-contrast-higher-hsl: 255, 255%, 255%;
    --li4-color-bg-light-hsl: 20, 30%, 15%;
    --li4-color-bg-lighter-hsl: 28, 24%, 61%;
    --li4-color-white-hsl: 0, 0%, 100%;
    --li4-color-black-hsl: 0, 0%, 0%;
    --li4-space-3xs: 0.25rem;
    --li4-space-2xs: 0.375rem;
    --li4-space-xs: 0.5rem;
    --li4-space-sm: 0.75rem;
    --picker-vertical-gap: 6px;
}

        /* Styly pro rozklikávací menu (details/summary) */
        .download-dropdown {
            background: rgba(13, 7, 38, 0.4);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 8px;
            margin-bottom: 12px;
            overflow: hidden;
            transition: all 0.3s ease;
        }
        .download-dropdown summary {
            padding: 12px 16px;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            color: var(--text-main);
            user-select: none;
            background: rgba(28, 24, 61, 0.6);
            transition: background 0.2s;
        }
        .download-dropdown summary:hover {
            background: rgba(45, 38, 95, 0.8);
        }
        .download-dropdown[open] summary {
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }
        .download-dropdown-content {
            padding: 12px;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .external-link-btn {
            background: var(--accent-blue);
            color: #000;
            padding: 4px 10px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 700;
            text-decoration: none;
            transition: filter 0.2s;
        }
        .external-link-btn:hover {
            filter: brightness(1.1);
        }

body {
    width: 100%;
    height: 100vh;
    margin: 0;
    overflow-y: auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    background: #0d0726;
}

/* Skutečná horní lišta přes celou šířku obrazovky - rozdělená na 3 sloupce pro dokonalé zarovnání */
.window-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: rgba(13, 7, 38, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 100;
}

.window-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
    justify-self: start;
}

.window-actions {
    display: flex;
    gap: 8px;
    justify-self: center;
}

.top-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(28, 24, 61, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: none;
    color: #fff;
}

.top-btn:hover {
    background: rgba(45, 38, 95, 0.95);
    border-color: var(--input-focus);
    transform: translateY(-1px);
}

.window-actions a.top-btn {
    text-decoration: none;
}

/* Language Picker integrace do horní lišty vpravo */
.language-picker {
    position: relative;
    justify-self: end;
    margin-right: 12px;
}
.language-picker__form {
    display: none;
}
.language-picker__button {
    height: 38px;
    min-width: 115px; /* Zafixuje minimální šířku, aby byl box širší než ikonková tlačítka */
    justify-content: space-between; /* Pěkně roztáhne text/vlajku vlevo a šipku vpravo */
    padding: 0 12px;
    background: rgba(28, 24, 61, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.language-picker__button:hover {
    background: rgba(45, 38, 95, 0.95);
    border-color: var(--input-focus);
}
.language-picker__button .li4-icon {
    height: 14px;
    width: 14px;
    display: inline-block;
    fill: currentColor;
}
.language-picker__button .li4-icon:first-of-type {
    display: none;
}
.language-picker__button .li4-icon:last-of-type {
    margin-left: 6px;
}
.language-picker__dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    width: 160px;
    background-color: #12102b;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    padding: 4px 0;
    border-radius: 8px;
    z-index: 105;
    margin-top: var(--picker-vertical-gap);
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 0.2s, opacity 0.2s;
}
.language-picker__button[aria-expanded=true] + .language-picker__dropdown {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s, opacity 0.2s;
}
.language-picker__item {
    display: flex;
    align-items: center;
    text-decoration: none;
    padding: 8px 12px;
    color: var(--text-main);
    font-size: 13px;
    transition: background 0.2s;
}
.language-picker__item:hover {
    background-color: rgba(99, 102, 241, 0.2);
}
.language-picker__item[aria-selected=true] {
    background-color: var(--input-focus);
    color: #fff;
}
.language-picker__flag {
    display: flex;
    align-items: center;
}
.language-picker__flag::before {
    content: "";
    height: 14px;
    width: 20px;
    margin-right: 8px;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    display: inline-block;
    border-radius: 2px;
}
.language-picker__flag--czech::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 480'%3E%3Cpath fill='%23fff' d='M0 0h640v240H0z'/%3E%3Cpath fill='%23d7141a' d='M0 240h640v240H0z'/%3E%3Cpath fill='%2311457e' d='m0 0 320 240L0 480z'/%3E%3C/svg%3E");
}
.language-picker__flag--polish::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 480'%3E%3Cpath fill='%23fff' d='M0 0h640v240H0z'/%3E%3Cpath fill='%23dc143c' d='M0 240h640v240H0z'/%3E%3C/svg%3E");
}
.language-picker__flag--english::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23002781' d='M46,6H2C0.896,6,0,6.896,0,8v32c0,1.104,0.896,2,2,2h44c1.104,0,2-0.896,2-2V8C48,6.896,47.104,6,46,6z'/%3E%3Cpath fill='%23E6E6E6' d='M48,8c0-1.104-0.896-2-2-2h-5.161L28,15.876V6h-8v9.876L7.161,6H2C0.896,6,0,6.896,0,8v2.586L12.239,20H0v8 h12.239L0,37.415V40c0,1.104,0.896,2,2,2h5.161L20,32.124V42h8v-9.876L40.839,42H46c1.104,0,2-0.896,2-2v-2.585L35.761,28H48v-8 H35.761L48,10.586V8z'/%3E%3Cpolygon fill='%23D10D24' points='48,22 26,22 26,6 22,6 22,22 0,22 0,26 22,26 22,42 26,42 26,26 48,26 '/%3E%3C/svg%3E");
}
.language-picker__flag--deutsch::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M48,18H0V8c0-1.105,0.895-2,2-2h44c1.105,0,2,0.895,2,2V18z'/%3E%3Crect y='18' fill='%23EE0000' width='48' height='12'/%3E%3Cpath fill='%23FDCF00' d='M48,40c0,1.105-0.895,2-2,2H2c-1.105,0-2-0.895-2-2V30h48V40z'/%3E%3C/svg%3E");
}
.li4-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Kosmické pozadí */
.sky {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #171038 0%, #0d0726 100%);
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    border-radius: 50%;
    background: transparent;
    animation: animStar 100s linear infinite;
    z-index: 2;
}
.stars::after {
    content: " ";
    position: absolute;
    top: 2560px;
    width: 1px;
    height: 1px;
    border-radius: 50%;
    background: transparent;
}

.stars2 {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: transparent;
    animation: animStar 125s linear infinite;
    z-index: 2;
}
.stars2::after {
    content: " ";
    position: absolute;
    top: 2560px;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: transparent;
}

.stars3 {
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: transparent;
    animation: animStar 175s linear infinite;
    z-index: 2;
}
.stars3::after {
    content: " ";
    position: absolute;
    top: 2560px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: transparent;
}

.comet {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 5px;
    height: 85px;
    border-top-left-radius: 50%;
    border-top-right-radius: 50%;
    background: linear-gradient(to top, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
    animation: animShootingStar 10s linear infinite;
    z-index: 2;
}

@keyframes animStar {
    from { transform: translateY(0px); }
    to { transform: translateY(-2560px) translateX(-2560px); }
}

@keyframes animShootingStar {
    from {
        transform: translateY(0px) translateX(0px) rotate(-45deg);
        opacity: 1;
        height: 5px;
    }
    to {
        transform: translateY(-2560px) translateX(-2560px) rotate(-45deg);
        opacity: 1;
        height: 800px;
    }
}

.container {
    width: 100%;
    max-width: 500px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 28px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    z-index: 10;
    margin-top: 30px;
}

/* Nadpis */
.matrix-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
}

.matrix-text {
    color: #0f0;
    font-size: 44px;
    font-family: monospace;
    letter-spacing: 2px;
    position: relative;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.6), 0 0 20px rgba(0, 255, 0, 0.4);
    margin: 0;
}

.matrix-text::before {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    animation: glitch 2s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    transform: translate(-2px, -2px);
    color: #0f0;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.8);
}

.tabs {
    display: flex;
    margin-bottom: 22px;
    background: rgba(13, 7, 38, 0.6);
    border-radius: 10px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.25s ease;
}

.tab.active.encrypt { background: var(--accent-green); color: #000; box-shadow: 0 0 15px rgba(34, 197, 94, 0.3); }
.tab.active.decrypt { background: var(--accent-blue); color: #000; box-shadow: 0 0 15px rgba(59, 130, 246, 0.3); }
.tab:not(.active) { color: var(--text-muted); }
.tab:not(.active):hover { color: var(--text-main); background: rgba(255, 255, 255, 0.03); }

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    letter-spacing: 0.3px;
}

textarea, input[type="password"], input[type="text"] {
    width: 100%;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: var(--text-main);
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 100px;
    transition: all 0.2s ease;
}

input[type="password"], input[type="text"] {
    min-height: auto;
}

textarea:focus, input[type="password"]:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--input-focus);
    background: rgba(35, 30, 75, 0.95);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.show-pwd {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.show-pwd input[type="checkbox"] {
    width: auto;
    cursor: pointer;
    margin: 0;
    accent-color: var(--input-focus);
}

button:not(.top-btn):not(.language-picker__button) {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    font-size: 15px;
    color: #000000;
    transition: all 0.2s ease;
}

button:not(.top-btn):not(.language-picker__button):hover { 
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-encrypt { 
    background: var(--accent-green); 
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.25);
}

.btn-decrypt { 
    background: var(--accent-blue); 
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.output-section {
    margin-top: 20px;
    display: none;
}

.output-box {
    background: var(--input-bg);
    color: var(--text-main);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    word-break: break-all;
    font-family: monospace;
    font-size: 13px;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.btn-copy {
    margin-top: 10px;
    background: #e2e8f0;
    color: #000000;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.error { 
    color: #f87171; 
    font-size: 13px; 
    margin-top: 10px; 
    text-align: center; 
    font-weight: 500;
}

@keyframes glitch {
    0%, 100% {
        clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
        transform: translate(0);
    }
    33% {
        clip-path: polygon(0 0, 100% 0, 100% 15%, 0 15%);
        transform: translate(-5px, -5px);
    }
    66% {
        clip-path: polygon(0 85%, 100% 85%, 100% 100%, 0 100%);
        transform: translate(5px, 5px);
    }
}

/* =========================================================
   RESPONZIVNÍ ÚPRAVY PRO MOBILY A TABLETY
   ========================================================= */

/* Tablety a menší notebooky - jemné zmenšení, header zůstává v jednom řádku */
@media (max-width: 820px) {
    .matrix-text {
        font-size: 36px;
    }
    .container {
        padding: 22px;
    }
    .window-title {
        font-size: 12px;
    }
    .language-picker__button {
        min-width: 100px;
    }
}

/* Mobily na šířku i na výšku - horní lišta se rozpadne na dva řádky,
   místo aby se vše mačkalo/zalamovalo přes sebe v pevné výšce 48px.
   Zůstává position:fixed (stejně jako na desktopu), aby šla vždy
   od kraje do kraje obrazovky - nezávisle na paddingu <body>. */
@media (max-width: 560px) {
    .window-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        min-height: 64px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 10px 12px;
        padding: 14px 16px;
    }
    .window-title {
        flex: 1 1 auto;
        font-size: 13px;
        text-align: left;
    }
    .window-actions {
        order: 3;
        flex: 1 1 100%;
        justify-content: center;
        gap: 8px;
    }
    .language-picker {
        margin-right: 0;
    }
    .language-picker__button {
        height: 38px;
        min-width: 96px;
        font-size: 13px;
    }
    .top-btn {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }

    body {
        padding: 12px;
        padding-top: 128px; /* místo pro dvouřádkovou fixed lištu, ať ji obsah nepodjíždí */
    }
    .container {
        margin-top: 0;
        padding: 18px;
        border-radius: 12px;
    }
    .matrix-text {
        font-size: 30px;
    }
    .tab {
        font-size: 13px;
        padding: 9px 4px;
    }
    textarea, input[type="password"], input[type="text"] {
        font-size: 16px; /* zabrání automatickému přiblížení na iOS při focusu inputu */
    }
}

/* Velmi malé telefony */
@media (max-width: 380px) {
    .matrix-text {
        font-size: 24px;
    }
    .window-title {
        font-size: 11px;
    }
    .top-btn {
        width: 34px;
        height: 34px;
    }
    .language-picker__button {
        min-width: 76px;
        padding: 0 8px;
    }
    .container {
        padding: 14px;
    }
}
