/* The pages of a player's own account: characters, PK logs, settings,
   notifications and explains (templates/characters.html,
   pklogs_dashboard.html, settings.html, notifications.html,
   explains_mine.html and explains_submit.html). Classes start with ac- so
   they never collide with site CSS. Every color comes from the scheme
   tokens. */
.ac {
    /* Secondary text that stays at AA on the page and panel grounds. */
    --meta: color-mix(in srgb, var(--text) 40%, var(--text-dim));
    --wash: color-mix(in srgb, var(--highlight) 12%, transparent);
    width: 100%;
    max-width: 980px;
}
.ac [hidden] { display: none !important; }
.ac :focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.ac h2 { margin: 0; padding: 0; border: 0; letter-spacing: -.01em; color: var(--text-bright); }
.ac p { margin: 0; }
.ac-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* page head */
.ac-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin: 0 0 22px; }
.ac .ac-head h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.02em; color: var(--text-bright); }
.ac .ac-deck { margin: 6px 0 0; max-width: 64ch; font-size: 14.5px; line-height: 1.6; color: var(--meta); text-wrap: pretty; }
.ac-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.ac .ac-tools input[type=text] { width: 230px; max-width: 100%; height: 33px; margin: 0; font-size: 13.5px; }
.ac .alert { margin: 0 0 18px; max-width: 78ch; font-size: 14px; }
.ac .ac-empty { padding: 26px 20px; border: 1px dashed var(--border); border-radius: 8px; font-size: 14px; text-align: center; color: var(--meta); }

/* panels and section heads */
.ac-panel { min-width: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-secondary); }
.ac-sec { margin: 26px 0 0; }
.ac .ac-sec-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; font-size: 16px; font-weight: 700; }
.ac .ac-sub { margin: -4px 0 12px; max-width: 78ch; font-size: 13px; line-height: 1.55; color: var(--meta); }

/* tags */
.ac-tag {
    display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--bg-active);
    font-size: 11.5px; font-weight: 600; line-height: 1.45; color: var(--text); white-space: nowrap;
}
.ac-tag.is-good { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.ac-tag.is-bad { background: color-mix(in srgb, var(--error) 16%, transparent); color: var(--error); }
.ac-tag.is-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

/* tables. A wide table scrolls inside its own box. */
.ac-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ac table.ac-table { width: 100%; margin: 0; border-collapse: collapse; border: 0; font-size: 14px; }
.ac-table th {
    padding: 10px 16px; border: 0; border-bottom: 1px solid var(--border); background: none;
    font-family: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; text-align: left;
    color: var(--meta); white-space: nowrap;
}
.ac-table td { padding: 10px 16px; border: 0; border-top: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.ac-table tbody tr:first-child td { border-top: 0; }
.ac-table tbody tr:hover td { background: var(--bg-hover); }
.ac-table .ac-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ac-table .ac-date { font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; color: var(--meta); }
.ac-table a { color: var(--text-bright); text-decoration: none; }
.ac-table a:hover { color: var(--highlight); }
.ac-table .ac-name { font-weight: 600; color: var(--text-bright); }
.ac-acts { width: 1%; text-align: right; white-space: nowrap; }
.ac-acts a { margin-left: 12px; font-size: 13px; color: var(--meta); }
.ac-acts a:first-child { margin-left: 0; }

/* characters to pick from, on the PK logs page */
.ac-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.ac-picks a {
    display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 12px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--bg-secondary);
    font-size: 13.5px; font-weight: 500; color: var(--text-bright); text-decoration: none;
}
.ac-picks a span { font-size: 12px; font-weight: 400; color: var(--meta); }
.ac-picks a:hover { border-color: var(--border-hover); }
.ac-picks a[aria-current] { border-color: var(--highlight); background: var(--wash); }

/* settings */
.ac-card { margin: 0 0 16px; padding: 20px 22px; scroll-margin-top: 16px; }
.ac .ac-card h2 { font-size: 16px; font-weight: 700; }
.ac .ac-card > .ac-note { margin: 4px 0 16px; max-width: 70ch; font-size: 13.5px; line-height: 1.55; color: var(--meta); }
.ac-avatar { display: flex; align-items: flex-start; gap: 22px; flex-wrap: wrap; }
.ac-avatar-img {
    flex: none; width: 88px; height: 88px; border-radius: 10px; border: 1px solid var(--border); object-fit: cover;
    display: grid; place-items: center; background: var(--bg-active); font-size: 34px; font-weight: 700; color: var(--text-bright); text-transform: uppercase;
}
.ac-avatar-side { display: grid; gap: 10px; min-width: 0; }
.ac-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ac-file:focus-visible + .btn { outline: 2px solid var(--highlight); outline-offset: 2px; }
.ac-file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--meta); }
.ac-file-row span { overflow-wrap: anywhere; }
.ac-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ac-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; margin: 0 0 16px; }
.ac .ac-choice {
    display: flex; align-items: baseline; gap: 10px; margin: 0; padding: 10px 12px; cursor: pointer;
    border: 1px solid var(--border); border-radius: 6px; background: var(--bg-body);
    font-family: inherit; font-size: 14px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--text);
}
.ac .ac-choice:hover { border-color: var(--border-hover); }
.ac .ac-choice:has(input:checked) { border-color: var(--highlight); background: var(--wash); }
.ac-choice input { flex: none; margin: 0; align-self: center; }
.ac-choice b { font-weight: 600; color: var(--text-bright); }
.ac-choice span { font-size: 12.5px; color: var(--meta); }
.ac-field { display: grid; gap: 6px; max-width: 420px; margin: 0 0 14px; }
.ac .ac-field label { margin: 0; font-family: inherit; font-size: 13px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text-bright); }
.ac .ac-field input[type=text] { width: 100%; max-width: none; margin: 0; }
.ac-after { font-size: 13px; color: var(--meta); }

