@import url("https://fonts.cdnfonts.com/css/jetbrains-mono-2");

:root {
    --font-family: "JetBrains Mono", monospace;
    --line-height: 1.2rem;
    --border-thickness: 2px;
    --text-color: #000;
    --text-color-alt: #666;
    --background-color: #fff;
    --background-color-alt: #eee;
    --font-weight-normal: 500;
    --font-weight-medium: 600;
    --font-weight-bold: 800;
    font-family: var(--font-family);
    font-size: 16px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #fff;
        --text-color-alt: #aaa;
        --background-color: #000;
        --background-color-alt: #111;
    }
}

body.force-dark { --text-color: #fff; --text-color-alt: #aaa; --background-color: #000; --background-color-alt: #111; }
body.force-light { --text-color: #000; --text-color-alt: #666; --background-color: #fff; --background-color-alt: #eee; }

/* FIX "BALL CLICKING AROUND" & FOCUS RINGS */
* { 
    box-sizing: border-box; 
    outline: none !important; 
    -webkit-tap-highlight-color: transparent; 
}
.no-select { user-select: none; -webkit-user-select: none; }
::-moz-focus-inner { border: 0; }

html, body {
    width: 100%; height: 100vh; margin: 0; padding: 0;
    overflow: hidden; background: var(--background-color); color: var(--text-color);
    transition: background 0.3s, color 0.3s;
}

#app-layout {
    display: flex; flex-direction: row; width: 100%; height: 100%; position: relative;
}

/* DRAG AND DROP OVERLAY */
#drop-zone {
    position: fixed; inset: 0; z-index: 9999;
    background: color-mix(in srgb, var(--background-color) 90%, transparent);
    border: 6px dashed var(--text-color);
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem; font-weight: var(--font-weight-bold); color: var(--text-color);
    opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
#drop-zone.active { opacity: 1; pointer-events: all; }

/* TOOLBARS */
#top-bar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 100;
    background: var(--background-color); border-bottom: var(--border-thickness) solid var(--text-color);
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1ch;
    padding: calc(var(--line-height) / 2) 1ch;
    transform: translateY(-100%); transition: transform 0.3s ease;
}
#top-bar.open { transform: translateY(0); }

#btn-settings-toggle {
    position: absolute; top: 10px; right: 20px; z-index: 99;
    background: var(--background-color); font-size: 1.2rem;
    padding: 0.5ch; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}

#bottom-bar {
    position: absolute; bottom: 0; left: 0; right: 0; z-index: 90;
    background: var(--background-color); border-top: var(--border-thickness) solid var(--text-color);
    display: flex; align-items: center; gap: 2ch; padding: 1ch 2ch;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}

/* SELECTION POPUP */
#selection-toolbar {
    position: fixed; z-index: 200; display: flex; align-items: center;
    background: var(--text-color); color: var(--background-color);
    border: var(--border-thickness) solid var(--background-color);
    padding: 0.5ch; gap: 0.5ch; box-shadow: 4px 4px 0px rgba(0,0,0,0.3);
}
#selection-toolbar button {
    background: var(--background-color); color: var(--text-color); border-color: var(--background-color);
}

.toolbar-group { display: flex; gap: 1ch; align-items: center; }

.file-label {
    cursor: pointer; border: var(--border-thickness) solid var(--text-color);
    padding: calc(var(--line-height) / 2 - var(--border-thickness)) calc(1ch - var(--border-thickness));
    font-weight: var(--font-weight-medium);
}
.file-label input { display: none; }

#reader-wrapper { flex: 1; position: relative; overflow: hidden; display: flex; flex-direction: column; }
#viewer-container { flex: 1; position: relative; overflow-y: auto; overflow-x: hidden; }

#welcome-text {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; max-width: 600px;
}

/* SIDEBAR */
#sidebar {
    width: clamp(300px, 30vw, 500px); border-left: var(--border-thickness) solid var(--text-color);
    display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
    background: var(--background-color); transition: width 0.3s ease, padding 0.3s ease;
}
#sidebar.collapsed { width: 0; border-left: none; }
.sidebar-section { padding: 1ch; }

.notes-toolbar { display: flex; gap: 0.5ch; margin-bottom: 0.5ch; }
.notes-toolbar button { height: auto; padding: 0.2ch 1ch; }
#native-editor {
    min-height: 250px; border: var(--border-thickness) solid var(--text-color);
    padding: 1ch; outline: none; background: var(--background-color);
    overflow-y: auto; word-break: break-word; cursor: text;
}
#native-editor blockquote {
    border-left: var(--border-thickness) solid var(--text-color);
    padding-left: 1ch; font-style: italic; color: var(--text-color-alt); margin: 1ch 0;
}

/* TYPOGRAPHY & ELEMENTS */
h1, h2, h3 { font-weight: var(--font-weight-bold); line-height: var(--line-height); margin: 0 0 var(--line-height) 0; text-transform: uppercase; }
h1 { font-size: 2rem; } h2 { font-size: 1rem; }
p { margin-bottom: var(--line-height); }
hr { border: none; border-top: var(--border-thickness) dashed var(--text-color); margin: var(--line-height) 0; }

input, button {
    border: var(--border-thickness) solid var(--text-color);
    padding: calc(var(--line-height) / 2 - var(--border-thickness)) calc(1ch - var(--border-thickness));
    background: var(--background-color); color: var(--text-color); font: inherit; cursor: pointer; text-transform: uppercase;
}
input[type="text"] { text-transform: none; cursor: text; width: 30ch; }
button:hover { background: var(--background-color-alt); }
button:active { transform: translate(2px, 2px); }

/* SCROLLBARS */
::-webkit-scrollbar { width: 1ch; height: var(--line-height); }
::-webkit-scrollbar-track { background: var(--background-color); }
::-webkit-scrollbar-thumb { background: var(--text-color); }

.tree { padding-left: 0; list-style: none; margin: 0; }
.tree li { position: relative; padding-left: 1.5ch; margin-left: 1.5ch; border-left: var(--border-thickness) solid var(--text-color); margin-bottom: 0.5ch; cursor: pointer; }
.tree li:before { position: absolute; top: calc(var(--line-height) / 2); left: 0; content: ""; width: 1ch; border-bottom: var(--border-thickness) solid var(--text-color); }

/* PDF & OVERLAYS */
.pdf-page-canvas { display: block; margin: 0 auto 2ch auto; border: var(--border-thickness) solid var(--text-color); max-width: 100%; transition: filter 0.3s; }
body.force-dark .pdf-page-canvas { filter: invert(1) hue-rotate(180deg); }

.nav-overlay { position: absolute; top: 0; bottom: 0; width: 15%; z-index: 50; cursor: pointer; opacity: 0; }
.nav-overlay.left { left: 0; } .nav-overlay.right { right: 0; }

/* SCRUBBER */
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 1.5rem; width: 1ch; background: var(--text-color); cursor: pointer; margin-top: -0.5rem; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 0.5rem; cursor: pointer; background: var(--text-color-alt); }
