:root {
    color-scheme: dark;
    --bg: #071018;
    --surface: #0d1823;
    --surface-2: #122130;
    --border: #213547;
    --text: #e9f1f7;
    --muted: #8fa5b6;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --success: #2dd4bf;
    --warning: #fbbf24;
    --danger: #fb7185;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

.shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding: 24px 18px;
    border-right: 1px solid var(--border);
    background: #09131d;
}

.brand,
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-mark {
    display: block;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--surface);
}

.brand strong,
.login-brand strong {
    display: block;
    letter-spacing: .01em;
}

.brand small,
.login-brand small,
.sidebar-user small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.nav {
    display: grid;
    gap: 6px;
    margin-top: 38px;
}

.nav a {
    padding: 11px 13px;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
}

.nav a:hover,
.nav a.active {
    background: var(--surface-2);
    color: var(--text);
}

.nav a.active {
    box-shadow: inset 3px 0 var(--accent);
}

.sidebar-user {
    margin-top: auto;
    padding: 14px 12px 0;
    border-top: 1px solid var(--border);
    overflow-wrap: anywhere;
}

.sidebar-user form { margin: 0; }
.sidebar-user-info { min-width: 0; }

.link-button {
    padding: 8px 0 0;
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
}

.content {
    min-width: 0;
    width: min(1500px, 100%);
    padding: 32px 38px 60px;
}

.page-header,
.panel-heading,
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.page-header {
    margin-bottom: 26px;
    align-items: flex-start;
}

.page-header > div { min-width: 0; }
.page-header h1 { overflow-wrap: anywhere; }

.page-header h1 {
    margin: 4px 0 0;
    font-size: clamp(26px, 3vw, 38px);
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card,
.panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 14px 35px rgb(0 0 0 / 14%);
}

.stat-card {
    padding: 19px;
    text-decoration: none;
}

a.stat-card:hover { border-color: var(--accent); background: var(--surface-2); }
a:focus-visible, button:focus-visible, summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.stat-card span {
    color: var(--muted);
    font-size: 13px;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
}

.stat-card.success {
    border-color: rgb(45 212 191 / 45%);
}

.stat-card.warning {
    border-color: rgb(251 191 36 / 45%);
}

.stat-card.accent {
    border-color: rgb(56 189 248 / 45%);
}

.panel {
    margin-bottom: 20px;
    overflow: hidden;
}

.panel-heading {
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
    margin: 0;
    font-size: 18px;
}

.panel-heading p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.table-wrap {
    overflow-x: auto;
    max-width: 100%;
    overscroll-behavior-x: contain;
}

.panel-body { padding: 20px 22px; }
.panel-body > :first-child { margin-top: 0; }
.panel-copy, .backup-health { margin: 18px 22px; line-height: 1.5; color: var(--muted); }
.backup-health:empty { display: none; }
[data-backup-jobs] { padding-left: 20px; line-height: 1.5; }
[data-backup-jobs] li + li { margin-top: 8px; }

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

th,
td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .09em;
    text-transform: uppercase;
}

tbody tr:hover {
    background: rgb(255 255 255 / 2%);
}

tbody tr:last-child td {
    border-bottom: 0;
}

.table-link {
    color: var(--text);
    font-weight: 650;
    text-decoration: none;
}

.table-link:hover {
    color: var(--accent);
}

.table-description {
    display: block;
    max-width: 430px;
    margin-top: 3px;
    color: var(--muted);
}

code {
    padding: 3px 7px;
    border-radius: 6px;
    background: #071018;
    color: #bae6fd;
}

