/* The pages that live outside the chat: sign in, register, account, usage and
 * credits, plans, users, feedback, policies.
 *
 * chat/app.css is linked first and owns the whole visual system — colour,
 * radius, shadow, type, motion. Nothing here redefines a token; this file only
 * adds the page-level layout and the handful of controls (buttons, fields,
 * tables, cards) the chat itself has no use for. Where a value has to be
 * literal it is expressed as a mix of two tokens, so it follows the theme into
 * dark mode instead of staying stubbornly light.
 *
 * The chrome is a deliberate copy of the chat's rail rather than a variation on
 * it: same width, same hairline, same account block pinned to the bottom. People
 * cross between the two surfaces constantly and should not notice the seam.
 */

:root {
    /* The one hue the chat has no token for: an advisory that is neither an
       error nor a success. */
    --page-warn: #92610b;
}

@media (prefers-color-scheme: dark) {
    :root { --page-warn: #f0c26a; }
}

/* ---------- shell ---------- */

.shell {
    display: flex;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg);
}

.shell-nav {
    width: var(--sidebar-width, 260px);
    flex: 0 0 var(--sidebar-width, 260px);
    border-right: 1px solid var(--border);
    background: var(--bg-subtle);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.shell-head { display: flex; align-items: center; height: 52px; flex: none; padding: 0 16px; }

.shell-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    opacity: 0.92;
    transition: opacity 0.12s var(--ease, ease);
}

.shell-brand:hover { opacity: 1; }
.shell-brand img { width: 22px; height: 22px; border-radius: 6px; display: block; }

.shell-links {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 13px;
    transition: background 0.12s var(--ease, ease), color 0.12s var(--ease, ease);
}

.nav-link .icon { width: 16px; height: 16px; }
.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.nav-link.active { background: var(--bg-hover); color: var(--text); font-weight: 500; }

.shell-foot { flex: none; border-top: 1px solid var(--border); padding: 8px; }

.shell-account {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-muted);
    transition: background 0.12s var(--ease, ease);
}

.shell-account:hover { background: var(--bg-hover); }
.shell-account:hover .avatar { background: var(--accent); color: var(--accent-text); }
.shell-account .who { min-width: 0; }

.shell-account .name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    line-height: 1.35;
    color: var(--text);
}

.shell-account .meta { display: block; font-size: 11px; line-height: 1.35; color: var(--text-faint); }

.shell-main { flex: 1; min-width: 0; overflow-y: auto; }

/* ---------- page ---------- */

.page {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 40px 32px 80px;
}

.page.narrow { max-width: 600px; }
.page.wide { max-width: 1060px; }

.page-head { margin-bottom: 28px; }

.page-head h1 {
    margin: 0;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.024em;
    line-height: 1.25;
}

.page-head p { margin: 8px 0 0; max-width: 62ch; color: var(--text-muted); font-size: 14px; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
    color: var(--text-faint);
    font-size: 12px;
    text-decoration: none;
    transition: color 0.12s var(--ease, ease);
}

.back-link:hover { color: var(--text-muted); }
.back-link .icon { width: 14px; height: 14px; }

.section { margin-top: 40px; }

.section-title {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.014em;
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

/* ---------- card ---------- */

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    box-shadow: var(--shadow-sm);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.card-head h2, .card-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.card-head p { margin: 0; font-size: 12px; color: var(--text-faint); }
.card-body { padding: 16px; }
.card-foot { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--bg-subtle); }
.card-foot.plain { background: none; }

/* Label / value rows, e.g. the account summary. */
.rows { display: flex; flex-direction: column; margin: 0; }

.rows .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.rows .row:last-child { border-bottom: 0; }
.rows .row dt { color: var(--text-muted); }
.rows .row dd { margin: 0; font-weight: 500; text-align: right; color: var(--text); }

.tag {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--bg-sunken);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.tag.ok { background: color-mix(in srgb, var(--ok) 12%, var(--bg)); color: var(--ok); }
.tag.warn { background: color-mix(in srgb, var(--page-warn) 14%, var(--bg)); color: var(--page-warn); }
.tag.bad { background: var(--danger-bg, color-mix(in srgb, var(--danger) 8%, var(--bg))); color: var(--danger); }

/* ---------- buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s var(--ease, ease), border-color 0.12s var(--ease, ease),
        color 0.12s var(--ease, ease);
}

.btn:hover { background: var(--bg-hover); }
.btn .icon { width: 15px; height: 15px; }

.btn.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.danger { color: var(--danger); }
.btn.danger:hover {
    border-color: var(--danger-border, var(--border-strong));
    background: var(--danger-bg, color-mix(in srgb, var(--danger) 7%, var(--bg)));
}

.btn.quiet { border-color: transparent; background: none; color: var(--text-muted); }
.btn.quiet:hover { background: var(--bg-hover); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.block { width: 100%; }

.btn:disabled, .btn[disabled] {
    background: var(--bg-sunken);
    border-color: transparent;
    color: var(--text-faint);
    cursor: default;
    pointer-events: none;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* An action that reads as a sentence rather than a control. */