/* log in and password reset */
.ac-auth .ac-card { margin: 0; }
.ac-auth .ac-field { max-width: none; }
.ac .ac-field input[type=password] { width: 100%; max-width: none; margin: 0; }
.ac-or { display: flex; align-items: center; gap: 12px; margin: 20px 0 16px; font-size: 12.5px; color: var(--meta); }
.ac-or::before, .ac-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.ac-auth .alert[hidden] { display: none; }

/* notifications */
.ac ul.ac-list { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.ac-list li { margin: 0; border-top: 1px solid var(--border); }
.ac-list li:first-child { border-top: 0; }
.ac-notif {
    display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: baseline; gap: 4px 14px;
    padding: 11px 16px; border-left: 2px solid transparent; font-size: 14px; line-height: 1.45; color: var(--text); text-decoration: none;
}
.ac-notif:hover { background: var(--bg-hover); color: var(--text-bright); }
.ac-notif.is-unread { border-left-color: var(--highlight); background: var(--wash); color: var(--text-bright); }
.ac-notif b, .ac-notif strong { font-weight: 600; color: var(--text-bright); }
.ac-notif .ac-tag { justify-self: start; text-transform: lowercase; }
.ac-when { font-size: 12.5px; color: var(--meta); white-space: nowrap; }
.ac-more { color: var(--meta); }
.ac .pagination { margin-top: 16px; }

@media (max-width: 720px) {
    .ac-tools { width: 100%; }
    .ac .ac-tools input[type=text] { flex: 1 1 160px; width: auto; }
    .ac-table th, .ac-table td { padding-left: 12px; padding-right: 12px; }
    .ac-card { padding: 16px; }
    .ac-notif { grid-template-columns: minmax(0, 1fr) auto; }
    .ac-notif .ac-tag { grid-column: 1 / -1; }
    .ac .ac-tools input[type=text], .ac .ac-field input[type=text], .ac .ac-field input[type=password] { height: 44px; font-size: 16px; }
}

/* my explains (templates/explains_mine.html). Its script draws most of the page. */
/* ── My Explains ── */
.my-ex-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
    font-family: var(--font-sans);
    font-size: 0.88rem;
}

.my-ex-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    margin-bottom: 0.3rem;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.1s;
    flex-wrap: wrap;
}
.my-ex-row:hover { background: var(--bg-hover); }

.my-ex-topic {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-bright);
    min-width: 120px;
}

.my-ex-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.my-ex-badge-pending {
    background: rgba(var(--highlight-rgb), 0.12);
    color: var(--highlight);
    border: 1px solid rgba(var(--highlight-rgb), 0.25);
}
.my-ex-badge-approved {
    background: rgba(122,158,122,0.12);
    color: var(--accent);
    border: 1px solid rgba(122,158,122,0.25);
}
.my-ex-badge-rejected {
    background: var(--accent-muted);
    color: var(--error);
    border: 1px solid rgba(var(--error-rgb), 0.25);
}

.my-ex-date {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-left: auto;
}

.my-ex-detail {
    display: none;
    border: 1px solid var(--border);
    border-top: none;
    margin-top: -0.3rem;
    margin-bottom: 0.3rem;
    padding: 0.85rem 1rem;
    background: var(--bg-secondary);
}
.my-ex-detail.open { display: block; margin-bottom: 1rem; }

.my-ex-yaml {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-primary, var(--bg));
    padding: 0.65rem;
    border: 1px solid var(--border);
    margin-bottom: 0.65rem;
}

.my-ex-review-info {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.5;
}
.my-ex-reason {
    margin-top: 0.25rem;
    font-style: italic;
    color: var(--error);
}

/* submit an explain (templates/explains_submit.html). Its script draws most of the page. */
/* ── Explain Submission ── */
.ac.ex-page { max-width: 1100px; }

.ex-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 768px) { .ex-grid { grid-template-columns: 1fr; } }

.ex-editor { min-width: 0; }

