:root {
    color-scheme: light dark;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f3f4f7;
    --sidebar: #fbfbfc;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;
    --text: #101828;
    --text-2: #344054;
    --muted: #667085;
    /* The ink of the app icon's squiggle, darkened for text contrast. */
    --accent: #4c5fd5;
    --accent-hover: #3e50c2;
    --accent-text: #ffffff;
    --accent-soft: #eef0fc;
    --ring: 0 0 0 3px rgba(76, 95, 213, 0.18);
    --success: #067647;
    --success-soft: #ecfdf3;
    --warning: #b54708;
    --warning-soft: #fffaeb;
    --danger: #d92d20;
    --danger-soft: #fef3f2;
    --stage: #eceef2;
    --radius: 10px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
    --sidebar-w: 248px;
    --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --surface: #171a20;
        --surface-2: #1e222a;
        --sidebar: #13161b;
        --border: #262b34;
        --border-strong: #353b46;
        --text: #eceef2;
        --text-2: #c7cbd4;
        --muted: #8b93a3;
        --accent: #8b9cf7;
        --accent-hover: #a3b0fa;
        --accent-text: #0e1230;
        --accent-soft: #1f2442;
        --ring: 0 0 0 3px rgba(139, 156, 247, 0.25);
        --success: #4ade80;
        --success-soft: #13291c;
        --warning: #f5b453;
        --warning-soft: #2f2510;
        --danger: #f87171;
        --danger-soft: #341a1a;
        --stage: #0b0d10;
        --shadow-sm: none;
        --shadow: none;
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    }
}

* {
    box-sizing: border-box;
}

/* Elements styled with a display value still hide. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font:
        14px/1.5 -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        'Helvetica Neue',
        Arial,
        sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
code {
    font-family: var(--mono);
    font-size: 12px;
}
h1 {
    font-size: 22px;
    font-weight: 650;
    line-height: 1.3;
    margin: 0;
    letter-spacing: -0.015em;
}
h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 28px 0 12px;
}
.card h2 {
    margin: 0 0 14px;
}
.muted {
    color: var(--muted);
    font-weight: 400;
}
.small {
    font-size: 12px;
}
.icon {
    width: 18px;
    height: 18px;
    flex: none;
}

/* Layout: a fixed sidebar, with the page scrolling beside it. */
.content {
    margin-left: var(--sidebar-w);
    max-width: 1320px;
    padding: 32px 40px 72px;
}
.bare {
    display: grid;
    place-items: center;
    min-height: 100vh;
}
.topbar,
.nav-toggle,
.nav-backdrop {
    display: none;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    padding: 18px 12px 12px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 650;
    font-size: 15px;
    line-height: 1.2;
    padding: 0 8px;
}
.brand:hover {
    text-decoration: none;
}
.brand small {
    display: block;
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
}
.brand-icon {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 9px;
    box-shadow:
        0 0 0 1px var(--border),
        var(--shadow-sm);
}
.nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 14px;
}
.nav-label {
    margin: 18px 10px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.nav a,
.nav-external {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 500;
}
.nav a .icon,
.nav-external .icon {
    color: var(--muted);
}
.nav a:hover,
.nav-external:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}
.nav a.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.nav a.active .icon {
    color: var(--accent);
}
.sidebar-foot {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.nav-external {
    font-size: 13px;
}
.nav-external .icon:last-child {
    width: 13px;
    height: 13px;
    margin-left: auto;
}
.account {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.account form {
    margin: 0;
}
.account-link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    color: var(--text);
}
.account-link:hover,
.account-link.active {
    background: var(--surface-2);
    text-decoration: none;
}
.avatar {
    width: 32px;
    height: 32px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}
.account-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}
.account-text strong,
.account-text span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-text strong {
    font-size: 13px;
    font-weight: 600;
}
.account-text span {
    font-size: 12px;
    color: var(--muted);
}
.icon-button {
    width: 34px;
    height: 34px;
    flex: none;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    box-shadow: none;
    color: var(--muted);
    cursor: pointer;
}
.icon-button:hover {
    background: var(--surface-2);
    color: var(--text);
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head p {
    margin: 4px 0 0;
}
.back {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 13px;
}
.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin: 28px 0 12px;
}
.section-head h2 {
    margin: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.card + .card {
    margin-top: 16px;
}
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.card-head h2 {
    margin: 0;
}

/* Controls */
label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    flex: 1;
    min-width: 0;
}
input,
select,
textarea,
button,
.button {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 7px 11px;
    line-height: 20px;
}
input,
select,
textarea {
    box-shadow: var(--shadow-sm);
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
input::placeholder,
textarea::placeholder {
    color: var(--muted);
}
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}
button,
.button {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition:
        background 0.15s,
        border-color 0.15s;
}
button .icon,
.button .icon {
    width: 16px;
    height: 16px;
}
button:hover,
.button:hover {
    background: var(--surface-2);
    text-decoration: none;
}
button:focus-visible,
.button:focus-visible,
a:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}
.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}
.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.danger {
    color: var(--danger);
}
.danger:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
}
.block {
    width: 100%;
}
button.link {
    border: 0;
    background: none;
    box-shadow: none;
    padding: 0;
    color: var(--accent);
}
.row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.row + .row {
    margin-top: 14px;
}
.row label {
    min-width: 140px;
}

