@import url('fonts/fonts.css?v=2');

:root {
    --bg-dark: #0f172a; /* Slate 900 */
    --bg-card: rgba(30, 41, 59, 0.7); /* Slate 800 with transparency for glass */
    --text-main: #f8fafc; /* Slate 50 */
    --text-muted: #94a3b8; /* Slate 400 */
    --accent: #6366f1; /* Indigo 500 */
    --accent-hover: #4f46e5; /* Indigo 600 */
    --error: #ef4444; /* Red 500 */
    --success: #10b981; /* Emerald 500 -- matches the hardcoded success color already used in dashboard.js */
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);
    --transition: all 0.2s ease-in-out;

    /* Aliases: some markup/JS was written against these names before they
       existed here, so point them at the equivalent canonical token above
       rather than rewriting every call site. */
    --border: var(--border-color);
    --text: var(--text-main);
    --primary: var(--accent);

    /* Genuinely new tokens (no existing equivalent) for nested panel
       backgrounds inside modals -- e.g. admin search/filter inputs. */
    --surface: rgba(15, 23, 42, 0.6);
    --surface-light: rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(circle at top left, #1e1b4b, var(--bg-dark));
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Container */
.container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 30px;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    flex-grow: 1;
    width: 90%;
}

h1, h2, h3 {
    font-weight: 600;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(to right, #a5b4fc, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Forms & Inputs */
form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

input, textarea, select {
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Buttons with Micro-animations */
button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:active {
    transform: scale(0.97);
}

button.primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 14px 0 color-mix(in srgb, var(--accent) 39%, transparent);
}

button.primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 23%, transparent);
    transform: translateY(-1px);
}

button.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

button.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}

/* Shared global nav classes (used by nav.js across marketing & app pages) */
.logo {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, #a855f7, #ec4899, #f43f5e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #a855f7, #ec4899);
    color: #ffffff !important;
    padding: 10px 22px;
    border-radius: 9999px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px 0 rgba(236, 72, 153, 0.35);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.48);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff !important;
    padding: 10px 20px;
    border-radius: 9999px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.22);
}

/* Dashboard Layout */
#dashboard-container {
    max-width: 1120px;
    width: 92%;
    margin: 24px auto 60px;
}

.dashboard-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 22px 26px;
    background: rgba(30, 41, 59, 0.65);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin-bottom: 28px;
}

.dashboard-toolbar h1 {
    font-size: 1.85rem;
    margin: 0;
}

.dashboard-toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* Utility classes for common inline text/status patterns */
.text-muted { color: var(--text-muted); }
.error, .text-error { color: var(--error); }
.warning { color: orange; } /* matches the ad-hoc 'orange' already used for JS-error banners */

/* Auth tab switcher (Login/Signup) -- buttons here carry .active directly
   rather than via .tab-btn, so they need their own default/active look. */
.tabs { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); }
.tabs button { flex: 1; background: transparent; color: var(--text-muted); border: none; border-radius: 0; box-shadow: none; padding: 10px 5px; }
.tabs button.active { color: white; box-shadow: inset 0 -2px 0 var(--accent); }

/* Card Grid. #card-grid itself is not a grid: renderCards() fills it with a
   heading + .grid per slot tier, which must stack, not sit side by side. */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 22px;
    margin-top: 20px;
}

.card-item {
    background: rgba(30, 41, 59, 0.55);
    backdrop-filter: var(--glass-blur);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.card-item:hover {
    transform: translateY(-4px);
    background: rgba(30, 41, 59, 0.78);
    box-shadow: 0 14px 34px -10px rgba(0,0,0,0.55);
}

.card-item h3 {
    margin-bottom: 0.5rem;
    background: none;
    -webkit-text-fill-color: var(--text-main);
}

.card-item a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.card-item a:hover {
    text-decoration: underline;
}

/* Modal Styling */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}

