* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== HEADER ===== */
.header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.logo-text {
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.02em;
    color: var(--gray-900);
}

.logo-back {
    font-size: 14px;
    color: var(--gray-500);
    text-decoration: none;
    font-weight: 500;
    transition: color .2s;
}
.logo-back:hover { color: var(--primary); }

.logo-divider {
    color: var(--gray-300);
    margin: 0 4px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-link {
    font-size: 14px;
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 500;
    transition: color .15s;
    transition: color .2s;
}
.nav-link:hover { color: var(--primary); }
.nav-link.active { color: var(--primary); font-weight: 600; }

.nav-btn {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    padding: 6px 14px;
    border: 1.5px solid var(--primary);
    border-radius: 20px;
    transition: all .2s;
}
.nav-btn:hover {
    background: var(--primary);
    color: #fff;
}
.nav-btn-deploy {
    background: var(--primary);
    color: #fff;
}
.nav-btn-deploy:hover {
    background: #4338ca;
    border-color: #4338ca;
}

/* ===== MAIN ===== */
.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 40px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.page-header p {
    font-size: 15px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stat-badge {
    font-size: 13px;
    font-weight: 500;
    padding: 4px 12px;
    background: var(--primary);
    color: #fff;
    border-radius: 20px;
}

.stat-path {
    background: var(--gray-200);
    color: var(--gray-600);
    font-family: monospace;
    font-size: 11px;
}

/* ===== FOLDER SECTIONS ===== */
.folder-section {
    margin-bottom: 40px;
}

.folder-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gray-500);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.folder-count {
    font-size: 12px;
    font-weight: 600;
    background: var(--gray-200);
    color: var(--gray-600);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 4px;
}

/* ===== FILE GRID ===== */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: all .2s;
    box-shadow: var(--shadow);
}

.file-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.file-card-icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: 8px;
    color: var(--primary);
}

.file-card-info {
    flex: 1;
    min-width: 0;
}

.file-card-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-card-path {
    font-size: 12px;
    color: var(--gray-400);
    font-family: monospace;
    margin-top: 2px;
}

.file-card-meta {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

.file-card-arrow {
    color: var(--gray-300);
    font-size: 18px;
    transition: color .2s;
    flex-shrink: 0;
}

.file-card:hover .file-card-arrow {
    color: var(--primary);
}

/* ===== ALERTS ===== */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-weight: 500;
    font-size: 14px;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ===== EDITOR HEADER ===== */
.editor-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.editor-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.editor-path {
    font-size: 13px;
    color: var(--gray-400);
    font-family: monospace;
}

.editor-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}
.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-danger {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}
.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

/* ===== BACKUPS PANEL ===== */
.backups-panel {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.backups-panel h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--gray-700);
}

.backup-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.backup-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: 8px;
    font-size: 13px;
    flex-wrap: wrap;
}

.backup-name {
    font-family: monospace;
    color: var(--gray-700);
    flex: 1;
    min-width: 200px;
}

.backup-date {
    color: var(--gray-400);
    white-space: nowrap;
}

/* ===== TEXTS COUNT ===== */
.texts-count {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 20px;
    padding: 8px 14px;
    background: var(--gray-100);
    border-radius: 6px;
    display: inline-block;
}

/* ===== TEXT BLOCKS ===== */
.text-blocks {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.text-block {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    transition: border-color .2s;
}

.text-block:has(.is-changed) {
    border-color: var(--primary);
}

.text-block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.text-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    text-transform: uppercase;
}