details {
    margin-top: 14px;
}
summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}
.help ul {
    margin: 8px 0 0;
    padding-left: 18px;
    color: var(--muted);
}
.help li + li {
    margin-top: 4px;
}

/* Flash and badges */
.flash {
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 20px;
    border: 1px solid;
    font-weight: 500;
}
.flash ul {
    margin: 6px 0 0;
    padding-left: 18px;
    font-weight: 400;
}
.flash-success {
    background: var(--success-soft);
    border-color: color-mix(in srgb, var(--success) 25%, transparent);
    color: var(--success);
}
.flash-error {
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 25%, transparent);
    color: var(--danger);
}
.badge {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 18px;
    padding: 0 8px;
    border-radius: 99px;
}
.badge-published {
    background: var(--success-soft);
    color: var(--success);
}
.badge-draft {
    background: var(--warning-soft);
    color: var(--warning);
}

/* Login */
.auth {
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}
/* The app icon's ruled paper, in white on the brand ink. */
.auth-brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
    padding: 40px 48px 40px 96px;
    color: #ffffff;
    background:
        linear-gradient(to right, transparent 63px, rgba(244, 176, 174, 0.5) 63px 65px, transparent 65px),
        repeating-linear-gradient(to bottom, transparent 0 43px, rgba(255, 255, 255, 0.1) 43px 44px),
        linear-gradient(160deg, #5a6de3, #3c4cbd);
}
.auth-brand-top {
    display: flex;
    align-items: center;
    gap: 14px;
}
.auth-name {
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -0.01em;
}
.auth-brand-copy {
    max-width: 420px;
}
.auth-brand-copy h2 {
    margin: 0 0 10px;
    font-size: 28px;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: -0.02em;
}
.auth-brand-copy p,
.auth-brand-foot {
    margin: 0;
    color: rgba(255, 255, 255, 0.75);
}
.auth-brand-foot {
    font-size: 12px;
}
.auth-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(16, 24, 40, 0.25);
}
.auth-main {
    display: grid;
    place-items: center;
    padding: 40px 24px;
    background: var(--surface);
}
.auth-form {
    width: min(360px, 100%);
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.auth-form header {
    margin-bottom: 8px;
}
.auth-form header p {
    margin: 6px 0 0;
}
.auth-form .flash {
    margin: 0;
}
.auth-form button {
    margin-top: 8px;
    padding: 9px 12px;
}
.auth-icon-compact {
    display: none;
    box-shadow:
        0 0 0 1px var(--border),
        var(--shadow);
}

/* Errors */
.empty {
    text-align: center;
    max-width: 420px;
    margin: 60px auto;
    padding: 16px;
}
.empty h1 {
    margin-bottom: 6px;
}
.empty p {
    margin: 0 0 20px;
}
.status-code {
    font-size: 56px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--accent);
    line-height: 1;
}

/* Dashboard */
.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
}
.stat span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}
.stat strong {
    display: block;
    margin-top: 4px;
    font-size: 28px;
    font-weight: 650;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
a.stat {
    color: var(--text);
    transition: border-color 0.15s;
}
a.stat:hover {
    border-color: var(--accent);
    text-decoration: none;
}
.columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
    gap: 32px;
    align-items: start;
}
.columns > section:only-child {
    grid-column: 1 / -1;
}
.list {
    padding: 4px 16px;
}
.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.list-row:last-child {
    border-bottom: 0;
}
.list-row.stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
a.list-link {
    color: var(--text);
}
a.list-link:hover {
    color: var(--accent);
    text-decoration: none;
}
.count {
    min-width: 28px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: 99px;
    padding: 1px 8px;
}
.action {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}
.action-name {
    color: var(--muted);
}
.action-auth {
    color: var(--muted);
}
.action-template,
.action-category,
.action-cover {
    color: var(--accent);
}
.action-language {
    color: var(--success);
}
.action-api_auth,
.action-api_session {
    color: var(--warning);
}
.action-user {
    color: var(--warning);
}