.arrow-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
}

.arrow-link .icon {
    width: 15px;
    height: 15px;
    color: var(--text-faint);
    transition: transform 0.14s var(--ease, ease), color 0.14s var(--ease, ease);
}

.arrow-link:hover .icon { transform: translateX(2px); color: var(--text-muted); }

.text-link {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: var(--border-strong);
    transition: text-decoration-color 0.12s var(--ease, ease);
}

.text-link:hover { text-decoration-color: var(--text-faint); }

/* ---------- fields ---------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.field-error { font-size: 12px; color: var(--danger); }
.field-error ul { margin: 0; padding-left: 1.1em; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-grid .field.full { grid-column: 1 / -1; }

/* These class names are produced by common/forms.py, which renders the widgets
   server-side; they are styled here rather than rewritten there. */
.input, .textarea, .select, .file-input,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="tel"], textarea, select {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.12s var(--ease, ease), box-shadow 0.12s var(--ease, ease);
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

.textarea, textarea {
    height: auto;
    min-height: 104px;
    padding: 10px;
    line-height: 1.55;
    resize: vertical;
}

.input:focus, .textarea:focus, .select:focus, input:focus, textarea:focus, select:focus {
    border-color: var(--focus);
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(79, 70, 229, 0.16));
}

.input:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
.input:disabled, input:disabled { background: var(--bg-sunken); color: var(--text-muted); }
.input-error { border-color: var(--danger); }
input[type="checkbox"], .checkbox { width: 15px; height: 15px; accent-color: var(--accent); }

/* ---------- notices ---------- */

/* .notice arrives from chat/app.css in its danger colouring; the other states
   are added here so every page speaks one vocabulary. */
.notice { display: flex; align-items: center; gap: 10px; }
.notice .icon { width: 16px; height: 16px; flex: none; }
.notice .grow { flex: 1; min-width: 0; }
.notice .btn { flex: none; }

.notice.ok, .notice.success {
    border-color: color-mix(in srgb, var(--ok) 28%, var(--bg));
    background: color-mix(in srgb, var(--ok) 8%, var(--bg));
    color: var(--ok);
}

.notice.warn, .notice.warning {
    border-color: color-mix(in srgb, var(--page-warn) 30%, var(--bg));
    background: color-mix(in srgb, var(--page-warn) 9%, var(--bg));
    color: var(--page-warn);
}

.notice.info { border-color: var(--border); background: var(--bg-subtle); color: var(--text-muted); }
.notices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }

table.data th {
    padding: 9px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
    text-align: left;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-faint);
    white-space: nowrap;
}

table.data td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-muted);
}

table.data td:first-child { color: var(--text); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .empty-row td { color: var(--text-faint); text-align: center; padding: 32px 16px; }
table.data .row-action { width: 1%; text-align: right; padding: 4px 10px 4px 0; }
table.data .row-action form { display: flex; justify-content: flex-end; }

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-faint);
}

.pager .icon-btn[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }

/* ---------- meter and chart ---------- */

.meter-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-faint);
}

.meter-head b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

/* Thirty numbers do not justify a charting library, and the one this page used
   came off a CDN just as blockable as the icon font this work removed. The bars
   are divs. */
.chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 132px;
    border-bottom: 1px solid var(--border);
}

.chart-col {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: flex-end;
    border-radius: 3px;
    transition: background 0.12s var(--ease, ease);
}

.chart-col:hover { background: var(--bg-sunken); }

.chart-bar {
    width: 100%;
    max-width: 18px;
    margin: 0 auto;
    border-radius: 3px 3px 1px 1px;
    background: var(--accent);
    opacity: 0.85;
}

.chart-axis {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-top: 10px;
    font-size: 11px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.buy-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.buy-btn { margin-top: 16px; }

/* ---------- auth ---------- */

.auth {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--bg-subtle);
}

.auth-card {
    width: 100%;
    max-width: 392px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    box-shadow: var(--shadow);
}

.auth-card.wide { max-width: 460px; }
.auth-mark { display: inline-block; margin-bottom: 20px; border-radius: 7px; }
.auth-mark img { width: 28px; height: 28px; border-radius: 7px; display: block; }

