/* ===== Scrollbar CSS ===== */
/* Firefox */
* {
    scrollbar-width: auto;
    scrollbar-color: #383838 #545454;
    overflow-wrap: break-word;
}

/* Chrome, Edge, and Safari */
*::-webkit-scrollbar {
    width: 16px;
}

*::-webkit-scrollbar-track {
    background: #545454;
}

*::-webkit-scrollbar-thumb {
    background-color: #383838;
    border-radius: 10px;
    border: 3px solid #ffffff;
}

/* === Global Layout === */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: "Inter", system-ui, sans-serif;
    background: #1e1e1e;
    color: #e6e6e6;
    overflow: hidden;
    /* nur aside und main scrollen */
}

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

body {
    display: flex;
    height: 100vh;
}

/* Highlighting für aktuell vorgelesenen Paragraph */
.reading {
    background-color: #49275a;
    outline: 5px solid #49275a;
    outline-offset: 0px;
    transition: background 0.3s;
    border-radius: 5px;
}

/* Button Styling */
#tts-btn,
.tts_follow {
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    border-radius: 5px;
    border: none;
    border-left: 3px solid #810dd4;
    background-color: #1e1e1e;
    color: white;
    font-size: 1rem;
    text-align: center;
    font-weight: 500;
    transition: background 0.2s, transform 0.1s;
}

#tts-btn:hover,
.tts_follow:hover {
    background-color: #2b2b2b;
    transform: scale(1.03);
}

/* Selectbox Styling */
#tts-rate-select,
#tts-volume-select,
#tts-mode-select {
    padding: 0.3rem 0.5rem;
    border-radius: 5px;
    border: 1px solid #810dd4;
    background-color: #1e1e1e;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

#tts-rate-select:hover,
#tts-volume-select:hover,
#tts-mode-select:hover {
    background-color: #2b2b2b;
    border-color: #a64ef5;
}

#tts-rate-select:focus,
#tts-volume-select:focus {
    outline: none;
    box-shadow: 0 0 5px #810dd4;
}

.tts {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tts-settings {
    display: flex;
    gap: 0.5rem;
}

.tts-settings>select {
    width: 50%;
}

aside .top {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

i.fa-folder {
    color: #6b6b6b;
}

.date {
    background-color: #252525;
    padding: 10px;
    width: fit-content;
    border-radius: 10px;
    border-left: 3px solid #810dd4;
}

footer {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7d7d7d;
    border-top: 1px solid #7d7d7d;
    padding-top: 0.5rem;
}

/* Hierarchische Struktur */
main h1,
main h2,
main h3,
main h4,
main h5 {
    border-bottom: 1px solid #383838;
}

main h1 {
    font-size: 2.2rem;
}

main h2 {
    font-size: 2rem;
}

main h3 {
    font-size: 1.8rem;
}

main h4 {
    font-size: 1.4rem;
}

main h5 {
    font-size: 1rem;
}

main>p,
main>blockquote {
    margin: 1rem 0rem;
}

blockquote {
    background-color: #2f2f2f;
    border: none;
    padding: 1rem;
    border-radius: 0.5rem;
    border-left: 3px solid #810dd4;
}

/* Terminal-Style Codeblöcke */
.terminal {
    background: #1e1e1e;
    color: #dcdcdc;
    border-radius: 8px;
    margin: 1em 0;
    overflow: hidden;
    font-family: 'Fira Code', monospace;
    position: relative;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c2c2c;
    padding: 0.5em 1em;
    font-size: 0.9em;
}

.terminal-header .language {
    font-weight: bold;
    text-transform: capitalize;
}

.terminal-header .copy-btn {
    background: transparent;
    border: none;
    color: #dcdcdc;
    cursor: pointer;
    font-size: 0.9em;
}

.terminal pre {
    margin: 0;
    padding: 1em;
    overflow-x: auto;
}

/* Image Modal */

/* Modal Hintergrund */
.img-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    z-index: 9999;
    overflow: hidden;
}

main>details>summary {
    background-color: #2c2c2c;
    font-size: 1.2rem;
    border-radius: 10px;
    padding: 0.5rem;
    cursor: pointer;
}

/* Bild im Modal */
.img-modal img {
    max-width: 100%;
    max-height: 100%;
    transform-origin: center center;
    transition: transform 0.2s ease;
    cursor: grab;
}

/* Schliessen Button */
.img-modal .closeImage-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    user-select: none;
}

