:root {
    color-scheme: light;
    --panel-bg: rgba(255, 255, 255, 0.50);
    --panel-border: rgba(255, 255, 255, 0.82);
    --text: #121212;
    --muted: #545454;
    --dark: #141414;
    --dark-hover: #292929;
    --line: rgba(0, 0, 0, 0.18);
    --focus: #9d1422;
    --danger: #aa1f2f;
    --radius: 24px;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.30);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(rgba(2, 16, 31, 0.08), rgba(2, 16, 31, 0.32)),
        url('/app/assets/images/background.jpg') center center / cover no-repeat fixed;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(circle at center, transparent 10%, rgba(0, 15, 31, 0.28) 100%);
    pointer-events: none;
}

.page-shell {
    width: min(92vw, 700px);
    padding: 32px 0 82px;
}

.welcome-panel {
    position: relative;
    padding: clamp(28px, 4vw, 40px) clamp(28px, 5vw, 42px);
    text-align: center;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    background: var(--panel-bg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(130%);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.intro {
    max-width: 600px;
    margin: 0 auto;
    font-size: clamp(1.08rem, 2.5vw, 1.35rem);
    line-height: 1.55;
}

.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 26px 0 22px;
    color: var(--muted);
}

.divider::before,
.divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

.shield {
    width: 34px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 2px solid var(--text);
    border-radius: 10px 10px 14px 14px;
    font-size: 0.95rem;
    font-weight: 800;
}

.actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

button,
input,
select,
textarea {
    font: inherit;
}

.button {
    min-height: 62px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: 1px solid var(--dark);
    border-radius: 13px;
    padding: 14px 22px;
    cursor: pointer;
    font-size: 1.08rem;
    font-weight: 650;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
}

.button:active {
    transform: translateY(0);
}

.button:focus-visible,
.icon-button:focus-visible,
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
    outline: 3px solid rgba(157, 20, 34, 0.28);
    outline-offset: 2px;
}

.button-primary {
    color: #fff;
    background: var(--dark);
}

.button-primary:hover {
    background: var(--dark-hover);
}

.button-secondary {
    color: var(--text);
    background: rgba(255, 255, 255, 0.78);
}

.button-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
}

.page-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 18px;
    display: flex;
    justify-content: center;
    gap: 11px;
    padding: 0 20px;
    color: #fff;
    font-size: 0.72rem;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.75);
}

.page-footer a {
    color: inherit;
    text-decoration: none;
}

.page-footer a:hover {
    text-decoration: underline;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: rgba(0, 10, 22, 0.66);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-backdrop.is-open {
    display: flex;
}

.modal {
    width: min(100%, 690px);
    max-height: min(88vh, 820px);
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.84);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 26px 28px 20px;
    border-bottom: 1px solid #e4e4e4;
    background: rgba(255, 255, 255, 0.97);
}

.modal-title {
    margin: 0;
    font-size: 1.55rem;
}

