/* ============================================
   TEMPLATE SELECTOR — Green Theme Match
   Consistent with ATS Perfect design system
   ============================================ */

/* Overlay */
.template-selector-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.template-selector-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Container */
.template-selector-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -48%) scale(0.96);
    background: #ffffff;
    border-radius: 16px;
    box-shadow:
        0 32px 64px -12px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(0, 0, 0, 0.06);
    z-index: 9999;
    width: 90%;
    max-width: 860px;
    max-height: 88vh;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.template-selector-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* ── Modal Header ── */
.template-modal-header {
    padding: 22px 28px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #10b981; /* your green-500 */
    color: white;
}

.template-modal-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.template-modal-icon {
    font-size: 26px;
    line-height: 1;
    animation: none; /* removed distracting float */
}

.template-modal-title h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: white;
}

.template-modal-subtitle {
    margin: 3px 0 0 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.82);
    font-weight: 400;
}

/* Close Button */
.template-close-btn {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.28);
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: white;
    font-size: 22px;
    font-weight: 300;
    flex-shrink: 0;
}

.template-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg);
}

/* ── Modal Body ── */
.template-modal-body {
    padding: 28px 28px 24px;
    max-height: calc(88vh - 88px);
    overflow-y: auto;
    background: #f8fafc;
}

/* ── Template Grid ── */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* ── Template Card ── */
.template-card {
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.template-card:hover {
    transform: translateY(-3px);
    border-color: #34d399;
    box-shadow:
        0 12px 24px -6px rgba(16, 185, 129, 0.18),
        0 4px 8px -2px rgba(16, 185, 129, 0.1);
}

.template-card.selected {
    border-color: #10b981;
    box-shadow:
        0 0 0 3px rgba(16, 185, 129, 0.18),
        0 12px 24px -6px rgba(16, 185, 129, 0.22);
}

/* ── Selected Badge — NO OVERLAP ── */
/* Badge sits BELOW preview, inside info area */
.template-selected-badge {
    display: none; /* hidden by default */
}

/* Show selected state via card border + info-area indicator only */
.template-card.selected .template-info::before {
    content: '✔  Currently Selected';
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #059669;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    width: fit-content;
    letter-spacing: 0.01em;
}

/* ── Template Preview Area ── */
.template-preview {
    height: 310px;
    background: #f1f5f9;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
}

.template-1-preview {
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
}

.template-2-preview {
    background: linear-gradient(160deg, #1e293b 0%, #334155 100%);
}

/* Screenshot Image */
.template-screenshot {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: top center;
    border-radius: 4px;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.22),
        0 2px 6px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s ease;
    display: block;
}

.template-card:hover .template-screenshot {
    transform: scale(1.025);
}

/* ── Template Info Panel ── */
.template-info {
    padding: 18px 20px 20px;
    background: white;
}

.template-name {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 5px 0;
    letter-spacing: -0.3px;
}

.template-description {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 12px 0;
    line-height: 1.55;
}

/* Feature Tags */
.template-features {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.template-feature-tag {
    background: #f1f5f9;
    color: #475569;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.template-card.selected .template-feature-tag {
    background: #f0fdf4;
    color: #059669;
    border-color: #bbf7d0;
}

.template-card:hover .template-feature-tag {
    background: #f0fdf4;
    color: #059669;
    border-color: #a7f3d0;
}

/* ── Template Selector Trigger Button (in preview header) ── */
.template-selector-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px !important;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px !important;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
    height: 36px !important;
    min-height: unset !important;
    width: auto !important;
    min-width: unset !important;
    box-sizing: border-box;
}

.template-selector-btn:hover {
    background: #f0fdf4;
    border-color: #10b981;
    color: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.template-selector-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* ── Scrollbar Styling ── */
.template-modal-body::-webkit-scrollbar {
    width: 6px;
}

.template-modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.template-modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.template-modal-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .template-selector-modal {
        width: 96%;
        max-height: 92vh;
        border-radius: 14px;
    }

    .template-modal-header {
        padding: 18px 20px;
    }

    .template-modal-title h3 {
        font-size: 17px;
    }

    .template-modal-body {
        padding: 20px 16px 18px;
    }

    .template-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .template-preview {
        height: 260px;
    }
}

/* ============================================================
   PREMIUM MATTE-BLACK OVERRIDE  +  TRUE A4 THUMBNAILS
   Appended last so it wins the cascade.
   ============================================================ */

/* ── Overlay: deeper dim ── */
.template-selector-overlay {
    background: rgba(6, 9, 14, 0.68) !important;
    backdrop-filter: blur(14px) saturate(120%) !important;
    -webkit-backdrop-filter: blur(14px) saturate(120%) !important;
}

/* ── Modal shell: matte charcoal glass ── */
.template-selector-modal {
    background:
        radial-gradient(130% 90% at 50% -12%, rgba(16,185,129,0.10) 0%, rgba(16,185,129,0) 52%),
        linear-gradient(168deg, rgba(30,34,42,0.94) 0%, rgba(14,16,20,0.97) 100%) !important;
    backdrop-filter: blur(30px) saturate(140%);
    -webkit-backdrop-filter: blur(30px) saturate(140%);
    border: 1px solid rgba(255,255,255,0.08) !important;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.07) inset,
        0 28px 70px rgba(0,0,0,0.60),
        0 8px 24px rgba(0,0,0,0.42) !important;
    color: #d6dbe4;
}