.auth-card h1 { margin: 0 0 4px; font-size: 17px; font-weight: 600; letter-spacing: -0.018em; }
.auth-card > p.sub { margin: 0 0 22px; font-size: 13px; color: var(--text-muted); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .btn { margin-top: 2px; }
.auth-alt { margin: 20px 0 0; text-align: center; font-size: 13px; color: var(--text-muted); }

.auth-foot { margin-top: 24px; font-size: 12px; color: var(--text-faint); text-align: center; }
.auth-foot a { color: inherit; text-decoration: none; }
.auth-foot a:hover { color: var(--text-muted); }

/* ---------- plans ---------- */

.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(236px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.plan-card { display: flex; flex-direction: column; }
.plan-card .card-body { flex: 1; }
.plan-name { margin: 0; font-size: 13px; font-weight: 600; }
.plan-price { margin: 8px 0 16px; display: flex; align-items: baseline; gap: 5px; }

.plan-price .amount {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.plan-price .cur { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.plan-price .per { font-size: 13px; color: var(--text-faint); }

.plan-desc {
    margin: 0 0 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    min-height: 58px;
    font-size: 13px;
    color: var(--text-muted);
}

.plan-facts { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.plan-facts li { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text-muted); }
.plan-facts .icon { width: 15px; height: 15px; margin-top: 2px; color: var(--ok); }
.plan-card .card-foot .btn-row .btn { flex: 1; }

/* ---------- checkout ---------- */

.checkout {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.checkout-inner { width: 100%; max-width: 440px; }
.checkout-head { text-align: center; margin-bottom: 24px; }
.checkout-head h1 { margin: 0 0 6px; font-size: 21px; font-weight: 600; letter-spacing: -0.024em; }
.checkout-head p { margin: 0 auto; max-width: 46ch; font-size: 13px; color: var(--text-muted); }
.pay-btn { margin-top: 20px; }
.pay-error { margin-top: 12px; }

/* ---------- small compositions ---------- */

.between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.identity { display: flex; align-items: center; gap: 12px; }
.identity .avatar { width: 34px; height: 34px; font-size: 12px; }
.identity .who { min-width: 0; }
.mini-title { font-size: 13px; font-weight: 500; color: var(--text); }
.mini-sub { font-size: 12px; color: var(--text-faint); }
.note { margin: 0; font-size: 13px; color: var(--text-muted); }
.link-list { display: flex; flex-direction: column; gap: 12px; }
.invite-row { flex-wrap: nowrap; align-items: center; }
.invite-row .input { width: 224px; }

/* ---------- prose (policies) ---------- */

.prose { font-size: 14px; color: var(--text); }
.prose h1 { margin: 0 0 4px; font-size: 21px; font-weight: 600; letter-spacing: -0.024em; }
.prose h2 { margin: 2em 0 0.5em; font-size: 15px; font-weight: 600; letter-spacing: -0.011em; }
.prose h3 { margin: 1.9em 0 0.4em; font-size: 14px; font-weight: 600; }
.prose p { margin: 0 0 1em; color: var(--text-muted); line-height: 1.65; }
.prose strong, .prose b { color: var(--text); font-weight: 600; }
.prose a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--border-strong); }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.3em; color: var(--text-muted); }
.prose li { margin: 0.3em 0; }
.prose .effective { font-size: 12px; color: var(--text-faint); margin-bottom: 2.5em; }
.prose hr { margin: 2.5em 0; border: 0; border-top: 1px solid var(--border); }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
    .shell { flex-direction: column; height: auto; min-height: 100dvh; overflow: visible; }

    .shell-nav {
        width: 100%;
        flex: none;
        position: sticky;
        top: 0;
        z-index: 20;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        height: 52px;
        padding: 0 10px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .shell-head { padding: 0 6px; }
    .shell-brand span { display: none; }

    .shell-links {
        flex: 1;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        gap: 2px;
        padding: 0;
        overflow: visible;
    }

    .nav-link { padding: 0 8px; }
    .nav-link span { display: none; }

    .shell-foot { border-top: 0; padding: 0; }
    .shell-account { padding: 0 4px; }
    .shell-account .who { display: none; }
    .shell-main { overflow-y: visible; }

    .page { padding: 28px 18px 64px; }
    .split, .field-grid, .buy-row { grid-template-columns: 1fr; }
    table.data th, table.data td { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 620px) {
    .card-head { flex-direction: column; align-items: stretch; }
    .invite-row .input { width: auto; flex: 1; }
}

.contact-card { display: block; text-decoration: none; color: inherit; transition: border-color 0.12s var(--ease, ease); }
.contact-card:hover { border-color: var(--border-strong); }
.contact-card .mini-title, .contact-card .mini-sub { display: block; }
.contact-card .icon { color: var(--text-faint); }
.done-mark { width: 20px; height: 20px; color: var(--ok); }
