:root {
    color-scheme: light;
    --bg: #eef3f8;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --border: #d6e0ea;
    --border-strong: #b7c6d8;
    --text: #17202b;
    --muted: #65748a;
    --blue: #1f5fe0;
    --blue-soft: #e9f0ff;
    --green: #047857;
    --danger: #b42318;
    --danger-soft: #fff1f1;
    --shadow: 0 14px 34px rgba(18, 28, 45, 0.08);
    --focus: 0 0 0 3px rgba(31, 95, 224, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 1180px;
    background: linear-gradient(180deg, #f6f9fc 0, var(--bg) 180px);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

body.is-loading {
    cursor: progress;
}

body.auth-page {
    min-width: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

body.admin-page {
    min-width: 1180px;
}

a {
    color: inherit;
    text-decoration: none;
}

.auth-card {
    width: min(100%, 420px);
    display: grid;
    gap: 16px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-card .notice {
    margin: 0;
}

.topbar {
    min-height: 58px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    padding: 0 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-center,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-left {
    justify-self: start;
}

.topbar-center {
    justify-self: start;
    min-width: 0;
    width: 100%;
}

.topbar-right {
    justify-self: end;
}

.topbar strong {
    font-size: 16px;
}

.topbar span,
.section-heading span,
.muted {
    color: var(--muted);
}

.account-badge {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.toolbar,
.row-actions,
.add-module,
.project-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-shell {
    display: grid;
    grid-template-columns: minmax(560px, 1fr) minmax(560px, 1fr);
    height: calc(100vh - 58px);
    min-height: 760px;
}

.editor-panel,
.preview-panel {
    overflow: auto;
    padding: 18px;
    border-right: 1px solid var(--border);
}

.editor-panel {
    background: var(--surface-soft);
}

.preview-panel {
    background: #e8edf5;
    border-right: 0;
    padding-left: 12px;
    padding-right: 12px;
    overflow: hidden;
    margin-top: unset;
}

.preview-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.preview-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #ffffff;
}

.preview-mode-toggle button {
    min-height: 26px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    cursor: pointer;
    padding: 0 10px;
}

.preview-mode-toggle button[aria-pressed="true"] {
    background: var(--blue);
    color: #ffffff;
}

section + section {
    margin-top: 24px;
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.2;
}

h2 {
    font-size: 13px;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0;
}

.stack,
.editor-form {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
    color: #334155;
    font-weight: 650;
    font-size: 12px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    padding: 9px 10px;
}

textarea {
    resize: vertical;
}

textarea.wysiwyg-source {
    display: none;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(37, 99, 235, 0.2);
    border-color: var(--blue);
}

.button,
.icon-button,
.row-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--blue);
    border-radius: 6px;
    background: var(--blue);
    color: #ffffff;
    min-height: 36px;
    padding: 0 13px;
    font-weight: 750;
    font-size: 13px;
    cursor: pointer;
}

.button.ghost,
.row-actions button {
    border-color: var(--border);
    background: #ffffff;
    color: #334155;
}

.button.danger {
    border-color: #fecaca;
    background: #fff1f1;
    color: var(--danger);
}

.row-actions .button.danger {
    min-width: 28px;
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0 7px;
}

.table-actions .button.danger {
    min-width: 34px;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.topbar-right .button,
.topbar-right .export-toggle {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    padding: 0 12px;
    text-align: center;
    justify-content: center;
    white-space: nowrap;
}

.export-group {
    display: inline-flex;
    align-items: stretch;
    gap: 0;
    border-radius: 8px;
}

.export-dropdown {
    position: relative;
    border-left: 1px solid var(--border);
    
}

.export-dropdown:not([open]) .export-menu {
    display: none;
}

.export-dropdown > summary {
    list-style: none;
    border-radius: 0px 8px 8px 0px!important;
}

.export-dropdown > summary::-webkit-details-marker {
    display: none;
}

.export-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    min-width: 176px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.export-primary {
    /* border-top-right-radius: 0;
    border-bottom-right-radius: 0; */
    border-radius: 8px 0px 0px 8px!important;
}

.export-toggle {
    min-width: 42px;
    width: 42px;
    padding: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.36);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    font-size: 12px;
    font-weight: 900;
}

.export-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 34px;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    text-align: left;
    cursor: pointer;
}

.export-menu-item:hover {
    background: var(--surface-soft);
}

.wide {
    width: 100%;
}

.icon-button {
    width: 38px;
    padding: 0;
}

.module-list,
.user-list {
    display: grid;
    gap: 8px;
}

.module-row,
.user-row {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
}

.user-row {
    display: grid;
    gap: 3px;
    padding: 9px;
}

.module-row strong,
.user-row strong {
    font-size: 13px;
}

.module-row span,
.user-row span {
    color: var(--muted);
    font-size: 12px;
}

.user-create-form {
    margin-top: 12px;
}

.admin-shell {
    width: min(1180px, calc(100vw - 36px));
    margin: 18px auto;
    display: grid;
    gap: 18px;
}

.admin-panel {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.projects-shell {
    width: min(1280px, calc(100vw - 36px));
    margin: 18px auto;
    display: grid;
    gap: 18px;
}

.projects-panel {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.projects-table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
}

.projects-filter-bar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 180px auto auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
}

.projects-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

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

.projects-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
}

.projects-table tr:last-child td {
    border-bottom: 0;
}

.project-group-row td {
    background: var(--surface-soft);
    color: #334155;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.project-name-cell {
    display: grid;
    gap: 3px;
}

.projects-heading-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.project-import-form {
    margin: 0;
}

.project-import-form label {
    display: inline-flex;
}

.projects-table td:last-child {
    width: 172px;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.table-actions form {
    margin: 0;
}

.table-actions .row-icon,
.table-actions button,
.row-actions .row-icon {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: #334155;
    font-size: 15px;
    font-weight: 750;
    cursor: pointer;
}

.empty-table {
    height: 92px;
    color: var(--muted);
    text-align: center;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.disabled-link {
    pointer-events: none;
    opacity: 0.5;
}

.project-create-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.4fr) 260px 1fr auto;
    gap: 10px;
    align-items: end;
}

.project-create-notes {
    grid-column: 1 / 4;
    width: 100%;
}

.project-create-notes textarea {
    min-height: 40px;
    height: 40px;
    overflow: auto;
}

.project-create-language-row {
    display: flex;
    align-items: end;
    gap: 12px;
}

.project-create-language {
    flex: 0 0 130px;
}

.project-create-language select {
    width: 130px;
}

.project-create-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.project-create-toggle input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.user-admin-list {
    display: grid;
    gap: 10px;
}

.user-admin-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.user-form-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.4fr 1fr 140px 130px auto;
    gap: 10px;
    align-items: end;
}

.totp-setup {
    display: grid;
    gap: 12px;
    margin: 18px 0;
}

.totp-setup input,
.totp-setup textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
}

