/* QR Code Generator - styles */

:root {
    --bg: #f4f5f9;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --border: #e2e5ee;
    --text: #1c2030;
    --muted: #646b80;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef0ff;
    --on-accent: #ffffff;
    --danger-bg: #fdecec;
    --danger-text: #a12222;
    --success-bg: #e8f7ee;
    --success-text: #17673a;
    --info-bg: #eef3ff;
    --info-text: #2a4597;
    --warning-bg: #fff4dc;
    --warning-text: #7a4b00;
    --check-a: #ffffff;
    --check-b: #eceef4;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 4px 16px rgba(20, 24, 40, .05);
    color-scheme: light;
}

/* Dark theme: used when chosen explicitly (data-theme="dark") or when the
   operating system prefers dark and the user has not picked light. */
:root[data-theme="dark"] {
    --bg: #11131a;
    --surface: #1a1d27;
    --surface-2: #222634;
    --border: #2e3344;
    --text: #e8eaf2;
    --muted: #9aa1b5;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #272b48;
    --on-accent: #11131a;
    --danger-bg: #3a1d22;
    --danger-text: #ffb4b4;
    --success-bg: #173226;
    --success-text: #9be2b8;
    --info-bg: #1e2848;
    --info-text: #b6c8ff;
    --warning-bg: #3a2e14;
    --warning-text: #ffd88a;
    --check-a: #2a2e3c;
    --check-b: #232633;
    --shadow: none;
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #11131a;
        --surface: #1a1d27;
        --surface-2: #222634;
        --border: #2e3344;
        --text: #e8eaf2;
        --muted: #9aa1b5;
        --accent: #818cf8;
        --accent-hover: #a5b4fc;
        --accent-soft: #272b48;
        --on-accent: #11131a;
        --danger-bg: #3a1d22;
        --danger-text: #ffb4b4;
        --success-bg: #173226;
        --success-text: #9be2b8;
        --info-bg: #1e2848;
        --info-text: #b6c8ff;
        --warning-bg: #3a2e14;
        --warning-text: #ffd88a;
        --check-a: #2a2e3c;
        --check-b: #232633;
        --shadow: none;
        color-scheme: dark;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header ---------------------------------------------------------------- */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-top: 14px;
    padding-bottom: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand h1 {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.2;
}

.tagline {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: .875rem;
}

.header-tools {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 8px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
}

.icon-btn:hover {
    border-color: var(--accent);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* Show the icon of the theme you would switch TO. */
.theme-toggle .icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun {
        display: block;
    }

    :root:not([data-theme="light"]) .theme-toggle .icon-moon {
        display: none;
    }
}

/* Language dropdown */

.lang-menu {
    position: relative;
}

.lang-menu summary {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

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

.lang-menu summary:hover,
.lang-menu[open] summary {
    border-color: var(--accent);
}

.lang-menu .chevron {
    width: 14px;
    height: 14px;
    color: var(--muted);
    transition: transform .15s;
}

.lang-menu[open] .chevron {
    transform: rotate(180deg);
}

.flag {
    width: 22px;
    height: 16.5px;
    flex-shrink: 0;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
    object-fit: cover;
}

.lang-popup {
    position: absolute;
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    width: 270px;
    max-width: calc(100vw - 32px);
    max-height: min(75vh, 520px);
    margin-top: 6px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}

[dir="rtl"] .lang-popup {
    right: auto;
    left: 0;
}

.lang-search {
    padding: 8px 8px 4px;
}

.lang-search input {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .875rem;
}

.lang-list {
    flex: 1;
    margin: 0;
    padding: 4px 6px 6px;
    overflow-y: auto;
    list-style: none;
}

.lang-empty {
    margin: 0;
    padding: 12px;
    color: var(--muted);
    font-size: .875rem;
    text-align: center;
}

.lang-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--text);
    font-size: .875rem;
    text-decoration: none;
}

.lang-list a:hover {
    background: var(--surface-2);
}

.lang-list a[aria-current] {
    background: var(--accent-soft);
    font-weight: 600;
}

.lang-list .lang-name {
    flex: 1;
    min-width: 0;
}

.lang-list .lang-sub {
    display: block;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 400;
}

@media (max-width: 480px) {
    .lang-menu .lang-current {
        display: none;
    }
}

/* Layout ---------------------------------------------------------------- */

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 20px;
    align-items: start;
    padding-top: 20px;
    padding-bottom: 20px;
}

.settings {
    display: grid;
    gap: 20px;
    min-width: 0;
}

.preview-column {
    position: sticky;
    top: 20px;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .preview-column {
        position: static;
        order: -1;
    }

    .tagline {
        display: none;
    }
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    min-width: 0;
}

.card h2 {
    margin: 0 0 14px;
    font-size: 1.0625rem;
}

.card h3 {
    margin: 20px 0 6px;
    font-size: .9375rem;
}

/* Forms ----------------------------------------------------------------- */

fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

label {
    display: block;
    margin: 12px 0 5px;
    font-size: .8125rem;
    font-weight: 600;
}

