* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ---------- Sizes ----------
   Every size in this file is a multiple of --vmin, so the whole page grows and
   shrinks with the screen like a picture. 1vmin is 1% of the screen's shorter side.

   The three lines that set --vmin are the only dials:
     - wide screens (desktop, laptop, phone held sideways): 1 unit = 1vmin
     - tall screens (tablet held upright):                  1 unit = 1.4vmin
     - narrow tall screens (phone held upright):            1 unit = 2.3vmin
   A phone's shorter side is so small that plain vmin would make text unreadable,
   which is why the upright cases use a bigger unit.

   px appears in two kinds of places only:
     - the 6.5px floor just below: in a very small window the unit stops shrinking
       there, so text never drops below a readable size
     - hairline borders on the panels and tabs (1-3px): a fraction of a vmin can
       round down to nothing on a small screen. The footer has none: its border,
       text shadow and outline are in vmin like the rest of it.
*/
:root {
    --vmin: max(1vmin, 6.5px);
}

@media (max-aspect-ratio: 4/5) {
    :root { --vmin: max(1.4vmin, 6.5px); }
}

@media (max-aspect-ratio: 5/8) {
    :root { --vmin: max(2.3vmin, 6.5px); }
}

:root {
    --footer-h: calc(1.35 * var(--vmin));   /* height of the red footer bar; the layout above it shrinks to match */
    --tab-w: calc(3.25 * var(--vmin));      /* width of the side tabs */
    --tab-font: calc(0.8 * var(--vmin));    /* size of the names on the side tabs.
                                               If all the names together are taller than the screen,
                                               app.js shrinks them just enough to fit (fitTabLabels). */
    --footer-font: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
    --bg-dim: 0.45;   /* 0 = photo untouched, 0.9 = nearly black; set by the slider */
}

body, html {
    width: 100%;
    height: 100%;
    font-family: Arial, sans-serif;
    font-size: calc(1.8 * var(--vmin));   /* the size of any text that sets none of its own */
    overflow: hidden;
    background: #14101c;
}

/* Lighthouse photo with an adjustable dark layer on top */
body {
    background:
        linear-gradient(rgba(12, 8, 20, var(--bg-dim)), rgba(12, 8, 20, var(--bg-dim))),
        url('/static/lighthouse.jpg') center / cover no-repeat,
        #14101c;
}

.viewport {
    position: relative;
    width: 100vw;
    height: calc(100vh - var(--footer-h));
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    width: calc(100vw - var(--tab-w));
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: calc(4.45 * var(--vmin));
    color: #fff;
    opacity: 0;
    visibility: hidden;
    z-index: 1;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow-y: auto;
}

/* 3D-gradient vertical divider */
.viewport::after {
    content: '';
    position: absolute;
    right: var(--tab-w);
    top: 0;
    width: calc(0.45 * var(--vmin));
    height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,0.5), rgba(255,255,255,0.2) 50%, rgba(0,0,0,0.6));
    z-index: 105;
}

/* Show the correct page when its radio is checked */
#tab-front:checked ~ .viewport #page-front,
#tab-hub:checked   ~ .viewport #page-hub,
#tab-kt:checked    ~ .viewport #page-kt,
#tab-sm:checked    ~ .viewport #page-sm,
#tab-ai:checked    ~ .viewport #page-ai,
#tab-ce:checked    ~ .viewport #page-ce,
#tab-url:checked   ~ .viewport #page-url,
#tab-fpdf:checked  ~ .viewport #page-fpdf,
#tab-qr:checked    ~ .viewport #page-qr,
#tab-att:checked   ~ .viewport #page-att,
#tab-item7:checked ~ .viewport #page-item7 {
    opacity: 1;
    visibility: visible;
    z-index: 50;
}

input[type="radio"] {
    display: none;
}

/* ---------- Front / Auth ---------- */
.front-content {
    text-align: center;
    background: rgba(0, 0, 0, 0.45);
    padding: calc(4 * var(--vmin)) calc(4.45 * var(--vmin));
    border-radius: calc(1.55 * var(--vmin));
    backdrop-filter: blur(calc(0.9 * var(--vmin)));
    max-width: calc(53.35 * var(--vmin));
    width: 100%;
}