.totp-qr-wrap {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
}

.totp-qr-wrap canvas {
    width: 220px;
    height: 220px;
}

.totp-qr-fallback {
    display: none;
    margin: 0;
    text-align: center;
}

.totp-qr-wrap.is-unavailable .totp-qr-fallback {
    display: block;
}

.module-row.active {
    border-color: rgba(37, 99, 235, 0.5);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09);
}

.project-meta {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    margin-bottom: 20px;
}

.project-meta label {
    min-width: 0;
}

.project-title-form {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.project-title-form input {
    width: min(420px, 52vw);
    text-align: center;
    font-weight: 750;
}

.add-module {
    align-items: stretch;
    margin-bottom: 12px;
}

.add-module select:first-of-type {
    flex: 1.2;
}

.add-module select:last-of-type {
    flex: 1;
}

.module-row {
    display: grid;
    gap: 0;
    padding: 9px;
}

.module-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.module-title {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.row-actions {
    gap: 4px;
}

.row-actions form {
    margin: 0;
}

.row-actions button,
.row-actions .row-icon {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: #334155;
    font-weight: 750;
    font-size: 13px;
    cursor: pointer;
}

.row-actions .row-icon {
    padding: 0;
}

.editor-form {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: none;
}

.rich-field {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.rich-field legend {
    padding: 0 4px;
    color: #334155;
    font-size: 12px;
    font-weight: 750;
}

.rich-toolbar,
.paragraph-heading,
.wysiwyg-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rich-toolbar {
    justify-content: flex-end;
}

.paragraph-list {
    display: grid;
    gap: 10px;
}

.paragraph-editor {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.paragraph-heading {
    justify-content: space-between;
}

.paragraph-heading strong {
    font-size: 12px;
}

.rich-toolbar button,
.paragraph-heading button,
.wysiwyg-toolbar button {
    min-height: 30px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: #334155;
    font-weight: 750;
    font-size: 12px;
    cursor: pointer;
    padding: 0 9px;
}

.wysiwyg-wrap {
    position: relative;
    display: grid;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: visible;
    background: #ffffff;
}

.wysiwyg-toolbar {
    flex-wrap: wrap;
    padding: 6px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.wysiwyg-toolbar button {
    min-width: 32px;
}

.wysiwyg-editor {
    min-height: 116px;
    padding: 10px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    outline: none;
    overflow: auto;
}

.wysiwyg-editor a {
    color: var(--blue) !important;
    text-decoration: underline !important;
}

.wysiwyg-editor:focus {
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.wysiwyg-link-popover {
    position: absolute;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: calc(100% - 16px);
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.wysiwyg-link-popover[hidden] {
    display: none;
}

.wysiwyg-link-popover input,
.wysiwyg-link-popover select {
    width: 100%;
    min-height: 32px;
    padding: 6px 8px;
    font-size: 12px;
}

.wysiwyg-link-popover button {
    min-height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: #334155;
    font-weight: 750;
    font-size: 12px;
    cursor: pointer;
    padding: 0 9px;
}

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

.preview-stage {
    width: min(100%, var(--preview-stage-width, 650px));
    margin: 0 auto;
    padding: 0;
    border-radius: 8px;
    background: #d9e2ee;
    box-shadow: var(--shadow);
}

.preview-panel iframe {
    display: block;
    width: var(--preview-frame-width, 650px);
    max-width: 100%;
    height: clamp(200px, 80vh, 1500px);
    min-height: 200px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    margin: 0 auto;
}

.preview-code {
    width: min(100%, 1000px);
    max-width: 100%;
    height: clamp(200px, 80vh, 1500px);
    min-height: 200px;
    margin: 0 auto;
    padding: 16px;
    overflow: auto;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #0f172a;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-code .code-token {
    font: inherit;
}

.preview-code .code-token-delim {
    color: #64748b;
}

.preview-code .code-token-tag {
    color: #1d4ed8;
    font-weight: 700;
}

.preview-code .code-token-attr {
    color: #0f766e;
}

.preview-code .code-token-string {
    color: #b45309;
}

.preview-code .code-token-comment {
    color: #7c3aed;
}

.preview-code[hidden] {
    display: none;
}

body.preview-mode-code .preview-panel iframe {
    display: none;
}

body.preview-mode-code .preview-code {
    display: block;
}

body:not(.preview-mode-code) .preview-code {
    display: none;
}

.compile-log,
.notice {
    white-space: pre-wrap;
    border-radius: 8px;
    padding: 12px;
}

.compile-log-toggle {
    flex: 0 0 auto;
    min-width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
}

.compile-log {
    color: var(--danger);
    background: #fff1f1;
    border: 1px solid #fecaca;
    margin-bottom: 12px;
}

.notice {
    margin: 12px 18px 0;
}

.notice.error {
    color: var(--danger);
    background: #fff1f1;
    border: 1px solid #fecaca;
}

.empty-state,
.welcome {
    display: grid;
    place-content: center;
    gap: 12px;
    height: 100%;
    text-align: center;
    color: var(--muted);
}

.welcome {
    grid-column: 2 / 4;
}

.welcome h1,
.empty-state h2 {
    color: var(--text);
    text-transform: none;
    font-size: 24px;
}

.copy-buffer {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
}

body.preview-mode-desktop {
    --preview-frame-width: 650px;
    --preview-stage-width: 650px;
}

body.preview-mode-mobile {
    --preview-frame-width: 390px;
    --preview-stage-width: 390px;
}

body.preview-mode-code {
    --preview-stage-width: 1000px;
}

@media (max-width: 1360px) and (min-width: 1200px) {
    body {
        min-width: 1200px;
    }

    .app-shell {
        grid-template-columns: minmax(500px, 1fr) minmax(610px, 1fr);
    }

    .editor-panel {
        padding: 14px;
    }

    .preview-panel {
        padding-left: 0;
        padding-right: 0;
    }
}

@media (max-width: 1199px) and (min-width: 901px) {
    body {
        min-width: 1000px;
    }

    .topbar {
        gap: 12px;
        padding: 0 12px;
    }

    .app-shell {
        grid-template-columns: minmax(430px, 1fr) minmax(520px, 1fr);
    }

    .editor-panel {
        grid-column: 1;
        grid-row: 1;
        padding: 12px;
    }

    .preview-panel {
        grid-column: 2;
        grid-row: 1;
        padding-left: 0;
        padding-right: 0;
    }

    .project-meta {
        grid-template-columns: 1fr auto;
    }

    .editor-form {
        box-shadow: none;
    }

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

@media (max-width: 900px) {
    body {
        min-width: 0;
    }

    .topbar {
        height: auto;
        min-height: 58px;
        grid-template-columns: 1fr;
        padding: 8px 12px;
    }

    .topbar-left,
    .topbar-center,
    .topbar-right {
        min-width: 0;
        justify-self: stretch;
        width: 100%;
    }

    .topbar-right {
        justify-content: flex-start;
    }

    .project-title-form {
        width: 100%;
    }

    .project-title-form input {
        width: 100%;
    }

    .toolbar {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    .toolbar .button {
        min-width: 0;
        padding: 0 8px;
        text-align: center;
    }

    .export-group {
        width: 100%;
    }

    .topbar-right .button,
    .topbar-right .export-toggle {
        flex: 1 1 auto;
    }

    .app-shell {
        display: block;
        height: auto;
        min-height: 0;
    }

    .editor-panel,
    .preview-panel {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .project-meta {
        grid-template-columns: 1fr;
    }

    .preview-panel iframe {
        width: 100%;
        height: 720px;
    }

    .projects-shell {
        width: calc(100vw - 24px);
        margin: 12px auto;
    }

    .project-create-grid {
        grid-template-columns: 1fr;
    }

    .project-create-language-row {
        flex-direction: column;
        align-items: stretch;
    }

    .project-create-language,
    .project-create-language select {
        width: 100%;
        flex-basis: auto;
    }

    .projects-filter-bar {
        grid-template-columns: 1fr;
    }

    .project-create-notes {
        grid-column: auto;
    }
}

/* Design refresh */
:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.notice {
    width: min(1280px, calc(100vw - 36px));
    margin: 14px auto 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font-weight: 650;
}

.notice.error {
    border-color: #fecaca;
    background: #fff7f7;
    color: var(--danger);
}

.auth-card {
    padding: 28px;
    border-color: #cad7e5;
    box-shadow: 0 24px 70px rgba(18, 28, 45, 0.12);
}

.auth-card h1 {
    font-size: 24px;
}

.topbar {
    min-height: 76px;
    grid-template-columns: auto minmax(320px, 1fr) auto;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 25;
    box-shadow: 0 1px 0 rgba(18, 28, 45, 0.04);
}

.app-mark,
.topbar-title {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.topbar-title {
    display: grid;
    gap: 1px;
}

.topbar-title strong {
    font-size: 15px;
    font-weight: 800;
}

.topbar-title span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.app-mark {
    padding: 4px 0;
}

.app-mark-logo {
    display: block;
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 10px;
}

.account-badge {
    padding: 0 2px;
}

.button,
.icon-button,
.row-actions button {
    min-height: 40px;
    border-radius: 8px;
    border-color: var(--blue);
    background: var(--blue);
    box-shadow: 0 1px 0 rgba(18, 28, 45, 0.08);
}

.button:hover,
.icon-button:hover,
.row-actions button:hover,
.table-actions button:hover,
.table-actions .row-icon:hover,
.row-actions .row-icon:hover {
    filter: brightness(0.98);
}

.button.ghost,
.row-actions button,
.table-actions button,
.table-actions .row-icon,
.row-actions .row-icon,
.rich-toolbar button,
.paragraph-heading button,
.wysiwyg-toolbar button,
.wysiwyg-link-popover button {
    border-color: var(--border);
    background: #ffffff;
    color: #2f3b4d;
}

.button.danger,
.row-actions .button.danger,
.table-actions .button.danger {
    border-color: #f7baba;
    background: var(--danger-soft);
    color: var(--danger);
}

.button.danger:hover,
.row-actions .button.danger:hover,
.table-actions .button.danger:hover {
    background: #ffe5e5;
}

input,
select,
textarea {
    min-height: 40px;
    border-color: var(--border);
    border-radius: 8px;
    background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: var(--focus);
}

label {
    color: #354156;
}

.app-shell {
    grid-template-columns: minmax(560px, 0.95fr) minmax(620px, 1.05fr);
    height: calc(100vh - 64px);
    min-height: 720px;
}

.editor-panel,
.preview-panel {
    padding: 20px;
}

.editor-panel {
    border-right-color: #cfdbe8;
    background: #f8fafc;
}

.preview-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 12px;
    background: #e7edf5;
    overflow: auto;
}

.section-heading {
    align-items: center;
}

.section-heading h2 {
    letter-spacing: 0.02em;
}

.project-title-form {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 38px;
    padding-left: 8px;
}

.project-title-main {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    position: relative;
    z-index: 2;
}

.project-title-form input {
    width: 5ch;
    min-width: 96px;
    height: 38px;
    text-align: center;
    transition: width 140ms ease, box-shadow 140ms ease;
}

.project-title-form.is-expanded .project-title-main {
    z-index: 3;
}

.project-title-form.is-expanded input {
    width: clamp(320px, 42vw, 560px);
}

.project-title-main .button {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    opacity: 0;
    pointer-events: none;
    transform: translate(-8px, -50%);
    transition: opacity 120ms ease, transform 120ms ease;
}

.project-title-form.is-expanded .project-title-main .button {
    opacity: 1;
    pointer-events: auto;
    transform: translate(0, -50%);
}

.project-title-meta {
    position: absolute;
    left: 122px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    line-height: 1.2;
    white-space: nowrap;
}

.export-group {
    gap: 0;
}

.export-toggle {
    padding-inline: 0;
}

.export-menu {
    border-color: #cbd7e4;
}

.export-menu-item {
    border-radius: 7px;
}

.export-menu-item:hover,
.export-menu-item:focus-visible {
    background: var(--blue-soft);
    color: #123f9a;
}

.projects-shell,
.admin-shell {
    width: min(1360px, calc(100vw - 40px));
    margin: 22px auto;
}

.projects-panel,
.admin-panel {
    border-color: #cbd7e4;
    box-shadow: 0 10px 30px rgba(18, 28, 45, 0.06);
}

.projects-filter-bar {
    grid-template-columns: minmax(280px, 1fr) 240px 180px auto auto;
    align-items: end;
}

.projects-filter-bar select,
.project-create-grid select,
.user-form-grid select {
    height: 40px;
    min-height: 40px;
    padding-top: 0;
    padding-bottom: 0;
}

.projects-search input {
    min-width: 0;
}

.projects-table-wrap {
    border-color: #cbd7e4;
}

.projects-table th {
    background: #f7f9fc;
    color: #59677a;
    font-size: 11px;
}

.projects-table td {
    padding-block: 12px;
}

.projects-table tbody tr:not(.project-group-row):hover {
    background: #fbfdff;
}

.project-group-row td {
    background: #eef4fb;
    color: #36465b;
    letter-spacing: 0.02em;
}

.project-name-cell strong {
    font-size: 14px;
}

.project-create-grid {
    grid-template-columns: minmax(260px, 1.2fr) minmax(220px, 0.8fr) minmax(260px, 0.9fr) auto;
}

.project-create-toggle {
    min-height: 40px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    font-weight: 750;
}

.project-meta {
    padding: 12px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
}

.add-module {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
}

.module-list {
    gap: 10px;
}

.module-row {
    position: relative;
    padding: 11px;
    border-color: #d1dce8;
    border-radius: 10px;
}

.module-row.active {
    border-color: #8fb0ff;
    background: #fbfdff;
    box-shadow: 0 0 0 3px rgba(31, 95, 224, 0.12);
}

.module-row.active::before {
    content: "";
    position: absolute;
    inset: 10px auto 10px 0;
    width: 3px;
    border-radius: 999px;
    background: var(--blue);
}

.module-summary {
    gap: 12px;
}

.module-title {
    padding-left: 4px;
}

.module-title strong {
    font-size: 14px;
    line-height: 1.25;
}

.row-actions {
    gap: 6px;
}

.row-actions button,
.row-actions .row-icon {
    min-width: 34px;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
}

.editor-form {
    margin-top: 14px;
    padding: 16px;
    border-color: #cfdbe8;
    border-radius: 10px;
    background: #ffffff;
}

.rich-field {
    border-color: #cfdbe8;
    border-radius: 10px;
}

.paragraph-editor {
    border-color: #d7e1ec;
    background: #f9fbfd;
}

.wysiwyg-wrap {
    border-color: #cfdbe8;
    border-radius: 10px;
}

.wysiwyg-toolbar {
    padding: 8px;
    background: #f4f7fa;
}

.wysiwyg-toolbar button {
    min-width: 36px;
    min-height: 34px;
}

.wysiwyg-editor {
    min-height: 132px;
    padding: 12px;
}

.wysiwyg-link-popover {
    border-color: #cbd7e4;
    border-radius: 10px;
}

.preview-meta {
    gap: 10px;
}

.preview-mode-toggle {
    padding: 4px;
    border-color: #cbd7e4;
    box-shadow: 0 1px 0 rgba(18, 28, 45, 0.04);
}

.preview-mode-toggle button {
    min-height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 13px;
}

.compile-log-toggle {
    width: 34px;
    height: 34px;
    border: 1px solid #f59e0b;
    border-radius: 999px;
    background: #fff8eb;
    color: #92400e;
    font-weight: 900;
}

.compile-log {
    max-height: 180px;
    margin: 0;
    padding: 12px;
    overflow: auto;
    border: 1px solid #f7baba;
    border-radius: 10px;
    background: #fff7f7;
    color: var(--danger);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
}

.preview-stage {
    width: min(100%, var(--preview-stage-width, 680px));
    padding: 10px;
    border: 1px solid #cbd7e4;
    border-radius: 12px;
    background: #f2f5f9;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75), 0 14px 34px rgba(18, 28, 45, 0.08);
}

.preview-panel iframe,
.preview-code {
    border-color: #c5d1df;
    border-radius: 8px;
    box-shadow: 0 1px 0 rgba(18, 28, 45, 0.04);
}

.preview-code {
    background: #fbfdff;
}

.user-form-grid {
    grid-template-columns: 1.1fr 1.3fr 1fr 130px 130px auto;
}

.user-admin-row {
    border-color: #cfdbe8;
    background: #fbfdff;
}

@media (max-width: 1300px) {
    .topbar {
        grid-template-columns: auto minmax(240px, 1fr) auto;
    }

    .account-badge {
        display: none;
    }

    .project-title-main {
        width: 100%;
        justify-content: flex-start;
    }

    .project-title-form input {
        width: 5ch;
        min-width: 96px;
    }

    .project-title-form.is-expanded input {
        width: clamp(260px, 34vw, 420px);
    }

    .project-title-meta {
        left: 118px;
    }
}