.status {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.status.large {
    padding: 7px 12px;
}

.status.online,
.status.active,
.status.authorized {
    border-color: rgb(45 212 191 / 35%);
    background: rgb(45 212 191 / 10%);
    color: var(--success);
}

.status.pending,
.status.requested {
    border-color: rgb(251 191 36 / 35%);
    background: rgb(251 191 36 / 10%);
    color: var(--warning);
}

.status.revoked,
.status.failed,
.status.decommissioned {
    border-color: rgb(251 113 133 / 35%);
    background: rgb(251 113 133 / 10%);
    color: var(--danger);
}

.empty-state {
    padding: 54px 24px;
    text-align: center;
}

.empty-state.compact {
    padding: 26px;
}

.empty-state h3 {
    margin: 0 0 6px;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 9px;
    text-decoration: none;
    cursor: pointer;
}

.button.primary {
    background: var(--accent-strong);
    color: white;
}

.button.primary:hover {
    background: #0284c7;
}

.button:disabled, button:disabled {
    opacity: .45;
    cursor: not-allowed;
    filter: saturate(.3);
}
.button.primary:disabled:hover { background: var(--accent-strong); }

.button.secondary {
    border-color: var(--border);
    background: var(--surface-2);
    color: var(--text);
}

.button.danger {
    border-color: rgb(251 113 133 / 45%);
    background: rgb(251 113 133 / 12%);
    color: var(--danger);
}

.button.danger:hover {
    background: rgb(251 113 133 / 22%);
}

.link-button.danger {
    color: var(--danger);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.header-actions form {
    margin: 0;
}

select:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.filters label { flex: 0 1 180px; }
.filters label:first-child { flex: 1 1 250px; }
.filters > .button { flex: 0 0 auto; }

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    min-width: 0;
}

input,
select,
textarea {
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
    background: #08131d;
    color: var(--text);
    min-width: 0;
    max-width: 100%;
}

fieldset {
    min-inline-size: 0;
    margin: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
}
fieldset legend { padding: 0 6px; font-weight: 650; }
fieldset .checkbox + .checkbox { margin-top: 12px; }
fieldset p { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(56 189 248 / 12%);
}

.filters input {
    width: 100%;
}

.form-panel {
    max-width: 850px;
}

[hidden] {
    display: none !important;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 18px;
    padding: 22px;
}

.full-width {
    grid-column: 1 / -1;
}

textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.token-box {
    margin: 0 20px 20px;
    padding: 16px;
    border: 1px solid rgb(251 191 36 / 45%);
    border-radius: 11px;
    background: rgb(251 191 36 / 8%);
}

.token-box strong,
.token-box code {
    display: block;
}

.token-box code {
    margin: 10px 0;
    padding: 12px;
    overflow-wrap: anywhere;
    user-select: all;
}

.token-box small {
    color: var(--muted);
}

.token-box p {
    margin: 12px 0 0;
}

.download-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    padding: 18px 20px 20px;
}

.download-card {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
}

.download-card h3,
.download-card p {
    margin: 0;
}

.download-card p {
    color: var(--muted);
    font-size: 14px;
}

.download-meta {
    font-size: 13px;
}

.download-hash {
    display: block;
    overflow-wrap: anywhere;
    font-size: 12px;
    color: var(--muted);
}

.os-tabs {
    position: relative;
}

.os-tabs > input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.download-note {
    margin: 0 0 14px;
    color: var(--muted);
}

.os-tablist {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.os-icon {
    display: grid;
    justify-items: center;
    gap: 12px;
    width: 168px;
    margin: 0;
    padding: 28px 16px 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.os-icon svg {
    width: 84px;
    height: 84px;
}

.os-icon span {
    font-size: 16px;
    font-weight: 650;
}

#download-os-windows:checked ~ .os-tablist label[for="download-os-windows"],
#download-os-macos:checked ~ .os-tablist label[for="download-os-macos"],
#download-os-linux:checked ~ .os-tablist label[for="download-os-linux"],
#download-os-android:checked ~ .os-tablist label[for="download-os-android"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.download-pick {
    margin: 0 0 8px;
    color: var(--muted);
}

#download-os-windows:checked ~ .download-pick,
#download-os-macos:checked ~ .download-pick,
#download-os-linux:checked ~ .download-pick,
#download-os-android:checked ~ .download-pick {
    display: none;
}

.os-panel {
    display: none;
}

#download-os-windows:checked ~ .os-panel-windows,
#download-os-macos:checked ~ .os-panel-macos,
#download-os-linux:checked ~ .os-panel-linux,
#download-os-android:checked ~ .os-panel-android {
    display: block;
}

.os-panel .panel {
    overflow: visible;
}

.download-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
}

.download-actions > .button.primary {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.download-actions > .button.primary:only-child {
    border-radius: 9px;
}

.version-menu {
    position: relative;
}

.version-menu summary {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 1px solid rgb(255 255 255 / 28%);
    background: var(--accent-strong);
    color: white;
    list-style: none;
}

.version-menu summary::-webkit-details-marker {
    display: none;
}

.version-menu summary:hover {
    background: #0284c7;
}

.version-menu-list {
    position: absolute;
    z-index: 3;
    top: calc(100% + 6px);
    right: 0;
    display: grid;
    min-width: 180px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 14px 35px rgb(0 0 0 / 28%);
}

.version-menu-list a {
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--text);
    text-decoration: none;
}

.version-menu-list a:hover {
    background: var(--surface-2);
}

.install-steps {
    margin: 0;
    padding: 0 20px 8px 40px;
    display: grid;
    gap: 10px;
    color: var(--text);
}

