html { height: 100%; }
html[data-bg="charcoal"] { --page: #2e3136; }
html[data-bg="graphite"] { --page: #3c4046; }
html[data-bg="iron"] { --page: #4e545c; }
html[data-bg="slate"] { --page: #5c6770; }
html[data-bg="pewter"] { --page: #6f6a63; }
html[data-bg="taupe"] { --page: #7d756c; }
html[data-bg="stone"] { --page: #8f877f; }
html[data-bg="ash"] { --page: #b1aaa3; }
html[data-bg="fog"] { --page: #d5d0ca; }
html[data-bg="mist"] { --page: #e6e2dc; }
html[data-bg="linen"] { --page: #f4f1eb; }
html[data-bg="porcelain"] { --page: #f5f7f8; }
html[data-theme="dark"] {
    color-scheme: dark;
    --ink: #f4f7fb;
    --card: #23262b;
    --line: rgba(255, 255, 255, 0.14);
    --top: rgba(24, 26, 30, 0.94);
    --field: rgba(255, 255, 255, 0.06);
    --field-line: rgba(255, 255, 255, 0.28);
    --link: #9ecbff;
    --danger: #ffb4b4;
    --ok: #b7f0c8;
}
html[data-theme="light"] {
    color-scheme: light;
    --ink: #1c1e22;
    --card: #ffffff;
    --line: rgba(0, 0, 0, 0.12);
    --top: rgba(255, 255, 255, 0.94);
    --field: #ffffff;
    --field-line: rgba(0, 0, 0, 0.22);
    --link: #0b57d0;
    --danger: #9b1c1c;
    --ok: #0d6b3a;
}
body {
    margin: 0;
    min-height: 100dvh;
    font-family: "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--page, #2e3136);
}
.stage {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: var(--page, #2e3136);
}
.backdrop {
    position: absolute;
    inset: 0;
    background: var(--page, #2e3136);
}
.frame {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
.frame-app {
    padding-top: max(4.6rem, env(safe-area-inset-top));
    padding-bottom: max(4.6rem, env(safe-area-inset-bottom));
}
.top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: center;
    padding: max(0.8rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.8rem max(1rem, env(safe-area-inset-left));
    background: var(--top);
    color: var(--ink);
    border-bottom: 1px solid var(--line);
}
.top a { color: var(--ink); }
main {
    box-sizing: border-box;
    width: min(28rem, 100%);
    margin-top: auto;
    margin-bottom: auto;
    padding: 1rem 1.2rem 1.4rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}
main.wide {
    width: min(40rem, 100%);
}
main.center {
    text-align: center;
}
label { display: block; margin: 0.8rem 0; }
input, select, button { font: inherit; }
input, select {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.7rem 0.75rem;
    color: var(--ink);
    background: var(--field);
    border: 1px solid var(--field-line);
    border-radius: 8px;
}
fieldset.colors {
    border: 0;
    margin: 0.9rem 0 1rem;
    padding: 0;
}
legend { font-weight: 650; }
.swatches {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem 0.4rem;
    margin-top: 0.55rem;
}
.swatches label {
    margin: 0;
    cursor: pointer;
}
.swatches input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
}
.swatch {
    display: block;
    height: 2.15rem;
    border: 1px solid rgba(0, 0, 0, 0.28);
    border-radius: 8px;
}
.swatch-name {
    display: block;
    margin-top: 0.28rem;
    font-size: 0.72rem;
    line-height: 1.15;
    text-align: center;
}
.swatches input:checked + .swatch,
.swatches input:focus-visible + .swatch {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); text-align: left; padding: 0.45rem; }
a { color: var(--link); }
.error { color: var(--danger); }
.saved { color: var(--ok); }
.qr {
    display: block;
    width: min(220px, 72%);
    height: auto;
    margin: 0.8rem auto 1rem;
    padding: 0.55rem;
    background: white;
    border-radius: 12px;
}
.letter { border: 1px solid var(--line); padding: 1.2rem; border-radius: 12px; }
button {
    padding: 0.65rem 1rem;
    color: white;
    background: #1d6fd6;
    border: 0;
    border-radius: 8px;
}
h1, h2 { font-weight: 650; }
h2 { font-size: 1.05rem; }

@media (max-width: 720px) {
    main { padding: 0.9rem; }
    table { display: block; overflow-x: auto; }
    .swatches { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Sign-in and the authenticator step keep the original graphic. */
html.arrival {
    color-scheme: dark;
}
html.arrival body {
    color: #f4f7fb;
    background: #05070b;
}
html.arrival .stage { background: #05070b; }
html.arrival .backdrop {
    inset: -42%;
    background-color: #05070b;
    background-image: url("/static/media/images/andrew-kliatskyi-r4HT6aurLQw-unsplash.jpg");
    background-repeat: no-repeat;
    background-position: right center;
    background-size: cover;
    animation: backdrop-drift 16s ease-in-out infinite alternate;
    animation-delay: calc(var(--drift-phase, 0) * -1s);
    will-change: transform;
}
html.arrival.step-open main { visibility: hidden; }
html.arrival dialog.step-modal {
    width: min(28rem, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
    margin: auto;
    padding: 1rem 1.2rem 1.4rem;
    color: #f4f7fb;
    background: rgba(8, 12, 18, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    text-align: center;
}
html.arrival dialog.step-modal::backdrop { background: transparent; }
@media (prefers-reduced-motion: no-preference) {
    html.arrival dialog.step-modal[open] { animation: step-in 180ms ease; }
}
@keyframes step-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
@keyframes backdrop-drift {
    from { transform: scale(1.08) translate3d(4%, 2%, 0); }
    to { transform: scale(1.22) translate3d(-8%, -6%, 0); }
}
@media (prefers-reduced-motion: reduce) {
    html.arrival .backdrop {
        animation: none;
        inset: 0;
        transform: none;
    }
}
html.arrival main {
    background: rgba(8, 12, 18, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: none;
}
html.arrival input,
html.arrival select {
    color: #f4f7fb;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.28);
}
html.arrival a { color: #9ecbff; }
html.arrival .error { color: #ffb4b4; }
@media (orientation: landscape) {
    html.arrival .backdrop { background-position: 80% center; }
}
@media (max-width: 720px) and (orientation: portrait) {
    html.arrival .backdrop { background-position: right center; }
}
