:root {
    color-scheme: dark;
    --bg-0: #060713;
    --bg-1: #090817;
    --bg-2: #100a20;
    --panel: rgba(11, 14, 29, .94);
    --panel-alt: #121427;
    --panel-hover: #181530;
    --border: #433168;
    --border-strong: #5b3f8f;
    --primary: #b65cff;
    --primary-hover: #c778ff;
    --primary-pressed: #9340d5;
    --primary-soft: #2b153f;
    --brand: #c767ff;
    --text: #f7f3ff;
    --muted: #b8a2d8;
    --subtle: #8e7ba9;
    --success: #3dd39d;
    --success-soft: #142c29;
    --error: #ff718e;
    --error-soft: #301622;
    --warning: #e7c45a;
    --shadow: 0 22px 70px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg-0); }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 82% 0%, rgba(182, 92, 255, .14), transparent 31rem),
        radial-gradient(circle at 0% 76%, rgba(115, 60, 191, .10), transparent 34rem),
        linear-gradient(135deg, var(--bg-0), var(--bg-1) 48%, var(--bg-2));
}

button, input, select { font: inherit; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.topbar {
    min-height: 84px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(91, 63, 143, .5);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { display: block; object-fit: contain; }
.brand-name { font-size: 15px; font-weight: 750; letter-spacing: .16em; }
.brand-product { margin-top: 2px; font-size: 13px; color: var(--muted); }

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
}
.topbar-actions .button { margin-top: 0; white-space: nowrap; }
.logout-form { margin: 0; display: flex; }

.account-tools-note { margin: 16px 0 9px; }
.account-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.account-actions .button { margin-top: 0; }

main { padding: 44px 0 70px; }

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.035em; }
h2 { margin-bottom: 14px; font-size: 20px; }
h3 { margin-bottom: 4px; font-size: 17px; }
p { line-height: 1.6; }

.eyebrow {
    margin-bottom: 7px;
    color: var(--brand);
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .15em;
}

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; word-break: break-all; }

.card {
    background: linear-gradient(145deg, rgba(18, 20, 39, .96), rgba(11, 14, 29, .95));
    border: 1px solid rgba(91, 63, 143, .72);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.centered-card, .login-card { width: min(520px, 100%); margin: 6vh auto 0; }
.section-gap { margin-top: 24px; }

.grid { display: grid; gap: 24px; }
.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.details-list { margin: 0; }
.details-list > div {
    display: grid;
    grid-template-columns: minmax(130px, .72fr) minmax(0, 1.4fr);
    gap: 18px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(67, 49, 104, .5);
}
.details-list > div:last-child { border-bottom: 0; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; }

.product-list { display: grid; gap: 10px; }
.product-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(67, 49, 104, .5);
}
.product-row:last-child { border-bottom: 0; }
.product-meta { display: grid; justify-items: end; gap: 7px; }