.tag-h1 { background: #fef3c7; color: #92400e; }
.tag-h2 { background: #fef3c7; color: #92400e; }
.tag-h3 { background: #fef3c7; color: #92400e; }
.tag-h4 { background: #fef3c7; color: #92400e; }
.tag-p  { background: #eff6ff; color: #1e40af; }
.tag-dt { background: #f0fdf4; color: #14532d; }
.tag-dd { background: #f0fdf4; color: #14532d; }
.tag-a  { background: #fdf4ff; color: #7e22ce; }
.tag-button { background: #fff1f2; color: #9f1239; }
.tag-span { background: var(--gray-100); color: var(--gray-600); }
.tag-li { background: #fefce8; color: #713f12; }
.tag-blockquote { background: #f0f9ff; color: #0c4a6e; }

.text-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

.text-line {
    font-size: 12px;
    color: var(--gray-400);
    margin-left: auto;
    font-family: monospace;
}

.text-changed-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: #eef2ff;
    padding: 2px 8px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* ===== TEXT INPUTS ===== */
.text-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    font-family: inherit;
    background: var(--gray-50);
    color: var(--gray-800);
    resize: vertical;
}

.text-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
    background: #fff;
}

.text-input.is-changed {
    border-color: var(--primary);
    background: #fafafe;
}

.text-textarea {
    line-height: 1.6;
    min-height: 70px;
}

/* ===== SAVE BAR ===== */
.save-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -4px 12px rgba(0,0,0,.06);
    z-index: 100;
    gap: 12px;
    flex-wrap: wrap;
}

.save-bar span {
    font-size: 14px;
    color: var(--gray-500);
    font-weight: 500;
}

.save-bar div {
    display: flex;
    gap: 10px;
}


/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    background: #fff;
    border-radius: var(--radius);
    border: 1.5px dashed var(--gray-200);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--gray-300);
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--gray-400);
    margin-bottom: 24px;
    line-height: 1.7;
}


/* ===== SEO DASHBOARD ===== */
.seo-card { align-items: flex-start; }

.seo-indicators {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.seo-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
}

.seo-indicator i { font-size: 12px; }

.seo-indicator-ok      { background: #d1fae5; color: #065f46; }
.seo-indicator-warn    { background: #fef3c7; color: #92400e; }
.seo-indicator-missing { background: #fee2e2; color: #991b1b; }

.seo-legend {
    margin-top: 20px;
    font-size: 13px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-title i { color: var(--primary); }

.page-header-url {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: var(--gray-400);
    text-decoration: none;
    transition: color .15s;
}

.page-header-url:hover { color: var(--primary); }

/* ===== SEO EDITOR ===== */
.seo-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 28px;
    margin-bottom: 80px;
}

@media (max-width: 900px) {
    .seo-grid { grid-template-columns: 1fr; }
}

.seo-fields {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.seo-field {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.seo-submit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--gray-50);
    border-color: var(--gray-200);
}

.seo-submit-info {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--gray-500);
}

.seo-submit-info i {
    font-size: 15px;
    color: var(--primary);
    flex-shrink: 0;
}

.seo-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.seo-field label, .seo-field > label {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-700);
    display: block;
    margin-bottom: 10px;
}

.seo-field-header label { margin-bottom: 0; }

.char-counter {
    font-size: 13px;
    color: var(--gray-400);
    font-family: monospace;
    font-weight: 600;
}

.seo-progress {
    height: 4px;
    background: var(--gray-100);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.seo-progress-bar {
    height: 100%;
    background: #10b981;
    border-radius: 2px;
    transition: width .3s, background .3s;
}

.seo-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 8px;
    line-height: 1.5;
}

.mb-3 { margin-bottom: 12px; }

/* ===== OG IMAGE PANEL ===== */
.seo-image-panel {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 80px;
}

.seo-image-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

/* OG-Vorschau wie Social Media Card */
.og-preview-box {
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
    background: #fff;
}

.og-preview-img-wrap {
    width: 100%;
    aspect-ratio: 1200/630;
    background: var(--gray-100);
    overflow: hidden;
}

.og-preview-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.og-preview-meta {
    padding: 10px 12px;
    border-top: 1px solid var(--gray-200);
}

.og-preview-domain {
    font-size: 11px;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 3px;
}

.og-preview-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.3;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.og-preview-desc {
    font-size: 12px;
    color: var(--gray-500);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: var(--gray-50);
    margin-bottom: 12px;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--primary);
    background: #eef2ff;
}

.upload-icon { font-size: 32px; margin-bottom: 6px; color: var(--gray-400); }

.upload-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 3px;
}

.upload-hint {
    font-size: 12px;
    color: var(--gray-400);
}

.upload-status {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 10px;
}

.upload-status.uploading { background: #eff6ff; color: #1e40af; }
.upload-status.success   { background: #ecfdf5; color: #065f46; }
.upload-status.error     { background: #fef2f2; color: #991b1b; }

.og-path-display {
    font-size: 12px;
    color: var(--gray-400);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.og-path-label { font-weight: 600; color: var(--gray-500); }

#og-path-text { font-family: monospace; word-break: break-all; }

/* ===== SPLIT-SCREEN EDITOR ===== */

/* Body im Editor-Modus: kein Scroll, volle Höhe */
body.editor-page {
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

body.editor-page .header {
    flex-shrink: 0;
}

.split-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 61px);
}

/* Linke Spalte */
.split-left {
    width: 420px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--gray-200);
    background: var(--gray-50);
    position: relative;
}

.split-left .alert {
    margin: 12px 16px 0;
    flex-shrink: 0;
}

.editor-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}

.editor-path {
    font-size: 12px;
    color: var(--gray-400);
    font-family: monospace;
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Tab-Navigation ──────────────────────────────────────── */
.editor-tabs {
    display: flex;
    border-bottom: 1.5px solid var(--gray-200);
    background: #fff;
    flex-shrink: 0;
}

.editor-tab {
    flex: 1;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1.5px;
    transition: color .15s, border-color .15s;
}

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

.editor-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: #fafafe;
}

.tab-badge {
    font-size: 10px;
    font-weight: 700;
    background: var(--gray-200);
    color: var(--gray-600);
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.editor-tab.active .tab-badge {
    background: #e0e7ff;
    color: var(--primary);
}

/* ── Tab-Panels ──────────────────────────────────────────── */
.tab-panel {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.tab-count {
    padding: 8px 16px;
    font-size: 12px;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
    flex-shrink: 0;
}

.tab-panel form {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Text-Blöcke im Tab */
.tab-panel .text-blocks {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 70px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Bild-Blöcke im Tab */
.tab-panel .img-blocks {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 70px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Scrollbarer Bereich für Text-Blöcke (legacy) */
.split-left .backups-panel,
.split-left .empty-state {
    overflow-y: auto;
}

/* Text-Block angepasst für Split-Screen */
.split-left .text-block {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--gray-200);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}

.split-left .text-block.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.08);
}

.split-left .text-block:has(.is-changed) {
    border-color: var(--primary);
}

/* Save-Bar fixiert am unteren Rand der linken Spalte */
/* ── Code-Editor ─────────────────────────────────────────── */
.code-editor-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #0f172a;
    padding-bottom: 54px; /* Platz für absolut positionierte save-bar */
}
.code-editor-bar {
    background: #1e293b;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 12px;
}
.code-editor-bar-left {
    display: flex;
    align-items: center;
    gap: 6px;
}
.code-dot {
    width: 11px; height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
}
.code-editor-filename {
    margin-left: 8px;
    font-size: 12px;
    color: #94a3b8;
    font-family: monospace;
    display: flex;
    align-items: center;
    gap: 5px;
}
.code-editor-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: #4f46e522;
    color: #a78bfa;
}
.code-editor-cm {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* CodeMirror füllt den Container */
.code-editor-cm .CodeMirror {
    flex: 1;
    min-height: 0;
    height: 100%;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 12.5px;
    line-height: 1.7;
    background: #282a36;
}
.code-editor-cm .CodeMirror-scroll {
    height: 100%;
}
/* Zeilennummern dezent anpassen */
.code-editor-cm .CodeMirror-gutters {
    background: #21222c;
    border-right: 1px solid #3d3f4e;
}
.code-editor-cm .CodeMirror-linenumber {
    color: #6272a4;
    padding: 0 10px 0 6px;
    font-size: 11px;
}
/* Scrollbar */
.code-editor-cm .CodeMirror-vscrollbar::-webkit-scrollbar { width: 6px; }
.code-editor-cm .CodeMirror-vscrollbar::-webkit-scrollbar-track { background: #282a36; }
.code-editor-cm .CodeMirror-vscrollbar::-webkit-scrollbar-thumb { background: #44475a; border-radius: 3px; }

#panel-code {
    overflow: hidden;
    padding: 0;
}

/* Code Sync Status in Preview-Toolbar */
.code-sync-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    padding: 3px 8px;
    border-radius: 5px;
    flex: 1;
}
.code-sync-status.sync-pending { color: #94a3b8; }
.code-sync-status.sync-syncing { color: #60a5fa; }
.code-sync-status.sync-done    { color: #4ade80; }
.code-sync-status.sync-error   { color: #f87171; }
.spin-icon { display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.split-save-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
    z-index: 10;
}

.split-save-bar span {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
}

.split-save-bar div {
    display: flex;
    gap: 8px;
}

/* Resizer */
.split-resizer {
    width: 16px;
    min-width: 16px;
    background: var(--gray-100);
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
    border-left: 1px solid var(--gray-200);
    border-right: 1px solid var(--gray-200);
    transition: background .15s;
    z-index: 20;
    /* Größere Klick-Zone über negative Margins */
    margin-left: -2px;
    margin-right: -2px;
}

.split-resizer:hover,
.split-resizer.is-dragging {
    background: #eef2ff;
    border-color: var(--primary);
}

/* Drei-Punkte-Griff in der Mitte */
.split-resizer::before {
    content: '⋮';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: var(--gray-400);
    line-height: 1;
    pointer-events: none;
    transition: color .15s;
}

.split-resizer:hover::before,
.split-resizer.is-dragging::before {
    color: var(--primary);
}

/* Drag-Overlay verhindert dass iframe Mouse-Events abfängt */
.iframe-drag-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 5;
    cursor: col-resize;
    background: transparent;
}

/* Rechte Spalte: Vorschau */
.split-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--gray-100);
    min-width: 0;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.preview-toolbar-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-right: auto;
}

.preview-toolbar-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--gray-200);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}

.preview-toolbar-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
    border-color: var(--primary);
}

.preview-iframe {
    flex: 1;
    width: 100%;
    border: none;
    background: #fff;
}

/* Preview-Status */
.preview-status {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--gray-100);
    color: var(--gray-500);
}

.preview-status.status-ok      { background: #d1fae5; color: #065f46; }
.preview-status.status-warn    { background: #fef3c7; color: #92400e; }
.preview-status.status-offline { background: #fee2e2; color: #991b1b; }

/* Spin-Animation für Lade-Icon */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin .8s linear infinite; }

/* ===== IMAGE EDITOR ===== */

.img-blocks {
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.img-block {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    gap: 12px;
    transition: border-color .15s;
}

.img-block:has(.text-changed-badge[style*="inline-flex"]) {
    border-color: var(--primary);
}

/* Thumbnail mit Hover-Overlay */
.img-block-preview {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--gray-100);
    cursor: pointer;
}

.img-block-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.img-block-overlay {
    position: absolute;
    inset: 0;
    background: rgba(79,70,229,.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    opacity: 0;
    transition: opacity .15s;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
}

.img-block-overlay i { font-size: 18px; }

.img-block-preview:hover .img-block-overlay {
    opacity: 1;
}

.img-block-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.img-block-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tag-img { background: #f0fdf4; color: #14532d; }

.img-src-display {
    font-size: 11px;
    color: var(--gray-400);
    font-family: monospace;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.img-alt-input {
    font-size: 13px;
    padding: 6px 10px;
}

.img-save-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--gray-100);
    gap: 8px;
}

.img-change-hint {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
}

.img-action-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.img-action-row label.btn { cursor: pointer; }

/* ===== BILD-PICKER MODAL ===== */

.picker-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
}

.picker-backdrop.is-open { display: block; }

.picker-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(1000px, 96vw);
    height: min(680px, 92vh);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0,0,0,.25);
    z-index: 201;
    flex-direction: column;
    overflow: hidden;
}

.picker-modal.is-open { display: flex; }

/* Header */
.picker-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
    background: #fff;
}

.picker-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.picker-title i { color: var(--primary); }

.picker-search-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-100);
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    padding: 6px 12px;
    transition: border-color .15s;
}