/* Pfeile */
.img-modal .arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    color: white;
    cursor: pointer;
    user-select: none;
}

.img-modal .arrow.left {
    left: 20px;
}

.img-modal .arrow.right {
    right: 20px;
}

/* Mobile Zoom Hinweis */
.img-modal .zoom-tip {
    position: absolute;
    bottom: 20px;
    color: white;
    font-size: 0.9rem;
}

/* Image Modal */


/* === Sidebar (Navigation) === */
aside {
    width: 280px;
    height: 100vh;
    /* volle Höhe */
    background: #2b2b2b;
    color: #ddd;
    border-right: 1px solid #3a3a3a;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem;
    overflow-y: auto;
    gap: 10px;
    /* Sidebar scrollbar */
}

aside h2 {
    font-size: 1.1rem;
    margin: 0 0 1rem;
    font-weight: 600;
    color: #f0f0f0;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-list li {
    margin: 0.15rem 0;
}

/* Links */
.nav-list a {
    display: flex;
    align-items: center;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    text-decoration: none;
    color: #ddd;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}

.nav-list a:hover {
    background: #3a3a3a;
    color: #fff;
}

img {
    max-width: 75%;
}

hr {
    margin: 1rem 0rem !important;
    opacity: 0.2;
}

.active {
    font-weight: 600;
    color: #c97dff !important;
}

/* Folder Toggle */
.folder>.folder-toggle {
    cursor: pointer;
    font-weight: 600;
    padding: 0.35rem 0.5rem;
    display: block;
    border-radius: 6px;
    transition: background 0.2s;
}

.folder>.folder-toggle:hover {
    background: #333;
}

.folder ul {
    display: none;
    /* Ordner standardmässig geschlossen */
    margin-left: 1rem;
    padding-left: 0;
    border-left: 1px solid #3a3a3a;
}

.folder.open>ul {
    display: block;
}


/* Grundstil der Checkbox */
.tts_follow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

#tts-follow-along {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 42px;
    height: 20px;
    background-color: #383838;
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s;
}

/* Der runde Schiebeknopf */
#tts-follow-along::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 15px;
    height: 15px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

/* Zustand aktiv */
#tts-follow-along:checked {
    background-color: #8d2bd3;
}

#tts-follow-along:checked::before {
    transform: translateX(22px);
}

/* === Main Content (Markdown Viewer) === */
main {
    flex: 1;
    height: 100vh;
    /* volle Höhe */
    overflow-y: auto;
    /* scrollbar für Inhalte */
    padding: 2rem 15%;
    line-height: 1.6;
}

.video-embed {
    max-width: 75%;
    width: 100%;
}

.video-embed * {
    width: 100%;
    aspect-ratio: 16/9;
}

/* Breadcrumb */
.breadcrumb {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #aaa;
}

.breadcrumb a {
    color: #c97eff;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.crumb-current {
    font-weight: 600;
    color: #fff;
}

