:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #eef4f8;
    --text: #15202b;
    --muted: #607083;
    --border: #d8e1ea;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #b42318;
    --shadow: 0 18px 50px rgba(31, 45, 61, .12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, .16), transparent 32rem),
        linear-gradient(135deg, #f7fafc 0%, var(--bg) 48%, #edf7f4 100%);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0;
}

.app-header {
    display: grid;
    gap: 10px;
    margin-bottom: 24px;
}

.eyebrow {
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    max-width: 760px;
    font-size: clamp(34px, 6vw, 58px);
    line-height: 1.04;
}

.intro {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
    font-size: 18px;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 22px;
    align-items: start;
}

.panel {
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(216, 225, 234, .9);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.form-panel,
.preview {
    padding: 22px;
}

.mode-tabs {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 22px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-soft);
}

.mode-tabs legend {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.mode-tab {
    position: relative;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    color: var(--muted);
    font-weight: 800;
    text-align: center;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.mode-tab input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.mode-tab span {
    display: inline-flex;
    width: 100%;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
}

.mode-tab input:checked + span {
    color: var(--primary-dark);
    background: #fff;
    box-shadow: 0 8px 22px rgba(31, 45, 61, .08);
}

.mode-section {
    display: none;
}

.mode-section.is-active {
    display: grid;
    gap: 16px;
}

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

.wide {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="password"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input,
select {
    min-height: 46px;
    padding: 0 12px;
}

textarea {
    min-height: 220px;
    padding: 14px 15px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, .14);
    outline: none;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-weight: 700;
}

.checkbox-row input {
    min-height: auto;
    width: 18px;
    height: 18px;
    padding: 0;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    color: var(--muted);
    font-size: 14px;
}

.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 22px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #fff;
    background: var(--primary);
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease, opacity .15s ease;
}

.button:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.button.secondary {
    color: var(--primary-dark);
    background: #fff;
    border-color: var(--border);
}

.button.secondary:hover:not(:disabled) {
    background: var(--panel-soft);
}

.button:disabled {
    cursor: not-allowed;
    opacity: .52;
}

.qr-frame {
    display: grid;
    min-height: 360px;
    place-items: center;
    border-radius: 8px;
    background:
        linear-gradient(45deg, rgba(216, 225, 234, .48) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(216, 225, 234, .48) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(216, 225, 234, .48) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(216, 225, 234, .48) 75%);
    background-color: #fff;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
}

#qr-canvas {
    display: none;
    width: min(100%, 320px);
    height: auto;
    border: 12px solid #fff;
    border-radius: 8px;
    box-shadow: 0 16px 36px rgba(31, 45, 61, .18);
    image-rendering: pixelated;
}

.has-code #qr-canvas {
    display: block;
}

.has-code .empty-preview {
    display: none;
}

.empty-preview {
    max-width: 260px;
    color: var(--muted);
    text-align: center;
}

.preview h2 {
    margin: 18px 0 6px;
    font-size: 22px;
}

.preview p {
    margin: 0;
    color: var(--muted);
}

.status {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid rgba(180, 35, 24, .2);
    border-radius: 8px;
    color: var(--danger);
    background: #fff4f2;
    font-weight: 700;
}

.notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-top: 22px;
}

.note {
    padding: 16px;
    border: 1px solid rgba(216, 225, 234, .85);
    border-radius: 8px;
    background: rgba(255, 255, 255, .72);
}

.note strong {
    display: block;
    margin-bottom: 4px;
}

.note span {
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 940px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .preview {
        order: -1;
    }
}

@media (max-width: 680px) {
    .shell {
        width: min(100% - 20px, 1180px);
        padding: 28px 0;
    }

    .mode-tabs,
    .field-grid,
    .controls,
    .notes {
        grid-template-columns: 1fr;
    }

    .actions {
        display: grid;
    }

    .button {
        width: 100%;
    }
}
