:root {
    --aper-bg-color: #2E3440;
    --aper-slide-bg: #3B4252;
    --aper-text-color: #D8DEE9;
    --aper-font-family-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --aper-font-family-mono: "Fira Code", "Consolas", "Monaco", monospace;
    --aper-font-size-base: clamp(18px, 4.5vmin, 55px);
    --aper-line-height-base: 1.6;
    --aper-slide-padding: clamp(20px, 5vmin, 60px);
    --aper-content-margin-y: 0.7em;
    --aper-code-padding: 1em;
    --aper-bg-color-rgb: 46, 52, 64;
    --aper-slide-bg-rgb: 59, 66, 82;
    --aper-text-color-rgb: 216, 222, 233;
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
    font-style: italic;
    background-repeat: no-repeat;
    margin-left: auto;
    margin-right: auto;
    margin-top: var(--aper-content-margin-y);
    margin-bottom: var(--aper-content-margin-y);
}

.aper-viewer {
    font-family: var(--aper-font-family-sans);
    background-color: var(--aper-bg-color);
    color: var(--aper-text-color);
    font-size: var(--aper-font-size-base);
    line-height: var(--aper-line-height-base);
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

.aper-viewer #presentation {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.aper-viewer .slide {
    display: none;
    width: 100%;
    height: 100%;
    background-color: var(--aper-slide-bg);
    border: 1px solid rgba(0,0,0, 0.1);
    overflow-y: auto;
    padding: var(--aper-slide-padding);
    color: var(--aper-text-color);
    transition: background-color 0.3s, color 0.3s;
}

.aper-viewer .slide.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.aper-viewer .slide.image-slide {
    padding: 0;
    background-color: var(--aper-bg-color);
    border: none;
}

.aper-viewer .slide.image-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    margin: 0;
    padding: 0;
    border: none;
    max-width: none;
    max-height: none;
    background-color: transparent;
}

.aper-viewer .slide.image-slide p,
.aper-viewer .slide.image-slide pre {
    display: none;
}

.aper-viewer .slide > * {
   max-width: 75ch;
   margin-left: auto;
   margin-right: auto;
}

.aper-viewer .slide > img {
    max-width: 100%;
    height: auto;
}

.aper-viewer h1, .aper-viewer h2, .aper-viewer h3 {
    margin-top: 0;
    margin-bottom: var(--aper-content-margin-y);
    color: var(--aper-text-color);
    line-height: 1.2;
    transition: color 0.3s;
}
.aper-viewer h1 { font-size: 1.8em; }
.aper-viewer h2 { font-size: 1.5em; }
.aper-viewer h3 { font-size: 1.2em; }

.aper-viewer p {
    margin-top: var(--aper-content-margin-y);
    margin-bottom: var(--aper-content-margin-y);
    text-align: left;
}

.aper-viewer ul, .aper-viewer ol {
    list-style: disc;
    padding-left: 1.5em;
    margin-top: var(--aper-content-margin-y);
    margin-bottom: var(--aper-content-margin-y);
    text-align: left;
}
.aper-viewer li { margin: 0.3em 0; }

.aper-viewer pre {
    font-family: var(--aper-font-family-mono);
    font-size: 0.85em;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    text-align: left;
    margin-top: var(--aper-content-margin-y);
    margin-bottom: var(--aper-content-margin-y);
    margin-left: auto;
    margin-right: auto;
    padding: var(--aper-code-padding);
    color: var(--aper-text-color);
    background-color: var(--aper-bg-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    width: 90%;
    max-width: 85ch;
    overflow-x: auto;
    transition: background-color 0.3s, color 0.3s;
}

.aper-viewer code {
    font-family: var(--aper-font-family-mono);
    background-color: rgba(0,0,0, 0.1);
    color: var(--aper-text-color);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-size: 0.9em;
    white-space: normal;
    transition: background-color 0.3s, color 0.3s;
}
.aper-viewer pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    white-space: inherit;
}

.aper-viewer a {
    color: var(--aper-text-color);
    text-decoration: underline;
    transition: color 0.3s;
}
.aper-viewer a:hover {
    opacity: 0.8;
}

.aper-viewer #configScreen {
    position: absolute;
    inset: 0;
    background-color: rgba(var(--aper-bg-color-rgb, 40, 40, 40), 0.97);
    color: var(--aper-text-color);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    overflow: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s step-end, background-color 0.3s, color 0.3s;
    visibility: visible;
    font-size: 1rem;
    line-height: 1.5;
}

