:root {
    --bg-main: #161616;
    --bg-lighter: #333333;
    /* Also used for borders */
    --bg-light: #222222;
    --bg-dark: #111111;
    --bg-danger: #a81808;
    --bg-danger-hover: #d61d08;
    --ref-status-undeciphered: #ff746986;
    --ref-status-filler: #ff8f477b;
    --ref-status-partial: #ffbc3575;
    --ref-status-complete: #51a6ff7e;
    --text-primary: rgba(255, 255, 255, 0.9);
    --text-muted: rgba(255, 255, 255, 0.5);
    --text-subtle: rgba(255, 255, 255, 0.7);
    --text-link: #85c6f7;
    --max-content-width: 800px;
    --max-grid-width: 738px;
    --ref-image-width: 760px;
    --border-radius: 6px;
    --font-family: Segoe UI, Verdana, Open Sans, sans-serif;
    --transition: background-color 0.2s ease;
}
body {
    font-family: var(--font-family);
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg-main);
    color: var(--text-primary);
}
a:not(.header-link) {
    color: var(--text-link);
    font-weight: bold;
}
.hidden {
    display: none !important;
}
/* Header and footer */
.site-header, .site-footer {
    width: 100%;
    display: flex;
    justify-content: center;
}
.header-title {
    font-size: 2rem;
    color: var(--text-primary);
}
.header-link, .header-link:hover {
    text-decoration: none;
    color: inherit;
    display: block;
}
.header-banner, .footer-banner {
    background-color: var(--bg-light);
    border-radius: var(--border-radius);
}
/* Header */
.site-header {
    margin-bottom: 16px;
}
.header-banner {
    padding: 4px 12px;
    text-align: center;
}
/* Header > subtitle */
.header-banner p {
    font-size: 0.9rem;
    color: var(--text-subtle);
    white-space: pre-line;
}
/* Footer */
.footer-banner {
    padding: 4px 8px;
    font-size: 0.9rem;
    color: var(--text-subtle);
    white-space: pre-line;
}
.site-footer {
    margin-top: 12px;
}
.footer-banner span, .banner-image-box-desc span {
    font-weight: bold;
    color: var(--text-primary);
}
/* Top buttons */
.controls, .output-grid, #output-area {
    margin-bottom: 20px;
}
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.btn-container {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
/* Controls > Text box */
.textinput {
    box-sizing: border-box;
    font-family: var(--font-family);
    width: 100%;
    max-width: var(--max-content-width);
    height: 87px;
    padding: 15px;
    font-size: 1.2rem;
    border-radius: var(--border-radius);
    border: 2px solid transparent;
    resize: none;
    transition: border-color 0.2s ease;
    background-color: var(--bg-light);
    color: var(--text-primary);
}
.textinput:focus {
    border: 2px solid var(--bg-lighter);
    outline: none;
}
/* Controls > Selection box */
.selector {
    color: var(--text-primary);
    background-color: var(--bg-light);
    border: 1px solid var(--bg-lighter);
    padding: 10px;
    border-radius: var(--border-radius);
    font-size: 1rem;
    cursor: pointer;
}
/* Controls > Buttons */
.btn {
    background-color: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--bg-lighter);
    padding: 6px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}