.status {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 9px;
    border: 1px solid rgba(142, 123, 169, .35);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(142, 123, 169, .08);
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.status-active { color: #a9f0d6; border-color: rgba(61, 211, 157, .36); background: rgba(20, 44, 41, .9); }
.status-revoked { color: #ffc2cf; border-color: rgba(255, 113, 142, .32); background: rgba(48, 22, 34, .9); }

.section-heading, .companion-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}
.count-pill {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--primary-soft);
    color: #e4c8ff;
    font-weight: 750;
}

.companion-list { display: grid; gap: 14px; margin-top: 20px; }
.companion-card {
    padding: 18px;
    border: 1px solid rgba(67, 49, 104, .76);
    border-radius: 12px;
    background: rgba(12, 14, 30, .78);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin: 16px 0 13px;
}
.metrics > div {
    padding: 10px;
    border-radius: 9px;
    background: rgba(43, 21, 63, .48);
    border: 1px solid rgba(91, 63, 143, .48);
}
.metrics span { display: block; color: var(--muted); font-size: 11px; }
.metrics strong { display: block; margin-top: 4px; font-size: 18px; }

.form-stack { display: grid; gap: 9px; }
.form-stack label { margin-top: 5px; color: #e5daf4; font-size: 13px; font-weight: 650; }
.form-stack input,
.form-stack select {
    width: 100%;
    min-height: 43px;
    padding: 9px 11px;
    color: var(--text);
    background: #111024;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
}
.form-stack input:focus,
.form-stack select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(182, 92, 255, .12); }
.compact-form { max-width: 500px; margin-top: 15px; }
.login-help { margin: 8px 0 18px; text-align: center; }
.login-help a { color: #d9b3ff; text-decoration: none; font-weight: 700; }
.login-help a:hover { color: #f1ddff; text-decoration: underline; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border-radius: 8px;
    padding: 9px 16px;
    border: 1px solid transparent;
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
}
.button-primary { margin-top: 10px; background: linear-gradient(135deg, #7b27dc, #b249f5 58%, #c35dff); }
.button-primary:hover { background: linear-gradient(135deg, #8c35ea, #c35cff 62%, #d378ff); }
.button-secondary { background: var(--panel-alt); border-color: var(--border-strong); }
.button-secondary:hover { background: var(--panel-hover); }
.button-danger { width: fit-content; margin-top: 8px; background: var(--error-soft); border-color: rgba(255, 113, 142, .55); color: #ffd5df; }
.button-danger:hover { background: #451c2b; border-color: var(--error); }
.critical-button { background: #511521; }

.notice {
    margin-bottom: 20px;
    padding: 13px 15px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--panel-alt);
}
.notice-success { color: #b8f7df; border-color: rgba(61, 211, 157, .42); background: var(--success-soft); }
.notice-error { color: #ffd5df; border-color: rgba(255, 113, 142, .48); background: var(--error-soft); }

.danger-zone { border-color: rgba(255, 113, 142, .34); }
.danger-text { color: var(--error); }
.danger-panel {
    margin-top: 15px;
    border: 1px solid rgba(255, 113, 142, .28);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(48, 22, 34, .35);
}
.danger-panel summary {
    padding: 13px 15px;
    cursor: pointer;
    font-weight: 700;
    color: #ffd5df;
}
.danger-panel[open] summary { border-bottom: 1px solid rgba(255, 113, 142, .22); }
.danger-panel > p, .danger-panel > form { margin-left: 15px; margin-right: 15px; }
.danger-panel > p { margin-top: 14px; color: var(--muted); }
.danger-panel > form { margin-bottom: 17px; }
.critical-panel { border-color: rgba(255, 113, 142, .48); }

footer {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-top: 1px solid rgba(91, 63, 143, .45);
    color: var(--subtle);
    font-size: 12px;
}

@media (max-width: 860px) {
    .two-column { grid-template-columns: 1fr; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .shell { width: min(100% - 20px, 1180px); }
    main { padding-top: 28px; }
    .topbar { min-height: 72px; align-items: flex-start; padding: 14px 0; gap: 12px; }
    .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
    .brand img { width: 36px; height: 36px; }
    .card { padding: 18px; border-radius: 13px; }
    .details-list > div { grid-template-columns: 1fr; gap: 4px; }
    dd { text-align: left; }
    .product-row, .section-heading, .companion-header { align-items: flex-start; flex-direction: column; }
    .product-meta { justify-items: start; }
    .metrics { grid-template-columns: 1fr 1fr; }
    footer { flex-direction: column; justify-content: center; gap: 3px; }
}

/* Persona Library */
.library-intro { margin-bottom: 30px; }
.library-intro p:last-child { margin-bottom: 0; }
.library-section { margin-top: 34px; }
.library-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}
.library-section-heading h2 { margin-bottom: 5px; }
.library-section-heading p { margin-bottom: 0; }
.persona-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}
.persona-card {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 20px;
    border: 1px solid rgba(91, 63, 143, .72);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(18, 20, 39, .96), rgba(11, 14, 29, .95));
    box-shadow: var(--shadow);
}
.persona-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}
.persona-card h3 { margin-bottom: 3px; font-size: 20px; }
.persona-subtitle { color: var(--brand); font-size: 13px; font-weight: 750; }
.persona-description { margin: 16px 0; color: var(--muted); font-size: 14px; }
.persona-edition {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
}
.persona-edition-pg {
    color: #a9f0d6;
    border: 1px solid rgba(61, 211, 157, .36);
    background: rgba(20, 44, 41, .9);
}
.persona-edition-adult {
    color: #efd4ff;
    border: 1px solid rgba(182, 92, 255, .46);
    background: rgba(43, 21, 63, .9);
}
.persona-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }
.persona-tag {
    padding: 4px 8px;
    border: 1px solid rgba(91, 63, 143, .5);
    border-radius: 999px;
    color: #d7c4ef;
    background: rgba(43, 21, 63, .35);
    font-size: 11px;
    font-weight: 650;
}
.persona-card-actions { margin-top: 18px; }
.persona-card-actions .button { width: 100%; margin-top: 0; text-decoration: none; }

@media (max-width: 960px) {
    .persona-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .library-section-heading { flex-direction: column; }
    .persona-grid { grid-template-columns: 1fr; }
}
