:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #687386;
    --line: #dce3ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #0f766e;
    --success: #12b76a;
    --warning: #f59e0b;
    --danger: #b42318;
    --shadow: 0 18px 44px rgba(31, 41, 55, 0.10);
}

* {
    box-sizing: border-box;
}

input[type="checkbox"] {
    transform: scale(0.8);
    transform-origin: center;
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
}

[hidden] {
    display: none !important;
}

.is-hidden {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

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

.index-link {
    color: var(--primary);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.th-sort {
    display: block;
    text-decoration: none;
    color: inherit;
    font-weight: 600;
    white-space: nowrap;
}

.th-sort:hover {
    color: #38bdf8;
}

.sort-arrow {
    font-size: 10px;
    margin-left: 2px;
}

.th-filter input {
    width: 100%;
    padding: 3px 6px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 12px;
    box-sizing: border-box;
}

.th-filter input:focus {
    outline: none;
    border-color: #38bdf8;
}

.index-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: 12px;
    font-weight: 700;
}

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

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    padding: 24px 18px 12px;
    background: #0d1628;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-toggle {
    display: none;
    font-size: 22px;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    font-size: 13px;
    color: #fff;
}

.sidebar-user a {
    color: #94a3b8;
    font-size: 12px;
    text-decoration: none;
}

.sidebar-user a:hover {
    color: #fff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand span,
.profile a,
.eyebrow,
.muted {
    color: var(--muted);
}

.brand span {
    display: block;
    color: #a7b0c0;
    font-size: 13px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #38bdf8;
    color: #082f49;
    font-weight: 800;
    overflow: hidden;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-mark.large {
    width: 56px;
    height: 56px;
    margin-bottom: 20px;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

nav a,
.profile {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
}

nav a .badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 10px;
    background: #38bdf8;
    color: #082f49;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.6;
}
nav a .badge-red {
    background: #ef4444;
    color: #fff;
}
    padding: 11px 12px;
    border-radius: 8px;
}

.nav-sublist {
    display: flex;
    flex-direction: column;
    padding-left: 16px;
}

.nav-sublist a {
    display: block;
    padding: 4px 12px;
    font-size: 13px;
}
.nav-sublist a::before {
    content: "▹";
    margin-right: 8px;
    opacity: 0.5;
}

nav a:hover,
nav a:focus {
    background: rgba(255, 255, 255, 0.10);
}

.sidebar-search {
    display: flex;
    margin: 4px 0;
}

.sidebar-search input {
    width: 100%;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 13px;
}

.sidebar-search input::placeholder {
    color: rgba(255,255,255,0.45);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
}

.sidebar-search input:focus {
    outline: none;
    border-color: #38bdf8;
    background: rgba(255,255,255,0.12);
}

.panel-search {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    width: 220px;
    max-width: 100%;
    box-sizing: border-box;
}
.panel-search:focus {
    outline: none;
    border-color: #38bdf8;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.search-result-item {
    display: block;
}

.search-result-title {
    color: var(--primary);
    font-size: 17px;
    font-weight: 600;
    text-decoration: none;
}

.search-result-title:hover {
    text-decoration: underline;
}

.search-result-meta {
    color: #1f8b4c;
    font-size: 13px;
    margin: 2px 0 4px;
}

.search-result-snippets {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.top-actions form {
    display: inline;
}

.userbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.userbar a {
    font-size: 13px;
    color: #64748b;
    text-decoration: none;
}

.userbar a:hover {
    color: #1e293b;
}

.content {
    flex: 1;
    padding: 34px;
    overflow-x: hidden;
}

.login-content {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(880px, 100%);
    min-height: 460px;
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 42px;
    align-items: center;
    padding: 56px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-card h1,
.page-head h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.2;
}

.login-card p,
.page-head p,
.card p {
    color: var(--muted);
}

.flash {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

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

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.page-head .actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.eyebrow {
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0;
    font-size: 12px;
    font-weight: 700;
}

.card-actions,
.row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.grid.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.check-form {
    display: flex;
    align-items: center;
    gap: 12px;
}

.check-form .check {
    margin: 0;
}

.check-form button {
    margin-left: auto;
}

.card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(31, 41, 55, 0.06);
}

.card {
    position: relative;
    padding: 20px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.drag-handle {
    position: absolute;
    top: 6px;
    right: 8px;
    cursor: grab;
    font-size: 18px;
    color: #94a3b8;
    user-select: none;
    line-height: 1;
    padding: 2px 4px;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle:hover {
    color: #475467;
}

.card h2,
.section-title h2 {
    margin: 0;
}

.panel {
    padding: 22px;
    margin-bottom: 18px;
}

.panel.narrow {
}

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

.section-title span {
    color: var(--muted);
    font-size: 14px;
}

.form-stack,
.field-builder,
.search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: flex-start;
    gap: 10px;
}

.form-stack label,
.field-builder label {
    flex: 0 1 auto;
    min-width: 180px;
}

.record-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 600px;
}

.search-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    flex: 1 1 300px;
}

.search-fields input {
    width: auto;
    min-width: 200px;
    max-width: 320px;
}

.search-fields label {
    flex: 0 1 200px;
    min-width: 140px;
}

.search-fields label input {
    width: 100%;
    max-width: none;
    min-width: 0;
}

.search-fields button,
.search-fields .button {
    flex: 0 0 auto;
}

.user-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 500px;
}