.modal-content {
    background: rgba(30, 41, 59, 0.95);
    width: 90%; max-width: 650px;
    border-radius: 16px; padding: 30px;
    position: relative; max-height: 90vh; overflow-y: auto;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s ease-out;
}

#admin-dashboard-modal .modal-content {
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

#admin-card-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.close-btn {
    position: absolute; top: 15px; right: 20px;
    font-size: 28px; cursor: pointer; color: var(--text-muted);
    transition: var(--transition);
}
.close-btn:hover { color: white; transform: rotate(90deg); }

.editor-tabs {
    display: flex; gap: 10px; border-bottom: 1px solid var(--border-color); margin-bottom: 25px;
    overflow-x: auto; padding-bottom: 10px;
}

.tab-btn {
    background: transparent; color: var(--text-muted); border: none;
    padding: 8px 12px; cursor: pointer; white-space: nowrap;
    border-radius: 6px; font-weight: 500;
}

.tab-btn:hover { background: rgba(255,255,255,0.05); }
.tab-btn.active { 
    color: white; 
    background: rgba(99, 102, 241, 0.1);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.tab-content { display: none; animation: fadeIn 0.3s ease-out; }
.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-footer { margin-top: 30px; display: flex; justify-content: flex-end; gap: 15px; border-top: 1px solid var(--border-color); padding-top: 20px; }

.dynamic-field { display: flex; gap: 10px; margin-bottom: 15px; align-items: center; }
.dynamic-field input { margin-bottom: 0; flex: 1; }
.remove-btn { 
    background: rgba(239, 68, 68, 0.1); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.2); 
    border-radius: 8px; padding: 12px; cursor: pointer; 
}
.remove-btn:hover { background: var(--error); color: white; }

/* Public Card Specific Styling */
#card-container {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-top: 6px solid var(--accent);
    border-radius: 16px;
    padding: 40px;
    max-width: 450px;
    width: 90%;
    margin: 40px auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.avatar {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-card), rgba(255,255,255,0.05));
    border: 4px solid var(--accent);
    margin: 0 auto 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4em;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#name {
    font-size: 2rem;
    margin-bottom: 0.2rem;
    color: white;
    background: none;
    -webkit-text-fill-color: white;
}

#title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 1.5rem;
}

#bio {
    font-weight: 600;
}

.card-field {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    text-align: left;
    transition: var(--transition);
}
.card-field:hover {
    background: rgba(255,255,255,0.06);
    transform: translateX(4px);
}
.card-field-icon {
    font-size: 1.2rem;
    margin-right: 12px;
    opacity: 0.8;
}
.card-field-content {
    display: flex;
    flex-direction: column;
}
.card-field-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.card-field-value {
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 500;
}

