:root {
    /* Obsidian/Zed inspired Dark Palette */
    --bg-main: #1e1e1e;
    --bg-sidebar: #252525;
    --bg-active-line: #161616;

    --text-main: #dcddde;
    --text-muted: #909090;
    --border-color: #333333;

    --accent: #ff7400; /* Orange */
    --accent-hover: #d96200;
    --bg-selected: #1a0c00;

    --icon-size: 13px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
}

body {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-main);
    color: var(--text-main);
    color-scheme: dark;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
}
.sidebar-search-btn {
    background: #1a1a1a;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    transition: all 0.2s;
}
.sidebar-search-btn:hover {
    border-color: var(--accent);
    color: var(--text-main);
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}
.tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    background: transparent;
    border: none;
    font-weight: bold;
    color: var(--text-muted);
    outline: none;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.tab.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
    background: var(--bg-selected);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Sort Controls */
.sort-controls {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    font-size: 12px;
}
.sort-controls select,
.sort-controls button {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px;
    background: #1a1a1a;
    color: var(--text-main);
    cursor: pointer;
    outline: none;
}
.sort-controls select:focus {
    border-color: var(--accent);
}
.sort-controls button {
    padding: 5px 10px;
}
.sort-controls button:hover {
    background: var(--bg-selected);
}

/* Lists */
.list-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 3px;
    display: flex;
    flex-direction: column;
    transition: background 0.1s;
}
.list-item:hover {
    background: #2a2a2a;
}
.list-item.active {
    background: var(--bg-selected);
    color: #ffffff;
}
.list-item.active .list-item-title {
    color: var(--accent);
}
.list-item-title {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-item-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
}

.tag-item {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    margin: 0 6px 6px 0;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    transition: all 0.2s;
}
.tag-item:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.active-filter {
    padding: 10px;
    background: rgba(255, 116, 0, 0.1);
    border: 1px solid rgba(255, 116, 0, 0.3);
    font-size: 12px;
    margin-bottom: 15px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--accent);
}
.clear-filter {
    cursor: pointer;
    font-weight: bold;
    color: var(--text-muted);
    font-size: 16px;
    margin-left: 10px;
}
.clear-filter:hover {
    color: #ff6b6b;
}

/* Editor */
.editor-container {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    scroll-behavior: smooth;
    transition: background-color 0.2s;
}

/* Drag & Drop Overlay Style */
.editor-container.drag-over {
    background-color: rgba(255, 116, 0, 0.05);
    box-shadow: inset 0 0 0 2px dashed var(--accent);
}

.editor-content {
    width: 100%;
    max-width: 850px;
    padding: 60px 40px 200px 40px;
    min-height: 100%;
}

.editor-content::after {
    content: "";
    display: block;
    height: 40vh; /* Sorgt dafür, dass man weit über den Text hinaus scrollen kann */
}

/* Editor Header (Rename / Delete) */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 25px;
}
.editor-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-main);
    flex: 1;
}
.editor-actions {
    display: flex;
    gap: 10px;
}

.editor-actions svg {
    width: var(--icon-size);
    height: var(--icon-size);
}
.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
}
.btn-icon:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}
.btn-icon.danger:hover {
    color: #ff4d4d;
    border-color: #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
}

/* Line styling */
.line-wrapper {
    margin-bottom: 0;
    min-height: 1.6em;
    position: relative;
    transition: background 0.1s;
    border-radius: 4px;
}