.ex-field { margin-bottom: 1rem; }
.ex-field label {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
}
.ex-field input[type="text"],
.ex-field textarea {
    width: 100%;
    padding: 0.45rem 0.65rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.ex-field input[type="text"]:focus,
.ex-field textarea:focus {
    outline: none;
    border-color: var(--highlight);
}

.ex-topic-input { font-family: var(--font-mono); }

.ex-topic-status {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    margin-top: 0.3rem;
    min-height: 1.2em;
}
.ex-topic-status.found { color: var(--text-dim); }
.ex-topic-status.new-file { color: var(--accent); }

/* Mode tabs */
.ex-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
.ex-tabs button {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    padding: 0.45rem 0.85rem;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    transition: color 0.15s, border-color 0.15s;
}
.ex-tabs button:hover { color: var(--text-bright); }
.ex-tabs button.active {
    color: var(--highlight);
    border-bottom-color: var(--highlight);
}

/* Form fields */
.ex-summary-input { font-family: var(--font-sans); }
.ex-charcount {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-dim);
    text-align: right;
    margin-top: 0.2rem;
}
.ex-charcount.over { color: var(--error); }

.ex-bullet {
    font-family: var(--font-sans);
    margin-bottom: 0.4rem;
    min-height: 2.4em;
    resize: vertical;
}
.ex-bullet-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.35rem;
}
.ex-bullet-controls button {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    padding: 0.25rem 0.6rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.ex-bullet-controls button:hover {
    border-color: var(--border-hover);
    color: var(--text-bright);
}

/* Raw editor */
.ex-raw textarea {
    width: 100%;
    min-height: 280px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    tab-size: 2;
    padding: 0.75rem;
    resize: vertical;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text);
    box-sizing: border-box;
}
.ex-raw textarea:focus { outline: none; border-color: var(--highlight); }

/* Upload */
.ex-upload {
    padding: 2.5rem 1rem;
    text-align: center;
    border: 2px dashed var(--border);
    background: var(--bg-secondary);
    transition: border-color 0.2s;
}
.ex-upload:hover { border-color: var(--border-hover); }
.ex-upload input[type=file] { display: none; }
.ex-upload label { cursor: pointer; color: var(--highlight); font-family: var(--font-sans); font-size: 0.85rem; }
.ex-upload-status { margin-top: 0.5rem; font-size: 0.8rem; color: var(--text-dim); }

.ex-panel { display: none; }
.ex-panel.active { display: block; }

/* Errors */
.ex-errors {
    background: var(--error-bg, rgba(168,114,114,0.08));
    border: 1px solid rgba(var(--error-rgb), 0.25);
    padding: 0.6rem 0.85rem;
    margin-bottom: 1rem;
    list-style: none;
}
.ex-errors li {
    color: var(--error);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    margin-bottom: 0.2rem;
}
.ex-errors li::before { content: "\2716\00a0"; }

/* Submit */
.ex-submit { margin-top: 1.25rem; display: flex; gap: 0.75rem; align-items: center; }
.ex-submit-msg { font-family: var(--font-sans); font-size: 0.82rem; }
.ex-submit-msg.ok { color: var(--accent); }
.ex-submit-msg.err { color: var(--error); }

.ex-submitted { display: none; }
.ex-submitted.show {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 0.85rem;
}

/* Preview */
.ex-preview-col { position: sticky; top: 1rem; min-width: 0; }
.ex-preview {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 1.25rem;
    min-height: 180px;
}
.ex-preview-label {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 0.85rem;
    display: block;
}
.ex-preview-topic {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 0.65rem;
}
.ex-preview-summary {
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--text);
    margin-bottom: 0.85rem;
    line-height: 1.5;
}
.ex-preview-summary em { color: var(--text-dim); }
.ex-preview-summary strong, .ex-preview-bullets strong { color: var(--highlight); font-weight: 600; }
.ex-preview-bullets { list-style: none; padding: 0; margin: 0; }
.ex-preview-bullets li {
    position: relative;
    padding-left: 1rem;
    margin-bottom: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text);
}
.ex-preview-bullets li::before { content: "\2022"; position: absolute; left: 0; color: var(--highlight); }

.ex-json {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    background: var(--bg-secondary);
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    white-space: pre-wrap;
    line-height: 1.5;
    margin-top: 0.75rem;
    max-height: 180px;
    overflow-y: auto;
    color: var(--text-dim);
}
.ex-json .jk { color: var(--error); }
.ex-json .js { color: var(--accent); }

/* ---- log in: one centered column under the crest ---- */
.ac.ac-auth { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; max-width: 400px; margin: 5vh auto 0; }
.ac.ac-auth .ac-head { display: block; margin: 0; text-align: center; }
.ac.ac-auth .ac-deck { margin-left: auto; margin-right: auto; }
.ac.ac-auth .ac-panel { width: 100%; max-width: none; box-sizing: border-box; padding: 22px; }
.ac.ac-auth form .btn { display: flex; width: 100%; height: 38px; }
.ac.ac-auth input { width: 100%; box-sizing: border-box; }
.ac-auth .ac-crest { width: 150px; height: auto; margin-bottom: -14px; overflow: visible; }
.ac-auth .ac-under { margin: 0; font-size: 13.5px; color: var(--meta); text-align: center; }
.ac-auth .ac-under a { color: var(--link); }
