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

html, body {
    height: 100%; background: var(--bg);
    font-family: var(--font); color: var(--text-primary);
    overflow: hidden;
}

:root {
    --topbar-height: 44px;
    --font: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Top Bar ── */
.topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; z-index: 100; user-select: none;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 13px; font-weight: 500; letter-spacing: 0.04em; }
.logo span { color: var(--accent); }
.divider { width: 1px; height: 16px; background: var(--border); }
.doc-id { font-size: 11px; color: var(--text-muted); letter-spacing: 0.02em; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.status-badge {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; color: var(--text-secondary); letter-spacing: 0.02em;
}
.status-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent); flex-shrink: 0;
}
.status-dot.error    { background: #f05050; }
.status-dot.saving   { background: #f0b050; animation: pulse 1s ease-in-out infinite; }
.status-dot.readonly { background: var(--text-muted); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.save-hint {
    font-size: 11px; color: var(--text-muted); background: var(--bg);
    border: 1px solid var(--border); padding: 3px 10px;
    border-radius: 4px; letter-spacing: 0.02em;
}

/* ── Editor (Edit-Mode) ── */
.editor-wrap {
    position: fixed; top: var(--topbar-height); left: 0; right: 0; bottom: 0;
    overflow-y: auto; background: var(--bg);
}
textarea {
    display: block;
    width: 100%; min-height: 100%;
    padding: 28px 32px;
    font-size: 14px; line-height: 1.7;
    font-family: var(--font);
    tab-size: 4;
    background: var(--bg);
    color: var(--text-primary);
    caret-color: var(--accent);
    border: none; outline: none; resize: none;
    white-space: pre-wrap; word-wrap: break-word;
}
textarea::placeholder { color: var(--text-muted); }

/* ── Read-Only Highlight View ── */
.highlight-wrap {
    display: none;
    width: 100%; min-height: 100%;
}
.highlight-wrap pre {
    margin: 0; padding: 28px 32px;
    font-size: 14px; line-height: 1.7;
    font-family: var(--font);
    background: var(--bg) !important;
    white-space: pre-wrap; word-wrap: break-word;
}

/* ── Scrollbar ── */
.editor-wrap::-webkit-scrollbar { width: 8px; }
.editor-wrap::-webkit-scrollbar-track { background: var(--bg); }
.editor-wrap::-webkit-scrollbar-thumb { background: var(--border); }
.editor-wrap::-webkit-scrollbar-thumb:hover { background: #2e2e2e; }

/* ── Toast ── */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text-primary); font-size: 12px;
    padding: 10px 16px; border-radius: 6px; z-index: 200;
    opacity: 0; transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none; display: flex; align-items: center;
    gap: 8px; max-width: 280px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-accent {
    width: 3px; align-self: stretch; border-radius: 2px;
    background: var(--accent); flex-shrink: 0;
}
.toast-accent.error { background: #f05050; }

/* ── Copy Button ── */
.copy-btn {
    font-family: var(--font); font-size: 11px; color: var(--text-secondary);
    background: var(--bg); border: 1px solid var(--border);
    padding: 3px 10px; border-radius: 4px; cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
    letter-spacing: 0.02em; display: none;
}
.copy-btn:hover { color: var(--text-primary); border-color: #333; background: #1c1c1c; }
.copy-btn.visible { display: block; }

#highlight-wrap {
    display: none; /* Standardmäßig aus, wird per JS aktiviert */
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 20px;
    background: var(--bg-color);
}

#highlighting-content {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
}