.front-content h1 {
    font-size: calc(4.25 * var(--vmin));
    margin-bottom: calc(1.35 * var(--vmin));
}

.front-content .subtitle {
    font-size: calc(1.85 * var(--vmin));
    margin-bottom: calc(2.65 * var(--vmin));
    opacity: 0.9;
}

.quote-box {
    background: rgba(0,0,0,0.35);
    border-radius: calc(1.1 * var(--vmin));
    padding: calc(2 * var(--vmin)) calc(2.2 * var(--vmin));
    margin-bottom: calc(3.1 * var(--vmin));
    min-height: calc(8.9 * var(--vmin));
}

.quote-box .quote-text {
    font-style: italic;
    color: #ffec8b;
    font-size: calc(1.7 * var(--vmin));
    line-height: 1.4;
}

.quote-box .quote-author {
    margin-top: calc(0.9 * var(--vmin));
    font-size: calc(1.4 * var(--vmin));
    color: #bbb;
}

.auth-tabs {
    display: flex;
    margin-bottom: calc(2.2 * var(--vmin));
    border-radius: calc(0.9 * var(--vmin));
    overflow: hidden;
}

.auth-tabs button {
    flex: 1;
    padding: calc(1.35 * var(--vmin));
    border: none;
    font-weight: 700;
    cursor: pointer;
    font-size: calc(1.6 * var(--vmin));
    transition: background 0.2s;
}

.auth-tabs .tab-active {
    background: #ffcc00;
    color: #222;
}

.auth-tabs .tab-inactive {
    background: rgba(255,255,255,0.15);
    color: #eee;
}

.auth-tabs .tab-inactive:hover {
    background: rgba(255,255,255,0.25);
}

.auth-form {
    text-align: left;
}

.auth-form label {
    display: block;
    font-size: calc(1.5 * var(--vmin));
    margin-bottom: calc(0.45 * var(--vmin));
    opacity: 0.9;
}

.auth-form input,
.auth-form select,
.auth-form textarea {
    width: 100%;
    padding: calc(1.2 * var(--vmin)) calc(1.55 * var(--vmin));
    border-radius: calc(0.9 * var(--vmin));
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: calc(1.7 * var(--vmin));
    margin-bottom: calc(1.55 * var(--vmin));
}

.auth-form input::placeholder,
.auth-form textarea::placeholder {
    color: rgba(255,255,255,0.5);
}

.auth-form .row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: calc(0.9 * var(--vmin));
}

.auth-form .row input {
    margin-bottom: calc(1.55 * var(--vmin));
}

/* Password field with an eye that shows the password only while it is pressed */
.pw-wrap {
    position: relative;
    margin-bottom: calc(1.55 * var(--vmin));
}

.auth-form .pw-wrap input {
    margin-bottom: 0;
    padding-right: calc(5.1 * var(--vmin));
}

