:root {
    color-scheme: light;
    --navy-950: #071923;
    --navy-900: #0b2430;
    --teal: #1a6b73;
    --teal-dark: #12555c;
    --paper: #f7f8f7;
    --white: #fff;
    --ink: #14262d;
    --muted: #687981;
    --line: #dce3e4;
    --danger: #a33b2e;
    --success: #176646;
    --focus: #51c5ca;
    --shadow: 0 18px 50px rgba(2, 15, 22, .2);
}

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

html {
    min-width: 320px;
    min-height: 100%;
    background: var(--navy-950);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--white);
    background: var(--navy-950);
    font-size: 16px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
}

body.dialog-open { overflow: hidden; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }

.portal-shell {
    position: relative;
    isolation: isolate;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    overflow: hidden;
}

.portal-shell::before,
.portal-shell::after {
    position: fixed;
    z-index: -2;
    inset: 0;
    content: "";
    pointer-events: none;
}

.portal-shell::before {
    background: url("../../img-app/intro-bg3.jpg") 58% center / cover no-repeat;
    transform: scale(1.01);
}

.portal-shell::after {
    z-index: -1;
    background:
        linear-gradient(90deg, rgba(5, 23, 33, .96) 0%, rgba(8, 32, 43, .88) 52%, rgba(7, 25, 35, .68) 100%),
        linear-gradient(180deg, rgba(5, 22, 31, .25), rgba(4, 18, 27, .78));
}

.page-width {
    width: min(1040px, calc(100% - 48px));
    margin-inline: auto;
}

.topbar {
    display: flex;
    min-height: 82px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, .16);
}