/* Tables */
.table-card {
    padding: 0;
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th,
td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th {
    padding-block: 9px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    background: var(--surface-2);
    white-space: nowrap;
}
tbody tr:last-child td {
    border-bottom: 0;
}
tbody tr:hover td {
    background: var(--surface-2);
}
.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.nowrap {
    white-space: nowrap;
}
.logs td {
    font-size: 13px;
}
.log-details {
    margin-top: 4px;
}
.log-details summary {
    font-weight: 500;
    font-size: 12px;
    color: var(--muted);
}
.log-details pre {
    margin: 6px 0 0;
    padding: 8px 10px;
    background: var(--surface-2);
    border-radius: 6px;
    font: 12px/1.45 var(--mono);
    max-width: 420px;
    overflow-x: auto;
}
.status {
    font: 600 12px var(--mono);
}
.status-2 {
    color: var(--success);
}
.status-3 {
    color: var(--muted);
}
.status-4 {
    color: var(--warning);
}
.status-5 {
    color: var(--danger);
}
.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
}
.badge-muted {
    background: var(--surface-2);
    color: var(--muted);
}
.badge-role-admin {
    background: var(--accent-soft);
    color: var(--accent);
}
.badge-role-editor {
    background: var(--surface-2);
    color: var(--text);
}
.badge-type-api {
    background: var(--surface-2);
    color: var(--muted);
}
.badge-type-admin {
    background: var(--accent-soft);
    color: var(--accent);
}

/* Forms */
.narrow {
    max-width: 760px;
}
.narrow .card > label + .row,
.narrow .card > label {
    margin-top: 12px;
}
label.check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text);
    margin-top: 14px;
}
label.check input {
    width: auto;
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Template cards */
.filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}
.template-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
.template-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}
.template-card .thumb {
    display: block;
    background: var(--stage);
    padding: 14px 14px 0;
}
.template-card canvas {
    display: block;
    width: 100%;
    border-radius: 3px 3px 0 0;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 2px 6px rgba(0, 0, 0, 0.08);
}
.template-card .meta {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.template-card .name {
    color: var(--text);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.template-card code {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
}
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}

/* Editor */
.editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.85fr);
    gap: 20px;
    align-items: start;
}
.editor-fields {
    min-width: 0;
}
textarea#elements {
    width: 100%;
    resize: vertical;
    min-height: 280px;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.55;
    tab-size: 2;
    background: var(--surface-2);
}
textarea.invalid {
    outline: 2px solid var(--danger);
    outline-offset: -1px;
}
.json-status {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--muted);
}
.json-status.error {
    color: var(--danger);
    font-weight: 500;
}
.insert {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.save-bar {
    position: sticky;
    bottom: 0;
    padding: 14px 0;
    background: linear-gradient(to top, var(--bg) 70%, transparent);
    display: flex;
    justify-content: flex-end;
}
.sticky {
    position: sticky;
    top: 24px;
}
.preview-controls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.preview-controls select {
    flex: 1;
    min-width: 70px;
    padding: 5px 8px;
    font-size: 13px;
}
.preview-stage {
    background: var(--stage);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    justify-content: center;
}
.preview-stage canvas {
    display: block;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 4px 14px rgba(0, 0, 0, 0.12);
}

@media (max-width: 1000px) {
    .editor,
    .columns {
        grid-template-columns: 1fr;
    }
    .editor-preview {
        order: -1;
    }
    .sticky {
        position: static;
    }
}

/* Narrow screens: the sidebar slides in over the page from a top bar. */
@media (max-width: 900px) {
    .topbar {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        align-items: center;
        gap: 6px;
        height: 56px;
        padding: 0 12px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
    }
    .topbar .brand {
        padding: 0;
    }
    .topbar .brand-icon {
        width: 28px;
        height: 28px;
        border-radius: 7px;
    }
    .nav-toggle {
        display: block;
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-lg);
    }
    .nav-toggle:checked ~ .sidebar {
        transform: none;
    }
    .nav-toggle:checked ~ .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(16, 24, 40, 0.4);
    }
    .content {
        margin-left: 0;
        padding: 24px 16px 48px;
    }
    .stats {
        gap: 10px;
    }
    .stat {
        padding: 12px 14px;
    }
    .stat strong {
        font-size: 22px;
    }
    .auth {
        grid-template-columns: 1fr;
    }
    .auth-brand {
        display: none;
    }
    .auth-icon-compact {
        display: block;
    }
}