/* ── Header: dark, not green ── */
.template-modal-header {
    background: transparent !important;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
    padding: 20px 26px !important;
}
.template-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 19px !important;
    background: rgba(16,185,129,0.16);
    border: 1px solid rgba(16,185,129,0.28);
}
.template-modal-title h3 { color: #f3f6fb !important; letter-spacing: -0.02em !important; }
.template-modal-subtitle { color: #8b93a1 !important; }

.template-close-btn {
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid rgba(255,255,255,0.10) !important;
    color: #aeb6c2 !important;
}
.template-close-btn:hover {
    background: rgba(239,68,68,0.18) !important;
    border-color: rgba(239,68,68,0.35) !important;
    color: #fca5a5 !important;
}

/* ── Body ── */
.template-modal-body {
    background: transparent !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.template-modal-body::-webkit-scrollbar { width: 8px; }
.template-modal-body::-webkit-scrollbar-track { background: transparent; }
.template-modal-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 8px; }

/* ── Cards: dark glass ── */
.template-card {
    background: rgba(255,255,255,0.035) !important;
    border: 1px solid rgba(255,255,255,0.09) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.32) !important;
}
.template-card:hover {
    border-color: rgba(16,185,129,0.45) !important;
    box-shadow: 0 14px 34px rgba(0,0,0,0.42), 0 0 0 1px rgba(16,185,129,0.22) !important;
}
.template-card.selected {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 1px rgba(16,185,129,0.55), 0 14px 34px rgba(16,185,129,0.16) !important;
}

/* ── THUMBNAIL: exact A4, no surrounding background ──
   Was a fixed 310px box with a dark gradient + 16px padding, so `object-fit:
   contain` letterboxed the page and painted bands around it. Now the frame IS
   the page: A4 aspect (210 x 297), zero padding, no gradient. */
.template-preview {
    height: auto !important;
    aspect-ratio: 210 / 297 !important;
    padding: 0 !important;
    background: #ffffff !important;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
    display: block !important;
    overflow: hidden !important;
}
/* Kill the per-template gradient backdrops */
.template-1-preview,
.template-2-preview,
.template-3-preview,
.template-4-preview,
.template-5-preview {
    background: #ffffff !important;
}

.template-screenshot {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: top center !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: block !important;
}
.template-card:hover .template-screenshot { transform: scale(1.015) !important; }

/* ── Info panel on dark ── */
.template-info { background: transparent !important; }
.template-name { color: #f3f6fb !important; }
.template-description { color: #8b93a1 !important; }

.template-feature-tag {
    background: rgba(255,255,255,0.05) !important;
    color: #b9c0cc !important;
    border: 1px solid rgba(255,255,255,0.10) !important;
}
.template-card:hover .template-feature-tag,
.template-card.selected .template-feature-tag {
    background: rgba(16,185,129,0.12) !important;
    color: #6ee7b7 !important;
    border-color: rgba(16,185,129,0.35) !important;
}

/* ── "Currently Selected" pill on dark ── */
.template-card.selected .template-info::before {
    background: rgba(16,185,129,0.13) !important;
    border: 1px solid rgba(16,185,129,0.38) !important;
    color: #6ee7b7 !important;
}

/* ── Mobile: keep the A4 ratio (no fixed height) ── */
@media (max-width: 640px) {
    .template-preview { height: auto !important; aspect-ratio: 210 / 297 !important; }
}

/* Square corners: structural containers only (pills/badges stay pills) */
.template-selector-modal { border-radius: 0 !important; }
.template-card { border-radius: 0 !important; }
.template-preview { border-radius: 0 !important; }
.template-screenshot { border-radius: 0 !important; }
.template-close-btn { border-radius: 0 !important; }
@media (max-width: 640px) {
    .template-selector-modal { border-radius: 0 !important; }
}

/* ============================================================
   DISTINCT PICKER — the page IS the card.
   Competitors (MyPerfectResume, Zety, Resume.io) all ship the same
   white-card-on-white grid. We keep our matte-black stage and let
   the white A4 pages float on it: pure contrast, zero chrome.
   Selection = an emerald spine down the page's left edge, never a
   ribbon over the content.
   ============================================================ */

/* Roomier grid: pages need air, not borders, to separate */
.template-grid {
    grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)) !important;
    gap: 30px 26px !important;
}

/* ── Card: dissolve it. No background, no border, no shadow. ── */
.template-card,
.template-card.selected,
.template-card:hover {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    transform: none !important;
    transition: none !important;
}

/* ── The page itself: true A4, hairline, subtle lift ── */
.template-preview {
    position: relative !important;
    height: auto !important;
    aspect-ratio: 210 / 297 !important;
    padding: 0 !important;
    background: #ffffff !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    display: block !important;
    opacity: 0.86;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.10), 0 10px 26px rgba(0,0,0,0.42) !important;
    transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease !important;
}
.template-1-preview,
.template-2-preview,
.template-3-preview,
.template-4-preview,
.template-5-preview { background: #ffffff !important; }

.template-card:hover .template-preview {
    opacity: 1;
    transform: translateY(-3px);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.20), 0 16px 34px rgba(0,0,0,0.50) !important;
}