/* Linktree Style Buttons */
.linktree-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px 50px;
    margin-bottom: 12px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
    border-radius: 30px;
    transition: all 0.2s ease-out;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.linktree-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    filter: brightness(1.1);
}
.linktree-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
}
.linktree-btn.brand-discord { background: #5865F2; }
.linktree-btn.brand-twitter { background: #1DA1F2; }
.linktree-btn.brand-linkedin { background: #0077b5; }
.linktree-btn.brand-github { background: #333; }
.linktree-btn.brand-youtube { background: #FF0000; }

/* Auth Container */
#auth-container {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-top: 6px solid var(--accent);
    border-radius: 16px;
    padding: 40px;
    max-width: 450px;
    width: 90%;
    margin: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.global-nav {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
}

/* Mobile Responsiveness for Dashboard/Card */
@media (max-width: 768px) {
    .container, #card-container, #auth-container {
        width: 95%;
        padding: 20px 15px;
        margin: 20px auto;
    }
    h1 {
        font-size: 2rem;
    }
    #global-nav {
        flex-direction: column;
        gap: 12px;
        padding: 16px 15px !important;
    }
    .editor-tabs {
        flex-wrap: wrap;
    }
    .avatar {
        width: 100px;
        height: 100px;
        font-size: 3em;
    }
    .modal-content {
        width: 95%;
        padding: 20px;
    }
    .dynamic-field {
        flex-direction: column;
        align-items: stretch;
    }
    .dynamic-field input {
        width: 100%;
    }
    .hide-on-mobile {
        display: none !important;
    }
}


input[type="color"] {
    padding: 0;
    width: 60px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
input[type="color"]::-moz-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

/* ===== Full-page card editor (card-editor-v2.js) ===== */
.editor-page {
    width: 100%;
    max-width: 1320px;
    margin: 8px auto 60px;
    padding: 0 24px;
}

.editor-topbar {
    position: sticky;
    top: 12px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 16px;
    margin-bottom: 20px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.6);
}
.editor-back-btn { padding: 9px 14px; font-size: 0.92rem; }
.editor-back-label { margin-left: 5px; }
.editor-topbar-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.editor-topbar-eyebrow {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    white-space: nowrap;
}
#editor-card-name {
    font-weight: 700;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.editor-tier-badge {
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.editor-tier-badge.pro { background: linear-gradient(135deg, #a855f7, #ec4899); color: #fff; }
.editor-tier-badge.free { background: rgba(148, 163, 184, 0.2); color: var(--text-main); }
.editor-topbar-actions { display: flex; gap: 10px; align-items: center; }
.editor-topbar-actions button { padding: 10px 18px; font-size: 0.95rem; }
.editor-dirty { font-size: 0.82rem; color: #fbbf24; white-space: nowrap; }

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 24px;
    align-items: start;
}
.editor-main {
    min-width: 0;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 22px 28px 28px;
}
/* Side-by-side inputs (first/last name, job/company) must be allowed to
   shrink below their default width, or they overflow on phones. */
.editor-main input, .editor-main select, .editor-main textarea { min-width: 0; }
.editor-main .editor-tabs { margin-bottom: 4px; }
.editor-main .tab-btn { padding: 10px 16px; font-size: 0.98rem; }
.editor-main h3 { margin: 22px 0 10px; font-size: 1.05rem; }
.editor-main .tab-content > h3:first-child { margin-top: 4px; }
.editor-hint { font-size: 0.88rem; margin: -4px 0 12px; }
.editor-tip {
    font-size: 0.88rem;
    color: var(--text-main);
    margin: 4px 0 16px;
    padding: 10px 14px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

/* Popups opened from the editor (per-link "More styles", image cropper).
   The default .modal blurs everything behind it; over the editor's glass
   panels that blur is redrawn every animation frame and the pop-in stutters.
   A plain dark overlay plus a short opacity/transform animation stays smooth. */
#item-style-modal, #cropper-modal {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(2, 6, 23, 0.72);
    animation: overlayFadeIn 0.15s ease-out;
}
#item-style-modal .modal-content, #cropper-modal .modal-content {
    animation: editorPopIn 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform, opacity;
    background: rgb(30, 41, 59);
}
@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes editorPopIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    #item-style-modal, #cropper-modal,
    #item-style-modal .modal-content, #cropper-modal .modal-content { animation: none; }
}

/* Inline per-link style pickers on phone / email / social rows */
#editor-page .dynamic-field {
    padding: 12px;
    margin-bottom: 12px !important;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.35);
}
.link-style-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}
.link-style-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-style-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.link-swatches { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.link-swatches .swatch { width: 22px; height: 22px; }
.link-swatches .swatch-default { width: auto; height: 22px; }
.link-shapes {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.link-shape {
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    border-right: 1px solid var(--border-color);
}
.link-shape:last-child { border-right: none; }
.link-shape:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.06); }
.link-shape.active { color: #fff; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.link-advanced-btn {
    margin-left: auto;
    padding: 6px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
    color: #c7d2fe;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
}
.link-advanced-btn:hover { color: #fff; border-color: var(--accent); }
.link-advanced-btn.has-style { color: #fff; background: color-mix(in srgb, var(--accent) 35%, transparent); }

.editor-danger-zone {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Live preview column */
.editor-preview { position: sticky; top: 96px; min-width: 0; }
.editor-preview-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    padding: 0 4px;
    font-weight: 700;
}
.editor-preview-head .text-muted { font-weight: 400; font-size: 0.82rem; }
.pv-browser {
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #0b0d14;
    box-shadow: 0 25px 50px -20px rgba(0, 0, 0, 0.7);
}
.pv-browser-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid var(--border-color);
}
.pv-dots { display: flex; gap: 5px; }
.pv-dots span { width: 9px; height: 9px; border-radius: 50%; background: #475569; }
.pv-dots span:first-child { background: #ef4444; }
.pv-dots span:nth-child(2) { background: #f59e0b; }
.pv-dots span:last-child { background: #10b981; }
.pv-url {
    flex: 1;
    min-width: 0;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pv-stage {
    background: radial-gradient(circle at top left, #1e1b4b, var(--bg-dark));
    padding: 28px 16px;
    max-height: calc(100vh - 210px);
    min-height: 420px;
    overflow-y: auto;
    color: var(--text-main);
    line-height: 1.6;
}
.pv-note { font-size: 0.8rem; margin: 10px 4px 0; }

/* The preview card copies #card-container / #name / #title / #bio from the
   public page, at phone-ish width. Keep in step with those rules above. */
.pv-card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-top: 6px solid var(--accent);
    border-radius: 16px;
    padding: 30px 20px;
    width: 100%;
    margin: 0 auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}
.pv-card .avatar { width: 120px; height: 120px; font-size: 3.4em; }
.pv-name {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
    margin-bottom: 0.2rem;
    color: white;
    overflow-wrap: anywhere;
}
.pv-title { font-size: 1.1rem; font-weight: 600; color: var(--accent); margin-bottom: 1.5rem; }
.pv-bio { font-weight: 600; }
.pv-links { margin: 30px 0; display: flex; flex-direction: column; gap: 10px; }
.pv-card .linktree-btn { cursor: default; font-size: 1rem; padding: 14px 46px; }
.pv-actions { margin-top: 24px; display: flex; justify-content: center; }
.pv-save {
    padding: 12px 26px;
    border-radius: 9999px;
    background: var(--accent);
    color: white;
    font-weight: 700;
    font-family: inherit;
    cursor: default;
}
.pv-save:active { transform: none; }
.pv-footer { margin: 24px 0 0; font-size: 12px; opacity: 0.7; }

/* Quick theme tiles */
.theme-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 10px;
    margin-bottom: 8px;
}
.theme-preset {
    flex-direction: column;
    gap: 7px;
    padding: 7px 7px 9px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 600;
}
.theme-preset:hover { border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.07); }
.theme-preset.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.theme-preset-thumb {
    width: 100%;
    height: 58px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-preset-card {
    width: 62%;
    height: 40px;
    border-radius: 6px;
    border-top: 3px solid;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}
.theme-preset-card i { display: block; height: 5px; border-radius: 3px; box-sizing: border-box; }
.theme-preset-name { line-height: 1.2; }

/* Quick color swatches under each color picker */
.swatch-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; max-width: 460px; }
.swatch {
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.18);
    box-shadow: none;
    flex-shrink: 0;
}
.swatch:hover { transform: scale(1.15); border-color: rgba(255, 255, 255, 0.55); }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.swatch-default {
    width: auto;
    padding: 0 10px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
}
.swatch-default.active { color: var(--text-main); }

/* The part of the preview tied to the field being edited (card-editor-v2.js) */
#preview-card .pv-focus {
    outline: 2px dashed color-mix(in srgb, var(--accent) 75%, #fff);
    outline-offset: 5px;
    animation: pvFocusIn 0.35s ease-out;
}
@keyframes pvFocusIn {
    from { outline-offset: 12px; outline-color: transparent; }
}
@media (prefers-reduced-motion: reduce) {
    #preview-card .pv-focus { animation: none; }
}

.pv-dock-controls { display: none; gap: 6px; margin-left: auto; }
.pv-dock-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    box-shadow: none;
}
.pv-dock-btn:hover { background: rgba(255, 255, 255, 0.12); }

/* Narrow screens: the preview docks above the form instead of beside it,
   stuck under the top bar, with the card zoomed down so more of it fits.
   --pv-dock-top / --pv-dock-h / --pv-zoom are set by updateDockMetrics(). */
@media (max-width: 1040px) {
    .editor-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .editor-preview {
        --pv-dock-gap: 6px;
        order: -1;
        position: sticky;
        top: var(--pv-dock-top, 72px);
        z-index: 40;
        padding: 8px;
        background: rgb(15, 23, 42);
        border: 1px solid var(--border-color);
        border-radius: 14px;
        box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.75);
    }
    .editor-preview-head { align-items: center; margin-bottom: 6px; font-size: 0.92rem; gap: 8px; }
    .pv-head-note, .pv-note { display: none; }
    .pv-dock-controls { display: flex; }
    .pv-browser { border-radius: 10px; box-shadow: none; }
    .pv-browser-bar { padding: 6px 10px; }
    .pv-stage {
        height: var(--pv-dock-h, 220px);
        max-height: none;
        min-height: 0;
        padding: 12px 8px;
        overscroll-behavior: contain;
    }
    .pv-card {
        width: 400px;
        max-width: none;
        zoom: var(--pv-zoom, 0.6);
    }
    .editor-preview.collapsed .pv-browser { display: none; }
    .editor-preview.collapsed .editor-preview-head { margin-bottom: 0; }

    /* Full screen: the whole viewport, card at real size */
    .editor-preview.fullscreen {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: flex;
        flex-direction: column;
        padding: 10px 10px max(10px, env(safe-area-inset-bottom));
        border: none;
        border-radius: 0;
    }
    .editor-preview.fullscreen #pv-toggle { display: none; }
    .editor-preview.fullscreen .pv-browser { flex: 1; min-height: 0; display: flex; flex-direction: column; }
    .editor-preview.fullscreen .pv-stage { flex: 1; height: auto; padding: 24px 12px; }
    .editor-preview.fullscreen .pv-card { width: 100%; max-width: 420px; zoom: 1; }
    body.pv-fullscreen-open { overflow: hidden; }
}

@media (max-width: 640px) {
    .editor-page { padding: 0 10px; }
    /* One compact row (back, name, save) so the docked preview gets the room.
       Back already asks before discarding, so Cancel is redundant here. */
    .editor-topbar { top: 0; gap: 8px; padding: 8px 10px; margin-bottom: 10px; border-radius: 0 0 12px 12px; flex-wrap: nowrap; }
    .editor-back-btn { padding: 8px 12px; }
    .editor-back-label, .editor-topbar-eyebrow { display: none; }
    #editor-card-name { font-size: 1rem; }
    #cancel-edit { display: none; }
    /* Top bar and docked preview join into one header, so the form can't
       peek through a gap between them. */
    .editor-topbar { margin-bottom: 0; border-radius: 0; border-bottom: none; box-shadow: none; background: rgb(15, 23, 42); }
    .editor-preview:not(.fullscreen) { --pv-dock-gap: 0px; border-top: none; border-radius: 0 0 14px 14px; padding-top: 2px; }
    .editor-topbar-actions button { padding: 9px 14px; font-size: 0.9rem; }
    .editor-dirty { display: none !important; }
    .editor-main { padding: 14px 12px 20px; }
    .editor-main .tab-btn { padding: 8px 12px; font-size: 0.9rem; }
}