.user-form label:not(.check):not(.msel-opt) {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msel-wrapper {
    position: relative;
    margin-top: 4px;
}

.msel-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
    user-select: none;
}

.msel-trigger:hover {
    border-color: #b8c2d4;
}

.msel-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.msel-count {
    color: var(--primary);
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.msel-dropdown {
    display: none;
    position: fixed;
    z-index: 1000;
    margin-top: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 320px;
    overflow: hidden;
    min-width: 200px;
}

.msel-dropdown.open {
    display: flex;
    flex-direction: column;
}

.msel-search {
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    box-sizing: border-box;
    outline: none;
}

.msel-options {
    overflow-y: auto;
    max-height: 260px;
    padding: 4px 0;
}

.msel-options .msel-opt {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 2px 12px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 400;
    white-space: nowrap;
    line-height: 0.6;
}

.msel-opt:hover {
    background: #f8fafc;
}

.msel-opt input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
}

.msel-divider {
    height: 1px;
    background: var(--line);
    margin: 4px 0;
}

.record-form label {
    gap: 6px;
}

.label-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.file-group input[type="file"] {
    flex: 1;
    min-width: 180px;
}

.file-group .file-current {
    white-space: nowrap;
}

.file-group label.check {
    height: auto;
    margin: 0;
    white-space: nowrap;
    font-size: 13px;
}

.search-bar {
    margin-bottom: 16px;
}

.per-page-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 400;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

.per-page-label select {
    width: auto;
    min-height: 32px;
    padding: 3px 6px;
}

label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-weight: 650;
    font-size: 14px;
}

label.check {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 42px;
    white-space: nowrap;
}

input,
select,
textarea {
    width: 100%;
    min-height: 36px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 7px 10px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(37, 99, 235, 0.16);
    border-color: var(--primary);
}

button,
.button {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #1f2937;
    cursor: pointer;
    font-size: 12px;
}

.button:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.bi { margin-right: 4px; font-style: normal; display: inline-block; width: 1.4em; text-align: center; }

button.primary,
.button.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

button.primary:hover,
.button.primary:hover {
    background: var(--primary-dark);
}

.button.ghost {
    background: #f8fafc;
}

.button.ghost:hover {
    background: #e2e8f0;
}

button.danger,
.button.danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

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

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

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--line);
}

