* {
    box-sizing: border-box;
}

#canvasContainer {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 9 / 16;
    /* aspect-ratio: 1/1; */
    margin: 0 auto 0px auto;
    background-image:
        radial-gradient(circle, #788a92 1px, transparent 1px),
        radial-gradient(circle, #788a92 1px, transparent 1px);
    /* background-size: 18px 18px;
background-position: 6px 6px; */
background-size: 30px 30px;
background-position: 10px 10px, 25px 25px;
}

[data-theme="dark"] #canvasContainer {
    background-image:
        radial-gradient(circle, rgba(128,128,128, 0.1) 1px, transparent 1px),
        radial-gradient(circle, rgba(128,128,128, 0.1) 1px, transparent 1px);
}

#canvas {
    width: 100%;
    height: 100%;
    font-family: 'Labrada', serif;
    padding: 40px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    outline: none;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

#canvas::first-line {
    font-weight: bold;
}

#canvas:empty:before {
    content: attr(data-placeholder);
    color: var(--sup-color);
}

.toggle-caps {
    position: relative;
    width: 80px;
    height: 40px;
    cursor: grab;
    user-select: none;
}

.toggle-caps:active {
    cursor: grabbing;
}

.toggle-caps .track {
    position: absolute;
    top: 50%;
    left: 8px;
    right: 8px;
    height: 2px;
    background: #ccc;
    transform: translateY(-50%);
}

.toggle-caps .cap {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
}

.toggle-caps .cap.left {
    left: 4px;
}

.toggle-caps .cap.right {
    right: 4px;
}

.toggle-caps .knob {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: var(--text-color);
    border-radius: 50%;
    transition: left 0.35s cubic-bezier(0.68, -0.3, 0.32, 1.3), background 0.35s ease;
    z-index: 1;
}

.toggle-caps.on .knob {
    left: 64px;
    background: #788a92;
}

#outputImage {
    width: 100%;
    height: 100%;
    display: block;
}

#fontSizeInput {
    font-family: 'Roboto Mono', monospace;
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    width: 50px;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    outline: none;
}

#fontSizeInput:focus {
    border-color: var(--h3-color);
}

#marginTopSlider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    background: var(--border-color);
    outline: none;
    transition: background 0.3s ease;
    vertical-align: middle;
}

#marginTopSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--text-color);
    cursor: pointer;
    border-radius: 50%;
}

#marginTopSlider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--text-color);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

#marginTopSlider:focus::-webkit-slider-thumb {
    background: var(--h3-color);
}

#marginTopSlider:focus::-moz-range-thumb {
    background: var(--h3-color);
}

#marginTopValue {
    font-family: inherit;
    font-size: inherit;
    display: inline-block;
    text-align: right;
}

label[for="fontSizeInput"],
label[for="marginTopSlider"] {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
}
