:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --text: #15181c;
    --muted: #6b7280;
    --border: #d9dde3;
    --phone: #2563eb;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111418;
        --panel: #1a1e24;
        --text: #e8eaed;
        --muted: #9aa0a8;
        --border: #2c323a;
        --phone: #2f6feb;
    }
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
html { overflow-x: hidden; }
body {
    display: flex;
    flex-direction: column;
    overflow-wrap: anywhere;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 16px;
    padding: 8px max(16px, calc((100% - 1068px) / 2));
    padding-top: max(8px, env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
h1 { margin: 0; font-size: 18px; }
h1 a { color: inherit; text-decoration: none; }
.status { font-size: 13px; color: var(--muted); }
.status.online { color: #16a34a; }
main {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.empty { color: var(--muted); text-align: center; margin: auto; }
main:has(.sign) > .empty { display: none; }
input {
    flex: 1;
    min-width: 0;
    font-size: 16px; /* >= 16px stops iOS zooming on focus */
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}
button {
    font-size: 16px;
    padding: 10px 16px;
    border-radius: 20px;
    border: 0;
    background: var(--phone);
    color: #fff;
}

/* Header navigation */
header .status { margin-left: auto; order: 1; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 11px; font-size: 14px; }
nav a { text-decoration: none; padding: 4px 0; }
nav a[aria-current] { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--phone); }
nav form { display: contents; }
@media (max-width: 420px) { nav { font-size: 13px; gap: 4px 9px; } }
@media (min-width: 700px) { nav { margin-left: auto; } header .status { margin-left: 0; order: 0; } }
a { color: var(--phone); }
button.link {
    background: none;
    color: var(--phone);
    padding: 0;
    font-size: 14px;
    border-radius: 0;
}

/* Single-card pages: login, one-time link, passkeys */
/* Centred when the card fits, top-aligned and scrollable when it doesn't ("justify-content: center"
   would push the top of a tall card off-screen, out of scroll reach). */
body.page {
    height: auto;
    min-height: 100%;
    align-items: center;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.card {
    /* .card is a <main>; undo the start page's scrolling-column layout */
    flex: 0 0 auto;
    display: block;
    overflow: visible;
    margin: auto 0;
    width: 100%;
    max-width: 420px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
}
.card h1 { font-size: 22px; margin-bottom: 16px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
h2:first-child { margin-top: 4px; }
button.primary { width: 100%; padding: 12px 16px; }
form.inline { display: flex; gap: 8px; }
form.inline button.primary { width: auto; }
.hint { font-size: 13px; color: var(--muted); }
.notice { color: var(--muted); }
.error { color: #dc2626; }
code { font-size: 13px; word-break: break-all; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.passkeys { list-style: none; padding: 0; margin: 0; }
.passkeys li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
button.danger { background: #dc2626; font-size: 14px; padding: 6px 12px; white-space: nowrap; }

/* SSH sign requests */
#approvals { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 8px; align-items: start; }
.sign {
    background: var(--panel);
    border: 2px solid #f59e0b;
    border-radius: 14px;
    padding: 12px 14px;
}
.sign-title { display: flex; justify-content: space-between; align-items: baseline; }
.sign-title.warn strong { color: #dc2626; }
.sign-title time { font-size: 12px; color: var(--muted); }
.sign dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; margin: 8px 0; font-size: 14px; }
.sign dt { color: var(--muted); }
.sign dd { margin: 0; overflow-wrap: anywhere; }
.sign .ok { color: #16a34a; font-size: 12px; }
.sign .bad, .warning { color: #dc2626; }
.warning { font-size: 14px; margin: 8px 0; }
.sign .actions { display: flex; gap: 8px; }
.sign .actions button { flex: 1; }
.sign button.deny { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.sign button.approve { background: #16a34a; }
.sign button:disabled { opacity: .6; }

/* SSH keys page */
.keys { list-style: none; padding: 0; margin: 0; }
.keys li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.keys .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.keys .row > div, .passkeys li > div { min-width: 0; }
.passkeys li { flex-wrap: wrap; }
.passkeys li > div { flex: 1 1 280px; }
.keys .ok { color: #16a34a; }
.keys .bad { color: #dc2626; }
.device { margin-top: 24px; }
textarea.pubkey {
    width: 100%;
    display: block;
    margin-top: 8px;
    font: 12px/1.3 ui-monospace, monospace;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    resize: none;
    word-break: break-all;
}
form.stacked { display: flex; flex-direction: column; gap: 8px; }
form.stacked input[type=file] { border: 0; padding: 0; background: none; border-radius: 0; }
form.stacked textarea {
    font: 16px/1.3 ui-monospace, monospace; /* >= 16px stops iOS zooming on focus */
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

/* Notifications banner on the start page */
.push {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    font-size: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.push[hidden], .push button[hidden] { display: none; }
.push span { flex: 1; }
.push button { font-size: 14px; padding: 8px 12px; white-space: nowrap; }

/* CLI downloads on the Computers page */
.downloads { list-style: none; padding: 0; margin: 4px 0 8px; display: flex; flex-direction: column; gap: 6px; }
.downloads a { font-weight: 600; }

/* Inner pages: one column on a phone, two on a wide screen (list | forms) */
.wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 32px; align-content: start; }
.col { min-width: 0; }
@media (min-width: 800px) {
    .wrap { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wrap > .col:first-child { padding-right: 32px; border-right: 1px solid var(--border); }
    .wrap { gap: 0; }
    .wrap > .col:last-child { padding-left: 32px; }
}
details { margin: 12px 0; }
summary { cursor: pointer; color: var(--phone); font-size: 14px; }
details[open] > summary { margin-bottom: 8px; }
.keys details { margin: 8px 0 0; }
.wrap > .col { padding-bottom: 12px; }

/* Addresses (can be 39-character IPv6) on one line when they fit; the user agent is clipped to one line. */
.addr { font-size: 14px; }
.ua { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