.tab {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab:hover {
    color: var(--text);
}

tr.unread td {
    font-weight: 700;
}

tr.unread td a {
    font-weight: 700;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.table-wrap table {
    width: max-content;
    min-width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

@media (max-width: 768px) {
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 680px; }
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
}

th {
    background: #f8fafc;
    color: #475467;
}

.meta-cell {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

.row-actions form {
    margin: 0;
}

.row-actions button,
.row-actions .button {
    color: var(--danger);
}

.empty {
    padding: 16px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: var(--muted);
    background: #f8fafc;
}

.empty-cell {
    padding: 18px 12px;
    color: var(--muted);
    text-align: center;
}

.form-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 18px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.42);
}

.form-modal {
    width: fit-content;
    min-width: min(420px, 100%);
    max-width: min(70vw, 100%);
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: auto;
    padding: 24px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 24px 72px rgba(15, 23, 42, 0.24);
}

.form-modal.wide {
    width: min(960px, 85vw);
    max-width: min(960px, 85vw);
}

.form-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.form-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.form-modal-header h1 {
    margin: 2px 0 0;
    font-size: 22px;
    line-height: 1.25;
}

.form-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
}

.form-modal-close:hover {
    color: var(--text);
    border-color: #b8c2d4;
    background: #f8fafc;
}

.form-modal .panel {
    padding: 0;
    border: 0;
    box-shadow: none;
}

@media (max-width: 720px) {
    .form-modal-backdrop {
        padding: 18px 10px;
    }

    .form-modal {
        max-height: calc(100vh - 36px);
        min-width: unset;
        max-width: 100%;
        padding: 18px;
    }
}