.command-block {
    margin: 0 20px 16px;
    padding: 14px 16px;
    overflow-x: auto;
    border-radius: 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.muted-copy {
    margin: 0 20px 20px;
    color: var(--muted);
}

.pagination {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    color: var(--muted);
}

.pagination div {
    display: flex;
    gap: 8px;
}

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

.detail-list {
    margin: 0;
}

.detail-list div {
    display: grid;
    grid-template-columns: minmax(140px, 35%) 1fr;
    gap: 16px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
}

.detail-list div:last-child {
    border-bottom: 0;
}

.detail-list dt {
    color: var(--muted);
}

.detail-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.display-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    padding: 20px;
}

.display-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
}

.display-card strong {
    display: flex;
    justify-content: space-between;
}

.display-card strong span {
    color: var(--accent);
    font-size: 10px;
    text-transform: uppercase;
}

.display-card p {
    margin: 10px 0 5px;
}

.display-card small,
.muted {
    color: var(--muted);
}

.notice,
.error {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 9px;
}

.notice {
    border: 1px solid rgb(45 212 191 / 40%);
    background: rgb(45 212 191 / 10%);
}

.error {
    border: 1px solid rgb(251 113 133 / 40%);
    background: rgb(251 113 133 / 10%);
    color: #fecdd3;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 22px;
    background:
        radial-gradient(circle at 20% 10%, rgb(14 165 233 / 14%), transparent 35%),
        radial-gradient(circle at 90% 90%, rgb(99 102 241 / 12%), transparent 35%),
        var(--bg);
}

.login-card {
    width: min(430px, 100%);
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 28px 80px rgb(0 0 0 / 35%);
}

.login-card h1 {
    margin: 30px 0 8px;
    font-size: 25px;
}

.login-card > p {
    margin: 0 0 22px;
}

.form-stack {
    display: grid;
    gap: 16px;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    padding: 0;
    accent-color: #38bdf8;
    justify-self: start;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.checkbox input {
    width: 16px;
    height: 16px;
    min-height: 16px;
    flex: 0 0 auto;
}

@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}