/* TTS server popup: dark, extendable and resizable */
.tts-server-popup {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 360px;
    max-width: calc(100% - 40px);
    max-height: calc(100% - 40px);
    background: rgba(18,18,18,0.95);
    color: #eee;
    border: 1px solid rgba(130, 50, 200, 0.5);
    border-radius: 8px;
    z-index: 99999;
    padding: 0.5rem;
    resize: both;
    overflow: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
.tts-server-popup .tts-server-popup-inner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.tts-server-popup button#tts-server-close{
    align-self: flex-end;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    color: #ddd;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}
/* Copy .tts-settings layout into the server popup so controls match */
.tts-server-popup .tts-settings {
    display: flex;
    gap: 0.5rem;
}
.tts-server-popup .tts-settings>select {
    width: 50%;
}

/* Service status small badges */
.svc { font-size: 0.9rem; color: #ddd; padding: 0.15rem 0.4rem; border-radius: 6px; background: rgba(255,255,255,0.02); border:1px solid rgba(255,255,255,0.02); }
.svc .status { font-weight: 700; margin-left:6px; }

/* Headings */
main h1,
main h2,
main h3 {
    margin-top: 1.2rem;
    margin-bottom: 0.6rem;
    color: #fff;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin: 1rem 0;
}

main table {
    border-collapse: collapse;
    width: 100%;
    background: #2a2a2a;
    border: 1px solid #444;
}

main th,
main td {
    padding: 0.5rem 0.8rem;
    border: 1px solid #444;
}

main th {
    background: #333;
    font-weight: 600;
}

/* Code Blocks */
pre,
code {
    background: #161616;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-family: "Fira Code", monospace;
    font-size: 0.9rem;
    color: #f5f5f5;
}

pre {
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

/* Inline code */
code {
    padding: 0.2rem 0.3rem;
    display: inline-flex;
}

/* Warning Box */
.warning {
    background: #3a2f1d;
    border: 1px solid #b37f00;
    padding: 0.8rem;
    margin: 1rem 0;
    border-radius: 6px;
    color: #f5d47a;
}

/* Attachments */
.attachments {
    margin-top: 2rem;
}

.attachments h3 {
    margin-bottom: 0.8rem;
    color: #fff;
}

.attachment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2f2f2f;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    margin: 0.3rem 0;
    color: #ddd;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.2s;
}

.attachment-item:hover {
    background: #444;
}

.attachment-item svg {
    width: 16px;
    height: 16px;
    fill: #aaa;
    transition: fill 0.2s;
}

.attachment-item:hover svg {
    fill: #fff;
}

/* Table of contents inside markdown */
.toc ul {
    max-height: 400px;
    overflow-y: auto;
}

.hljs {
    padding: 0 !important;
    background-color: transparent !important;
}

.toc ul,
.toc ol {
    margin: 1rem 0;
    padding: 0.8rem;
    padding-left: 40px;
    background: #252525;
    border-radius: 6px;
    border-left: 3px solid #810dd4;
}

.toc a {
    display: block;
    padding: 0.2rem 0;
    text-decoration: none;
    color: #bbb;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.toc a:hover {
    color: #fff;
}

/* Hierarchische Einrückung nach Level */
.toc-level-1 {
    margin-left: 0rem;
    font-weight: 600;
}

.toc-level-2 {
    margin-left: 1rem;
    color: #9b2beb;
}

.toc-level-3 {
    margin-left: 2rem;
    font-size: 0.9em;
}

.toc-level-4 {
    margin-left: 3rem;
    font-size: 0.85em;
}

.toc-level-5 {
    margin-left: 4rem;
    font-size: 0.8em;
}

.toc-level-6 {
    margin-left: 5rem;
    font-size: 0.75em;
}

main ul,
main ol {
    padding: 0.5rem 1rem;
}

main ul li,
main ol li {
    margin-left: 1rem;
}

figure {
    margin: 1rem 0rem;
}

main a {
    color: #cb87ff;
    font-weight: 500;
}

/* MOBILE */
/* === Mobile Anpassungen === */
.mobile-header {
    display: none;
    background: #2b2b2b;
    padding: 0.8rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-header>h3,
.head>h2 {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
}

#menu-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

.mobile-header {
    display: none;
}

.head {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid white;
    padding: 1rem 0rem;
}

.head .actions {
    display: flex;
    align-items: center;
    justify-content: center;
}

.head .actions .controls {
    padding-right: 10px;
    margin-right: 10px;
    border-right: 1px solid white;
}

.head button,
.head a {
    background: #3a3a3a;
    border: none;
    color: #ddd;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.head h2 {
    margin: 0px;
}

.head button:hover {
    background: #555;
}

/* Sidebar default auf Mobile verstecken */
@media (max-width: 1440px) {
    main {
        padding: 2rem 5%;
    }
}

@media (max-width: 1024px) {
    img {
        max-width: 100%;
    }

    .video-embed {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    aside {
        position: fixed;
        top: 0;
        left: -280px;
        /* versteckt */
        width: 280px;
        height: 100%;
        z-index: 1000;
        background: #2b2b2b;
        transition: left 0.3s ease;
    }

    aside.open {
        left: 0;
        /* sichtbar */
    }

    main {
        padding: 2rem;
        padding-top: 5rem;
    }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 900;
    }
}








#searchResultsBox>.headbox>div {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

#closeSearchBtn {
    background-color: #1e1e1e;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    color: white;
    height: fit-content;
    width: fit-content;
    display: flex;
    align-items: center;
    justify-content: center;
}

#closeSearchBtn i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    padding: 5px;
    font-size: 1.5rem;
    aspect-ratio: 1;
    height: 40px;
}

.headbox {
    position: sticky;
    padding: 10px;
    top: 0;
    display: flex;
    background: #2e2e2e;
    flex-direction: column;
}

#searchOverlay {
    position: fixed;
    padding-top: 5%;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(33, 21, 33, 0.6);
    display: flex;
    justify-content: center;
    z-index: 10000;
}