.todo-list {
    list-style: none;
    padding: 0;
    margin: 0;
    min-width: max-content;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.todo-item:last-child {
    border-bottom: none;
}

.todo-item.done .todo-title {
    text-decoration: line-through;
    color: var(--muted);
}

.todo-toggle {
    margin: 0;
}

.todo-title {
    flex: 0 1 auto;
    font-size: 13px;
}

.todo-remaining {
    font-size: 13px;
    font-weight: 600;
    color: #f59e0b;
    white-space: nowrap;
    min-width: 70px;
}

.todo-item.overdue .todo-remaining {
    color: #ef4444;
}

.todo-item.done .todo-remaining {
    color: #94a3b8;
}

.todo-date,
.todo-meta {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

.todo-due-form {
    margin: 0;
}

.todo-due-form input {
    width: 175px;
    padding: 3px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 12px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    box-sizing: border-box;
}

.todo-due-form input:hover,
.todo-due-form input:focus {
    border-color: var(--line);
    background: #fff;
}

.todo-delete {
    margin: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.todo-item:hover .todo-delete {
    opacity: 1;
}

.detail-panel {
    display: grid;
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.detail-row {
    display: grid;
    grid-template-columns: minmax(180px, 260px) 1fr;
    border-bottom: 1px solid var(--line);
}

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

.detail-label,
.detail-value {
    padding: 8px 14px;
    font-size: 13px;
}

.detail-label {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    color: #475467;
    font-weight: 700;
}

.detail-value {
    min-height: 40px;
    color: var(--text);
}

.file-current {
    font-size: 13px;
    color: var(--muted);
}

.lookup-combo {
    font-size: 14px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.page-info {
    font-size: 14px;
    color: var(--muted);
}

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

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 200;
        overflow-y: auto;
        transition: left 0.25s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        z-index: 199;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .content {
        padding: 20px;
    }

    .login-card {
        grid-template-columns: 1fr;
        padding: 28px;
    }

    .page-head {
        display: grid;
    }

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

    .menu-toggle {
        display: block;
    }
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.cal-head {
    background: var(--panel);
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    padding: 8px 4px;
    color: var(--muted);
}

.cal-day {
    background: var(--panel);
    min-height: 100px;
    padding: 4px;
    font-size: 13px;
}

.cal-other {
    background: #f9fafb;
}

.cal-today {
    background: #eff6ff;
}

.cal-day-num {
    font-weight: 700;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.cal-add {
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    padding: 0 4px;
}

.cal-add:hover {
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
}

.cal-event {
    font-size: 11px;
    padding: 2px 4px;
    margin-bottom: 2px;
    border-radius: 2px;
    background: #f0f4ff;
    line-height: 1.3;
}

.cal-event a {
    color: inherit;
    text-decoration: none;
    display: block;
}

.cal-event a:hover {
    text-decoration: underline;
}

.cal-creator {
    color: var(--muted);
    font-size: 10px;
}

.cal-location {
    display: block;
    font-size: 10px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-event-multi {
    background: #e0f2fe;
}
.cal-event-multi.cal-event-first {
    border-left-width: 4px;
}
.cal-event-multi.cal-event-last {
    border-right: 3px solid transparent;
}

.page-notice {
    margin-bottom: 16px;
    padding: 14px 18px;
    border-radius: 8px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    font-size: 14px;
    line-height: 1.6;
}
.page-notice > *:first-child { margin-top: 0; }
.page-notice > *:last-child { margin-bottom: 0; }

td[data-editable] {
    cursor: pointer;
    transition: background 0.1s;
}
td[data-editable]:hover {
    background: #f0f9ff;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    min-width: 320px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.confirm-modal p {
    margin: 0 0 20px;
    font-size: 15px;
    font-weight: 600;
}

@media print {
    body * {
        visibility: hidden;
    }
    .form-modal-backdrop,
    .form-modal-backdrop * {
        visibility: visible;
    }
    .form-modal-backdrop {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: #fff;
        padding: 20px;
    }
    .form-modal-close,
    .form-modal-header-actions .button {
        display: none !important;
    }
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 10;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 6px;
    border-right: 1px solid var(--line);
}

.toolbar-group:last-child {
    border-right: 0;
}

.toolbar-right {
    margin-left: auto;
}

.tool-btn {
    min-height: 32px;
    min-width: 32px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: #475467;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.tool-select {
    min-height: 32px;
    padding: 2px 4px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    width: auto;
}

.tool-color {
    min-height: 28px;
    width: 28px;
    padding: 1px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
}

.editor-wrapper {
    border: 1px solid var(--line);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.editor-area {
    min-height: 420px;
    max-height: calc(80vh - 140px);
    overflow-y: auto;
    padding: 18px;
    font-size: 15px;
    line-height: 1.7;
    outline: none;
    background: #fff;
}

.editor-area img {
    max-width: 100%;
    display: inline-block;
    resize: both;
    overflow: auto;
    cursor: nwse-resize;
    min-width: 40px;
    min-height: 40px;
}

.editor-area a {
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}

.editor-area a:hover {
    color: var(--primary-dark);
}

.editor-link-tooltip {
    position: absolute;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 12px;
}

.editor-source {
    width: 100%;
    min-height: 420px;
    max-height: calc(80vh - 140px);
    padding: 18px;
    border: 0;
    border-radius: 0;
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    background: #1e1e2e;
    color: #cdd6f4;
    outline: none;
}

.editor-source:focus {
    outline: none;
    border-color: transparent;
}

.cms-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text);
    padding: 28px 32px;
}

.cms-content img {
    max-width: 100%;
    height: auto;
}

.cms-content a {
    color: var(--primary);
    text-decoration: underline;
}

.cms-content a:hover {
    color: var(--primary-dark);
}

.cms-content ul,
.cms-content ol {
    padding-left: 24px;
}

.cms-content table {
    width: auto;
    min-width: 0;
    margin: 12px 0;
}

.cms-content table td,
.cms-content table th {
    border: 1px solid var(--line);
}

.button i, .button .fa-solid, .button .fa-regular, .button .fa-light { margin-right: 6px; }
.button.ghost i, .button.ghost .fa-solid, .button.ghost .fa-regular, .button.ghost .fa-light { margin-right: 6px; }
.button:hover i, .button.ghost:hover i { opacity: 0.85; }