label output {
    float: inline-end;
    color: var(--muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.optional {
    color: var(--muted);
    font-weight: 400;
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    display: block;
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

/* Addresses, numbers and file names are always written left to right,
   also in right-to-left languages. */
[dir="rtl"] input[type="url"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="number"],
[dir="rtl"] #filename {
    direction: ltr;
    text-align: right;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

input[type="color"] {
    display: block;
    width: 100%;
    height: 40px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    cursor: pointer;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

input[type="file"] {
    max-width: 100%;
    font: inherit;
    font-size: .875rem;
}

label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
}

label.check input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
}

.row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
}

.row > .align-end {
    display: flex;
    align-items: flex-end;
    padding-bottom: 10px;
}

@media (max-width: 480px) {
    .row {
        grid-template-columns: minmax(0, 1fr);
    }
}

.hint {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: .8125rem;
}

.center {
    text-align: center;
}

.file-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

span.label {
    display: block;
    margin: 12px 0 5px;
    font-size: .8125rem;
    font-weight: 600;
}

label.file-btn {
    margin: 0;
    font-size: .875rem;
}

.visually-hidden:focus-visible + .file-btn {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.file-name {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: .875rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Content type tabs ---------------------------------------------------- */

.type-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.type-tab {
    margin: 0;
}

.type-tab input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.type-tab span {
    display: inline-block;
    padding: 6px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.type-tab span:hover {
    border-color: var(--accent);
}

.type-tab input:checked + span {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
}

.type-tab input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Preview --------------------------------------------------------------- */

.qr-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.qr-preview canvas,
.qr-preview svg {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
}

.qr-preview.is-empty {
    opacity: .5;
}

.checkerboard {
    background-color: var(--check-a);
    background-image:
        linear-gradient(45deg, var(--check-b) 25%, transparent 25%),
        linear-gradient(-45deg, var(--check-b) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--check-b) 75%),
        linear-gradient(-45deg, transparent 75%, var(--check-b) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.notice {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 9px;
    font-size: .875rem;
    background: var(--info-bg);
    color: var(--info-text);
}

.notice-error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.notice-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.notice-success {
    background: var(--success-bg);
    color: var(--success-text);
}

body > noscript .notice {
    margin-top: 16px;
}

/* Buttons --------------------------------------------------------------- */

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.btn:hover:not(:disabled) {
    border-color: var(--accent);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-primary {
    flex: 1 1 auto;
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-ghost {
    background: transparent;
}

/* Footer ---------------------------------------------------------------- */

.site-footer {
    padding-bottom: 28px;
    color: var(--muted);
    font-size: .8125rem;
    text-align: center;
}

.site-footer .storage-note {
    max-width: 640px;
    margin: 4px auto 0;
    font-size: .75rem;
}

.site-footer .credits {
    margin-top: 6px;
}

.site-footer a {
    color: var(--accent);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* Static build start page (shown only until the redirect runs or without JS) */

.landing {
    padding-top: 40px;
    padding-bottom: 40px;
}

.landing-languages {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
    margin: 20px 0 0;
    padding: 0;
    list-style: none;
}

.landing-languages a {
    color: var(--accent);
    text-decoration: none;
}

/* Print: only the QR code ---------------------------------------------- */

.print-area {
    display: none;
}

@media print {
    @page {
        margin: 15mm;
    }

    body {
        background: #fff;
    }

    body > *:not(.print-area) {
        display: none !important;
    }

    .print-area {
        display: flex;
        justify-content: center;
    }

    .print-area img {
        max-width: 100%;
        height: auto;
    }
}

/* Readability check badge ---------------------------------------------- */

.scan-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 0;
    padding: 8px 12px;
    border-radius: 9px;
    font-size: .875rem;
    font-weight: 600;
}

.scan-status::before {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1;
}

.scan-status.is-ok {
    background: var(--success-bg);
    color: var(--success-text);
}

.scan-status.is-ok::before {
    content: "✓";
}

.scan-status.is-fail {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.scan-status.is-fail::before {
    content: "!";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: currentColor;
    color: var(--danger-bg);
    font-size: .75rem;
}

.scan-status.is-checking {
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 500;
}

/* Saved styles --------------------------------------------------------- */

.inline-row {
    display: flex;
    gap: 8px;
}

.inline-row > select,
.inline-row > input {
    flex: 1;
    min-width: 0;
}

.inline-row > .btn {
    flex-shrink: 0;
}

/* Preview header with undo / redo --------------------------------------- */

.preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

.preview-head h2 {
    margin: 0;
}

.history-tools {
    display: flex;
    gap: 6px;
}

.history-tools .icon-btn {
    width: 34px;
    height: 34px;
}

.icon-btn:disabled {
    opacity: .4;
    cursor: default;
    border-color: var(--border);
}

/* Mirror the arrows for right-to-left languages. */
[dir="rtl"] .history-tools svg {
    transform: scaleX(-1);
}

/* Drag and drop of the center image ------------------------------------- */

.drop-zone {
    transition: border-color .15s, background-color .15s;
}

.drop-zone.is-dragover {
    border-color: var(--accent);
    border-style: dashed;
    background: var(--accent-soft);
}

/* Full-width button (style link) ---------------------------------------- */

.btn-block {
    display: block;
    width: 100%;
    margin-top: 14px;
}
