body {
    padding: 0 calc(20px * var(--space-scale)) calc(60px * var(--space-scale)) calc(20px * var(--space-scale));
}

#site-header {
    margin: 0 calc(-20px * var(--space-scale));
}

.container {
    max-width: 720px;
    padding: calc(30px * var(--space-scale));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    text-align: left;
}

#container {
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    gap: calc(20px * var(--space-scale));
}

#container button {
    align-self: flex-start;
}

#container>div {
    flex-wrap: wrap;
}

.container > header {
    width: 100%;
    margin-bottom: calc(40px * var(--space-scale));
}

.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: calc(20px * var(--space-scale));
}

.sub {
    font-size: 0.9em;
    color: var(--text-muted);
    margin: calc(5px * var(--space-scale)) 0;
    text-align: right;
    font-style: italic;
    max-width: 220px;
}

h1 {
    color: var(--text);
    font-size: 2.2em;
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.02em;
}

h2 {
    color: var(--accent-bright);
    font-size: 1em;
    margin: 0;
}

h3,
h5 {
    color: var(--text);
    font-weight: 700;
}

h5 {
    margin-bottom: calc(10px * var(--space-scale));
}

.note {
    font-size: 0.9em;
    color: var(--text-muted);
    font-style: italic;
}

section {
    margin-bottom: calc(30px * var(--space-scale));
}

/* Collapsible "Instructions" (a <details>, not a <section>, so it needs
   its own margin instead of inheriting the section rule above). */
.instructions {
    margin-bottom: calc(30px * var(--space-scale));
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: calc(10px * var(--radius-scale));
    overflow: hidden;
}

.instructions summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: calc(12px * var(--space-scale));
    padding: calc(16px * var(--space-scale)) calc(20px * var(--space-scale));
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.instructions summary::-webkit-details-marker {
    display: none;
}

.instructions summary::after {
    content: "\25BE";
    color: var(--accent-bright);
    font-size: 0.85em;
    transition: transform 0.2s ease;
}

.instructions[open] summary {
    border-bottom: 1px solid var(--border);
}

.instructions[open] summary::after {
    transform: rotate(180deg);
}

.instructions summary:hover {
    color: var(--accent-bright);
}

.instructions-body {
    padding: calc(18px * var(--space-scale)) calc(20px * var(--space-scale)) calc(4px * var(--space-scale)) calc(20px * var(--space-scale));
    color: var(--text-muted);
}

.instructions-body p {
    margin: 0 0 calc(14px * var(--space-scale)) 0;
}

.instructions-body strong {
    color: var(--text);
}

.instructions-body code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(4px * var(--radius-scale));
    padding: calc(2px * var(--space-scale)) calc(6px * var(--space-scale));
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--accent-bright);
}

