:root {
    color-scheme: light;
    --portal-text: #1f2933;
    --portal-muted: #52606d;
    --portal-border: #d9e2ec;
    --portal-surface: #ffffff;
    --portal-background: #f5f7fa;
    --portal-accent: #2563eb;
}

* {
    box-sizing: border-box;
}

/* Author display rules (for example .portal-form's flex) must never undo the
   hidden attribute: the invitation form stays hidden until portal.js has
   read a valid link. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--portal-text);
    background: var(--portal-background);
}

.portal-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    background: var(--portal-surface);
    border-bottom: 1px solid var(--portal-border);
}

.portal-brand {
    font-weight: 600;
}

.portal-subtitle {
    color: var(--portal-muted);
    font-size: 0.9rem;
}

.portal-main {
    max-width: 48rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.portal-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    /* Long e-mail addresses, order numbers and links wrap instead of
       widening the page on narrow screens. */
    overflow-wrap: anywhere;
    min-width: 0;
}

.portal-card h1 {
    margin: 0 0 0.75rem;
    font-size: 1.35rem;
}

.portal-card p {
    margin: 0;
    color: var(--portal-muted);
}

.portal-card h2 {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
}

.portal-card p + p {
    margin-top: 0.75rem;
}

.portal-card-spaced {
    margin-top: 1rem;
}

.portal-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.portal-form label {
    font-size: 0.9rem;
    color: var(--portal-muted);
}

.portal-form input {
    font: inherit;
    font-size: 16px;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--portal-border);
    border-radius: 6px;
}

.portal-form button,
.portal-inline-form button {
    font: inherit;
    padding: 0.6rem 1rem;
    border: 1px solid var(--portal-accent);
    border-radius: 6px;
    background: var(--portal-accent);
    color: #ffffff;
    cursor: pointer;
}

.portal-inline-form {
    display: inline-block;
    margin: 0.5rem 0.5rem 0 0;
}

.portal-inline-form button {
    background: var(--portal-surface);
    color: var(--portal-text);
    border-color: var(--portal-border);
}

.portal-error {
    color: #b42318;
}

.portal-error:empty {
    display: none;
}

.portal-notice {
    color: #027a48;
}

.portal-actions {
    margin-top: 1rem;
}

.portal-link {
    color: var(--portal-accent);
}

.portal-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-left: auto;
    font-size: 0.95rem;
}

.portal-nav a {
    color: var(--portal-accent);
    text-decoration: none;
}

.portal-nav a[aria-current="page"] {
    color: var(--portal-text);
    font-weight: 600;
}

.portal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.portal-usage {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 1rem;
    margin: 0.75rem 0 0;
}

.portal-usage dt {
    font-size: 0.85rem;
    color: var(--portal-muted);
}

.portal-usage dd {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.portal-card .portal-error,
.portal-card .portal-notice {
    margin-top: 0.75rem;
}

.portal-muted {
    color: var(--portal-muted);
    font-size: 0.9rem;
}

/* Prompts wrap instead of scrolling sideways (long URLs and JSON included). */
.portal-prompt {
    margin: 0.75rem 0 0;
    padding: 0.75rem;
    background: var(--portal-background);
    border: 1px solid var(--portal-border);
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.portal-copy {
    font: inherit;
    padding: 0.5rem 1rem;
    border: 1px solid var(--portal-accent);
    border-radius: 6px;
    background: var(--portal-accent);
    color: #ffffff;
    cursor: pointer;
}

.portal-copy-status {
    margin-left: 0.5rem;
}

.portal-choice {
    border: 1px solid var(--portal-border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.portal-choice label {
    display: block;
    margin: 0.25rem 0;
    color: var(--portal-text);
}

.portal-choice input {
    padding: 0;
    border: 0;
    margin-right: 0.35rem;
}

@media (max-width: 640px) {
    .portal-grid,
    .portal-usage {
        grid-template-columns: minmax(0, 1fr);
    }

    .portal-nav {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .portal-main {
        padding: 1rem 0.75rem 2rem;
    }

    .portal-card {
        padding: 1rem;
    }

    .portal-copy-status {
        display: block;
        margin: 0.5rem 0 0;
    }
}
