@font-face {
    font-family: AppSans;
    src: url('/fonts/app-sans-0.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: AppSans;
    src: url('/fonts/app-sans-1.woff2') format('woff2');
    font-weight: 500 800;
    font-display: swap;
}

:root {
    color-scheme: light;
    /* Default blue palette of the 花序 client. */
    --p-bg: #edf1f6;
    --p-card: #fff;
    --p-shell: #fff;
    --p-line: #c2cede;
    --p-rule: #e1e7ef;
    --p-text: #1e2d45;
    --p-label: #637188;
    --p-value: #24344c;
    --p-accent: #315b9f;
    --p-tint: #edf2fb;
    --p-on-accent: #fff;
    --error: #b13435;
    background: var(--p-bg);
    color: var(--p-text);
    font: 14px/1.45 AppSans, system-ui, "Microsoft YaHei", sans-serif;
    accent-color: var(--p-accent);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
button, input { font: inherit; }
a { color: var(--p-accent); text-underline-offset: .18em; }
:focus-visible { outline: 2px solid var(--p-accent); outline-offset: 2px; }
::selection { background: var(--p-tint); color: var(--p-accent); }

.portal {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    margin-inline: auto;
    overflow: hidden;
    background: var(--p-bg);
}

@media (min-width: 460px) and (pointer: fine) {
    body { display: grid; place-items: center; padding: 24px; }
    .portal {
        --portrait-width: clamp(320px, calc((100dvh - 48px) * 390 / 844), 390px);
        width: var(--portrait-width);
        height: min(calc(100dvh - 48px), calc(var(--portrait-width) * 844 / 390));
        border-radius: 16px;
        outline: 1px solid var(--p-line);
    }
}

.portal-header {
    flex-shrink: 0;
    padding: env(safe-area-inset-top) 16px 0;
    background: var(--p-shell);
}

.portal-brand { display: flex; align-items: center; gap: 8px; height: 64px; font-size: 20px; font-weight: 500; }
.portal-brand img { display: block; width: 52px; height: 56px; object-fit: contain; }

.portal-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin: 0 0 12px;
    padding: 4px;
    border-radius: 14px;
    background: var(--p-tint);
}

.portal-nav a {
    display: grid;
    place-items: center;
    min-height: 44px;
    border-radius: 11px;
    color: var(--p-label);
    text-decoration: none;
}

.portal-nav a[aria-current='page'] { color: var(--p-accent); background: var(--p-card); font-weight: 500; }

.portal-main { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: 14px 16px 20px; scrollbar-width: thin; }
h1, h2 { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
h1 { margin: 0 0 12px; font-size: 20px; }
h2 { font-size: 16px; }

.portal-card, .auth form { margin: 0 0 12px; background: var(--p-card); border-radius: 15px; }
.card-heading { padding: 14px 16px 0; }
.card-message { margin: 0; padding: 8px 16px 14px; color: var(--p-label); }
.card-data { margin: 0; padding: 10px 16px; }
.card-data > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-data dt { flex-shrink: 0; color: var(--p-label); }
.card-data dd { margin: 0; color: var(--p-value); font-weight: 500; text-align: end; overflow-wrap: anywhere; }
.card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 8px 16px 14px; }
.release-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.release-hash { margin: 0 16px; color: var(--p-label); }
.release-hash summary { display: list-item; padding: 12px 0; cursor: pointer; }
.release-hash code { overflow-wrap: anywhere; }

.auth form { display: grid; padding: 16px; }
.auth label { margin-bottom: 6px; font-weight: 500; }
.auth input, .admin-invite input {
    width: 100%;
    min-height: 44px;
    margin: 0 0 14px;
    padding: 8px 12px;
    border: 1px solid var(--p-line);
    border-radius: 10px;
    background: var(--p-tint);
    color: inherit;
    caret-color: var(--p-accent);
}

.auth small { margin: -9px 0 14px; color: var(--p-label); }

.admin-portal button,
.user-portal :where(.portal-card, .portal-main > form, .portal-sheet) button,
.primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 16px;
    border: 0;
    border-radius: 11px;
    background: var(--p-accent);
    color: var(--p-on-accent);
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.admin-portal .secondary, .user-portal .secondary { background: var(--p-tint); color: var(--p-accent); }
.admin-portal button:hover, .primary:hover { filter: brightness(.96); }
.admin-portal button:disabled, .portal-sheet button:disabled { opacity: .65; cursor: wait; }
.error { margin: 0 0 8px; color: var(--error); overflow-wrap: anywhere; }
.sign-out .error { margin: 0; padding: 0 16px 12px; }

.admin-invite { padding: 16px; margin: 0; }
.admin-invite form { display: grid; margin-top: 12px; }
.admin-invite label { margin-bottom: 6px; }
.admin-issued { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--p-tint); }
.admin-issued span, .admin-issued output { display: block; }
.admin-issued output { margin-top: 4px; font-weight: 500; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
.admin-list { padding: 0 16px; overflow: auto; }
.admin-list h2 { padding-top: 14px; }
.admin-list table { width: 100%; border-collapse: collapse; text-align: start; }
.admin-list th, .admin-list td { padding: 12px 8px; text-align: start; overflow-wrap: anywhere; }
.admin-list th { color: var(--p-label); font-weight: 500; }
.admin-list tbody tr { border-top: 1px solid var(--p-rule); }
.admin-pagination { display: flex; gap: 16px; padding: 12px 8px; border-top: 1px solid var(--p-rule); }

@media (max-width: 360px) {
    .portal-header, .portal-main { padding-inline: 12px; }
}

@media (min-width: 720px) and (pointer: fine) {
    .admin-portal.workspace {
        width: min(100%, 1040px);
        height: min(844px, calc(100dvh - 48px));
    }

    .admin-portal.workspace .portal-header { padding-inline: 20px; border-bottom: 1px solid var(--p-line); }
    .admin-portal.workspace .portal-main { padding: 24px; }
    .admin-portal.workspace .portal-main h1 { margin-bottom: 16px; }

    .admin-portal.auth { width: min(100%, 460px); height: auto; max-height: calc(100dvh - 48px); }
}
