*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    color: #12304a;
    background:
        radial-gradient(circle at top left, rgba(255, 145, 77, 0.18), transparent 30%),
        radial-gradient(circle at top right, rgba(33, 92, 160, 0.12), transparent 30%),
        linear-gradient(180deg, #f7fbff 0%, #eef4fb 100%);
}

input,
textarea,
button {
    font: inherit;
}

.app-shell {
    width: min(1400px, calc(100% - 32px));
    margin: 0 auto;
    height: 100vh;
    padding: 18px 0;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 16px;
}

.site-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #ff8e3c 0%, #f97316 100%);
    box-shadow: 0 10px 25px rgba(249, 115, 22, 0.28);
    flex: 0 0 auto;
}

.site-header h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.05;
    color: #184b7a;
}

.tagline {
    margin: 4px 0 0;
    color: #4f6b86;
    font-size: 0.98rem;
}

.trust-note {
    max-width: 420px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(24, 75, 122, 0.08);
    border: 1px solid rgba(24, 75, 122, 0.12);
    color: #234766;
    font-size: 0.92rem;
    line-height: 1.4;
}

.panel {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(24, 75, 122, 0.12);
    border-radius: 18px;
    box-shadow: 0 12px 35px rgba(17, 44, 72, 0.08);
    backdrop-filter: blur(8px);
}

.key-panel {
    padding: 18px 20px;
}

.panel-heading {
    margin-bottom: 12px;
}

.panel-heading h2 {
    margin: 0 0 4px;
    font-size: 1.1rem;
    color: #184b7a;
}

.panel-heading p {
    margin: 0;
    font-size: 0.92rem;
    color: #5a7289;
}

.key-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
}

.key-input,
.text-area {
    width: 100%;
    border: 1px solid rgba(24, 75, 122, 0.18);
    border-radius: 14px;
    background: #ffffff;
    color: #12304a;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.key-input:focus,
.text-area:focus {
    border-color: #2b6cb0;
    box-shadow: 0 0 0 4px rgba(43, 108, 176, 0.12);
}

.key-input {
    height: 48px;
    padding: 0 14px;
}

.workspace {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.text-panel {
    min-height: 0;
    padding: 18px;
    display: flex;
    flex-direction: column;
}

.plain-panel {
    border-top: 5px solid #ff8e3c;
}

.cipher-panel {
    border-top: 5px solid #2b6cb0;
}

.text-area {
    flex: 1 1 auto;
    min-height: 0;
    resize: none;
    padding: 14px;
    line-height: 1.45;
}

.plain-area {
    background: linear-gradient(180deg, #fffaf5 0%, #ffffff 100%);
}

.cipher-area {
    background: linear-gradient(180deg, #f5faff 0%, #ffffff 100%);
}

.panel-footer {
    margin-top: 14px;
    display: grid;
    gap: 12px;
}

.button-row,
.inline-options,
.encoding-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.encoding-label {
    font-weight: 700;
    color: #184b7a;
    margin-right: 2px;
}

.btn {
    appearance: none;
    border: 0;
    border-radius: 12px;
    height: 40px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, #ff8e3c 0%, #f97316 100%);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(249, 115, 22, 0.22);
}

.btn-secondary {
    background: #eef4fb;
    color: #184b7a;
    border: 1px solid rgba(24, 75, 122, 0.12);
}

.radio-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    border-radius: 999px;
    background: #f4f8fc;
    border: 1px solid rgba(24, 75, 122, 0.12);
    color: #184b7a;
    font-size: 0.92rem;
}

.radio-pill input {
    margin: 0;
}

::placeholder {
    color: #8b9db0;
}

/* Tablet */
@media (max-width: 1100px) {
    .site-header {
        grid-template-columns: 1fr;
    }

    .trust-note {
        max-width: none;
    }

    .key-layout {
        grid-template-columns: 1fr;
    }
}

/* Mobile / stacked layout */
@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .app-shell {
        height: auto;
        min-height: 100vh;
        padding: 16px 0 20px;
        width: min(100% - 20px, 760px);
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .text-panel {
        min-height: unset;
    }

    .text-area {
        min-height: 260px;
        resize: vertical;
    }

    .site-header h1 {
        font-size: 1.7rem;
    }

    .brand-mark {
        width: 46px;
        height: 46px;
        font-size: 1.2rem;
    }
}