#searchResultsBox {
    position: relative;
    background: #2b2b2b;
    border-radius: 12px;
    height: fit-content;
    width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

#searchResultsBox h2 {
    margin-top: 0;
}

/* Shared overlay/box classes to match search modal */
.overlay { position: fixed; padding-top: 5%; top: 0; left: 0; right: 0; bottom: 0; background: rgba(33, 21, 33, 0.6); display: none; justify-content: center; z-index: 10000; }
.overlay-box { position: relative; background: #2b2b2b; border-radius: 12px; height: fit-content; width: 600px; max-height: 80vh; overflow-y: auto; box-shadow: 0 0 20px rgba(0,0,0,0.4); padding: 18px; }

/* Ensure auth inner styles still apply inside overlay-box */
.overlay-box .auth-close { position:absolute; right:10px; top:10px; border:0; background:transparent; color:#ccc; font-size:20px; cursor:pointer; }
.overlay-box .auth-tabs { display:flex; gap:8px; margin-bottom:12px; }
.overlay-box .auth-tab { background:transparent; border:1px solid rgba(255,255,255,0.06); color:#ddd; padding:8px 12px; border-radius:6px; cursor:pointer; }
.overlay-box .auth-tab.active { background: transparent; border-color: rgba(255,255,255,0.12); }
.overlay-box .auth-panel { display:none; }
.overlay-box .auth-panel.active { display:block; }
.overlay-box .auth-panel h3 { margin-top:0; color:#fff; }
.overlay-box .auth-panel label { display:block; margin:8px 0; color:#ccc; }
.overlay-box .auth-panel input { width:100%; padding:8px 10px; border-radius:6px; border:1px solid rgba(255,255,255,0.08); background:#1a1a1a; color:#eee; }
.overlay-box .auth-btn { background:#2b2b2b; border:1px solid rgba(255,255,255,0.06); color:#fff; padding:8px 12px; border-radius:6px; cursor:pointer; }
.overlay-box .auth-btn:hover { background:#3b3b3b; }

#resultsList {
    list-style: none;
    padding: 10px;
}

#resultsList li {
    margin: 0px;
}

.search-count {
    list-style: none;
    padding: 8px 12px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

#resultsList li h5 {
    color: white;
}


#searchForm {
    width: 100%;
}

#searchForm input {
    padding: 5px;
    width: 100%;
    border-radius: 5px;
    color: white;
    font-size: 1.2rem;
    background-color: #1e1e1e;
    border: none;
    border-left: 4px solid #810dd4;
}

#resultsList small {
    color: rgb(140, 140, 140);
}

mark {
    background-color: #810dd497;
    padding: 0px 3px;
    color: white;
}

li:has(a.search-result) {
    padding: 5px;
    border-radius: 5px;
}

li:has(a.search-result):hover {
    background-color: #171717;
}

/* === Service Panel Styling === */
#servicePanel .panel {
    font-family: inherit;
    width: 100%;
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
    border-radius: 10px;
    overflow: hidden;
}

#servicePanel .tabs {
    display: flex;
    gap: 4px;
    background: linear-gradient(90deg,#2c2c2c,#262626);
    padding: 6px;
}

#servicePanel .tabs button {
    background: transparent;
    color: #dcdcdc;
    border: none;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

#servicePanel .tabs button:hover { background: #333; }

#servicePanel .tabcontent { max-height: 340px; overflow:auto; }

#servicePanel input, #servicePanel textarea, #servicePanel select {
    background: #1e1e1e;
    color: #e6e6e6;
    border: 1px solid #3a3a3a;
    padding: 6px 8px;
    border-radius: 6px;
}

#servicePanel button[id^="sendBtn"] {
    margin-top: 8px;
    background: linear-gradient(90deg,#7a1cf0,#a64ef5);
    color: white;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}

#servicePanel pre { background: #111; padding: 8px; border-radius:6px; color:#ddd; }

@media (max-width: 800px) {
    #servicePanel { width: calc(100% - 24px); left:12px; right:12px; }
}

/* Slightly different visual for explicit server-send button */
#tts-send-server {
    padding: 0.32rem 0.5rem;
    border-radius: 6px;
    border: 1px solid rgba(166,78,245,0.12);
    background: linear-gradient(180deg,#2a2233,#221824);
    color: #f3eefe;
    cursor: pointer;
    font-weight: 600;
}

#tts-send-server:hover {
    transform: scale(1.03);
    border-color: rgba(166,78,245,0.28);
}

