/* Variables */
:root {
	color-scheme: light dark;
}
:root, .light-theme {
    --bg-color: #fff;
    --secondary-bg-color: #f7f7f7;
    --trans-secondary-bg-color: #f7f7f7cc;
    --grouped-bg-color: #f7f7f7;
    --grouped-secondary-bg-color: #fff;
    --heading-text-color: #111;
    --text-color: #333;
    --secondary-text-color: #888;
    --inverted-text-color: #fff;
    --transparent-header-color: #f7f7f7;
    --chapter-nav-bg-color: #fff8;
    --border-color: #b3b3b3;
    --accent-color: #5eb5fa;
    --control-color: #f7f7f7;
    --control-text-color: #000;
    --border-radius: 16px;
}
@media (prefers-color-scheme: dark) {
	:root {
	    --bg-color: #111113;
	    --secondary-bg-color: #1c1c1e;
        --trans-secondary-bg-color: #1c1c1eaa;
        --grouped-bg-color: #111113;
    	--grouped-secondary-bg-color: #1c1c1e;
	    --heading-text-color: #fff;
	    --text-color: #ddd;
        --secondary-text-color: #888;
	    --inverted-text-color: #000;
	    --transparent-header-color: #1c1c1e;
        --chapter-nav-bg-color: #24242688;
        --control-color: #fff2;
        --control-text-color: #fff;
	    --border-color: #5d5d5d;
	}
}
:root[data-theme="dark"], .dark-theme {
    --bg-color: #111113;
    --secondary-bg-color: #1c1c1e;
    --trans-secondary-bg-color: #1c1c1eaa;
    --grouped-bg-color: #111113;
	--grouped-secondary-bg-color: #1c1c1e;
    --heading-text-color: #fff;
    --text-color: #ddd;
    --secondary-text-color: #888;
    --inverted-text-color: #000;
    --transparent-header-color: #1c1c1e;
    --chapter-nav-bg-color: #24242688;
    --control-color: #fff2;
    --control-text-color: #fff;
    --border-color: #5d5d5d;
}

/* General */
* {
    max-width: 100%;
    box-sizing: border-box;
}
body {
    margin: 0;
    font-family: "SF Pro Text", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    -webkit-font-smoothing: antialiased;
    background-color: var(--secondary-bg-color);
    color: var(--text-color);
}
body section {
    background-color: var(--bg-color);
    width: 100%;
    padding: 32px 0;
}
body section.secondary-bg {
    background-color: var(--secondary-bg-color);
}
body section.grouped-secondary-bg {
    background-color: var(--grouped-secondary-bg-color);
}
body section section, body header nav, body footer section {
	width: 980px;
    background-color: initial;
    padding: 28px 12px;
	margin: auto;
    text-align: center;
}
@media (max-width: 500px) /* Compact Width */ {
    body * section {
        text-align: left;
    }
}

