.back-link {
    color: #2a9d8f;
    text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.qr-main {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(340px, 520px);
    gap: 2.5em;
    width: 100%;
    margin: 0;
    padding: 2em 2.5em 4em;
    box-sizing: border-box;
}

@media (max-width: 900px) {
    .qr-main { grid-template-columns: 1fr; padding: 1em; gap: 1.2em; }
    .qr-preview-sticky { position: static !important; }
    .qr-config, .qr-preview-sticky { padding: 1.2em; }
}

@media (max-width: 600px) {
    .tabs { gap: 0.2em; }
    .tab { padding: 0.6em 0.9em; font-size: 0.85em; }
    .qr-config h2, .qr-preview-sticky h2 { font-size: 1em; margin-top: 1.5em; }
    .cfg-row { gap: 0.7em; margin-bottom: 1em; }
    .cfg-row.two { flex-direction: column; align-items: stretch; }
    .cfg-row.two > * { min-width: 0; }
    .cfg-range { flex-wrap: wrap; }
    .cfg-range input[type="range"] { flex: 1 1 100%; }
    .dl-grid { grid-template-columns: 1fr 1fr; }
    .save-row { flex-direction: column; align-items: stretch; }
    .saved-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.8em; }
    .qr-preview-box { min-height: 240px; padding: 0.8em; }
}

.qr-config, .qr-preview-sticky {
    background: #fff;
    border-radius: 1em;
    padding: 2.5em 2.8em 3em;
    box-shadow: 0 10px 20px #dbdbdb;
}

.qr-preview-sticky {
    position: sticky;
    top: 1em;
    align-self: start;
}

.qr-config h2, .qr-preview-sticky h2 {
    margin: 2.5em 0 1.4em;
    font-size: 1.15em;
    color: #264653;
    border-bottom: 2px solid #f4a261;
    padding-bottom: 0.5em;
}

.qr-config h2:first-of-type, .qr-preview-sticky h2:first-of-type {
    margin-top: 0;
}

.tabs {
    display: flex;
    gap: 0.5em;
    border-bottom: 3px solid #f4a261;
    margin-bottom: 2.5em;
    flex-wrap: wrap;
}

.tab {
    background: #f5f5f5;
    color: #555;
    border: none;
    padding: 1em 1.6em;
    border-radius: 0.5em 0.5em 0 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 1em;
    transition: background 0.15s, color 0.15s;
}

.tab:hover {
    background: #e9c46a;
    color: #264653;
}

.tab.active {
    background: #f4a261;
    color: #fff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-badge {
    background: #e76f51;
    color: #fff;
    padding: 1px 7px;
    border-radius: 0.8em;
    font-size: 0.75em;
    margin-left: 0.3em;
    font-weight: 700;
}

.tab.active .tab-badge {
    background: rgba(255,255,255,0.3);
}

.cp-empty {
    color: #999;
    font-style: italic;
    margin: 0 0 1em;
}

.cp-hint {
    color: #999;
    font-size: 0.8em;
    margin: 0.4em 0 0;
}

.cfg-row {
    display: flex;
    gap: 1.4em;
    margin-bottom: 1.8em;
    flex-wrap: wrap;
    align-items: center;
}

.cfg-row.two > * { flex: 1; min-width: 0; }

.cfg-row label, .tab-content > label {
    display: flex;
    flex-direction: column;
    gap: 0.7em;
    font-size: 0.95em;
    color: #555;
    font-weight: 600;
}

.tab-content > label {
    margin-bottom: 1.8em;
    display: flex;
}

.cfg-row input, .cfg-row select, .tab-content select {
    padding: 0.95em 1.1em;
    border: 1px solid #ccc;
    border-radius: 0.5em;
    font-size: 1em;
    font-family: inherit;
}

.cfg-row input[type="color"] {
    height: 56px;
    padding: 0;
    cursor: pointer;
    background: none;
}

.cfg-row textarea, textarea.cfg-input {
    width: 100%;
    min-height: 120px;
    padding: 1em 1.2em;
    border: 1px solid #ccc;
    border-radius: 0.5em;
    font-family: inherit;
    font-size: 1em;
    resize: vertical;
    box-sizing: border-box;
}