.template-card.selected .template-preview {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 0 0 1px rgba(16,185,129,0.55), 0 16px 34px rgba(0,0,0,0.50) !important;
}

/* Screenshot fills the page exactly */
.template-screenshot {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: top center !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: block !important;
    transform: none !important;
}
.template-card:hover .template-screenshot { transform: none !important; }

/* ── Caption: name + who it's for. Nothing else. ── */
.template-info {
    padding: 14px 2px 0 !important;
    background: transparent !important;
}
.template-info::before { content: none !important; }   /* kill "Currently Selected" pill */

.template-name {
    font-size: 13.5px !important;
    font-weight: 600 !important;
    color: #cfd5df !important;
    margin: 0 0 3px 0 !important;
    letter-spacing: -0.01em !important;
    transition: color 0.15s ease !important;
}
.template-card:hover .template-name { color: #ffffff !important; }
.template-card.selected .template-name { color: #ffffff !important; font-weight: 700 !important; }


/* Legacy bits, now unused */
.template-description,
.template-features,
.template-feature-tag,
.template-selected-badge { display: none !important; }

/* ── Wider modal: five pages want room ── */
.template-selector-modal { max-width: 980px !important; }

@media (max-width: 640px) {
    .template-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 20px 16px !important; }
    .template-name { font-size: 12.5px !important; }
}

/* ATS-Friendly badge: the one tag that IS the pitch. Kept, the rest cut. */
.ats-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding: 3px 9px 3px 7px;
    border-radius: 999px;
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.32);
    color: #6ee7b7;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1;
    white-space: nowrap;
}
.ats-badge svg { width: 10px; height: 10px; flex-shrink: 0; }
.template-card.selected .ats-badge {
    background: rgba(16,185,129,0.20);
    border-color: rgba(16,185,129,0.55);
    color: #a7f3d0;
}

