:root {
    --text: black;
    --background: #eaeaea;
    --highlight: #038c78;
    --border: #777777;
    --border-hover: #333333;
    --textarea: #fafafa;
    --cm-background: #ffffff;
    --cm-scrollbar-color: #888;
    --cm-scrollbar-hover: #555;
    /* Tooltip Variables */
    --tooltip-font-size: 0.9em; /* Default tooltip font size */
    --tooltip-margin-bottom: 5px; /* Default margin between the tooltip and element */
    --tooltip-bg-color: #fff; /* Light mode tooltip background */
    --tooltip-text-color: #333; /* Light mode tooltip text color */
}
[data-theme="dark"] {
    --text: white;
    --background: #0d0f11;
    --cm-background: #494e53;
    --cm-textc: #ffffff;
    --cm-scrollbar-color: #ccc;
    --cm-scrollbar-hover: #aaa;
    /* Dark mode Tooltip Variables */
    --tooltip-font-size: 0.9em; /* Dark mode tooltip font size (optional adjustment) */
    --tooltip-margin-bottom: 8px; /* Dark mode tooltip margin (optional adjustment) */
    --tooltip-bg-color: #333; /* Dark mode tooltip background */
    --tooltip-text-color: #fff; /* Dark mode tooltip text color */
}
[data-theme="dark"] .footer::after,
[data-theme="dark"] .tooltip::after,
[data-theme="dark"] .controls button:before,
[data-theme="dark"] .large-buttons button:before {
    background-color: #333; /* Dark background for tooltip and footer in dark mode */
    color: #fff; /* White text color for the tooltip in dark mode */
}
/* Custom tooltip styling */
.tooltip {
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 5px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: auto;  /* Ensure custom tooltip is interactive */
}
/* Active tooltip class for showing */
.tooltip.active {
    opacity: 1;
}
/* Tooltip Style for Buttons and Controls */
button[title]:hover::after,
.controls button:hover::after,
.large-buttons button:hover::after {
    content: attr(title); /* Display the tooltip text */
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8em;
    text-align: center;
    opacity: 0; /* Initially hidden */
    transition: opacity 0.3s ease-out;
    pointer-events: none;
    white-space: pre-wrap;
}
button[title]:hover,
.controls button:hover,
.large-buttons button:hover {
    position: relative; /* Ensure position is set for tooltips */
}
button[title]:hover::after,
.controls button:hover::after,
.large-buttons button:hover::after {
    opacity: 1; /* Show tooltip on hover */
}
/* Light Mode Tooltip Color */
button[title]:hover::after,
.controls button:hover::after,
.large-buttons button:hover::after {
    background-color: #fff;
    color: #333;
}
/* Dark Mode Tooltip Color */
[data-theme="dark"] button[title]:hover::after,
[data-theme="dark"] .controls button:hover::after,
[data-theme="dark"] .large-buttons button:hover::after {
    background-color: #333;
    color: #fff;
}
.counter {
    color: var(--text);
    font-size: 12px;
    margin-top: 20px;
    margin-left: 5px;
    display: inline-block;
}
#charCounter span {
    font-weight: bold;
}
body {
    background: var(--background);
    display: inline-flexbox;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 95vh;
    width: 95vw;
    margin: 0 auto;
    max-width: 600px;
    color: var(--text);
}
body, button, textarea {
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.CodeMirror {
    font-family: inherit;
    font-size: 22px;
    color: var(--cm-textc);
    padding: 18px;
    width: 95%;
    min-height: 300px;
    background: var(--cm-background);
    margin: 0 auto;
    overflow: hidden;
    resize: vertical;
    scrollbar-width: thin;
    scrollbar-color: var(--cm-scrollbar-color) var(--cm-background);
}
button:focus,
summary:focus,
a:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--highlight);
}
@media screen and (max-width: 768px) {
    .CodeMirror {
        width: 90%;
    }
}
@media screen and (max-width: 480px) {
    .CodeMirror {
        width: 80%;
    }
}
.CodeMirror::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.CodeMirror::-webkit-scrollbar-thumb {
    background-color: var(--cm-scrollbar-color);
    border-radius: 4px;
}
.CodeMirror::-webkit-scrollbar-thumb:hover {
    background-color: var(--cm-scrollbar-hover);
}
.CodeMirror::-webkit-scrollbar-track {
    background-color: var(--cm-background);
}
.logo {
    display: flex;
    justify-content: center;
    margin: 1em auto 0.5em auto;
    text-decoration: none;
    color: var(--text);
    font-size: 115%;
    transition: color 0.2s ease-out;
}
.logo:hover {
    color: var(--highlight);
}
a.logo img {
    width: 100%;
    max-width: 360px;
}
h1 {
    font-size: 4vw;
    line-height: 1.2;
    text-align: center;
    margin: 5;
    color: var(--text); /* Default text color */
    transition: color 0.3s ease; /* Smooth transition for color change */
}
h1:hover {
    color: #5363aa;
}
@media (min-width: 1200px) {
    h1 {
        font-size: 40px;
    }
}
@media (max-width: 400px) {
    h1 {
        font-size: 20px;
    }
}
.github {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 0 20px;
    transition: all 0.5s ease;
}
.github a {
    flex: 1 1 200px;
    max-width: 200px;
    transition: all 0.5s ease;
}
@media (max-width: 500px) {
    .github {
        display: grid;
        grid-template-columns: repeat(2, auto);
        grid-row-gap: 2px;
        grid-column-gap: 2px;
        justify-content: center;
    }
    .github a {
        max-width: 100%;
    }
}
.controls {
    padding: 0.6em;
    transition: all 0.4s ease-out;
    width: auto;
    max-width: 600px;
    position: relative;
    margin-top: 10px;
}
.control-btns {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.4em;
    margin-top: 0.7em;
}
.more-fonts summary {
    margin: 0 0 12px 6px;
    cursor: pointer;
    border-radius: 2px;
}
.controls button {
    margin: 0.1em;
    width: 30px;
    height: 30px;
    cursor: pointer;
    background: inherit;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 2px;
    display: flex;
    gap: 1px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    white-space: pre-wrap;
    transition: background 0.2s ease-in;
    position: relative; /* Ensure position is set for tooltips */
}
.controls button:hover {
    border-color: var(--border-hover);
}
@media (max-width: 600px) {
    .control-btns {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
}
textarea {
    width: 100%;
    height: 70vh;
    border: none;
    outline: none;
    background: var(--textarea);
    padding: 1em;
    font-size: 1.4em;
    resize: vertical;
}
@media screen and (max-width: 768px) {
    textarea {
        height: 50vh;
    }
}
@media screen and (max-width: 480px) {
    textarea {
        height: 40vh;
    }
}
.large-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
}
.btn {
    color: white;
    font-size: 1.1em;
    padding: 0.8em 1.1em;
    border-radius: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 134px;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    margin: 1.4em 0.5em 0 0.5em;
    border: none;
    outline: none;
    cursor: pointer;
}
.btn:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), 0 6px 6px rgba(0, 0, 0, 0.22);
}
.btn svg {
    margin-right: 0.5em;
}
.clear-button {
    background: #4f70bd;
}
.clear-button:hover {
    background: #1b3671;
}
.copy-to-clipboard-button {
    background: #858585;
}
.copy-to-clipboard-button:hover {
    background: #3c3c3c;
}
/* Tooltip for .btn */
.btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + var(--tooltip-margin-bottom));
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: var(--tooltip-font-size); /* Control tooltip font size here */
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    background-color: #fff;
    color: #333;
}
.btn[title]:hover::after {
    opacity: 1; /* Show the tooltip on hover */
}
.subtitle {
    font-size: 0.7em;
    color: inherit;
    text-decoration: none;
    text-align: center;
    margin-bottom: 10px;
    position: relative;
}
.subtitle a {
    color: inherit;
}
.footer:hover::after,
.footer:focus::after,
.tooltip:hover::after,
.tooltip:focus::after {
    opacity: 1;
}
.footer:active::after,
.tooltip:active::after {
    opacity: 1;
}
.tooltip {
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 5px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.tooltip.active {
    opacity: 1;
}
.footer {
    margin-bottom: 10px;
    text-align: center;
    font-size: 0.95em;
    color: inherit;
    text-decoration: none;
    position: relative;
}
.footer a {
    color: inherit;
    text-decoration: underline;
}
.footer::after,
.tooltip::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + var(--tooltip-margin-bottom));
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 5px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    background-color: #fff;
    color: #333;
    font-size: var(--tooltip-font-size); /* Control tooltip font size here */
}
