:root {
    color-scheme: light dark;
    --brand: #e30613;
    --hover: #9b0410;
    --page-bg: #d8d8dd;
    --surface: #ececef;
    --text: #000;
    --title: #e30613;
    --card-title: #000;
    --divider-strong: #b4b4ba;
    --shadow: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --page-bg: #2b2b31;
        --surface: #1a1a1e;
        --text: #e6e6e6;
        --title: #e30613;
        --card-title: #fff;
        --divider-strong: #686870;
        --shadow: rgba(0, 0, 0, 0.5);
    }
}

:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page-bg: #2b2b31;
    --surface: #1a1a1e;
    --text: #e6e6e6;
    --title: #e30613;
    --card-title: #fff;
    --divider-strong: #686870;
    --shadow: rgba(0, 0, 0, 0.5);
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--page-bg);
}

/* Hides English text until script.js swaps in the saved language */
.lang-loading body {
    visibility: hidden;
}

header {
    background: var(--surface);
    border-bottom: 4px solid var(--brand);
    padding: 16px;
    text-align: center;
}

header img {
    max-height: 80px;
    max-width: 100%;
}

.intro {
    margin: 32px 16px 0;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
}

main {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 320px);
    justify-content: center;
    align-content: start;
    align-items: start;
    gap: 12px;
    padding: 24px;
}

@media (max-width: 720px) {
    main {
        grid-template-columns: minmax(0, 320px);
    }
}

.form-card {
    border: 1px solid var(--brand);
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 2px 6px var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
}

.card-title {
    flex: 1;
    padding: 16px 20px;
    color: var(--card-title);
    font-size: 1.15rem;
    font-weight: 600;
    text-decoration: none;
}

.card-title:hover {
    background: var(--hover);
    color: #fff;
}

.qr-toggle {
    border: none;
    border-left: 1px solid var(--brand);
    background: none;
    padding: 0 16px;
    color: var(--text);
    cursor: pointer;
}

.qr-toggle:hover {
    background: var(--hover);
    color: #fff;
}

.qr-toggle svg {
    display: block;
    width: 28px;
    height: 28px;
}

.qr-dialog img {
    display: block;
    box-sizing: border-box;
    width: 300px;
    max-width: 100%;
    margin: 0 auto;
    padding: 8px;
    /* QR codes need a light quiet zone to scan reliably, even in dark mode */
    background: #fff;
    border-radius: 4px;
}

footer {
    position: relative;
    border-top: 4px solid var(--brand);
    padding: 16px;
    text-align: center;
}

.footer-link {
    border: none;
    background: none;
    padding: 4px 8px;
    color: var(--text);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.footer-link:hover {
    color: var(--hover);
}

.footer-controls {
    position: absolute;
    top: 50%;
    right: 16px;
    display: flex;
    gap: 8px;
    transform: translateY(-50%);
}

.dropdown {
    position: relative;
    display: flex;
}

.pill-button {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 2px solid var(--divider-strong);
    border-radius: 999px;
    padding: 6px 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.pill-button:hover,
.pill-button[aria-expanded="true"] {
    border-color: var(--hover);
    background: var(--hover);
    color: #fff;
}

.pill-button svg {
    width: 20px;
    height: 20px;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    min-width: 140px;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    border-top: 4px solid var(--brand);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 8px 24px var(--shadow);
    text-align: left;
}

.dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: none;
    padding: 8px 16px;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.dropdown-menu svg {
    width: 18px;
    height: 18px;
}

.dropdown-menu button[aria-current="true"] {
    color: var(--title);
    font-weight: 700;
}

.dropdown-menu button:hover {
    background: var(--hover);
    color: #fff;
}

@media (max-width: 720px) {
    .footer-controls {
        position: static;
        justify-content: center;
        margin-top: 8px;
        transform: none;
    }
}

dialog {
    width: min(420px, 90vw);
    border: none;
    border-top: 4px solid var(--brand);
    border-radius: 8px;
    padding: 20px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 8px 24px var(--shadow);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

dialog h2 {
    margin: 0 0 12px;
    color: var(--title);
}

dialog a {
    color: var(--title);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.dialog-actions button {
    border: none;
    border-radius: 4px;
    padding: 8px 20px;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.dialog-actions button:hover {
    background: var(--hover);
}