/* Translations */
.translations-head {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.lang-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.lang-chip {
    padding: 3px 8px;
    font: 500 12px/1.4 var(--mono);
    border-radius: 99px;
    gap: 5px;
}
.lang-chip[aria-selected='true'] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}
.dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border);
    flex: none;
}
[data-status='complete'] .dot,
.coverage-complete .dot {
    background: var(--success);
}
[data-status='partial'] .dot,
.coverage-partial .dot {
    background: var(--warning);
}
.lang-chip[aria-selected='true'] .dot {
    box-shadow: 0 0 0 1.5px var(--accent-text);
}
.table-scroll {
    overflow-x: auto;
}
.translation-table th,
.translation-table td {
    padding: 6px 8px;
    vertical-align: middle;
}
.translation-table tbody th {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    width: 1%;
}
.translation-table .source-col {
    color: var(--muted);
    width: 38%;
}
.translations.is-source .source-col {
    display: none;
}
.translation-table input {
    width: 100%;
}
.translation-table tbody tr:hover td {
    background: none;
}
.coverage {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
}
.coverage:hover {
    text-decoration: none;
}
.matrix th,
.matrix td {
    padding: 7px 8px;
}
.matrix tbody th {
    font-weight: 500;
    white-space: nowrap;
}
.matrix tbody th .muted {
    display: block;
    font-size: 11px;
}
.matrix .lang-col {
    text-align: center;
    font-family: var(--mono);
    font-size: 11px;
}
.matrix .lang-col .dot {
    width: 10px;
    height: 10px;
}
.matrix tfoot th,
.matrix tfoot td {
    color: var(--muted);
    border-top: 1px solid var(--border);
    border-bottom: 0;
}
.legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 10px;
}
label.check.inline {
    margin: 0;
    flex: none;
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.small-button {
    padding: 3px 10px;
    font-size: 12px;
}

/* Covers */
.cover-thumb canvas,
.cover-thumb .cover-image,
.cover-thumb .cover-pdf {
    display: block;
    width: 100%;
    aspect-ratio: 595 / 842;
    border-radius: 3px 3px 0 0;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 2px 6px rgba(0, 0, 0, 0.08);
}
.cover-thumb .cover-image {
    object-fit: cover;
    background: var(--surface);
}
.cover-pdf {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    background: var(--surface);
    color: var(--muted);
    text-align: center;
    font-size: 11px;
    overflow: hidden;
    word-break: break-all;
}
.cover-pdf strong {
    font-size: 22px;
    color: var(--danger);
    letter-spacing: 0.04em;
}
.cover-stage {
    flex-direction: column;
    align-items: center;
    min-height: 200px;
}
.cover-stage img,
.cover-stage iframe {
    display: block;
    object-fit: cover;
    border: 0;
    background: #fff;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 4px 14px rgba(0, 0, 0, 0.12);
}
.cover-stage canvas {
    border-radius: 2px 6px 6px 2px;
}
.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
}
.segment {
    flex-direction: row;
    flex: none;
    cursor: pointer;
}
.segment input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.segment span {
    display: block;
    padding: 6px 14px;
    border-radius: 7px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
}
.segment input:checked + span {
    background: var(--accent);
    color: var(--accent-text);
}
.segment input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.card-head.spaced {
    margin-top: 18px;
}
.card h3 {
    font-size: 14px;
    margin: 0;
}
input[type='color'] {
    padding: 2px;
    height: 36px;
    width: 100%;
    cursor: pointer;
}
input[type='file'] {
    padding: 6px;
}
.file-info {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: baseline;
    margin: 0 0 12px;
}

/* Product preview: the cover above a strip of its pages */
textarea#pages {
    width: 100%;
    resize: vertical;
    min-height: 240px;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.55;
    background: var(--surface-2);
}
.product-preview {
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.product-cover canvas,
.product-cover img {
    display: block;
    width: 140px;
    border-radius: 3px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.page-strip {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 12px;
    max-height: 520px;
    overflow-y: auto;
}
.page-strip figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.page-strip canvas {
    display: block;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 2px 6px rgba(0, 0, 0, 0.08);
}
.page-strip figcaption {
    font-size: 11px;
    color: var(--muted);
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.page-strip figcaption.error {
    color: var(--danger);
}