.ats-badge, .layout-badge { display: none !important; }
/* ── Picker ("Studio Light"): a grid of pages on soft grey, and a big preview with one "Use" button.
      A card click only previews; nothing changes on the resume until "Use".
      #templateSelectorModal so these win over the older layers above and builder-premium.css. ── */
html body #templateSelectorModal {
    display: flex; flex-direction: column;
    width: min(1180px, 94vw) !important; max-width: none !important;
    height: min(820px, 94vh); max-height: none !important;
    border-radius: 16px !important; color: #111827 !important;
}
#templateSelectorModal button { font-family: inherit; }
html body #templateSelectorModal .template-modal-header { flex-shrink: 0; padding: 18px 28px 16px; border-bottom: 1px solid #ECEDEF !important; }
html body #templateSelectorModal .template-modal-title h3 { font-size: 20px !important; font-weight: 600 !important; letter-spacing: -0.02em !important; color: #111827 !important; margin: 0 0 6px !important; }
html body #templateSelectorModal .template-modal-subtitle { font-size: 13.5px !important; color: #6B7280 !important; margin: 0 !important; }
html body #templateSelectorModal .template-close-btn {
    width: 40px; height: 40px; border-radius: 999px !important; border: 1px solid #E5E7EB !important;
    background: #fff !important; color: #6B7280 !important; font-size: 22px; line-height: 1;
}
html body #templateSelectorModal .template-close-btn:hover { background: #F4F5F7 !important; border-color: #D1D5DB !important; color: #111827 !important; }

.tp-layout {
    flex: 1; min-height: 0; display: grid; background: #fff;
    grid-template-columns: minmax(0, 1fr) minmax(440px, 46%);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "grid stage" "info actions";   /* a bottom bar: name on the left, buttons on the right */
}
html body #templateSelectorModal .template-modal-body {
    grid-area: grid; max-height: none; min-height: 0; overflow-y: auto;
    padding: 24px 24px 28px; background: #F4F5F7 !important; border-right: 1px solid #ECEDEF;
}
html body #templateSelectorModal .template-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important; gap: 24px 20px !important; }