.aper-viewer #configScreen.hidden {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s step-start, background-color 0.3s, color 0.3s;
}

.aper-viewer .config-content {
    background-color: var(--aper-slide-bg);
    padding: 20px 25px;
    border-radius: 6px;
    border: 1px solid rgba(var(--aper-text-color-rgb, 216, 222, 233), 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    overflow-y: auto;
    position: relative;
    color: var(--aper-text-color);
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.aper-viewer .config-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(var(--aper-text-color-rgb, 216, 222, 233), 0.2);
    transition: border-color 0.3s;
}
.aper-viewer .config-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.aper-viewer .config-content h2 {
    margin-top: 0;
    color: var(--aper-text-color);
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.4em;
}
.aper-viewer .config-content h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--aper-text-color);
    opacity: 0.9;
    border-bottom: 1px solid rgba(var(--aper-text-color-rgb, 216, 222, 233), 0.2);
    padding-bottom: 5px;
    font-size: 1.1em;
    transition: color 0.3s, border-color 0.3s;
}
.aper-viewer .config-content p {
    font-size: 0.85em;
    line-height: 1.4;
    margin: 10px 0;
    text-align: left;
    color: var(--aper-text-color);
}
.aper-viewer .config-content small {
    font-size: 0.75em;
    opacity: 0.8;
    display: block;
    margin-top: 5px;
}

.aper-viewer .config-content button,
.aper-viewer .button-like-label {
    background-color: var(--aper-bg-color);
    color: var(--aper-text-color);
    border: 1px solid rgba(var(--aper-text-color-rgb, 216, 222, 233), 0.3);
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    margin: 5px 5px 5px 0;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
    display: inline-block;
    text-align: center;
    line-height: 1.2;
}
.aper-viewer .config-content button:hover,
.aper-viewer .button-like-label:hover {
    background-color: var(--aper-slide-bg);
    opacity: 0.9;
}


.aper-viewer #loadedFileName {
    font-style: italic;
    opacity: 0.9;
    font-size: 0.8em;
    display: block;
    margin-top: 10px;
    color: var(--aper-text-color);
}

.aper-viewer #themeButtonsContainer {
    margin-bottom: 15px;
}

.aper-viewer #themeButtonsContainer h4 {
    margin-top: 0;
    margin-bottom: 8px;
    color: var(--aper-text-color);
    opacity: 0.9;
    border-bottom: 1px solid rgba(var(--aper-text-color-rgb, 216, 222, 233), 0.2);
    padding-bottom: 4px;
    font-size: 1.0em;
    font-weight: bold;
    transition: color 0.3s, border-color 0.3s;
}

.aper-viewer #themeButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aper-viewer #colorEditor {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    gap: 8px 10px;
    align-items: center;
    font-size: 0.9em;
    margin-top: 10px;
}

.aper-viewer .color-edit-row {
    display: contents;
}

.aper-viewer #colorEditor label {
    justify-self: end;
    font-size: 0.95em;
    text-transform: capitalize;
    color: var(--aper-text-color);
}
.aper-viewer #colorEditor input[type="color"] {
    width: 40px;
    height: 25px;
    padding: 0;
    border: 1px solid rgba(var(--aper-text-color-rgb, 216, 222, 233), 0.3);
    cursor: pointer;
    background: none;
    vertical-align: middle;
    transition: border-color 0.3s;
}
.aper-viewer #colorEditor input[type="text"] {
    background-color: var(--aper-bg-color);
    color: var(--aper-text-color);
    border: 1px solid rgba(var(--aper-text-color-rgb, 216, 222, 233), 0.3);
    border-radius: 3px;
    padding: 4px 6px;
    font-family: var(--aper-font-family-mono);
    font-size: 0.9em;
    width: 100%;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}
.aper-viewer .color-preview {
    width: 20px;
    height: 20px;
    border: 1px solid rgba(var(--aper-text-color-rgb, 216, 222, 233), 0.3);
    border-radius: 3px;
    justify-self: start;
    margin-left: 5px;
    transition: border-color 0.3s;
}

.aper-viewer .close-button {
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 1.5em;
    background: none;
    border: none;
    color: var(--aper-text-color);
    opacity: 0.7;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: opacity 0.2s, color 0.3s;
}
.aper-viewer .close-button:hover { opacity: 1; }