@media (max-width: 760px) {
    .shell {
        display: block;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 16px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .nav {
        display: flex;
        margin-top: 18px;
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .nav a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .page-header,
    .panel-heading,
    .pagination {
        flex-wrap: wrap;
    }

    .download-list {
        grid-template-columns: minmax(0, 1fr);
        padding: 14px;
    }

    .download-card,
    .download-actions .button {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .sidebar-user {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        margin-top: 12px;
        padding: 12px 0 0;
    }

    .sidebar-user .link-button { padding: 8px; }

    .content {
        padding: 24px 16px 44px;
    }

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

    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-card { padding: 14px; }
    .stat-card strong { font-size: 26px; }
    .detail-list div { grid-template-columns: minmax(0, 1fr); gap: 6px; }

    .filters {
        align-items: stretch;
        flex-direction: column;
    }

    .filters label, .filters label:first-child { flex: 0 1 auto; }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .full-width {
        grid-column: auto;
    }

    .filters input {
        width: 100%;
    }
}

.button.compact {
    min-height: 32px;
    padding: 5px 10px;
    font-size: 13px;
}

body.knowledge-app .content {
    width: 100%;
    padding: 20px 24px 16px;
}

body.knowledge-app .page-header {
    margin-bottom: 12px;
}

body.knowledge-app .page-header h1 {
    font-size: 26px;
}

.knowledge-board {
    display: grid;
    grid-template-columns: 260px minmax(240px, 320px) minmax(0, 1fr);
    height: calc(100vh - 118px);
    min-height: 520px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.knowledge-col {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-right: 1px solid var(--border);
}

.knowledge-col-notebooks:has(details[open]) {
    z-index: 3;
}

.knowledge-col:last-child {
    border-right: 0;
}

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

.knowledge-col-notebooks .knowledge-col-head {
    align-items: flex-start;
    flex-wrap: wrap;
}

.knowledge-col-head h2,
.knowledge-side h3 {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.knowledge-tools,
.knowledge-current,
.knowledge-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.knowledge-current {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.knowledge-actions form {
    margin: 0;
}

.knowledge-scroll {
    min-height: 0;
    overflow: auto;
    flex: 1;
}

.knowledge-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
}

.knowledge-row span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
}

.knowledge-row small,
.knowledge-meta,
.knowledge-empty,
.knowledge-files small {
    color: var(--muted);
}

.knowledge-row small {
    flex: 0 0 auto;
    font-size: 12px;
}

.knowledge-row:hover {
    background: rgb(255 255 255 / 3%);
}

.knowledge-row.active {
    background: var(--surface-2);
    box-shadow: inset 3px 0 var(--accent);
}

.knowledge-count {
    min-width: 1.6em;
    padding: 1px 6px;
    border-radius: 999px;
    background: #071018;
    text-align: center;
}

.knowledge-search {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.knowledge-search input {
    flex: 1;
    min-width: 0;
    width: auto;
}

.knowledge-empty {
    margin: 0;
    padding: 22px 16px;
}

.knowledge-reader {
    padding: 22px 28px 40px;
}

.knowledge-reader-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.knowledge-reader-head h2 {
    margin: 0;
    font-size: 28px;
}

.knowledge-meta {
    margin: 6px 0 0;
    font-size: 13px;
}

.knowledge-markdown {
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.knowledge-markdown > :first-child {
    margin-top: 0;
}

.knowledge-markdown h1,
.knowledge-markdown h2,
.knowledge-markdown h3 {
    margin: 1.2em 0 .4em;
    line-height: 1.3;
}

.knowledge-markdown h1 {
    font-size: 1.6rem;
}

.knowledge-markdown h2 {
    font-size: 1.3rem;
}

.knowledge-markdown p,
.knowledge-markdown ul,
.knowledge-markdown ol,
.knowledge-markdown blockquote {
    margin: .6em 0;
}

.knowledge-markdown ul,
.knowledge-markdown ol {
    padding-left: 1.3em;
}

.knowledge-markdown blockquote {
    margin-left: 0;
    padding-left: 12px;
    border-left: 3px solid var(--border);
    color: var(--muted);
}

.knowledge-markdown a,
.knowledge-files a {
    color: var(--accent);
}

.knowledge-markdown img {
    max-width: 100%;
}

.knowledge-markdown pre {
    padding: 12px 14px;
    overflow: auto;
    border-radius: 9px;
    background: #071018;
}

.knowledge-markdown pre code {
    padding: 0;
    background: transparent;
    color: inherit;
}

.knowledge-markdown th {
    color: var(--text);
    font-size: inherit;
    letter-spacing: 0;
    text-transform: none;
}

.knowledge-side {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.knowledge-side h3 {
    margin-bottom: 10px;
}

.knowledge-files,
.knowledge-links {
    margin: 0;
    padding-left: 18px;
}

.knowledge-files li,
.knowledge-links li {
    margin: 6px 0;
}

.knowledge-link {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin: 0 0 8px;
}

.knowledge-pop {
    position: relative;
}

.knowledge-pop > summary {
    list-style: none;
    cursor: pointer;
}

.knowledge-pop > summary::-webkit-details-marker {
    display: none;
}

.knowledge-pop[open] > .knowledge-pop-form {
    position: absolute;
    z-index: 5;
    top: calc(100% + 6px);
    left: 0;
    display: grid;
    gap: 8px;
    width: 280px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 16px 40px rgb(0 0 0 / 35%);
}

.knowledge-pop-form input {
    width: 100%;
}

.knowledge-editor {
    max-width: none;
}

.knowledge-editor-form {
    display: grid;
    gap: 16px;
    padding: 22px;
}

.knowledge-editor-form input:not([type="file"]):not([type="hidden"]),
.knowledge-editor-form select,
.knowledge-editor-form textarea {
    width: 100%;
}

.knowledge-editor-form textarea {
    min-height: 60vh;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.5;
}

.knowledge-editor-form small,
.knowledge-editor .muted {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.knowledge-editor-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.knowledge-grant-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
}

@media (max-width: 1100px) {
    .knowledge-board {
        grid-template-columns: 220px 220px minmax(0, 1fr);
    }
}

@media (min-width: 761px) and (max-width: 1050px) {
    .knowledge-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        height: auto;
        min-height: 0;
    }
    .knowledge-col-reader { grid-column: 1 / -1; border-top: 1px solid var(--border); }
    .knowledge-scroll { max-height: 280px; }
    .knowledge-col-reader .knowledge-scroll { max-height: none; }
}

@media (max-width: 760px) {
    body.knowledge-app .content {
        padding: 16px 16px 24px;
    }

    .knowledge-board {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }

    .knowledge-scroll {
        max-height: 280px;
    }

    .knowledge-col-reader .knowledge-scroll {
        max-height: none;
    }

    .knowledge-editor-row,
    .knowledge-reader-head {
        grid-template-columns: 1fr;
        display: grid;
    }

    .knowledge-col-notebooks .knowledge-col-head { position: relative; }
    .knowledge-pop { position: static; }
    .knowledge-pop[open] > .knowledge-pop-form {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: calc(100% - 24px);
    }

    .knowledge-editor-form textarea {
        height: clamp(220px, 38dvh, 360px);
        min-height: 180px;
    }

    .responsive-table, .responsive-table tbody { display: block; }
    .responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .responsive-table tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
    .responsive-table tr:last-child { border-bottom: 0; }
    .responsive-table td { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; padding: 8px 16px; border: 0; overflow-wrap: anywhere; }
    .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; }
    .responsive-table td:not([data-label])::before { display: none; }
    .responsive-table .form-grid { padding: 14px 0; }
    .responsive-table .checkbox { width: auto; }
}
