html[data-theme="dark"] .legal-panel a {
    color: oklch(82% 0.16 235deg);
}

html[data-theme="dark"] .legal-panel a:hover {
    color: oklch(90% 0.11 210deg);
}

.backend-page,
.accounts-page {
    margin-left: auto;
    margin-right: auto;
    max-width: calc(100vw - 24px);
}

.backend-page {
    align-items: center;
    display: flex;
    min-height: calc(100vh - 64px);
}

.accounts-page {
    padding: 0;
    width: 90vw;
}

.backend-panel {
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.account-admin-panel {
    max-width: calc(100vw - 24px);
}

.accounts-page .account-admin-panel {
    width: 100%;
}

.account-page .account-admin-panel {
    max-width: 760px;
}

.setup-status {
    display: grid;
    gap: 8px;
    margin: 20px 0 0;
    text-align: left;
}

.setup-status div {
    display: flex;
    justify-content: space-between;
}

.setup-status dt {
    font-weight: 700;
}

.setup-status dd {
    margin: 0;
}

.setup-checkbox {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.account-create-form {
    margin-left: auto;
    margin-right: auto;
    max-width: 420px;
}

.account-create-toggle {
    align-items: center;
    display: inline-flex;
    gap: 10px;
    justify-content: center;
}

.account-create-toggle .account-icon-toggle {
    flex: 0 0 auto;
}

.account-table-wrap {
    margin-top: 24px;
    overflow-x: auto;
}

.account-table {
    border-collapse: collapse;
    width: 100%;
}

.account-table th,
.account-table td {
    border-bottom: 1px solid var(--panel-border);
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
}

.account-meta {
    color: var(--muted-text);
    margin-top: 0;
}

.account-inline-form {
    align-items: center;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
}

.account-inline-form input {
    background: var(--input-bg);
    border: 1px solid var(--accent);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    max-width: none;
    min-height: 34px;
    padding: 0.35em 0.55em;
}

.account-password-input {
    min-width: 260px;
}

.account-date-cell {
    white-space: nowrap;
}

.account-toggle-cell {
    text-align: center;
    width: 72px;
}

.account-icon-toggle {
    display: inline-flex;
}

.account-icon-toggle input {
    opacity: 0;
    position: absolute;
}

.account-icon-toggle span,
.account-save-button {
    align-items: center;
    background: var(--control-bg);
    border: 1px solid var(--accent);
    border-radius: 999px;
    color: var(--control-text);
    cursor: pointer;
    display: inline-flex;
    height: 32px;
    justify-content: center;
    padding: 0;
    width: 32px;
}

.account-icon-toggle span {
    background: oklch(30% 0.03 250deg);
    color: #fff;
}

.account-icon-toggle svg,
.account-save-button svg {
    fill: none;
    height: 18px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    width: 18px;
}

.account-admin-toggle input:checked + span {
    background: oklch(48% 0.16 55deg);
    border-color: oklch(70% 0.15 65deg);
}

.account-active-toggle input:checked + span {
    background: oklch(42% 0.14 150deg);
    border-color: oklch(70% 0.14 150deg);
}

.account-active-toggle input:not(:checked) + span {
    background: oklch(38% 0.16 25deg);
    border-color: oklch(65% 0.15 25deg);
}

.account-icon-toggle .icon-eye-off,
.account-icon-toggle input:not(:checked) + span .icon-eye {
    display: none;
}

.account-icon-toggle input:not(:checked) + span .icon-eye-off {
    display: block;
}

.account-save-button {
    min-height: 32px;
}

.legal-page {
    gap: 14px;
}

.legal-panel {
    line-height: 1.65;
    margin-bottom: 14px;
    overflow-wrap: anywhere;
}

.legal-panel h1,
.legal-panel h2 {
    margin-top: 0;
}

.legal-panel h1 {
    margin-bottom: 18px;
}

.legal-panel h2 {
    font-size: clamp(1.25rem, 2vw, 1.6rem);
}

.legal-panel p {
    margin: 0 0 12px;
}

.legal-panel p:last-child {
    margin-bottom: 0;
}

.legal-panel ul {
    margin: 0 0 12px 1.2em;
    padding: 0;
}

.legal-panel li {
    margin-bottom: 6px;
}

.legal-updated {
    font-weight: 700;
}

.legal-panel a {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.16em;
}

body.stats-page {
    padding: 64px 14px 48px;
}

.stats-page main {
    margin: 0 auto;
    max-width: 1120px;
}

.stats-header {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: center;
    margin-bottom: 18px;
    text-align: center;
}

.stats-page h1,
.stats-page h2,
.stats-page p {
    margin-top: 0;
}

.stats-page h1 {
    font-size: clamp(1.4rem, 3vw, 2rem);
    margin-bottom: 6px;
}

.stats-page h2 {
    font-size: 1.15rem;
    margin-bottom: 12px;
}

.stats-page a {
    color: var(--accent);
    text-decoration: none;
}

.stats-summary {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 16px;
}

.stats-summary-card,
.stats-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 16px;
}

.stats-summary-label {
    color: var(--muted-text);
    font-size: 0.88rem;
}

.stats-summary-value {
    display: block;
    font-size: 1.7rem;
    line-height: 1.1;
    margin-top: 6px;
}

.stats-summary-value.stats-summary-date {
    font-size: 1rem;
}

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

.stats-section,
.stats-signifier-section {
    margin-top: 16px;
}

.stats-language-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-page table {
    border-collapse: collapse;
    width: 100%;
}

.stats-page th,
.stats-page td {
    border-bottom: 1px solid oklch(70% 0.05 245 / 24%);
    padding: 8px 4px;
    text-align: left;
}

.stats-page th:last-child,
.stats-page td:last-child {
    text-align: right;
}

.stats-matrix-wrap {
    overflow-x: auto;
}

.stats-signifier-matrix {
    min-width: 780px;
}

.stats-signifier-matrix th,
.stats-signifier-matrix td {
    border: 1px solid oklch(70% 0.05 245 / 22%);
    font-size: 1.2rem;
    padding: 8px 10px;
    text-align: center;
    white-space: nowrap;
}

.stats-signifier-key {
    background: oklch(18% 0 0 / 100%);
}

.stats-signifier-value {
    background: oklch(43% 0 0 / 100%);
}

.element-space {
    background: oklch(100% 0 0 / 100%);
    color: oklch(10% 0 0 / 100%);
}

.element-fire {
    background: oklch(43% 0.17 28 / 100%);
    color: oklch(100% 0 0 / 100%);
}

.element-water {
    background: oklch(31% 0.17 264 / 100%);
    color: oklch(100% 0 0 / 100%);
}

.element-wind {
    background: oklch(42% 0.16 143 / 100%);
    color: oklch(100% 0 0 / 100%);
}

.element-earth {
    background: oklch(78% 0.17 75 / 100%);
    color: oklch(10% 0 0 / 100%);
}

.element-diamond {
    background: oklch(70% 0.16 55 / 100%);
    color: oklch(100% 0 0 / 100%);
}

@media (max-width: 760px) {
    .stats-header {
        align-items: start;
        display: block;
    }

    .stats-summary,
    .stats-grid,
    .stats-language-grid {
        grid-template-columns: 1fr;
    }
}