/* each page: a soft layered shadow; the one in the big preview gets a black ring; the one in use an "In use" pill */
html body #templateSelectorModal .template-card .template-preview {
    position: relative !important; border-radius: 6px !important;
    box-shadow: 0 0 0 1px rgba(17,24,39,.06), 0 1px 2px rgba(17,24,39,.05), 0 10px 24px -12px rgba(17,24,39,.18) !important;
    transition: transform .2s ease, box-shadow .2s ease !important;
}
html body #templateSelectorModal .template-card:hover .template-preview {
    transform: translateY(-4px);
    box-shadow: 0 0 0 1px rgba(17,24,39,.08), 0 4px 8px rgba(17,24,39,.06), 0 22px 38px -14px rgba(15,28,53,.36) !important;
}
html body #templateSelectorModal .template-card:active .template-preview { transform: translateY(-1px) scale(.985); }
/* the page in the big preview: a navy ring with a small gap; looking is not choosing, so not green */
html body #templateSelectorModal .template-card.focused .template-preview { box-shadow: 0 0 0 3px #F4F5F7, 0 0 0 5px #0F1C35, 0 18px 32px -14px rgba(15,28,53,.3) !important; }
html body #templateSelectorModal .template-card:focus-visible { outline: none; }
html body #templateSelectorModal .template-card:focus-visible .template-preview { box-shadow: 0 0 0 3px #F4F5F7, 0 0 0 5px #3B82F6 !important; }
html body #templateSelectorModal .template-name { font-size: 14px !important; font-weight: 500 !important; color: #6B7280 !important; transition: color .15s; }
html body #templateSelectorModal .template-card:hover .template-name,
html body #templateSelectorModal .template-card.focused .template-name { color: #111827 !important; }
.template-card .tpl-select {
    position: absolute; inset: 0; z-index: 3; pointer-events: none;
    display: flex; align-items: flex-end; justify-content: center; padding-bottom: 14px;
    background: linear-gradient(to top, rgba(15,28,53,.35), rgba(15,28,53,0) 50%);
    opacity: 0; transition: opacity .2s ease;
}
.template-card .tpl-select-btn {
    display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 999px;
    background: #fff; color: #0F1C35; font-size: 13px; font-weight: 600; box-shadow: 0 4px 12px rgba(15,28,53,.18);
    transform: translateY(4px); transition: transform .2s ease;
}
.template-card:hover .tpl-select { opacity: 1; }
.template-card:hover .tpl-select-btn { transform: none; }
.template-card.focused .tpl-select { opacity: 0; }
/* green only where it means "safe / yours": the template in use and the ATS-safe badge */
.tp-inuse {
    position: absolute; top: 8px; left: 8px; z-index: 4; display: none; align-items: center; gap: 3px;
    height: 20px; padding: 0 8px; border-radius: 999px; background: #067647; color: #fff; font-size: 11px; font-weight: 600;
    box-shadow: 0 2px 6px rgba(6,118,71,.35);
}
.template-card.selected .tp-inuse { display: inline-flex; }