/* TTS primary button tweaks */
#tts-btn {
    box-shadow: 0 6px 18px rgba(0,0,0,0.4), inset 0 -2px 0 rgba(0,0,0,0.2);
}

#tts-btn:active,
#tts-send-server:active,
#tts-mode-select:active {
    transform: scale(0.98);
}

/* Auth modal dark theme */
.auth-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.6); z-index:10000; }
.auth-modal-content { width:460px; max-width:94%; margin:6% auto; background:#111; color:#ddd; padding:18px; border-radius:8px; position:relative; box-shadow:0 8px 30px rgba(0,0,0,0.6); }
.auth-close { position:absolute; right:10px; top:10px; border:0; background:transparent; color:#ccc; font-size:20px; cursor:pointer; }
.auth-tabs { display:flex; gap:8px; margin-bottom:12px; }
.auth-tab { background:transparent; border:1px solid rgba(255,255,255,0.06); color:#ddd; padding:8px 12px; border-radius:6px; cursor:pointer; }
.auth-tab.active { background: transparent; border-color: rgba(255,255,255,0.12); }
.auth-panel { display:none; }
.auth-panel.active { display:block; }
.auth-panel h3 { margin-top:0; color:#fff; }
.auth-panel label { display:block; margin:8px 0; color:#ccc; }
.auth-panel input { width:100%; padding:8px 10px; border-radius:6px; border:1px solid rgba(255,255,255,0.08); background:#1a1a1a; color:#eee; }
.auth-btn { background:#2b2b2b; border:1px solid rgba(255,255,255,0.06); color:#fff; padding:8px 12px; border-radius:6px; cursor:pointer; }
.auth-btn:hover { background:#3b3b3b; }

/* Ensure desktop auth widget doesn't overlap on small screens */
@media (max-width: 768px) {
    #auth-desktop { display:none !important; }
}