.pw-eye {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: calc(4.9 * var(--vmin));
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.pw-eye:hover {
    color: #fff;
}

.pw-eye.showing {
    color: #ffcc00;
}

.pw-eye svg {
    width: calc(2.2 * var(--vmin));
    height: calc(2.2 * var(--vmin));
    pointer-events: none;
}

/* The repeated password: a green check in place of the eye when it matches,
   a red X just before the eye when it does not (see initPasswordMatchMarks) */
.pw-match {
    position: absolute;
    top: 0;
    bottom: 0;
    right: calc(4.9 * var(--vmin));
    width: calc(3.4 * var(--vmin));
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.pw-match svg { width: calc(2.2 * var(--vmin)); height: calc(2.2 * var(--vmin)); }
.pw-wrap.pw-mismatched .pw-match { display: flex; color: #ff4d4d; }
.pw-wrap.pw-matched .pw-match { display: flex; color: #2ecc71; right: 0; width: calc(4.9 * var(--vmin)); }
.pw-wrap.pw-matched .pw-eye { display: none; }
.pw-wrap.pw-mismatched input { padding-right: calc(8.3 * var(--vmin)); }

.status-msg {
    text-align: center;
    font-size: calc(1.6 * var(--vmin));
    margin-bottom: calc(1.35 * var(--vmin));
    min-height: 1.2em;
}

.status-msg.error { color: #ff6b6b; }
.status-msg.success { color: #69db7c; }
.status-msg.info { color: #74c0fc; }

.btn-primary {
    width: 100%;
    padding: calc(1.45 * var(--vmin));
    background: #ffcc00;
    color: #222;
    border: none;
    border-radius: calc(0.9 * var(--vmin));
    font-weight: 700;
    font-size: calc(1.8 * var(--vmin));
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #e6b800;
}

.btn-secondary {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: calc(1.1 * var(--vmin)) calc(2 * var(--vmin));
    border-radius: calc(0.9 * var(--vmin));
    cursor: pointer;
    font-weight: 600;
    font-size: calc(1.5 * var(--vmin));
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.25);
}

.switch-link {
    text-align: center;
    margin-top: calc(1.8 * var(--vmin));
    font-size: calc(1.6 * var(--vmin));
}

.switch-link a {
    color: #ffcc00;
    cursor: pointer;
    text-decoration: underline;
}

/* ---------- Hub cards ----------
   Sized in vmin like everything else, and always the same number per row, so
   the cards grow and shrink together like a picture instead of changing shape:
   4 per row on a screen wider than tall, 2 on an upright tablet, 1 on an upright
   phone (below). A card is 26 units wide, or less when the window is too narrow
   for four of them (then the four share what there is). */
.cards-grid {
    /* the room for the cards: the page less its padding (8.9), the grid's padding (6.2) and 3 gaps (6) */
    --card-w: min(calc(26 * var(--vmin)), calc((100vw - var(--tab-w) - 21.5 * var(--vmin)) / 4));
    display: grid;
    grid-template-columns: repeat(4, var(--card-w));
    grid-auto-rows: minmax(calc(22.2 * var(--vmin)), auto);   /* a card is at least this tall, and taller when its text needs it */
    gap: calc(2 * var(--vmin));
    width: max-content;
    max-width: 100%;
    background: rgba(0, 0, 0, 0.3);
    padding: calc(3.1 * var(--vmin));
    border-radius: calc(1.55 * var(--vmin));
    max-height: 82vh;
    overflow-y: auto;
}

/* upright tablet: two cards per row (four would not fit at this unit) */
@media (max-aspect-ratio: 4/5) {
    .cards-grid {
        --card-w: min(calc(26 * var(--vmin)), calc((100vw - var(--tab-w) - 17.5 * var(--vmin)) / 2));
        grid-template-columns: repeat(2, var(--card-w));
    }
}

.card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: calc(2.45 * var(--vmin)) calc(2 * var(--vmin));
    text-align: center;
    border-radius: calc(1.1 * var(--vmin));
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card:hover {
    transform: translateY(calc(-0.55 * var(--vmin)));
    background: rgba(255, 255, 255, 0.18);
    border-color: #ffcc00;
}

.card .card-icon {
    font-size: calc(4.25 * var(--vmin));
    margin-bottom: calc(1.35 * var(--vmin));
}

.card h3 {
    font-size: calc(2.05 * var(--vmin));
    margin-bottom: calc(1.1 * var(--vmin));
}

.card p {
    font-size: calc(1.4 * var(--vmin));
    line-height: 1.4;
    opacity: 0.85;
    text-align: left;
    flex-grow: 1;
}

.card .launch-badge {
    margin-top: calc(1.55 * var(--vmin));
    display: inline-block;
    background: rgba(46, 204, 113, 0.25);
    color: #69db7c;
    font-size: calc(1.35 * var(--vmin));
    font-weight: 700;
    padding: calc(0.55 * var(--vmin)) calc(1.35 * var(--vmin));
    border-radius: calc(0.65 * var(--vmin));
    letter-spacing: 0.04em;
}

.card.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------- User bar (top-left when logged in) ---------- */
.user-bar {
    position: fixed;
    top: calc(1.8 * var(--vmin));
    left: calc(2.2 * var(--vmin));
    z-index: 200;
    display: none;
    align-items: center;
    gap: calc(1.55 * var(--vmin));
    background: rgba(0,0,0,0.55);
    padding: calc(0.9 * var(--vmin)) calc(1.8 * var(--vmin));
    border-radius: calc(1.1 * var(--vmin));
    backdrop-filter: blur(calc(0.65 * var(--vmin)));
    color: #fff;
    font-size: calc(1.6 * var(--vmin));
}

.user-bar.visible {
    display: flex;
}

.user-bar .greeting {
    font-weight: 600;
}

.user-bar button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.35);
    color: #fff;
    padding: calc(0.55 * var(--vmin)) calc(1.35 * var(--vmin));
    border-radius: calc(0.65 * var(--vmin));
    cursor: pointer;
    font-size: calc(1.4 * var(--vmin));
}

.user-bar button:hover {
    background: rgba(255,255,255,0.15);
}

.user-bar .logout-btn {
    border-color: #e74c3c;
    color: #ff8a80;
}

/* Refresh: reloads the app in the tab that is showing (app.js, "Refresh one app").
   It is in the bar only while an app tab is in front. Its arrow turns while the
   app's files are being fetched again. */
.user-bar .refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: calc(0.65 * var(--vmin));
    border-color: #f1c40f;
    color: #ffe082;
    min-width: calc(4.5 * var(--vmin));     /* never narrower than its arrow and its padding */
    flex-shrink: 10;                        /* gives way first: see just below */
}

/* The bar stops before the side tabs. On a screen too narrow for all of it, the
   app's name on Refresh is cut short first ("Refresh Knowle…"), then a very
   long name in the greeting. Profile and Logout always stay whole. */
.user-bar {
    max-width: calc(100vw - var(--tab-w) - 3.3 * var(--vmin));
}

.user-bar button:not(.refresh-btn) {
    flex-shrink: 0;
    white-space: nowrap;
}

.user-bar .greeting,
.user-bar .refresh-btn .refresh-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-bar .refresh-btn[hidden] {
    display: none;
}

.user-bar .refresh-btn svg {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
}

.user-bar .refresh-btn.busy {
    cursor: progress;
    opacity: 0.75;
}

.user-bar .refresh-btn.busy svg {
    animation: refresh-turn 0.9s linear infinite;
}

@keyframes refresh-turn {
    to { transform: rotate(360deg); }
}

/* ---------- Profile page ---------- */
.page-content {
    background: rgba(0, 0, 0, 0.45);
    padding: calc(4 * var(--vmin));
    border-radius: calc(1.35 * var(--vmin));
    text-align: center;
    max-width: calc(53.35 * var(--vmin));
    width: 100%;
}

.page-content h2 {
    font-size: calc(3.55 * var(--vmin));
    margin-bottom: calc(2 * var(--vmin));
}

.page-content p {
    opacity: 0.9;
    margin-bottom: calc(1.35 * var(--vmin));
}

/* ---------- App pages: the app fills its tab ---------- */
.page.app-page {
    padding: calc(7.1 * var(--vmin)) calc(1.8 * var(--vmin)) calc(4.9 * var(--vmin));   /* clears the user bar (top) and the dimming control (bottom) */
}

.app-frame {
    flex: 1;
    min-height: 0;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: calc(1.1 * var(--vmin));
    background: #fff;
}

/* A real app that draws its own panels over the lighthouse (placeholders keep the white frame) */
.app-frame.see-through {
    background: transparent;
    border: 0;
    border-radius: 0;
}

/* ---------- Side tabs ---------- */
.cabinet-tabs {
    position: fixed;
    right: 0;
    top: 0;
    width: var(--tab-w);
    height: calc(100vh - var(--footer-h));
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: calc(0.9 * var(--vmin)) 0;
    z-index: 110;
}

/* Each tab is as tall as its name needs (one word per line), and any spare
   height is shared out equally. --tab-fit is 1 unless app.js had to shrink the
   names to fit the screen. */
.cabinet-tabs label {
    width: 100%;
    flex: 1 0 auto;
    height: min-content;
    padding: 0.75em 0;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    display: grid;
    place-content: center;
    text-align: center;
    font-size: calc(var(--tab-font) * var(--tab-fit, 1));
    line-height: 1.1;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    /* the two cut corners keep one size whatever the tab's height */
    clip-path: polygon(0 0, 70% 0, 100% calc(var(--tab-w) * 0.2), 100% calc(100% - var(--tab-w) * 0.2), 70% 100%, 0 100%);
    box-shadow: inset calc(-0.2 * var(--vmin)) 0 calc(0.55 * var(--vmin)) rgba(0,0,0,0.3);
    transition: transform 0.2s, filter 0.2s;
    text-transform: uppercase;
}

.cabinet-tabs label:hover {
    filter: brightness(1.2);
    transform: translateX(calc(-0.45 * var(--vmin)));
}

/* Bell on a side tab: app.js adds "has-bell" while the app in that tab is showing
   a bell of its own (Secure Mail: unread mail). The bell sits above the name and
   is sized in "em", so it grows and shrinks with the name.
   The names run sideways, so what the grid calls a "column" here is stacked from
   top to bottom: first the bell, then the name. */
.cabinet-tabs label.has-bell {
    grid-auto-flow: column;
    place-items: center;
    column-gap: 0.45em;
}

.cabinet-tabs label.has-bell::before {
    content: '';
    width: 2em;
    height: 2em;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23ffc107' stroke='%23222' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M9.4 19.4a2.6 2.6 0 0 0 5.2 0z'/%3E%3Cpath d='M12 2.4c-.9 0-1.6.7-1.6 1.6v.5C7.7 5.2 6 7.600 6 10.500c0 3.600-1 5.200-2.600 6.600-.6.5-.2 1.500.6 1.500h16c.8 0 1.200-1 .6-1.500C19 15.700 18 14.100 18 10.500c0-2.900-1.700-5.300-4.400-6v-.5c0-.9-.7-1.600-1.600-1.600z'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

.tab-front { background-color: #e74c3c; }
.tab-hub   { background-color: #e67e22; }
.tab-kt    { background-color: #f1c40f; color: #333 !important; }
.tab-sm    { background-color: #2ecc71; }
.tab-ai    { background-color: #1abc9c; }
.tab-ce    { background-color: #3498db; }
.tab-url   { background-color: #9b59b6; }
.tab-fpdf  { background-color: #e84393; }
.tab-qr    { background-color: #dfe6e9; color: #222 !important; }
.tab-att   { background-color: #c0703f; }
.tab-item7 { background-color: #34495e; }

/* Active tab styling */
#tab-front:checked ~ .cabinet-tabs label[for="tab-front"],
#tab-hub:checked   ~ .cabinet-tabs label[for="tab-hub"],
#tab-kt:checked    ~ .cabinet-tabs label[for="tab-kt"],
#tab-sm:checked    ~ .cabinet-tabs label[for="tab-sm"],
#tab-ai:checked    ~ .cabinet-tabs label[for="tab-ai"],
#tab-ce:checked    ~ .cabinet-tabs label[for="tab-ce"],
#tab-url:checked   ~ .cabinet-tabs label[for="tab-url"],
#tab-fpdf:checked  ~ .cabinet-tabs label[for="tab-fpdf"],
#tab-qr:checked    ~ .cabinet-tabs label[for="tab-qr"],
#tab-att:checked   ~ .cabinet-tabs label[for="tab-att"],
#tab-item7:checked ~ .cabinet-tabs label[for="tab-item7"] {
    transform: translateX(calc(0.35 * var(--vmin))) scaleY(0.95);
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(0, 0, 0, 0.2)) !important;
    filter: brightness(1.35);
    box-shadow: inset calc(-0.45 * var(--vmin)) 0 calc(1.1 * var(--vmin)) rgba(0,0,0,0.6), calc(0.45 * var(--vmin)) 0 calc(1.35 * var(--vmin)) rgba(0,0,0,0.5);
    z-index: 120;
    border-left: 3px solid #fff;
    color: #000 !important;     /* the open tab: bold black on its brightened color */
}

/* Locked tabs. Logged out: everything but Home. Logged in: Home, plus each app tab
   until its app is launched from the Hub. */
#tab-front:disabled ~ .cabinet-tabs label[for="tab-front"],
#tab-hub:disabled   ~ .cabinet-tabs label[for="tab-hub"],
#tab-item7:disabled ~ .cabinet-tabs label[for="tab-item7"],
#tab-kt:disabled    ~ .cabinet-tabs label[for="tab-kt"],
#tab-sm:disabled    ~ .cabinet-tabs label[for="tab-sm"],
#tab-ai:disabled    ~ .cabinet-tabs label[for="tab-ai"],
#tab-ce:disabled    ~ .cabinet-tabs label[for="tab-ce"],
#tab-url:disabled   ~ .cabinet-tabs label[for="tab-url"],
#tab-fpdf:disabled  ~ .cabinet-tabs label[for="tab-fpdf"],
#tab-qr:disabled    ~ .cabinet-tabs label[for="tab-qr"],
#tab-att:disabled   ~ .cabinet-tabs label[for="tab-att"] {
    cursor: not-allowed;
    /* A dark layer over the tab's own color, instead of fading the whole tab:
       the tab recedes but its name stays readable, in light gray. */
    background-image: linear-gradient(rgba(20, 16, 28, 0.72), rgba(20, 16, 28, 0.72));
    color: #d3d3d3 !important;
    filter: none;
    transform: none;
}

/* Bot-check overlay */
.bot-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: #fff;
    text-align: center;
}

.bot-overlay.hidden {
    display: none;
}

.bot-overlay h2 {
    font-size: calc(3.55 * var(--vmin));
    margin-bottom: calc(0.9 * var(--vmin));
}

.bot-overlay p {
    margin-bottom: calc(2.65 * var(--vmin));
    color: #ccc;
}

.bot-overlay .btn-row {
    display: flex;
    gap: calc(1.35 * var(--vmin));
    justify-content: center;
    margin-bottom: calc(3.1 * var(--vmin));
}

.bot-overlay .btn-row button {
    padding: calc(1.35 * var(--vmin)) calc(2.65 * var(--vmin));
    border: none;
    border-radius: calc(0.9 * var(--vmin));
    font-weight: 700;
    font-size: calc(1.8 * var(--vmin));
    cursor: pointer;
    color: #fff;
}

.bot-overlay .homage {
    font-size: calc(1.7 * var(--vmin));
    color: #777;
}

/* ---------- Background dimming control (bottom-left) ---------- */
.dim-control {
    position: fixed;
    left: calc(2.2 * var(--vmin));
    bottom: calc(var(--footer-h) + 0.45 * var(--vmin));
    z-index: 200;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: calc(1.1 * var(--vmin));
    max-width: calc(100vw - var(--tab-w) - 4.45 * var(--vmin));
    background: rgba(0,0,0,0.55);
    padding: calc(0.9 * var(--vmin)) calc(1.55 * var(--vmin));
    border-radius: calc(1.1 * var(--vmin));
    backdrop-filter: blur(calc(0.65 * var(--vmin)));
    color: #fff;
    font-size: calc(0.8 * var(--vmin));
    opacity: 0.7;
    transition: opacity 0.2s;
}

.dim-control:hover,
.dim-control:focus-within {
    opacity: 1;
}

.dim-control input[type="range"] {
    width: calc(14.45 * var(--vmin));
    accent-color: #ffcc00;
    cursor: pointer;
}

.dim-control output {
    min-width: 2.6em;
    text-align: right;
    font-weight: 700;
    color: #ffcc00;
    font-variant-numeric: tabular-nums;
}

/* ---------- Footer bar ---------- */
.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--footer-h);
    z-index: 210;   /* above the user bar and dimming control, so the credit card is never covered */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: calc(1.8 * var(--vmin));
    padding: 0 calc(1.55 * var(--vmin));
    background: linear-gradient(to bottom, #fa2b17 0, #cf0404 calc(0.55 * var(--vmin)));
    border-top: calc(0.22 * var(--vmin)) solid #000;
    color: #fff;
    font-family: var(--footer-font);
    font-size: calc(0.8 * var(--vmin));
    font-weight: 700;
    letter-spacing: 0.02em;
    text-shadow: calc(0.11 * var(--vmin)) calc(0.11 * var(--vmin)) 0 #000;
    white-space: nowrap;
}

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

.site-footer a:hover,
.site-footer a:focus-visible {
    text-decoration: underline;
}

/* Credit: the word in the footer, and the card that opens above it on hover, focus or tap */
.credit {
    position: relative;
}

.credit-trigger {
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-shadow: inherit;
    cursor: help;
}

.credit-trigger:focus-visible {
    outline: calc(0.11 * var(--vmin)) solid #fff;
    outline-offset: calc(0.22 * var(--vmin));
}

.credit-card {
    position: absolute;
    right: 0;
    bottom: calc(100% + 1.1 * var(--vmin));
    display: flex;
    flex-direction: column;
    gap: calc(1.1 * var(--vmin));
    width: max-content;
    max-width: min(46.65 * var(--vmin), calc(100vw - 3.1 * var(--vmin)));
    padding: calc(1.8 * var(--vmin)) calc(2 * var(--vmin));
    background: rgba(12, 8, 20, 0.86);
    border: calc(0.11 * var(--vmin)) solid rgba(255, 255, 255, 0.22);
    border-radius: calc(1.35 * var(--vmin));
    backdrop-filter: blur(calc(0.9 * var(--vmin)));
    box-shadow: 0 calc(1.1 * var(--vmin)) calc(3.35 * var(--vmin)) rgba(0, 0, 0, 0.5);
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: calc(1.5 * var(--vmin));
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: normal;
    text-shadow: none;
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    transform: translateY(calc(0.65 * var(--vmin)));
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

/* keeps the card open while the mouse crosses the gap between the word and the card */
.credit-card::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: calc(1.35 * var(--vmin));
}

.credit-card strong {
    color: #ffcc00;
    font-size: calc(1.35 * var(--vmin));
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.credit:hover .credit-card,
.credit:focus-within .credit-card,
.credit.open .credit-card {
    opacity: 1;
    visibility: visible;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .credit-card {
        transform: none;
        transition: none;
    }
}

/* Phone held upright: one card per row, less empty space around the pages,
   and a taller footer with its two lines stacked */
@media (max-aspect-ratio: 5/8) {
    :root {
        --footer-h: calc(4.9 * var(--vmin));
    }

    .page {
        padding: calc(7.1 * var(--vmin)) calc(1.8 * var(--vmin)) calc(4.9 * var(--vmin));   /* same clearances as an app page */
    }

    .cards-grid {
        grid-template-columns: 1fr;
        width: 100%;
        padding: calc(1.8 * var(--vmin));
        max-height: 100%;
    }

    /* the bar is nearly as wide as the screen already: Refresh keeps its arrow
       and drops its words (its tooltip and screen-reader name still say them) */
    .user-bar .refresh-btn .refresh-name {
        display: none;
    }

    .site-footer {
        flex-direction: column;
        justify-content: center;
        gap: calc(0.1 * var(--vmin));
    }

    .credit-card {
        position: fixed;
        left: calc(1.55 * var(--vmin));
        right: calc(1.55 * var(--vmin));
        bottom: calc(var(--footer-h) + 1.1 * var(--vmin));
        width: auto;
        max-width: none;
    }
}

/* Utility */
.hidden { display: none !important; }