button {
    font-weight: 600;
    padding: calc(10px * var(--space-scale)) calc(18px * var(--space-scale));
    font-size: 0.95rem;
    background: linear-gradient(180deg, var(--accent-bright), var(--accent));
    color: var(--text-strong);
    border: none;
    border-radius: calc(8px * var(--radius-scale));
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

button:hover:enabled {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(var(--accent-bright-rgb), 0.3);
}

button:disabled {
    background: var(--surface-alt);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

button:disabled:hover {
    transform: none;
    box-shadow: none;
}

#errorPopup {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface-alt);
    color: var(--text);
    padding: calc(15px * var(--space-scale)) calc(20px * var(--space-scale));
    border-radius: calc(8px * var(--radius-scale));
    border: 1px solid #e0524a;
    display: none;
    z-index: 1000;
    transition: opacity 0.5s ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.container textarea,
.container input[type="text"] {
    width: 100%;
    height: 40px;
    padding: calc(10px * var(--space-scale));
    margin: calc(10px * var(--space-scale)) 0;
    border: 1px solid var(--border);
    border-radius: calc(8px * var(--radius-scale));
    background: var(--surface-alt);
    color: var(--text);
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.container textarea:focus,
.container input[type="text"]:focus {
    border-color: var(--accent-bright);
    outline: none;
}

.container textarea {
    width: 100%;
    height: 200px;
    resize: vertical;
}

input[type="range"] {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: linear-gradient(to right, var(--accent), var(--accent-bright));
    border-radius: 999px;
    outline: none;
    margin: calc(10px * var(--space-scale)) 0;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--text);
    border: 2px solid var(--accent-bright);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--text);
    border: 2px solid var(--accent-bright);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
}

#maxCharText {
    width: 100%;
    margin-top: calc(10px * var(--space-scale));
    font-weight: bold;
    text-align: center;
    color: var(--accent-bright);
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

.tt {
    --tooltip-bg: var(--surface-alt);
    --tooltip-border-radius: calc(8px * var(--radius-scale));
    --tooltip-font-size: 12px;
    --tooltip-text-color: var(--text);
    --tooltip-padding-x: calc(8px * var(--space-scale));
    --tooltip-padding-y: calc(7px * var(--space-scale));
    --tooltip-offset: 8px;
    --tooltip-transition-duration: 0.3s;

    box-sizing: border-box;
    border-radius: var(--tooltip-border-radius);
    cursor: pointer;
    position: relative;
    outline: none;
}

.tooltip {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: var(--tooltip-font-size);
    color: var(--tooltip-text-color);
    background: var(--tooltip-bg);
    padding: var(--tooltip-padding-y) var(--tooltip-padding-x);
    border: 1px solid var(--border);
    border-radius: var(--tooltip-border-radius);
    pointer-events: none;
    transition: all var(--tooltip-transition-duration) cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.tooltip::before {
    content: attr(data-text-initial);
}

.tooltip::after {
    content: "";
    position: absolute;
    bottom: calc(var(--tooltip-padding-y) / 2 * -1);
    width: var(--tooltip-padding-y);
    height: var(--tooltip-padding-y);
    background: inherit;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    z-index: -999;
    pointer-events: none;
    border: 1px solid var(--border);
}

.tt:hover .tooltip,
.tt:focus:not(:focus-visible) .tooltip {
    opacity: 1;
    visibility: visible;
    top: calc((100% + var(--tooltip-offset)) * -1);
}

.tt:focus:not(:focus-visible) .tooltip::before {
    content: attr(data-text-end);
}

#zipWarningOverlay {
    z-index: 1001 !important;
}

#zipWarningPopup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    padding: calc(40px * var(--space-scale));
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1002;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-sizing: border-box;
}

#zipWarningPopup.show {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#zipWarningPopup h1 {
    color: var(--text);
    text-align: center;
    margin-top: 0;
    margin-bottom: calc(20px * var(--space-scale));
    padding-right: calc(30px * var(--space-scale));
}

#zipWarningPopup p {
    color: var(--text-muted);
    margin: calc(15px * var(--space-scale)) 0;
    line-height: 1.6;
}

#zipWarningPopup ol {
    color: var(--text-muted);
    margin: calc(15px * var(--space-scale)) 0;
    padding-left: calc(20px * var(--space-scale));
}

#zipWarningPopup li {
    margin-bottom: calc(10px * var(--space-scale));
    line-height: 1.6;
    color: var(--text-muted);
}

#zipWarningPopup button {
    padding: calc(16px * var(--space-scale)) calc(32px * var(--space-scale));
    font-size: 1.1rem;
    width: 100%;
    margin-top: calc(20px * var(--space-scale));
}

.zip-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none !important;
    border: none !important;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    box-shadow: none !important;
    transition: color 0.2s ease;
    line-height: 1;
}

.zip-close-btn:hover {
    color: var(--accent-bright);
    transform: none;
    box-shadow: none !important;
}

@media (max-width: 768px) {
    #zipWarningPopup {
        width: 95%;
        padding: calc(30px * var(--space-scale));
        max-height: 80vh;
    }

    #zipWarningPopup h1 {
        font-size: 1.5em;
        margin-bottom: calc(15px * var(--space-scale));
    }

    #zipWarningPopup ol {
        padding-left: calc(15px * var(--space-scale));
        font-size: 0.95em;
    }

    #zipWarningPopup button {
        padding: calc(12px * var(--space-scale)) calc(24px * var(--space-scale));
        font-size: 1rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: calc(18px * var(--space-scale));
    }

    h1 {
        font-size: 1.7em;
    }

    .sub {
        text-align: left;
        max-width: none;
    }

    input,
    select,
    button {
        width: 100%;
        box-sizing: border-box;
    }

    input[type="range"] {
        width: 100%;
    }
}
