:root {
    --bg: #f0f0f0;
    --surface: #ffffff;
    --text: #1a1a1a;
    --muted: #666666;
    --border: #dddddd;
    --accent: #007bff;
    --accent-hover: #0056b3;
    --error: #c0392b;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121212;
        --surface: #1e1e1e;
        --text: #eaeaea;
        --muted: #a0a0a0;
        --border: #3a3a3a;
    }
}

body {
    margin: 0;
    padding: 20px;
    font-family: system-ui, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    /* dvh shrinks with the on-screen keyboard, so the box stays centered in the visible area */
    min-height: 100dvh;
    box-sizing: border-box;
    background: var(--bg);
    color: var(--text);
}

.container {
    text-align: center;
    background: var(--surface);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: min(100%, 540px);
    box-sizing: border-box;
    transition: padding 0.4s ease;
}

.container.compact {
    padding: 20px 30px;
}

h1 {
    margin: 0 0 20px;
    font-size: 1.25rem;
    font-weight: 600;
}

#qrcode {
    display: none;
    margin: 0 auto 20px;
    padding: 16px;
    width: fit-content;
    max-width: 100%;
    box-sizing: border-box;
    /* QR codes need a white quiet zone, also in dark mode */
    background: #ffffff;
    border-radius: 6px;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.4s ease, transform 0.4s ease, display 0.4s allow-discrete;
}

#qrcode.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

@starting-style {
    #qrcode.visible {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.qr-view {
    display: block;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
    /* no tap flash/overlay on touch devices */
    -webkit-tap-highlight-color: transparent;
}

.qr-view:hover,
.qr-view:active {
    background: none;
}

/* border effect only for real pointers, not sticky tap-hover on touch */
@media (hover: hover) and (pointer: fine) {
    #qrcode:has(.qr-view:hover) {
        outline: 2px solid var(--accent);
    }
}

.qr-view svg {
    display: block;
    width: min(65vmin, 320px);
    max-width: 100%;
    height: auto;
    color: #000000;
}

.error {
    margin: 0;
    color: var(--error);
}

.input-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    max-width: 500px;
    margin: 0 auto;
}

input {
    padding: 10px;
    font-size: 16px;
    flex: 1;
    min-width: 180px;
    border: 2px solid var(--border);
    border-radius: 5px;
    box-sizing: border-box;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--accent);
}

button {
    padding: 10px 20px;
    font-size: 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
}

button:hover {
    background: var(--accent-hover);
}

#saveBtn {
    display: none;
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, display 0.3s allow-discrete;
}

#saveBtn.visible {
    display: block;
    opacity: 1;
    transform: translateX(0);
}

@starting-style {
    #saveBtn.visible {
        opacity: 0;
        transform: translateX(10px);
    }
}

.impressum-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 30px;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.impressum-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 123, 255, 0.4);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, display 0.3s allow-discrete;
}

.modal.visible {
    display: flex;
    opacity: 1;
}

@starting-style {
    .modal.visible {
        opacity: 0;
    }
}

.modal-content {
    background: var(--surface);
    padding: 40px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    box-sizing: border-box;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.modal.visible .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--muted);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
    background: none;
}

.impressum-content {
    text-align: left;
    line-height: 1.6;
}

.impressum-content h2 {
    margin-top: 0;
    color: var(--accent);
}

.impressum-content h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--text);
}

.impressum-content p,
.impressum-content ul {
    margin: 5px 0;
    color: var(--muted);
}

.impressum-content ul {
    padding-left: 20px;
}