.cfg-input {
    width: 100%;
    padding: 0.95em 1.1em;
    border: 1px solid #ccc;
    border-radius: 0.5em;
    font-size: 1em;
    box-sizing: border-box;
    font-family: inherit;
}

.cfg-check {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.8em !important;
    margin: 0.8em 0 1.6em !important;
    font-weight: 500 !important;
    cursor: pointer;
    font-size: 1em;
}

.cfg-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.cfg-range {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 1.2em !important;
    margin: 0.8em 0 1.8em !important;
    font-weight: 500 !important;
    font-size: 1em;
}

.cfg-range input[type="range"] { flex: 1; height: 6px; }
.cfg-range span {
    color: #264653;
    font-size: 0.9em;
    font-family: monospace;
    min-width: 65px;
    text-align: right;
    background: #f5f5f5;
    padding: 0.3em 0.5em;
    border-radius: 0.3em;
}

.file-drop {
    display: block;
    border: 2px dashed #f4a261;
    border-radius: 0.6em;
    padding: 1.5em 1em;
    text-align: center;
    color: #f4a261;
    cursor: pointer;
    margin: 0.4em 0 1.2em;
    transition: background 0.15s, border-color 0.15s;
    font-weight: 600;
    font-size: 0.95em;
}
.file-drop:hover, .file-drop.dragover {
    background: #fff5e8;
    border-color: #e76f51;
    color: #e76f51;
}

.del-action {
    background: #e76f51;
    color: #fff;
    border: none;
    padding: 0.5em 0.9em;
    border-radius: 0.4em;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
}
.del-action:hover { background: #c2503a; }

.qr-preview-box {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #ddd 25%, transparent 25%),
        linear-gradient(-45deg, #ddd 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ddd 75%),
        linear-gradient(-45deg, transparent 75%, #ddd 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, 10px 0px;
    border-radius: 0.6em;
    padding: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    margin-bottom: 0.8em;
}

#qrCanvas {
    max-width: 100%;
}

#qrCanvas canvas, #qrCanvas svg {
    max-width: 100%;
    height: auto;
    display: block;
}

.qr-info {
    color: #888;
    font-size: 0.85em;
    text-align: center;
    margin: 0 0 1.5em;
}

.dl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7em;
}

.dl-btn {
    background: #f4a261;
    color: #fff;
    border: none;
    padding: 0.9em 0.5em;
    border-radius: 0.5em;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: background 0.15s;
}

.dl-btn:hover { background: #e76f51; }

.qr-status {
    margin: 0.6em 0 0;
    color: #888;
    font-size: 0.8em;
    text-align: center;
    min-height: 1em;
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #f4a261;
    color: #fff;
    padding: 0.9em 1.6em;
    border-radius: 0.6em;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    z-index: 9999;
    font-weight: 600;
    font-size: 0.95em;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.save-row {
    display: flex;
    gap: 0.7em;
    flex-wrap: wrap;
    margin-bottom: 1em;
}

.save-row input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 0.8em 1em;
    border: 1px solid #ccc;
    border-radius: 0.5em;
    font-size: 0.95em;
}

#saveBtn {
    background: #e9c46a;
    color: #264653;
    border: none;
    padding: 0.85em 1.2em;
    border-radius: 0.5em;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}

#saveBtn:hover {
    background: #f4a261;
    color: #fff;
}

#saveBtn:active {
    transform: scale(0.98);
}

.saved-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.2em;
    margin-bottom: 1.5em;
}

.saved-qr-item {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 0.6em;
    padding: 1em;
    cursor: pointer;
    position: relative;
    transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
}

.saved-qr-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
    border-color: #f4a261;
}

.saved-qr-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: #fff;
    border-radius: 0.3em;
    display: block;
    margin-bottom: 0.7em;
}

.saved-qr-item .save-name {
    font-size: 0.85em;
    color: #264653;
    font-weight: 600;
    word-break: break-all;
    line-height: 1.2;
}

.saved-qr-item .save-date {
    font-size: 0.7em;
    color: #888;
    margin-top: 0.2em;
}

.saved-qr-item .save-del {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 255, 255, 0.95);
    color: #e76f51;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1em;
    line-height: 1;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.saved-qr-item .save-del:hover {
    background: #e76f51;
    color: #fff;
}

.saved-actions {
    display: flex;
    gap: 0.8em;
    flex-wrap: wrap;
    margin-top: 1em;
}