.brand {
    display: inline-flex;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

.brand-logo {
    display: block;
    width: auto;
    height: 38px;
}

.topbar-label {
    color: rgba(237, 244, 246, .68);
    font-size: .7rem;
}

.topbar-label { letter-spacing: .08em; }

.launcher {
    display: flex;
    min-height: calc(100vh - 82px);
    flex: 1;
    flex-direction: column;
    justify-content: center;
    padding-block: clamp(42px, 8vh, 82px) 24px;
}

.launcher-heading { margin-bottom: 28px; }
.launcher-heading p, .launcher-heading h1 { margin: 0; }

.launcher-heading p {
    margin-bottom: 7px;
    color: rgba(230, 241, 243, .7);
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.launcher-heading h1 {
    font-size: clamp(2.3rem, 5vw, 3.8rem);
    font-weight: 620;
    letter-spacing: -.045em;
    line-height: 1;
}

.applications-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.app-card {
    display: flex;
    min-width: 0;
    min-height: 238px;
    flex-direction: column;
    align-items: stretch;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, .66);
    border-radius: 12px;
    color: var(--ink);
    background: rgba(249, 250, 249, .95);
    box-shadow: var(--shadow);
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.app-card:hover:not(:disabled) {
    border-color: rgba(126, 203, 207, .95);
    box-shadow: 0 22px 58px rgba(2, 15, 22, .28);
    transform: translateY(-3px);
}

.app-card:disabled { cursor: not-allowed; }
.app-card.is-unavailable { opacity: .65; }

.app-visual {
    display: flex;
    height: 94px;
    align-items: center;
}

.app-visual img {
    display: block;
    width: auto;
    max-width: 168px;
    max-height: 78px;
    object-fit: contain;
}

.app-visual--support { padding-left: 9px; }

.support-lock {
    position: relative;
    width: 44px;
    height: 36px;
    margin-top: 13px;
    border-radius: 6px;
    background: var(--teal);
}

.support-lock::before {
    position: absolute;
    top: -19px;
    left: 10px;
    width: 24px;
    height: 23px;
    border: 3px solid var(--teal);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
    content: "";
}

.support-lock::after {
    position: absolute;
    top: 11px;
    left: 19px;
    width: 6px;
    height: 12px;
    border-radius: 4px;
    background: var(--white);
    content: "";
}

.app-name {
    margin-top: 20px;
    font-size: 1.08rem;
    font-weight: 680;
    letter-spacing: -.015em;
}

.app-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .76rem;
    font-weight: 650;
}

.app-action > span {
    color: var(--teal);
    font-size: 1rem;
    transition: transform 160ms ease;
}

.app-card:hover:not(:disabled) .app-action > span { transform: translateX(3px); }
.app-card--support:hover:not(:disabled) .app-action > span { transform: translateY(2px); }

.portal-footer {
    margin-top: auto;
    padding-top: 34px;
    color: rgba(232, 241, 243, .55);
    font-size: .64rem;
    font-weight: 650;
    letter-spacing: .13em;
    text-transform: uppercase;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

.support-dialog {
    width: min(520px, calc(100% - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    overflow: auto;
    border: 0;
    border-radius: 14px;
    color: var(--ink);
    background: var(--paper);
    box-shadow: 0 28px 90px rgba(0, 9, 14, .52);
}

.support-dialog:not([open]) { display: none; }
.support-dialog::backdrop { background: rgba(1, 13, 20, .78); backdrop-filter: blur(5px); }
.dialog-shell { padding: clamp(24px, 5vw, 34px); }

.dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.dialog-header p, .dialog-header h2 { margin: 0; }

.dialog-header p {
    margin-bottom: 5px;
    color: var(--teal);
    font-size: .68rem;
    font-weight: 750;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.dialog-header h2 {
    font-size: clamp(1.6rem, 5vw, 2rem);
    font-weight: 650;
    letter-spacing: -.035em;
}

.dialog-close {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    place-items: center;
    padding: 0 0 2px;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-size: 1.25rem;
}

.dialog-close:hover { color: var(--ink); background: #edf1f1; }

.dialog-description {
    margin: 16px 0 18px;
    color: var(--muted);
    font-size: .86rem;
}

.installer-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--white);
    font-size: .74rem;
}

.installer-line strong { font-size: .8rem; }
.installer-line span { color: var(--muted); }

.installer-details {
    margin: 8px 0 20px;
    padding-inline: 4px;
    color: var(--muted);
    font-size: .7rem;
}

.installer-details summary { width: fit-content; cursor: pointer; }
.installer-details span, .installer-details code { display: block; margin-top: 7px; }

.installer-details code {
    overflow-wrap: anywhere;
    color: #586b72;
    font-size: .62rem;
}

.support-form { display: grid; gap: 18px; margin-top: 20px; }
.field-group { display: grid; gap: 7px; }
.field-group label { font-size: .78rem; font-weight: 680; }

.text-input {
    width: 100%;
    height: 48px;
    padding: 0 13px;
    border: 1px solid #cbd5d7;
    border-radius: 8px;
    color: var(--ink);
    background: var(--white);
    caret-color: var(--teal);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.text-input:hover { border-color: #aebdc0; }
.text-input:focus { border-color: var(--teal); outline: 0; box-shadow: 0 0 0 3px rgba(26, 107, 115, .13); }

.code-input, .captcha-input {
    font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
    font-weight: 700;
}

.code-input { font-size: 1.22rem; letter-spacing: .28em; }
.captcha-input { font-size: 1.05rem; letter-spacing: .16em; text-transform: uppercase; }

.captcha-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
}

.captcha-image-frame {
    display: flex;
    min-height: 70px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid #cbd5d7;
    border-radius: 8px;
    background: #e7edef;
}

.captcha-image-frame img {
    display: block;
    width: 220px;
    max-width: 100%;
    height: 68px;
    object-fit: contain;
    transition: opacity 140ms ease;
}

.captcha-image-frame img.is-loading { opacity: .4; }

.captcha-reload {
    display: inline-flex;
    min-width: 105px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding-inline: 13px;
    border: 1px solid #cbd5d7;
    border-radius: 8px;
    color: var(--ink);
    background: var(--white);
    cursor: pointer;
    font-size: .74rem;
    font-weight: 650;
}

.captcha-reload:hover { background: #edf1f1; }

.form-status {
    min-height: 20px;
    margin: -4px 0;
    color: var(--muted);
    font-size: .75rem;
}

.form-status[data-tone="error"] { color: var(--danger); }
.form-status[data-tone="success"] { color: var(--success); }

.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }

.button {
    min-height: 44px;
    padding-inline: 17px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: .76rem;
    font-weight: 700;
    transition: background-color 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .7; }
.button--secondary { border-color: #cbd5d7; color: var(--ink); background: transparent; }
.button--secondary:hover:not(:disabled) { background: #e9eeee; }
.button--primary { min-width: 170px; color: var(--white); background: var(--teal); }
.button--primary:hover:not(:disabled) { background: var(--teal-dark); }

.button-progress {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

.button.is-loading { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.button.is-loading .button-progress { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 780px) {
    .applications-grid { grid-template-columns: 1fr; }

    .app-card {
        display: grid;
        min-height: 114px;
        grid-template-columns: 100px minmax(0, 1fr) auto;
        align-items: center;
        gap: 18px;
        padding: 18px 20px;
    }

    .app-visual { width: 100px; height: 76px; }
    .app-visual img { max-width: 96px; max-height: 62px; }
    .app-visual--support { padding-left: 14px; }
    .app-name { margin: 0; }

    .app-action {
        min-width: 78px;
        margin: 0;
        padding: 0 0 0 16px;
        border-top: 0;
        border-left: 1px solid var(--line);
    }
}

@media (max-width: 560px) {
    .page-width { width: calc(100% - 30px); }
    .topbar { min-height: 70px; }
    .brand-logo { height: 32px; }
    .topbar-label { display: none; }

    .launcher {
        min-height: calc(100vh - 70px);
        justify-content: flex-start;
        padding-block: 42px 20px;
    }

    .launcher-heading { margin-bottom: 22px; }
    .applications-grid { gap: 10px; }

    .app-card {
        min-height: 100px;
        grid-template-columns: 72px minmax(0, 1fr) auto;
        gap: 13px;
        padding: 14px;
        border-radius: 10px;
    }

    .app-visual { width: 72px; height: 66px; }
    .app-visual img { max-width: 70px; max-height: 54px; }
    .app-visual--support { padding-left: 10px; }
    .support-lock { transform: scale(.83); transform-origin: left center; }
    .app-name { font-size: .96rem; }
    .app-action { min-width: auto; padding-left: 12px; font-size: 0; }
    .app-action > span { font-size: 1rem; }
    .portal-footer { padding-top: 26px; }

    .support-dialog {
        width: calc(100% - 18px);
        max-height: calc(100vh - 18px);
        border-radius: 11px;
    }

    .captcha-row { grid-template-columns: 1fr; }
    .captcha-reload { min-height: 42px; }
    .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
    .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (forced-colors: active) {
    .app-card, .support-dialog, .text-input, .captcha-reload, .button {
        border: 1px solid CanvasText;
    }
}