.modal-subtitle {
    margin: 7px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.icon-button {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border: 0;
    border-radius: 50%;
    background: #ededed;
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
}

.modal-body {
    padding: 26px 28px 30px;
}

.notice {
    margin-bottom: 24px;
    padding: 15px 17px;
    border-left: 4px solid var(--danger);
    border-radius: 8px;
    background: #f6ecee;
    line-height: 1.5;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field.full {
    grid-column: 1 / -1;
}

.field label {
    font-size: 0.93rem;
    font-weight: 700;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid #b9b9b9;
    border-radius: 9px;
    padding: 12px 13px;
    color: var(--text);
    background: #fff;
}

.field textarea {
    min-height: 105px;
    resize: vertical;
}

.field small {
    color: var(--muted);
    line-height: 1.35;
}

.address-field {
    display: flex;
    align-items: stretch;
}

.address-field input {
    border-radius: 9px 0 0 9px;
}

.address-domain {
    display: flex;
    align-items: center;
    padding: 0 13px;
    border: 1px solid #b9b9b9;
    border-left: 0;
    border-radius: 0 9px 9px 0;
    background: #eeeeee;
    white-space: nowrap;
    font-weight: 650;
}

.checkbox-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    margin-top: 4px;
    line-height: 1.45;
}

.checkbox-row input {
    margin-top: 4px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 26px;
}

.modal-actions .button {
    min-height: 48px;
    padding: 10px 18px;
    font-size: 1rem;
}

.access-placeholder {
    padding: 12px 0 2px;
    color: var(--muted);
    line-height: 1.6;
}

@media (max-width: 680px) {
    body {
        justify-content: flex-start;
        background-attachment: scroll;
    }

    .page-shell {
        width: min(94vw, 520px);
        padding-top: 36px;
        padding-bottom: 100px;
    }

    .welcome-panel {
        padding: 28px 22px;
        border-radius: 20px;
    }

    .actions,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .page-footer {
        position: absolute;
        flex-wrap: wrap;
    }

    .modal-header,
    .modal-body {
        padding-left: 20px;
        padding-right: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

/* Access-only landing page */
.actions-single {
    grid-template-columns: minmax(220px, 360px);
    justify-content: center;
}

.access-modal {
    width: min(100%, 560px);
}

.access-fields {
    display: grid;
    gap: 18px;
}

.access-field {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    align-items: center;
    gap: 14px;
}

.access-field > label {
    font-size: 1rem;
    text-align: right;
}

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

.passphrase-row small {
    font-size: 0.75rem;
    white-space: nowrap;
}

.access-actions {
    justify-content: center;
}

.unlock-button {
    min-width: 210px;
}

@media (max-width: 560px) {
    .access-field {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .access-field > label {
        text-align: left;
    }

    .passphrase-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}

/* Both visible interface panels at 50% size. */
.page-shell {
    transform: scale(0.5);
    transform-origin: center center;
}

.access-modal {
    transform: scale(0.5);
    transform-origin: center center;
}

@media (max-width: 680px) {
    .page-shell {
        width: min(188vw, 1040px);
        transform: scale(0.5);
        transform-origin: top center;
    }

    .access-modal {
        width: min(190vw, 690px);
        transform: scale(0.5);
        transform-origin: center center;
    }
}

/* Login result modal */
.result-modal {
    width: min(100%, 420px);
    transform: scale(0.5);
    transform-origin: center center;
}

.result-body {
    text-align: center;
}

.result-body p {
    margin: 14px 0 24px;
    font-size: 1.45rem;
    font-weight: 700;
}

.result-symbol {
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    margin: 4px auto 0;
    border: 3px solid currentColor;
    border-radius: 50%;
    font-size: 2rem;
    font-weight: 800;
}

.result-success .result-symbol {
    color: #1d7438;
}

.result-denied .result-symbol {
    color: #a51f2d;
}

.result-close {
    min-width: 150px;
}

@media (max-width: 680px) {
    .result-modal {
        width: min(190vw, 600px);
        transform: scale(0.5);
    }
}

/* Key access layout */
.access-code-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    padding-left: 98px;
}

.compact-access-field {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.compact-access-field label {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
}

.compact-access-field small {
    grid-column: 2;
    margin-top: -4px;
    color: var(--muted);
    font-size: 0.72rem;
    white-space: nowrap;
}

@media (max-width: 560px) {
    .access-code-row {
        grid-template-columns: 1fr;
        padding-left: 0;
    }

    .compact-access-field {
        grid-template-columns: 70px minmax(0, 1fr);
    }
}

/* Compact PK-U and VKP controls beside each other. */
.access-code-row {
    grid-template-columns: max-content max-content;
    justify-content: center;
    align-items: start;
    gap: 28px;
    padding-left: 0;
}

.compact-access-field {
    grid-template-columns: auto auto;
    width: max-content;
}

.compact-access-field input {
    min-width: 0;
}

#pk-u {
    width: 112px;
}

#vkp {
    width: 152px;
}

@media (max-width: 560px) {
    .access-code-row {
        grid-template-columns: max-content max-content;
        justify-content: center;
        gap: 18px;
        padding-left: 0;
    }

    .compact-access-field {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .compact-access-field small {
        grid-column: 1;
        margin-top: -2px;
    }
}