.btn:hover {
    background-color: var(--bg-lighter);
}
.btn-icon {
    display: block;
    width: 24px;
    pointer-events: none;
}
/* Controls > Red Buttons */
.btn.btn-danger {
    background-color: var(--bg-danger);
    border: 1px solid var(--bg-danger-hover);
}
.btn.btn-danger:hover {
    background-color: var(--bg-danger-hover);
}
/* Tile and output grid */
.output-grid, .tile-grid {
    width: 100%;
    max-width: var(--max-grid-width);
}
/* Output */
.output-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    align-content: flex-start;
    min-height: 32px;
    padding: 20px 15px;
    background-color: var(--bg-light);
    border-radius: var(--border-radius);
}
/* Output > Line Break */
.output-grid .line-break {
    display: block;
    flex-basis: 100%;
    height: 16px;
}
/* Output > BG Toggle */
.output-grid.bg-black {
    background-color: #000000;
}
.output-grid.bg-invert {
    filter: invert(100%);
}
.output-grid.bg-green {
    background-color: #FB0BFB;
}
/* Output > Glyph */
.output-grid .glyph, .tile .glyph-tile {
    font-size: 48px;
    display: inline-block;
    text-align: center;
    color: var(--text-primary);
}
.output-grid .glyph {
    line-height: 48px;
}
/* Output > Placeholder Image */
.output-grid img {
    height: 40px;
    width: auto;
    object-fit: contain;
    opacity: 0.6;
}
/* Output > Default Font Char */
.output-grid .default-font-char {
    font-family: var(--font-family);
    font-size: 1.2rem;
    line-height: 32px;
    display: inline-block;
    padding: 0 4px;
}
/* Tile grid */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}
/* Tile Grid > Tile */
.tile {
    appearance: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    padding: 8px;
    border-radius: var(--border-radius);
    border: 1px solid var(--bg-lighter);
    color: inherit;
    font: inherit;
    width: 100%;
}
.tile:focus-visible {
    outline: 2px solid var(--text-link);
    outline-offset: 2px;
}
.tile-warn {
    opacity: 0.5;
}
.tile:hover {
    background-color: var(--bg-lighter);
}
/* Tile Grid > Glyph */
.tile .glyph-tile {
    line-height: 40px;
    pointer-events: none;
}
/* Tile top spacing */
.tile span {
    margin-top: 10px;
    font-size: 1rem;
    color: var(--text-primary);
}
/* Bannerbox and search bar */
.banner-box, .font-search {
    background-color: var(--bg-light);
    border-radius: var(--border-radius);
    border: 1px solid var(--bg-lighter);
    width: 100%;
    margin-top: 8px;
    margin-bottom: 8px;
    max-width: var(--max-content-width);
    box-sizing: border-box;
}
/* Banner Box */
.banner-box {
    padding: 8px 16px;
    font-size: 0.9rem;
    color: var(--text-subtle);
}
/* Search bar */
.font-search {
    padding: 12px 16px;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: var(--font-family);
    transition: border-color 0.2s ease;
}
.font-search:focus {
    border-color: var(--text-subtle);
    outline: none;
}
#font-container {
background-color: var(--bg-dark);
}
/* Banner + image box */
.banner-image-box {
    display: flex;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 10px;
    box-sizing: border-box;
}
.banner-image-box img {
    max-width: 110px;
    max-height: 110px;
    object-fit: contain;
    flex-shrink: 0;
}
.banner-image-box-content {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    display: flex;
    flex-direction: column;
}
.banner-image-box-title {
    color: var(--text-primary);
    font-size: 1rem;
}
.banner-image-box-desc {
    margin: 4px 0 8px 0;
    color: var(--text-subtle);
}
.banner-image-box-link {
    margin-top: auto;
}
/* References */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.ref-list {
    width: 100%;
    max-width: var(--max-content-width);
}
.ref-card {
    background-color: var(--bg-light);
    border: 1px solid var(--bg-lighter);
    border-radius: var(--border-radius);
    box-sizing: border-box;
    color: var(--text-subtle);
    margin: 8px 0;
    overflow: hidden;
    padding: 16px;
}
.ref-card h2 {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin: 0 0 4px;
}
.ref-desc {
    margin: 0 0 12px;
}
.ref-meta, .ref-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}
/* Reference > Tags */
.ref-status, .ref-tag {
    background-color: var(--bg-light);
    border: 1px solid var(--bg-lighter);
    border-radius: var(--border-radius);
    box-sizing: border-box;
    color: var(--text-primary);
    display: inline-flex;
    font-size: 0.8rem;
    line-height: 1.2;
    padding: 4px 8px;
}
.ref-tag-wip {
    background-color: var(--ref-status-partial);
}
/* Reference > Status */
.ref-status {
    background-color: var(--bg-lighter);
}
.ref-status.status-1 {
    background-color: var(--ref-status-undeciphered);
}
.ref-status.status-2 {
    background-color: var(--ref-status-filler);
}
.ref-status.status-3 {
    background-color: var(--ref-status-partial);
}
.ref-status.status-4 {
    background-color: var(--ref-status-complete);
}
.ref-body {
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.ref-body p {
    margin: 0 0 1em;
}
.ref-body ul, .ref-body ol {
    margin: 0 0 1em;
    padding-left: 1.75em;
}
.ref-body li + li {
    margin-top: 0.25em;
}
.ref-body blockquote {
    border-left: 3px solid var(--bg-lighter);
    margin: 0 0 1em;
    padding: 8px 12px;
}
.ref-body blockquote > :last-child {
    margin-bottom: 0;
}
.ref-body hr {
    border: 0;
    border-top: 1px solid var(--bg-lighter);
    margin: 1em 0;
}
.ref-body pre {
    border: 1px solid var(--bg-lighter);
    border-radius: var(--border-radius);
    overflow-x: auto;
    padding: 12px;
    white-space: pre;
}
.ref-body table {
    border-collapse: collapse;
    margin-bottom: 1em;
    max-width: 100%;
}
.ref-body th, .ref-body td {
    border: 1px solid var(--bg-lighter);
    padding: 6px 10px;
    text-align: left;
}
.ref-body img {
    cursor: zoom-in;
}
.ref-body code {
    background-color: var(--bg-lighter);
    border-radius: var(--border-radius);
    color: var(--text-subtle);
    padding: 1px 5px;
}
.ref-body pre code {
    background: transparent;
    color: inherit;
    display: block;
    font-family: monospace;
    padding: 0;
}
.ref-body del {
    color: var(--text-muted);
}
.ref-quote {
    white-space: normal;
}
/* Reference > Images */
.ref-image {
    box-sizing: border-box;
    margin: 12px auto;
    max-width: 100%;
    text-align: center;
}
.ref-image img {
    border-radius: var(--border-radius);
    display: block;
    height: auto;
    margin: 0 auto;
    max-height: 70vh;
    max-width: min(100%, var(--ref-image-width));
    object-fit: contain;
}
.ref-image-open {
    background: none;
    border: 0;
    cursor: pointer;
    display: block;
    margin: 0 auto;
    max-width: 100%;
    padding: 0;
}
.ref-image-open:focus-visible {
    outline: 2px solid var(--text-link);
    outline-offset: 3px;
}
.ref-image.ref-image-left, .ref-image.ref-image-right {
    max-width: min(50%, var(--ref-image-width));
}
.ref-image.ref-image-left {
    margin: 8px auto 8px 0;
}
.ref-image.ref-image-right {
    margin: 8px 0 8px auto;
}
.ref-body td .ref-image-open.ref-image-left {
    margin: 0 auto 0 0;
}
.ref-body td .ref-image-open.ref-image-right {
    margin: 0 0 0 auto;
}
.ref-image-viewer[open] {
    align-items: center;
    background-color: transparent;
    border: 0;
    border-radius: 0;
    box-sizing: border-box;
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    height: 100dvh;
    inset: 0;
    justify-content: center;
    margin: auto;
    max-height: 100vh;
    max-height: 100dvh;
    max-width: 100vw;
    overflow: hidden;
    padding: 64px 16px 16px;
    width: 100vw;
}
.ref-image-viewer::backdrop {
    background-color: rgba(0, 0, 0, 0.6);
}
.ref-image-viewer > img {
    height: auto;
    max-height: calc(100dvh - 80px);
    max-width: calc(100vw - 32px);
    object-fit: contain;
    width: auto;
}
.ref-image-viewer-close {
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 1;
}
/* Mobile stuff */
@media (max-width: 520px) {
    .ref-card {
        padding: 12px;
    }
}