/* the big preview */
.tp-stage {
    grid-area: stage; position: relative; min-height: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 16px 64px; background: #EBEDF0;
    container-type: size;   /* the page sizes itself to fit both the height and the width */
}
.tp-stage-img {
    display: block; width: auto; aspect-ratio: 210 / 297; object-fit: cover; object-position: top;
    height: min(100cqh, 100cqw * 297 / 210);   /* as big as the panel allows, never cut off */
    background: #fff; border-radius: 3px;
    box-shadow: 0 1px 2px rgba(17,24,39,.06), 0 14px 28px -8px rgba(17,24,39,.18), 0 40px 70px -30px rgba(17,24,39,.3);
}
.tp-stage-img.tp-fade { animation: tpFade .22s ease; }
@keyframes tpFade { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tp-stage-img.tp-fade { animation: none; } }
/* their own resume, page 1, drawn full size and scaled down to the panel (js/template-selector.js fitStage) */
.tp-stage-img[hidden], .tp-doc[hidden] { display: none !important; }
.tp-doc {
    position: relative; flex: none; aspect-ratio: 210 / 297; height: min(100cqh, 100cqw * 297 / 210);
    background: #fff; border-radius: 3px; overflow: hidden;
    box-shadow: 0 1px 2px rgba(17,24,39,.06), 0 14px 28px -8px rgba(17,24,39,.18), 0 40px 70px -30px rgba(17,24,39,.3);
}
.tp-doc-in { position: absolute; top: 0; left: 0; transform-origin: 0 0; transition: opacity .2s ease; }
.tp-doc .resume-page { margin: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
.tp-doc.tp-loading .tp-doc-in { opacity: .35; }
.tp-doc.tp-fade { animation: tpFade .22s ease; }
@media (prefers-reduced-motion: reduce) { .tp-doc.tp-fade { animation: none; } }
.tp-arrow {
    position: absolute; z-index: 2; top: 50%; transform: translateY(-50%); width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center; border: 1px solid #E5E7EB; border-radius: 999px;
    background: #fff; color: #374151; cursor: pointer; box-shadow: 0 1px 2px rgba(17,24,39,.06);
    transition: transform .15s ease, box-shadow .15s ease, color .15s;
}
.tp-arrow:hover { transform: translateY(-50%) scale(1.06); color: #111827; box-shadow: 0 6px 16px -6px rgba(17,24,39,.3); }
.tp-arrow:active { transform: translateY(-50%) scale(.95); }
.tp-prev { left: 14px; } .tp-next { right: 14px; }
.tp-info { grid-area: info; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px 12px 28px; border-top: 1px solid #ECEDEF; border-right: 1px solid #ECEDEF; min-width: 0; }
html body #templateSelectorModal .tp-name { margin: 0; font-size: 16px; font-weight: 600; color: #111827; letter-spacing: -.01em; }
.tp-count { flex-shrink: 0; font-size: 13px; color: #9CA3AF; }
.tp-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tp-ats {
    flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
    border-radius: 999px; background: #ECFDF3; border: 1px solid #C6F0D8; color: #067647; font-size: 12px; font-weight: 600;
}
.tp-actions { grid-area: actions; display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 12px 20px; border-top: 1px solid #ECEDEF; }
/* "Use this template": brand navy, lifts on hover, arrow slides, presses in */
.tp-use {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 14px 0 18px; border: 0; border-radius: 10px;
    background: linear-gradient(180deg, #22314F 0%, #0F1C35 100%); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 1px 2px rgba(15,28,53,.3), 0 6px 14px -6px rgba(15,28,53,.45);
    transition: transform .15s ease, box-shadow .15s ease;
}
.tp-use:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 2px 4px rgba(15,28,53,.3), 0 12px 22px -8px rgba(15,28,53,.55); }
.tp-use:active { transform: translateY(0) scale(.98); }
.tp-use .tp-use-arrow { transition: transform .15s ease; }
.tp-use:hover .tp-use-arrow { transform: translateX(3px); }
.tp-use.in-use, .tp-use.in-use:hover, .tp-use.in-use:active {
    padding: 0 16px; background: #ECFDF3; color: #067647; box-shadow: none; transform: none; cursor: default;
}
.tp-keep {
    flex-shrink: 0; height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: none;
    color: #4B5563; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s;
}
.tp-keep:hover { background: #F3F4F6; color: #111827; }
html body #templateSelectorModal .template-close-btn { transition: background .15s, color .15s; }

/* phones: the big preview on top, the pages as a strip of small thumbnails, "Use" at the bottom */
@media (max-width: 768px) {
    html body #templateSelectorModal { width: 100vw !important; height: 100vh; height: 100dvh; border-radius: 0 !important; border: 0 !important; }
    html body #templateSelectorModal .template-modal-header { padding: 16px 16px 14px; }
    html body #templateSelectorModal .template-modal-title h3 { font-size: 19px !important; margin-bottom: 4px !important; }
    html body #templateSelectorModal .template-modal-subtitle { font-size: 13px !important; }
    .tp-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto auto; grid-template-areas: "stage" "info" "grid" "actions"; }
    .tp-stage { margin: 14px 16px 0; padding: 16px 0; background: #F4F5F7; border-radius: 14px; }
    .tp-arrow { width: 44px; height: 44px; }
    .tp-info { padding: 14px 16px 0; border: 0; }
    html body #templateSelectorModal .tp-name { font-size: 18px; }
    html body #templateSelectorModal .template-modal-body { border-right: 0; overflow-x: auto; overflow-y: hidden; padding: 14px 16px 10px; background: #fff !important; }
    html body #templateSelectorModal .template-grid { display: flex !important; gap: 10px !important; }
    /* the scroller's right padding is lost when the row scrolls: a spacer gives the last design the same 16px as the first */
    html body #templateSelectorModal .template-grid::after { content: ""; flex: 0 0 6px; }
    html body #templateSelectorModal .template-card { flex: 0 0 56px; }
    html body #templateSelectorModal .template-card .template-preview { border-radius: 4px !important; }
    html body #templateSelectorModal .template-card:hover .template-preview { transform: none; }
    .template-card .template-info, .template-card .tpl-select, .template-card .tp-inuse { display: none !important; }
    .tp-actions { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid #ECEDEF; }
    .tp-use { flex: 1; height: 52px; font-size: 16px; border-radius: 12px; }
    .tp-keep { display: none; }
}
