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

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

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

.ms-config, .ms-preview-sticky {
    background: #fff;
    border-radius: 1em;
    padding: 2em 2.2em;
    box-shadow: 0 10px 20px #dbdbdb;
}

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

.ms-config h2, .ms-preview-sticky h2 {
    margin: 1.8em 0 1em;
    font-size: 1.1em;
    color: #264653;
    border-bottom: 2px solid #e76f51;
    padding-bottom: 0.4em;
}

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

.tabs {
    display: flex;
    gap: 0.4em;
    border-bottom: 3px solid #e76f51;
    margin-bottom: 1.8em;
    flex-wrap: wrap;
}

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

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

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

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

.tab-content > label {
    display: flex;
    flex-direction: column;
    gap: 0.6em;
    font-size: 0.95em;
    color: #555;
    font-weight: 600;
    margin-bottom: 1.2em;
}

.tab-content input[type="text"],
.tab-content input[type="email"],
.tab-content input[type="tel"],
.tab-content textarea,
.tab-content select {
    padding: 0.85em 1em;
    border: 1px solid #ccc;
    border-radius: 0.5em;
    font-size: 1em;
    font-family: inherit;
    box-sizing: border-box;
    width: 100%;
}

.tab-content textarea {
    min-height: 90px;
    resize: vertical;
}

.cfg-row {
    display: flex;
    gap: 1em;
    flex-wrap: wrap;
    margin-bottom: 1.2em;
}

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

.cfg-row label {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    font-size: 0.9em;
    color: #555;
    font-weight: 600;
}

.cfg-row input[type="color"] {
    height: 50px;
    padding: 0;
    cursor: pointer;
    background: none;
    border: 1px solid #ccc;
    border-radius: 0.5em;
}

.cfg-range {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.9em !important;
    font-weight: 500 !important;
    margin-bottom: 1.2em;
}

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

.file-drop {
    display: block;
    border: 2px dashed #e76f51;
    border-radius: 0.6em;
    padding: 1.2em;
    text-align: center;
    color: #e76f51;
    cursor: pointer;
    margin-bottom: 1em;
    transition: background 0.15s, border-color 0.15s;
    font-weight: 600;
}
.file-drop:hover, .file-drop.dragover {
    background: #fff0ec;
    border-color: #c2503a;
}

.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;
    margin-top: 0.5em;
}
.del-action:hover { background: #c2503a; }

.add-action {
    background: #2a9d8f;
    color: #fff;
    border: none;
    padding: 0.7em 1em;
    border-radius: 0.5em;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    margin-top: 0.5em;
}
.add-action:hover { background: #264653; }

.hint {
    color: #888;
    font-size: 0.85em;
    margin: 0 0 1em;
}

/* Social links list */

.social-row, .list-row {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin-bottom: 0.6em;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 0.5em;
    padding: 0.6em 0.7em;
    flex-wrap: wrap;
}

.social-row select {
    width: 130px !important;
    padding: 0.5em 0.6em !important;
}

.social-row input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 0.5em 0.6em !important;
}

.social-row .del-soc, .list-row .del-row {
    background: #e76f51;
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    line-height: 1;
    flex-shrink: 0;
}

.list-row .row-label-input {
    width: 100px !important;
    padding: 0.5em 0.6em !important;
    font-size: 0.85em !important;
    background: #fff;
}

.list-row .row-value-input {
    flex: 1;
    min-width: 0;
    padding: 0.5em 0.6em !important;
}

.list-row .row-image-thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 0.3em;
    border: 1px solid #ccc;
}

.list-row .row-color {
    width: 40px;
    height: 32px;
    padding: 0;
    cursor: pointer;
    background: none;
    border: 1px solid #ccc;
    border-radius: 0.3em;
}

.list-row .row-file {
    flex: 1;
    min-width: 140px;
    font-size: 0.85em;
    color: #555;
}

.list-row .row-file-btn {
    background: #2a9d8f;
    color: #fff;
    border: none;
    padding: 0.45em 0.7em;
    border-radius: 0.3em;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
}

.list-row .row-file-btn:hover { background: #264653; }

/* Preview */

.ms-preview-frame {
    background: #f0f4f8;
    border-radius: 0.6em;
    padding: 1em;
    margin-bottom: 1em;
    overflow-x: auto;
}

.email-mock {
    background: #fff;
    border-radius: 0.4em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
    min-width: 320px;
}

.email-header, .email-subject {
    padding: 0.5em 1em;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 0.85em;
    color: #555;
}

.email-subject { font-weight: 600; color: #264653; }

.email-body {
    padding: 1em 1.2em;
    color: #333;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.email-body p { margin: 0 0 0.8em; }

#signaturePreview {
    margin-top: 1em;
    border-top: 1px solid #eee;
    padding-top: 1em;
}

/* Export tab */

#htmlOutput {
    width: 100%;
    min-height: 200px;
    padding: 1em;
    background: #264653;
    color: #e9c46a;
    font-family: monospace;
    font-size: 0.85em;
    border: none;
    border-radius: 0.5em;
    resize: vertical;
    box-sizing: border-box;
    margin-bottom: 0.8em;
}

.export-actions {
    display: flex;
    gap: 0.6em;
    flex-wrap: wrap;
    margin-bottom: 1.5em;
}

.export-actions button {
    background: #e76f51;
    color: #fff;
    border: none;
    padding: 0.8em 1.2em;
    border-radius: 0.5em;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: background 0.15s;
}

.export-actions button:hover { background: #c2503a; }

.howto {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 0.5em;
    padding: 0.8em 1em;
    margin-bottom: 0.6em;
}

.howto summary {
    cursor: pointer;
    font-weight: 600;
    color: #264653;
}

.howto ol {
    margin: 0.6em 0 0.2em;
    padding-left: 1.5em;
    line-height: 1.5;
    color: #555;
}

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

/* Toast */

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #e76f51;
    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;
}

@media (max-width: 600px) {
    .tabs { gap: 0.2em; }
    .tab { padding: 0.6em 0.9em; font-size: 0.85em; }
    .ms-config h2, .ms-preview-sticky h2 { font-size: 1em; }
    .cfg-row.two { flex-direction: column; }
    .social-row { flex-wrap: wrap; }
    .social-row select { width: 100% !important; }
}
