*,
*:before,
*:after {
    box-sizing: border-box;
}

:root {
    --font-family: Lato, sans-serif;
    --font-size: 16px;
    --radius: 5px;
    --sidebar-width: 280px;
    --color-scheme: dark;
    --primary-color: #fab229;
    --primary-color-darken: #d99c38;
    --page-background: #18151f;
    --surface-background: #241f2c;
    --surface-background-hover: #302939;
    --text-color: #f5f1fb;
    --muted-color: #beb5c9;
    --control-border: #62586d;
    --control-background: #211d28;
    --control-background-disabled: #393240;
    --fieldset-border: #3c3445;
    --heading-background: #2b2534;
    --toggle-icon-color: #f1eef7;
    --max-size: 660px;
}

body.theme-light {
    --color-scheme: light;
    --page-background: #fff;
    --surface-background: #f7f7f7;
    --surface-background-hover: #fff;
    --text-color: #242424;
    --muted-color: #666;
    --control-border: rgb(180, 180, 180);
    --control-background: rgb(250, 250, 250);
    --control-background-disabled: rgb(200, 200, 200);
    --fieldset-border: rgb(230, 230, 230);
    --heading-background: #eee;
    --toggle-icon-color: #f1eef7;
}

::selection {
    background: var(--primary-color);
    color: #242424;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size);
    color: var(--text-color);
    color-scheme: var(--color-scheme);
    margin: 0;
    padding: 0;
    background: var(--page-background);
}

main {
    display: block;
    min-width: 0;
    text-align: center;
}

.app-layout {
    margin-left: 0;
    transition: margin-left 180ms ease;
}

.tools-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 3;
    width: var(--sidebar-width);
    overflow-y: auto;
    text-align: left;
    background: var(--surface-background);
    border-right: 1px solid var(--fieldset-border);
    transform: translateX(-100%);
    transition: transform 180ms ease;
}

.tools-sidebar.is-open {
    transform: translateX(0);
}

.tools-sidebar-inner {
    padding: 24px 18px 24px;
}

.tools-sidebar-toggle,
.theme-toggle {
    position: fixed;
    top: 12px;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 45px;
    min-height: 45px;
    width: auto;
    margin: 0;
    border-radius: var(--radius);
    transition: left 180ms ease;
}

.tools-sidebar-toggle {
    left: 12px;
}

.theme-toggle {
    left: 65px;
}

.tools-sidebar-toggle-icon {
    position: relative;
    display: inline-block;
    width: 25px;
    height: 23px;
    border: 2px solid #000;
    border-radius: 4px;
}

.tools-sidebar-toggle-icon:before {
    content: "";
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 7px;
    border-left: 2px solid #000;
}

.tools-sidebar-toggle-icon:after {
    content: "";
    position: absolute;
    top: 5px;
    left: 3px;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: #000;
    box-shadow:
        0 5px 0 #000,
        0 10px 0 #000;
}

.theme-toggle-icon:before {
    content: "☀";
    color: #000;
    font-size: 24px;
    line-height: 1;
}

.theme-light .theme-toggle-icon:before {
    content: "☾";
}

@media (min-width: 861px) {
    .app-layout {
        margin-left: var(--sidebar-width);
    }

    .tools-sidebar {
        transform: translateX(0);
    }

    .tools-sidebar-toggle {
        left: calc(var(--sidebar-width) + 12px);
    }

    .theme-toggle {
        left: calc(var(--sidebar-width) + 65px);
    }

    .is-sidebar-closed .app-layout {
        margin-left: 0;
    }

    .is-sidebar-closed .tools-sidebar {
        transform: translateX(-100%);
    }

    .is-sidebar-closed .tools-sidebar-toggle {
        left: 12px;
    }

    .is-sidebar-closed .theme-toggle {
        left: 65px;
    }
}

.tools-sidebar h2 {
    margin: 0 0 16px;
    border-bottom: 1px solid var(--fieldset-border);
    padding: 0;
    padding-bottom: 16px;
    background: transparent;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
}

.tools-sidebar h2 a {
    padding: 5px;
    border-radius: var(--radius);
    font-style: italic;
    background: var(--surface-background-hover);
    color: var(--muted-color);
}

.tools-list {
    display: grid;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.tools-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: var(--radius);
    color: inherit;
    padding: 10px 12px;
    text-decoration: none;
}

.tools-list a:hover,
.tools-list a:focus,
.tools-list a.is-active {
    background: var(--surface-background-hover);
    outline: none;
}

.tools-list a:focus-visible {
    box-shadow: 0 0 0 2px var(--primary-color);
}

.tool-placeholder {
    max-width: var(--max-size);
    margin: 20vh auto 0;
    text-align: center;
}

.tool-placeholder h2 {
    margin-bottom: 8px;
    background: transparent;
    font-size: 28px;
    font-weight: 700;
}

.tool-placeholder p {
    margin: 0;
    color: var(--muted-color);
}

h2 {
    background: var(--heading-background);
    font-weight: 400;
    font-size: 22px;
    padding: 3px 0;
}

h2 a {
    color: inherit;
    text-decoration: none;
}

h2 a:hover,
h2 a:focus {
    text-decoration: underline;
}

fieldset {
    display: inline-block;
    border: 1px solid var(--fieldset-border);
    border-radius: var(--radius);
    vertical-align: top;
    width: calc(100% - 20px);
}

.two-columns fieldset {
    width: 100%;
    min-width: 200px;
    max-width: calc(50% - 35px);
}

hr.half-screen {
    width: 50%;
}

.component-content {
    padding: 0 10px;
    max-width: var(--max-size);
    margin: 0 auto;
}

.component {
    display: none;
    scroll-margin-top: 24px;
}

.component.is-active {
    display: block;
}

.is-hidden {
    display: none;
}

.hide {
    display: none;
}

.inline {
    display: inline-block !important;
    width: auto !important;
}

.ratio {
    display: block;
    margin-top: 8px;
    font-size: 14px;
    color: #555;
}

.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;
}

@media (max-width: 860px) {
    .app-layout {
        margin-left: 0;
        padding-top: 0;
    }

    .tools-sidebar {
        width: min(var(--sidebar-width), 85vw);
        max-height: none;
    }

    .tools-sidebar-inner {
        padding: 85px 14px 14px;
    }

    .tools-list {
        grid-template-columns: 1fr;
    }

    #proportions fieldset + fieldset {
        margin-top: 20px;
    }

    .tool-placeholder {
        margin-top: 64px;
    }
}
