:root {
    --field-height: calc(1.5rem * 1.5 + 30px + 1.4px);
}

#input-container {
    width: 100%;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    margin-bottom: 5px;
}

.input-side {
    flex-grow: 1;
    min-width: 0;
    display: grid;
    row-gap: 6px;
}

.input-wrapper {
    position: relative;
    flex-grow: 1;
    min-width: 0;
    display: grid;
    grid-template-areas: "field";
    align-items: start;
}

#text-input,
#bulk-textarea {
    grid-area: field;
    width: 100%;
    overflow: hidden;
    transition: max-height 0.28s cubic-bezier(0.165, 0.84, 0.44, 1),
        opacity 0.18s ease,
        transform 0.28s cubic-bezier(0.165, 0.84, 0.44, 1),
        padding 0.28s ease,
        border-color 0.14s ease;
}

#text-input {
    max-height: 64px;
    min-height: var(--field-height);
}

#text-input.is-hidden,
#bulk-textarea.is-hidden {
    max-height: 0;
    min-height: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    padding-top: 0;
    padding-bottom: 0;
    border-bottom-color: transparent;
}

#bulk-textarea {
    min-height: 180px;
    max-height: 260px;
    resize: vertical;
    text-align: left;
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 0.4px;
    line-height: 1.6;
    padding-right: 48px;
}

#bulk-textarea::placeholder {
    color: #414141;
    opacity: 1;
}

#mode-switch-row {
    width: 100%;
    display: flex;
    justify-content: flex-start;
}

#mode-switch-btn {
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    letter-spacing: 1px;
    padding: 0;
    transition: color 0.14s ease;
}

#mode-switch-btn:hover {
    color: #fff;
}

.format-dropdown {
    position: relative;
    user-select: none;
    flex-shrink: 0;
    align-self: flex-start;
    width: 132px;
}

.format-btn {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    border-bottom: 1.4px solid #414141;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 200;
    line-height: 1.5;
    letter-spacing: 1.4px;
    padding: 15px 10px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    transition: all 0.14s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    min-height: var(--field-height);
    gap: 5px;
    white-space: nowrap;
}

.format-btn:hover {
    border-bottom-color: #fff;
}

.format-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    margin-top: 10px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 100;
    min-width: 120px;
}

.format-dropdown.open .format-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.format-option {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.14s;
    color: #aaa;
    font-size: 1rem;
}

.format-option:hover {
    background: #2a2a2a;
    color: #fff;
}

.format-option.active {
    color: #fff;
    font-weight: 600;
    background: #222;
}

#options-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 0;
    margin-top: 0;
    font-size: 0.95rem;
    color: #ccc;
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
    transition: all 0.2s ease;
}

#options-container.visible {
    opacity: 1;
    pointer-events: auto;
    max-height: 50px;
    margin-top: 10px;
    margin-bottom: 2rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    appearance: none;
    background-color: transparent;
    margin: 0;
    font: inherit;
    color: currentColor;
    width: 1.25em;
    height: 1.25em;
    border: 1.4px solid #414141;
    border-radius: 4px;
    display: grid;
    place-content: center;
    transition: all 0.14s ease;
    cursor: pointer;
    padding: 0;
    outline: none;
    border-bottom: 1.4px solid #414141;
}

.checkbox-label input[type="checkbox"]::before {
    content: "";
    width: 0.7em;
    height: 0.7em;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em #2a2a2a;
    transform-origin: center;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
    background-color: #141414;
}

.checkbox-label input[type="checkbox"]:checked {
    border-color: #fff;
    background-color: #fff;
}

.checkbox-label input[type="checkbox"]:checked::before {
    transform: scale(1);
}

#error-msg {
    margin-bottom: 1.5rem;
    min-height: 20px;
    width: 100%;
}

#bulk-download-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
}

#bulk-download-actions[hidden] {
    display: none;
}

#reset-btn {
    top: 50%;
    transform: translateY(-50%);
}

.input-wrapper.bulk-active #reset-btn {
    top: 14px;
    transform: none;
}

#qrcode-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.14s cubic-bezier(0.165, 0.84, 0.44, 1);
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
}

#qrcode-wrapper.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
    max-height: 600px;
}

#qrcode-container {
    background: #fff;
    padding: 0;
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

#qrcode {
    display: block;
    /* Canvas size is controlled by JS, but max-width ensures responsiveness */
    max-width: 100%;
}

#download-actions {
    margin-top: 25px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.download-action {
    background: transparent;
    border: 1.4px solid #414141;
    color: #fff;
    padding: 14px 28px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.14s ease;
    text-decoration: none;
    letter-spacing: 1.4px;
}

.download-action:hover {
    border-color: #fff;
    transform: translateY(-1.4px);
    box-shadow: 0 0 14px rgba(255, 255, 255, 0.14);
}

.download-action:active {
    transform: translateY(0);
}

.download-action svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.download-action[hidden] {
    display: none;
}

.download-action.is-busy {
    opacity: 0.55;
    pointer-events: none;
}