/* Rendered HTML Styling (Obsidian-like) */
.rendered-line {
    cursor: text;
    padding: 2px 8px;
    line-height: 1.6;
    color: var(--text-main);
    font-size: 16px;
    word-wrap: break-word; /* Kein pre-wrap mehr wegen Listen-Bug */
}
.rendered-line:hover {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.rendered-line h1,
.rendered-line h2,
.rendered-line h3,
.rendered-line h4 {
    color: #ffffff;
    margin-top: 0.5em;
    margin-bottom: 0.3em;
    font-weight: 600;
}
.rendered-line h1 {
    font-size: 2em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}
.rendered-line h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}
.rendered-line h3 {
    font-size: 1.25em;
}
.rendered-line h4 {
    font-size: 1.1em;
}
.rendered-line p {
    margin-bottom: 0;
}
.rendered-line a {
    color: var(--accent);
    text-decoration: none;
}
.rendered-line a:hover {
    text-decoration: underline;
}
.rendered-line img {
    max-width: 100%;
    border-radius: 6px;
    margin: 10px 0;
}
.rendered-line code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}
.rendered-line pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    overflow-x: auto;
}
.rendered-line pre code {
    background: transparent;
    padding: 0;
}
.rendered-line ul,
.rendered-line ol {
    padding-left: 20px;
    margin-top: 0;
    margin-bottom: 0;
}
.rendered-line li {
    margin-bottom: 0;
}
.rendered-line li p {
    margin: 0;
}
.rendered-line strong {
    color: #ffffff;
}

/* Active Edit Line - Textarea */
.active-line-wrapper {
    background: var(--bg-active-line);
    box-shadow: 0 0 0 4px var(--bg-active-line);
}

.active-textarea {
    width: 100%;
    border: none;
    outline: none;
    font-size: 16px;
    /* font-family: "Fira Code", "Consolas", "Monaco", monospace; */
    line-height: 1.6;
    padding: 2px 8px;
    background: transparent;
    color: #ffffff;
    resize: none;
    overflow: hidden;
    white-space: pre-wrap;
    word-wrap: break-word;
    display: block;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 150px;
}
.empty-state strong {
    color: var(--accent);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}
.modal {
    background: #2a2a2a;
    padding: 30px;
    border-radius: 12px;
    width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}
.modal h2 {
    margin-bottom: 20px;
    font-size: 20px;
    color: #ffffff;
}
.modal input[type="text"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 18px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #1a1a1a;
    color: var(--text-main);
    font-size: 15px;
    outline: none;
}
.modal input[type="text"]:focus {
    border-color: var(--accent);
}
.modal label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    margin-bottom: 25px;
    cursor: pointer;
    color: var(--text-muted);
}
.modal label:hover {
    color: var(--text-main);
}
.modal input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-cancel {
    background: #3a3a3a;
    color: var(--text-main);
}
.btn-cancel:hover {
    background: #4a4a4a;
}
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-hover);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Tags & Wikilinks im Render-Modus */
.inline-tag {
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}
.inline-tag:hover {
    text-decoration: underline;
    opacity: 0.8;
}
.wikilink {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(217, 98, 0, 0.4);
    cursor: pointer;
    transition: all 0.2s;
}
.wikilink:hover {
    background: rgba(217, 98, 0, 0.15);
    border-radius: 4px;
}

/* Dropdowns für Slash-Commands & Wikilinks */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background: #2a2a2a;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    min-width: 250px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    display: none;
    list-style: none;
    padding: 5px 0;
    margin-top: 5px;
}
.autocomplete-item {
    padding: 8px 15px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 14px;
}
.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--accent);
    color: white;
}

.rendered-line blockquote {
    padding: 1rem;
    border-left: 3px solid var(--border-color);
}

.rendered-line hr {
    border-bottom: 0.5px solid var(--border-color);
}

/* Tables */
.rendered-line table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 15px;
}
.rendered-line th,
.rendered-line td {
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    text-align: left;
}
.rendered-line th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: var(--text-main);
}
.rendered-line tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Search Results */
.search-results {
    max-height: 350px;
    overflow-y: auto;
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}
.search-result-group {
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.1);
}
.search-result-item {
    padding: 10px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
.search-result-title {
    font-weight: bold;
    color: var(--accent);
    font-size: 13px;
    margin-bottom: 4px;
}
.search-result-snippet {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
}
.search-highlight {
    background: rgba(217, 98, 0, 0.4);
    color: white;
    padding: 0 2px;
    border-radius: 2px;
}
.search-more-toggle {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    transition: background 0.1s;
}
.search-more-toggle:hover {
    background: rgba(0, 0, 0, 0.4);
}
.search-hidden-results {
    display: none;
}