.picker-search-wrap:focus-within {
    border-color: var(--primary);
    background: #fff;
}

.picker-search-wrap i { color: var(--gray-400); font-size: 15px; flex-shrink: 0; }

.picker-search-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--gray-800);
}

.picker-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--gray-200);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s;
}

.picker-close:hover { background: var(--gray-100); color: var(--danger); }

/* Subfolder-Leiste */
.picker-subfolder-bar {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--gray-100);
    flex-shrink: 0;
    overflow-x: auto;
    background: var(--gray-50);
    flex-wrap: wrap;
}

.picker-folder-btn {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border: 1.5px solid var(--gray-200);
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    transition: all .15s;
}

.picker-folder-btn:hover { border-color: var(--primary); color: var(--primary); }
.picker-folder-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Scrollbarer Wrapper */
.picker-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Bild-Grid */
.picker-grid {
    padding: 14px 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    align-content: start;
}

.picker-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    color: var(--gray-400);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.picker-item {
    cursor: pointer;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    overflow: hidden;
    transition: all .15s;
    background: #fff;
}

.picker-item:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
    transform: translateY(-2px);
}

.picker-item-img {
    width: 100%;
    height: 160px;
    /* Schachbrett-Hintergrund zeigt Transparenz bei PNGs/SVGs */
    background-color: #f8f8f8;
    background-image:
        linear-gradient(45deg, #e5e5e5 25%, transparent 25%),
        linear-gradient(-45deg, #e5e5e5 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e5e5 75%),
        linear-gradient(-45deg, transparent 75%, #e5e5e5 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 32px;
    color: var(--gray-300);
}

.picker-item-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    padding: 10px;
}

.picker-item-name {
    padding: 6px 10px;
    font-size: 11px;
    color: var(--gray-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-top: 1px solid var(--gray-200);
    background: #fff;
    font-weight: 500;
}

/* Footer */
.picker-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
    background: var(--gray-50);
    gap: 12px;
}

#picker-count {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

.picker-upload-btn { cursor: pointer; }

/* ===== FILE EDITOR (robots/llms) ===== */
.files-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 80px;
}

@media (max-width: 900px) { .files-grid { grid-template-columns: 1fr; } }

.file-editor-card {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.file-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.file-editor-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-editor-title i {
    font-size: 24px;
    color: var(--primary);
    width: 40px;
    height: 40px;
    background: var(--gray-100);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-editor-title h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.file-editor-path {
    font-size: 12px;
    color: var(--gray-400);
    font-family: monospace;
}

.file-info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: #1e40af;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    line-height: 1.5;
}

.file-info-box code {
    background: rgba(30,64,175,.1);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 12px;
}

.code-editor {
    width: 100%;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.7;
    padding: 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    resize: vertical;
    outline: none;
    transition: border-color .2s;
}

.code-editor:focus {
    border-color: var(--primary);
}

.file-editor-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.file-editor-hints {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.file-editor-hints span {
    font-size: 11px;
    color: var(--gray-400);
}

.file-editor-hints code {
    font-family: monospace;
    background: var(--gray-100);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
    color: var(--gray-600);
}

/* ===== SCHEMA EDITOR ===== */
.schema-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 28px;
    margin-bottom: 80px;
}

@media (max-width: 1000px) { .schema-layout { grid-template-columns: 1fr; } }

.schema-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.schema-section {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.schema-section h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.schema-section h3 i { color: var(--primary); }

.schema-field-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.schema-preview-panel {
    background: #0f172a;
    border-radius: var(--radius);
    overflow: hidden;
    height: fit-content;
    position: sticky;
    top: 80px;
    box-shadow: var(--shadow-md);
}

.schema-preview-header {
    padding: 12px 16px;
    background: #1e293b;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.schema-live-badge {
    margin-left: auto;
    background: #10b981;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.schema-preview-code {
    padding: 16px;
    margin: 0;
    color: #7dd3fc;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 500px;
    overflow-y: auto;
}

.schema-preview-footer {
    padding: 12px 16px;
    background: #1e293b;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== CLIENTS ===== */

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

.client-card {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all .2s;
    box-shadow: var(--shadow);
}
.client-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.client-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.client-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    flex-shrink: 0;
}

.client-avatar-lg {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    flex-shrink: 0;
}

.client-card-title {
    flex: 1;
    min-width: 0;
}

.client-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-domain {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-status-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}
.client-status-active  { background: #d1fae5; color: #065f46; }
.client-status-paused  { background: #fef3c7; color: #92400e; }
.client-status-inactive { background: var(--gray-100); color: var(--gray-500); }

.client-card-projects {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.client-project-pill {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    background: var(--gray-100);
    border-radius: 20px;
    color: var(--gray-700);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.client-project-count {
    font-size: 11px;
    color: var(--gray-400);
    margin-left: 2px;
}
.client-project-empty {
    color: var(--gray-400);
    font-style: italic;
}

.client-card-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--gray-400);
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 4px;
    border-top: 1px solid var(--gray-100);
}
.client-card-footer i { font-size: 13px; }
.client-card-arrow {
    margin-left: auto;
    font-size: 18px;
    color: var(--gray-300);
    transition: color .2s;
}
.client-card:hover .client-card-arrow { color: var(--primary); }

.client-empty {
    text-align: center;
    padding: 80px 24px;
    color: var(--gray-400);
}
.client-empty i {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
    opacity: .4;
}
.client-empty h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 8px;
}
.client-empty p {
    font-size: 14px;
    margin-bottom: 24px;
}

/* Client Detail */
.client-detail-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 24px;
    border-bottom: 1.5px solid var(--gray-200);
    flex-wrap: wrap;
}

.client-detail-title {
    flex: 1;
    min-width: 0;
}

.client-domain-link {
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: opacity .15s;
}
.client-domain-link:hover { opacity: .75; }

.client-notes-bar {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    color: #92400e;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 32px;
}
.client-notes-bar i { flex-shrink: 0; margin-top: 2px; font-size: 16px; }

/* ===== MODALS (global) ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.modal h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--gray-900);
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}
.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    background: var(--gray-50);
    color: var(--gray-800);
    font-family: inherit;
    transition: border .15s, background .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}

/* Save status indicator */
.save-status {
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    background: #fef3c7;
    color: #92400e;
    align-items: center;
    gap: 4px;
}

/* ===== RICH TEXT TOOLBAR ===== */
.rich-toolbar {
    position: fixed;
    background: #1e293b;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    gap: 1px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    z-index: 99999;
    pointer-events: all;
    opacity: 1;
    transition: opacity .1s, transform .1s;
    transform-origin: bottom center;
    user-select: none;
}
.rich-toolbar.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(.95);
}
.rich-toolbar::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e293b;
    border-bottom: none;
}

.rich-btn {
    width: 30px; height: 30px;
    border: none; border-radius: 6px;
    background: transparent; color: #94a3b8;
    cursor: pointer; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    transition: all .12s; flex-shrink: 0;
}
.rich-btn:hover  { background: rgba(255,255,255,.12); color: #fff; }
.rich-btn.active { background: rgba(99,102,241,.5); color: #fff; }

.rich-divider {
    width: 1px; height: 18px;
    background: rgba(255,255,255,.12);
    margin: 0 3px; flex-shrink: 0;
}

.rich-color-wrap { position: relative; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; }
.rich-color-preview {
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.3); cursor: pointer;
    transition: border-color .12s; pointer-events: none;
}
.rich-color-wrap:hover .rich-color-preview { border-color: rgba(255,255,255,.7); }
.rich-color-input {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

/* Contenteditable Felder */
.text-rich {
    min-height: 38px;
    padding: 8px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    background: #fff;
    font-size: 14px;
    line-height: 1.65;
    color: var(--gray-800);
    outline: none;
    cursor: text;
    word-break: break-word;
    transition: border-color .2s, box-shadow .2s;
    font-family: inherit;
}
.text-rich:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.text-rich strong, .text-rich b { font-weight: 700; }
.text-rich em, .text-rich i { font-style: italic; }
.text-rich u { text-decoration: underline; }
.text-rich:empty::before {
    content: attr(data-placeholder);
    color: var(--gray-400);
    pointer-events: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .main { padding: 20px 16px 100px; }
    .file-grid { grid-template-columns: 1fr; }
    .client-grid { grid-template-columns: 1fr; }
    .editor-header { flex-direction: column; }
    .text-line { display: none; }
    .form-row-2 { grid-template-columns: 1fr; }
}