/* Header + Footer */
body header {
    padding: 0 8px;
    display: flex;
    position: sticky;
    top: 0;
    z-index: 99;
    background-color: var(--grouped-bg-color);
    align-items: center;
    justify-content: space-between;
}
.header-space {
    height: 44px;
    padding: 0;
    background-color: transparent;
}
@supports(padding: max(0px)) {
    body header nav, body section section {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
}
header a, footer section a {
    line-height: 36px;
    white-space: nowrap;
}
header a:hover {
    text-decoration: none;
    color: #5eb5faaa;
}
header h2, header h3 {
    display: inline-block;
    margin: 0;
    padding: 4px 8px;
    line-height: 36px;
}
header h2 a {
    margin-right: 8px;
}
header h3, .title-bar h3 {
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}
header h3 {
    font-weight: 500;
    color: var(--secondary-text-color);
}
footer {
    font-size: 0.8em;
    border-top: 0.5px solid var(--border-color);
}
footer section a {
    margin: 4px;
}

/* General */
.banner {
    height: 540px;
    padding: 0;
    background-color: #888;
}
.button, img, figcaption, input, textarea {
    margin: 4px;
}
h1, h2, h3, h4, h5, h6, p {
    color: var(--heading-text-color);
    padding: 4px;
    margin: auto;
}
h1 {
    font-size: 2em;
    margin: 12px auto;
}
h2 {
    font-size: 24px;
    margin: 8px auto;
}
h3 {
    font-size: 20px;
    margin: 4px auto;
}
p {
    font-size: 1.2em;
    line-height: 1.45;
    color: var(--text-color);
}
p.secondary {
    color: var(--secondary-text-color);
    font-size: 1em;
    padding: 0 4px;
}
a, button, summary {
    color: var(--accent-color);
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s;
}
a:hover {
    text-decoration: underline;
}
a:hover, a:hover h1, a:hover h2, a:hover h3 {
    color: var(--accent-color);
}
a.selected {
    color: var(--text-color) !important;
}
.disabled {
    opacity: 0.5;
    filter: grayscale(50%);
}
button, .button {
    color: var(--accent-color);
    background-color: var(--control-color);
    font-size: 1em;
    line-height: 44px;
    text-align: center;
    padding: 0 12px;
    display: inline-block;
    border-radius: 8px;
    border: none;
}
.button:hover {
    text-decoration: none;
    background-image: linear-gradient(rgba(0,0,0,0.1), rgba(0,0,0,0.1));
}
.button.filled {
    color: #fff;
    background-color: var(--accent-color);
    font-weight: bold;
    min-width: 64px;
}
.button.disabled {
    opacity: 1;
    color: #aaa;
    background-image: none;
    cursor: not-allowed;
}
dialog {
    border: 0;
}
dialog::backdrop {
    background-color: #0006;
}
figure {
    display: inline-table;
	margin: 0;
}
figcaption {
    display: table-caption;
    caption-side: bottom;
}
input, textarea {
    font-size: 16px;
    padding: 8px;
    width: calc(100% - 8px);
    border-radius: 12px;
    background-color: var(--control-color);
    color: var(--control-text-color);
    border: none;
    outline: none;
    -webkit-appearance: none;
}
textarea {
    resize: none;
}
summary:focus {
    outline: none;
}
summary::-webkit-details-marker {
    display: none;
}
pre {
    background-color: var(--secondary-bg-color);
    padding: 2rem;
    overflow-x: scroll;
    margin: 16px 4px;
    text-align: left;
    border-radius: var(--border-radius);
}
code {
    font-family: "Melno";
    background-color: var(--secondary-bg-color);
    padding: 4px 8px;
    font-size: 1rem;
    border-radius: 4px;
}
pre code {
    background-color: initial;
    padding: initial;
    font-size: initial;
}
.flex {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-content: center;
}
.invert-text {
    color: var(--inverted-text-color);
}

/* Page-Specific */
.split {
    min-height: 100vh;
    padding: 0;
    display: flex;
}
.sidebar {
    position: relative;
    padding: 0;
    padding-left: env(safe-area-inset-left);
    padding-bottom: 44px;
    width: 280px;
    flex-shrink: 0;
    border-right: 0.5px solid var(--border-color);
    margin: 0;
    background-color: var(--secondary-bg-color);
    text-align: left;
}
.sidebar header {
    background-color: var(--secondary-bg-color);
}
.sidebar>a {
    display: flex;
    margin: 10px 12px;
    line-height: 32px;
    color: var(--heading-text-color);
    border-radius: 8px;
    align-items: center;
}
.sidebar>a:hover {
    text-decoration: none;
}
.sidebar>a.selected {
    color: #fff !important;
    background-color: var(--accent-color);
}
.sidebar>a.donate {
    line-height: initial;
    background-color: #14C00022;
    padding: 8px;
}
.sidebar>a.donate .button {
    color: #14C000;
    background-color: var(--control-color);
}
@media (prefers-color-scheme: dark) {
    .sidebar>a.donate {
        background-color: #1aff001a;
    }
    .sidebar>a.donate .button {
        color: #1aff00;
        background-color: #1aff0033;
    }
}
.sidebar>a picture, .sidebar>a img {
    width: 26px;
    height: 26px;
    image-rendering: crisp-edges;
    margin: 0 8px;
}
@supports (image-rendering: pixelated) {
    .sidebar>a picture, .sidebar>a img {
        image-rendering: pixelated;
    }
}
.sidebar h4 {
    margin: 12px;
    margin-bottom: -5px;
    color: var(--secondary-text-color);
}
.sidebar .footer {
    display: flex;
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 44px;
    background-color: var(--secondary-bg-color);
}
.sidebar .footer a {
    margin: auto;
}
.grid {
    margin: initial;
    padding: 0;
    padding-right: env(safe-area-inset-right);
    width: 100%;
    background-color: var(--grouped-bg-color);
}
.grid div {
    margin: 12px;
    display: flex;
    flex-wrap: wrap;
    text-align: left;
}
.grid div a {
    margin: 4px;
    padding: 6px;
    width: 66px;
    height: 66px;
    background-color: var(--grouped-secondary-bg-color);
    border-radius: 12px;
}
.grid.artwork div a {
    width: 132px;
    height: 132px;
    padding: 0;
    clip-path: content-box;
}
.grid div a img {
    margin: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: crisp-edges;
}
@supports (image-rendering: pixelated) {
    .grid div a img {
        image-rendering: pixelated;
    }
}
.grid.artwork div a img {
    object-fit: cover;
}
.grid a.app-promo img {
    margin: 0;
    padding: 16px;
}
.sheet {
    padding: 16px;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    box-shadow: 0 0 24px #0008;
}
.sheet>img {
    min-width: 320px;
    width: calc(100% - 8px);
    height: 320px;
    object-fit: contain;
    image-rendering: crisp-edges;
}
@supports (image-rendering: pixelated) {
    .sheet>img {
        image-rendering: pixelated;
    }
}
.title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.title-bar h3 {
    margin: 0;
}
.title-bar div {
    display: flex;
    align-items: center;
}
.title-bar a {
    margin-left: 8px;
}
#download {
    width: 100%;
    margin: 0;
}
#share, #open-sp {
    display: none;
}

/* Desktop VS Mobile */

@media (max-width: 500px) {
    .desktop-only {
        display: none;
    }
    .sidebar {
        width: 100%;
        border-right: none;
    }
}
@media (min-width: 501px) {
    .mobile-only {
        display: none;
    }
}