:root {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --box-bg: #1e1e1e;
    --accent: #00e676; /* Green */
    --link-color: #64b5f6; /* Light Blue */
    --border-color: #333;
}

body {
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* Header & Navigation */
.header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 300;
}

.back-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
}

.back-link:hover {
    text-decoration: underline;
}

/* Rendered Content Box */
.content-box {
    background-color: var(--box-bg);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Source Code Box (Hidden by default) */
.source-box {
    display: none;
    background-color: #2d2d2d;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* Prism Overrides */
pre[class*="language-"] {
    margin: 0;
    border-radius: 0;
    padding: 20px;
    font-size: 14px;
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
}

.btn {
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn:hover {
    background-color: #444;
    border-color: #777;
}

.btn.active {
    background-color: var(--accent);
    color: #000;
    border-color: var(--accent);
    font-weight: bold;
}

/* Tags */
.tags-container {
    margin-top: 10px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background-color: #333;
    color: #b0bec5;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid #444;
}

/* Latex Elements */
h2 {
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    margin-top: 1.5em;
    font-size: 1.4em;
    color: #fff;
}

h3 {
    margin-top: 1.2em;
    font-size: 1.2em;
    color: #ddd;
}

ul,
ol {
    margin-left: 20px;
    padding-left: 0;
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Environments */
.env-box {
    margin: 1.5em 0;
    padding: 15px;
    border-left: 4px solid #555;
    background-color: #252526;
    border-radius: 0 4px 4px 0;
}

.env-header {
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 8px;
    display: block;
}

.env-theorem {
    border-left-color: #ff9800;
}

.env-lemma {
    border-left-color: #29b6f6;
}

.env-fakcik {
    border-left-color: #e91e63;
}

.env-algorithmic {
    border-left-color: #00e676;
}

.env-zasada {
    border-left-color: #9c27b0;
}

/* Proof */
.proof {
    margin: 1.5em 0;
    color: var(--text-color);
}

.proof-title {
    font-weight: bold;
    color: #ffffff;
    margin-right: 6px;
}

.qed {
    float: right;
    color: var(--accent);
    font-weight: bold;
    user-select: none;
}

.proof::after {
    content: "";
    display: table;
    clear: both;
}

/* Images */
figure {
    margin: 2rem 0;
    text-align: center;
    background-color: #151515;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #333;
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    filter: invert(0.9) hue-rotate(180deg);
}

figcaption {
    color: #888;
    font-size: 0.9rem;
    margin-top: 10px;
    font-style: italic;
}

/* Layout */
.latex-center {
    text-align: center;
    margin: 1em 0;
}

.latex-minipage,
.latex-subfigure {
    display: inline-block;
    vertical-align: top;
    box-sizing: border-box;
    padding-right: 15px;
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    .latex-minipage,
    .latex-subfigure {
        width: 100% !important;
        display: block;
        padding-right: 0;
    }
}

/* Tables */
.latex-table {
    border-collapse: collapse;
    margin: 20px auto;
    font-size: 0.9em;
    color: var(--text-color);
}

.latex-table th,
.latex-table td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: center;
}

.latex-table th {
    background-color: #333;
    font-weight: bold;
}

/* MathJax Scroll */
mjx-container[display="true"] {
    overflow-x: auto;
    overflow-y: hidden;
    padding-top: 4px;
    padding-bottom: 4px;
}

mjx-container[display="false"] {
    overflow: visible !important;
}

.tex-source-info {
    margin-top: 40px;
    font-size: 0.8rem;
    color: #666;
    border-top: 1px solid #333;
    padding-top: 10px;
}
