
/* Lock the shell to viewport height so the page itself never scrolls.
   Wheel/touchpad events then fall naturally into the inner scrollable panels. */
html, body { overflow: hidden; height: 100%; }
.admin-layout { height: 100vh; overflow: hidden; }
.admin-main   { min-height: 0; height: 100vh; overflow: hidden; }

/* ── Resume Builder Layout ───────────────────────────────── */
.admin-content.rb-root {
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* dvh accounts for mobile browser chrome resizing */
    height: calc(100vh - var(--header-height, 64px));
    height: calc(100dvh - var(--header-height, 64px));
}

/* Top bar */
.rb-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 56px;
}
.rb-versions {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    flex: 1;
    min-width: 0;
}
.rb-versions::-webkit-scrollbar { display: none; }
.rb-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Version tabs */
.rb-version-tab {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border-glass);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    font-family: var(--font);
}
.rb-version-tab:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.rb-version-tab.active {
    background: var(--peach-soft);
    border-color: rgba(255,110,59,0.3);
    color: var(--peach);
}
.rb-tab-delete {
    font-size: 15px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s;
    margin-left: 2px;
}
.rb-tab-delete:hover { opacity: 1; }

/* Buttons */
.rb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font);
    border: 1px solid var(--border-glass);
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.rb-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.rb-btn-primary {
    background: var(--peach);
    border-color: var(--peach);
    color: #fff;
    font-weight: 600;
}
.rb-btn-primary:hover { background: #e85a28; border-color: #e85a28; }
.rb-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ATS badge */
.rb-ats-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    font-size: 12px;
    cursor: default;
    position: relative;
    user-select: none;
}
.rb-ats-badge:hover { border-color: rgba(255,110,59,0.5); }
.rb-ats-label { color: rgba(240,240,242,0.55); }
.rb-ats-score { font-size: 14px; font-weight: 700; color: var(--peach); }

/* Resume score tooltip - shown on hover */
.rb-score-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 272px;
    background: #1c1c22;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,110,59,0.08);
    padding: 16px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.rb-ats-badge:hover .rb-score-popover {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.rb-score-popover-title {
    font-size: 10px;
    font-weight: 700;
    color: rgba(240,240,242,0.45);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 12px;
}
.rb-score-row {
    display: grid;
    grid-template-columns: 1fr 32px;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    margin-bottom: 1px;
}
.rb-score-row-label { color: rgba(240,240,242,0.85); }
.rb-score-row-bar-wrap {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 7px;
}
.rb-score-row-bar { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
.rb-score-row-pts { color: rgba(240,240,242,0.6); text-align: right; font-size: 10px; font-variant-numeric: tabular-nums; }
.rb-score-popover-divider { border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 10px 0; }
.rb-score-total-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; }
.rb-score-total-label { color: rgba(240,240,242,0.55); font-size: 11px; }
.rb-score-total-val { font-weight: 700; font-size: 18px; }
.rb-score-tip {
    font-size: 10px;
    color: rgba(240,240,242,0.5);
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.07);
    line-height: 1.5;
}
.rb-score-missing {
    font-size: 10px;
    color: rgba(255,100,100,0.9);
    margin-top: 1px;
    margin-bottom: 4px;
    padding-left: 2px;
}

/* JD Checker button */
.rb-jd-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font);
    border: 1px solid rgba(72,199,116,0.35);
    background: rgba(72,199,116,0.07);
    color: #48c774;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.rb-jd-btn:hover { background: rgba(72,199,116,0.15); border-color: rgba(72,199,116,0.55); }

/* JD Checker modal - wide two-column layout */
.rb-jd-modal {
    width: min(1100px, 96vw) !important;
    max-width: none !important;
    height: min(82vh, 760px);
    display: grid !important;
    grid-template-columns: 380px 1fr;
    grid-template-rows: 1fr;
    gap: 0;
    padding: 0 !important;
    overflow: hidden;
}

/* Left panel: header + input */
.rb-jd-left {
    grid-column: 1;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    padding: 28px 24px;
    border-right: 1px solid var(--border-glass);
    background: var(--bg-surface);
    overflow: hidden;
}
.rb-jd-left h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--text-primary); }
.rb-jd-subtitle { font-size: 12px; color: var(--text-muted); margin: 0 0 16px; line-height: 1.5; }

.rb-jd-textarea {
    flex: 1;
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 12px 14px;
    font-size: 12.5px;
    font-family: var(--font);
    resize: none;
    outline: none;
    box-sizing: border-box;
    line-height: 1.6;
    transition: border-color var(--transition);
    min-height: 0;
}
.rb-jd-textarea:focus { border-color: rgba(72,199,116,0.4); }
.rb-jd-textarea::placeholder { color: var(--text-muted); }

.rb-jd-left-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    flex-shrink: 0;
}
.rb-jd-left-actions .rb-btn { flex: 1; justify-content: center; }
.rb-jd-left-actions .rb-btn-primary { flex: 2; justify-content: center; }

/* Hint below actions */
.rb-jd-hint {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
}

/* Right panel: results */
.rb-jd-right {
    grid-column: 2;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(0,0,0,0.12);
}

.rb-jd-right-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.rb-jd-right-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* Results area */
.rb-jd-results {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 16px 20px 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.rb-jd-results::-webkit-scrollbar { width: 3px; }
.rb-jd-results::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Empty state */
.rb-jd-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 13px;
    opacity: 0.5;
    user-select: none;
    padding: 40px;
    text-align: center;
}
.rb-jd-empty-icon { font-size: 36px; }

/* Per-version result card */
.rb-jd-result-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    transition: border-color 0.3s;
    flex-shrink: 0;
}
.rb-jd-result-card.checking { border-color: rgba(255,183,71,0.3); }
.rb-jd-result-card.done-high { border-color: rgba(72,199,116,0.35); }
.rb-jd-result-card.done-mid  { border-color: rgba(255,183,71,0.35); }
.rb-jd-result-card.done-low  { border-color: rgba(255,82,82,0.35); }

.rb-jd-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.rb-jd-ver-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.rb-jd-score-wrap { display: flex; align-items: baseline; gap: 4px; }
.rb-jd-big-score { font-size: 26px; font-weight: 700; line-height: 1; }
.rb-jd-score-max { font-size: 11px; color: var(--text-muted); }

/* Status line */
.rb-jd-status { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; min-height: 16px; }

/* Category bars - two-column grid inside each card */
.rb-jd-cats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 20px;
}
.rb-jd-cat {
    display: grid;
    grid-template-columns: 120px 1fr 36px;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}
.rb-jd-cat-label { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-jd-cat-bar { height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden; }
.rb-jd-cat-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; width: 0%; }
.rb-jd-cat-pct { font-size: 10px; color: var(--text-secondary); text-align: right; }

/* Matched / missing keywords */
.rb-jd-kw-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.rb-jd-kw {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
    border: 1px solid;
}
.rb-jd-kw.hit  { background: rgba(72,199,116,0.1); border-color: rgba(72,199,116,0.3); color: #48c774; }
.rb-jd-kw.miss { background: rgba(255,82,82,0.08); border-color: rgba(255,82,82,0.25); color: #ff5252; }

/* Tips panel */
.rb-jd-tips { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.rb-jd-tips-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.rb-jd-tip {
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(255,179,71,0.07);
    border-left: 2px solid rgba(255,179,71,0.5);
    padding: 4px 8px;
    border-radius: 0 4px 4px 0;
}

/* Checking spinner */
@keyframes rb-spin { to { transform: rotate(360deg); } }
.rb-jd-spinner {
    display: inline-block;
    width: 12px; height: 12px;
    border: 2px solid rgba(255,183,71,0.3);
    border-top-color: #ffb347;
    border-radius: 50%;
    animation: rb-spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

/* Summary banner inside results */
.rb-jd-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.rb-jd-summary strong { color: var(--text-primary); }

/* Responsive: collapse to single column below 860px */
@media (max-width: 860px) {
    .rb-jd-modal {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto 1fr !important;
        width: min(560px, 96vw) !important;
        height: min(92vh, 720px) !important;
    }
    .rb-jd-left {
        grid-column: 1;
        grid-row: 1;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        padding: 20px 18px;
        overflow: visible;
        flex: none;
    }
    .rb-jd-textarea { min-height: 110px; flex: none; }
    .rb-jd-right {
        grid-column: 1;
        grid-row: 2;
    }
    .rb-jd-cats { grid-template-columns: 1fr; }
}

/* Workspace */
.rb-workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Builder panel */
.rb-builder {
    width: 380px;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,110,59,0.3) transparent;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}
.rb-builder::-webkit-scrollbar { width: 4px; }
.rb-builder::-webkit-scrollbar-thumb { background: rgba(255,110,59,0.3); border-radius: 2px; }

/* Page meter */
.rb-page-meter {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-glass);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.rb-meter-bar {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    overflow: hidden;
    min-width: 80px;
}
.rb-meter-fill {
    height: 100%;
    background: var(--peach);
    transition: width 0.4s ease, background 0.3s ease;
    border-radius: 2px;
    width: 0%;
}
.rb-meter-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.rb-meter-warning {
    font-size: 11px;
    color: #ff5252;
    width: 100%;
    display: none;
}

/* Section panels */
.rb-section-panel {
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-surface);
    transition: opacity 0.2s;
}
.rb-section-panel.rb-hidden-section { opacity: 0.45; }
.rb-section-panel.rb-drag-over { border-top: 2px solid var(--peach); }

.rb-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
}
.rb-section-header:hover { background: rgba(255,255,255,0.02); }

.rb-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
}
.rb-drag-handle:active { cursor: grabbing; }

.rb-section-icon { font-size: 14px; }
.rb-section-title { font-size: 13px; font-weight: 500; color: var(--text-primary); flex: 1; }

.rb-toggle-vis {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    padding: 2px 4px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}
.rb-toggle-vis:hover { color: var(--text-primary); }
.rb-toggle-vis--hidden { color: #e07b54; }
.rb-toggle-vis--hidden:hover { color: #c0623c; }

.rb-chevron {
    font-size: 16px;
    color: var(--text-muted);
    transition: transform var(--transition);
    display: inline-block;
}
.rb-section-panel.expanded .rb-chevron { transform: rotate(90deg); }

.rb-section-body {
    display: none;
    padding: 4px 16px 16px;
}
.rb-section-panel.expanded .rb-section-body { display: block; }

/* Form elements */
.rb-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.rb-form-grid .rb-full { grid-column: 1 / -1; }
.rb-form-group { display: flex; flex-direction: column; gap: 4px; }
.rb-label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.rb-input, .rb-textarea, .rb-select {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 7px 10px;
    font-size: 12.5px;
    font-family: var(--font);
    transition: border-color var(--transition);
    outline: none;
    box-sizing: border-box;
}
.rb-textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
.rb-input:focus, .rb-textarea:focus, .rb-select:focus { border-color: rgba(255,110,59,0.45); }
.rb-input::placeholder, .rb-textarea::placeholder { color: var(--text-muted); }
.rb-select option { background: #1a1a1f; color: var(--text-primary); }

/* Checkbox row */
.rb-check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-top: 2px;
}
.rb-check-row input[type="checkbox"] { accent-color: var(--peach); width: 14px; height: 14px; cursor: pointer; }

/* Entry cards */
.rb-entry-card {
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 10px;
}
.rb-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.rb-entry-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.rb-entry-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.2s;
}
.rb-entry-delete:hover { color: #ff5252; }

/* Bullet list */
.rb-bullet-row {
    display: flex;
    gap: 6px;
    margin-bottom: 5px;
    align-items: center;
}
.rb-bullet-del {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    padding: 0;
    transition: color 0.2s;
}
.rb-bullet-del:hover { color: #ff5252; }
.rb-add-bullet {
    background: none;
    border: 1px dashed rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 11px;
    padding: 5px 10px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: var(--font);
    transition: all 0.2s;
    margin-top: 4px;
}
.rb-add-bullet:hover { border-color: rgba(255,110,59,0.3); color: var(--peach); }

/* Add entry button */
.rb-add-entry {
    background: none;
    border: 1px dashed rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    padding: 8px 12px;
    cursor: pointer;
    width: 100%;
    text-align: center;
    font-family: var(--font);
    transition: all 0.2s;
    margin-top: 4px;
}
.rb-add-entry:hover { border-color: rgba(255,110,59,0.3); color: var(--peach); background: var(--peach-soft); }

/* Tag inputs */
.rb-tag-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 36px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    cursor: text;
    transition: border-color var(--transition);
    align-items: center;
}
.rb-tag-wrap:focus-within { border-color: rgba(255,110,59,0.45); }
.rb-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--peach-soft);
    border: 1px solid rgba(255,110,59,0.2);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 11px;
    color: var(--peach);
    white-space: nowrap;
}
.rb-tag-x {
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    opacity: 0.7;
}
.rb-tag-x:hover { opacity: 1; }
.rb-tag-input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font);
    flex: 1;
    min-width: 100px;
}
.rb-tag-input::placeholder { color: var(--text-muted); }

/* Section divider within forms */
.rb-skill-group { margin-bottom: 12px; }
.rb-skill-group:last-child { margin-bottom: 0; }

/* Preview panel */
.rb-preview-wrap {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: #16161a;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}
.rb-preview-wrap::-webkit-scrollbar { width: 4px; }
.rb-preview-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Scaler: its box matches the VISUAL dimensions of the scaled A4 sheet.
   overflow:clip clips layout overflow from the unscaled .rb-preview-a4 without creating
   a scroll container - so touchpad wheel events bubble up to .rb-preview-wrap normally. */
#previewScaler {
    position: relative;
    overflow: clip;
    flex-shrink: 0;
}

.rb-preview-a4 {
    width: 794px;
    min-height: 1123px;
    background: #ffffff;
    color: #1a1a1a;
    position: relative;
    box-shadow: 0 8px 64px rgba(0,0,0,0.6), 0 2px 16px rgba(0,0,0,0.4);
    font-family: 'Times New Roman', Times, serif;
    transform-origin: top left;
}
.rb-preview-a4::after {
    content: 'Page limit';
    position: absolute;
    left: 0;
    right: 0;
    top: 1123px;
    height: 2px;
    background: rgba(255, 60, 60, 0.7);
    pointer-events: none;
    font-size: 9px;
    color: rgba(255,60,60,0.7);
    text-align: right;
    padding-right: 6px;
    line-height: 1.4;
}

/* Modals */
.rb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}
.rb-modal-overlay.open { display: flex; }
.rb-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 420px;
    max-width: 90vw;
}
.rb-modal h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 18px;
}
.rb-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: flex-end;
}

/* Template picker */
.rb-template-grid {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.rb-template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
    padding: 8px;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    transition: all var(--transition);
}
.rb-template-card:hover { background: rgba(255,255,255,0.04); }
.rb-template-card.active { border-color: var(--peach); }
.rb-template-card.coming-soon { opacity: 0.35; pointer-events: none; }
.rb-template-thumb {
    width: 100px;
    height: 135px;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    padding: 6px 5px;
    gap: 3px;
    box-sizing: border-box;
}
.rb-template-thumb-line { background: #1a1a1a; border-radius: 1px; }
.rb-template-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.rb-coming-soon { font-size: 10px; color: var(--text-muted); }

/* Toast */
.rb-toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    background: rgba(20,20,26,0.96);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: 12.5px;
    font-family: var(--font);
    transform: translateY(12px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
    backdrop-filter: blur(8px);
}
.rb-toast.show { transform: translateY(0); opacity: 1; }
.rb-toast.success { border-color: rgba(72,199,116,0.4); color: #48c774; }
.rb-toast.error { border-color: rgba(255,82,82,0.4); color: #ff5252; }

/* ─── Responsive Breakpoints ─────────────────────────────── */

/* Small desktop / large tablet landscape - shrink builder */
@media (max-width: 1200px) {
    .rb-builder { width: 340px; }
}

/* Tablet landscape - overlay preview mode */
@media (max-width: 960px) {
    /* Show preview toggle in topbar */
    .rb-preview-toggle { display: inline-flex !important; }

    /* Workspace stacks; builder fills full width */
    .rb-workspace { position: relative; }
    .rb-builder { width: 100%; border-right: none; }

    /* Preview hidden by default; becomes absolute overlay when toggled */
    .rb-preview-wrap {
        display: none;
        position: absolute;
        inset: 0;
        z-index: 50;
        padding: 0;
    }
    .rb-preview-wrap.rb-preview-open { display: flex; }

    /* Close-preview bar visible inside overlay */
    .rb-preview-close-bar { display: flex !important; align-items: center; align-self: stretch; }

    /* The preview wrap overlay scrolls vertically; scaler sits below close bar */
    .rb-preview-wrap.rb-preview-open {
        flex-direction: column;
        align-items: center;
        overflow-y: scroll; /* use scroll, not auto, to prevent layout shift from scrollbar appearing */
    }
    .rb-preview-wrap.rb-preview-open #previewScaler { margin: 20px 0 28px; }
}

/* Tablet portrait */
@media (max-width: 768px) {
    .rb-topbar { padding: 8px 14px; gap: 8px; min-height: 48px; }
    .rb-topbar-right { gap: 6px; }
    .rb-ats-label { display: none; }
    .rb-ats-badge { padding: 5px 10px; }
    .rb-modal { width: calc(100vw - 32px); padding: 20px; }
    .rb-template-grid { gap: 10px; }
    .rb-template-thumb { width: 80px; height: 108px; }
    .rb-jd-btn span.rb-jd-btn-text { display: none; }
}

/* Mobile */
@media (max-width: 600px) {
    /* Topbar wraps: versions row first, actions row second */
    .rb-topbar { padding: 8px 12px; gap: 6px; }
    .rb-versions { min-width: 100%; order: 1; }
    .rb-topbar-right { width: 100%; order: 2; justify-content: flex-end; gap: 5px; }

    .rb-btn { padding: 5px 10px; font-size: 11px; }
    .rb-ats-badge { padding: 5px 8px; font-size: 11px; }
    .rb-ats-score { font-size: 12px; }

    /* Single-column form layout */
    .rb-form-grid { grid-template-columns: 1fr; gap: 8px; }
    .rb-form-grid .rb-full { grid-column: 1; }

    .rb-section-header { padding: 10px 12px; gap: 8px; }
    .rb-section-body { padding: 4px 12px 12px; }
    .rb-page-meter { padding: 6px 12px; gap: 8px; }
    .rb-entry-card { padding: 10px; }
    .rb-meter-bar { min-width: 60px; }
}

/* Small mobile - hide lower-priority actions to prevent cramping */
@media (max-width: 420px) {
    #btnTemplate { display: none; }
    .rb-ats-badge { display: none; }
    .rb-jd-btn { display: none; }
    .rb-btn { padding: 5px 8px; }
}

/* Prevent grid cells from overflowing their column on any screen width */
.rb-form-grid > * { min-width: 0; }
.rb-entry-card .rb-form-grid > * { min-width: 0; }

/* Safe-area padding for notched phones (iPhone X+) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .rb-topbar { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
    @media (max-width: 600px) {
        .rb-topbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
    }
    .rb-toast { bottom: max(28px, env(safe-area-inset-bottom)); }
}

/* Print - Ctrl+P fallback */
@media print {
    .admin-layout > :not(.admin-content) { display: none !important; }
    .rb-topbar, .rb-builder, .rb-page-meter,
    .rb-preview-close-bar { display: none !important; }
    body, .admin-layout, .admin-content.rb-root {
        display: block !important;
        overflow: visible !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }
    .rb-workspace, .rb-preview-wrap, #previewScaler {
        display: block !important;
        overflow: visible !important;
        height: auto !important;
        width: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }
    #resumePreview {
        transform: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        width: 100% !important;
    }
    @page { size: A4; margin: 0; }
}

/* ══════════════════════════════════════════════════════════ */
/* PUBLIC SHELL                                               */
/*                                                            */
/* The public builder has no sidebar, so it reuses the        */
/* .admin-* shell from student_dashboard.css with the sidebar */
/* gutter removed and its own slim header.                    */
/* ══════════════════════════════════════════════════════════ */

.rb-public .admin-main { margin-left: 0; }

.rb-public-header {
    display: flex;
    align-items: center;
    gap: 14px;
    height: var(--header-height, 64px);
    padding: 0 20px;
    background: rgba(10, 10, 12, 0.85);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
}

.rb-public-header .rb-brand { display: flex; align-items: center; gap: 10px; }
.rb-public-header .rb-brand img { height: 26px; width: auto; display: block; }

.rb-public-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    padding-left: 14px;
    border-left: 1px solid var(--border-glass);
    white-space: nowrap;
}

.rb-public-spacer { flex: 1; }

/* "Stored in this browser" pill — states the actual guarantee, not a slogan. */
.rb-privacy-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: 999px;
    padding: 5px 12px;
    white-space: nowrap;
}
.rb-privacy-pill svg { width: 13px; height: 13px; color: #4ade80; flex-shrink: 0; }
.rb-privacy-pill .rb-pill-short { display: none; }

.rb-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(135deg, var(--peach), #e85a2a);
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 15px;
    white-space: nowrap;
    transition: filter var(--transition);
}
.rb-cta:hover { filter: brightness(1.1); }

.rb-cta-ghost {
    font-size: 12.5px;
    text-decoration: none;
    color: var(--text-secondary);
    white-space: nowrap;
}
.rb-cta-ghost:hover { color: var(--text-primary); }

.rb-local-warning {
    padding: 9px 20px;
    font-size: 12.5px;
    line-height: 1.5;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
    border-bottom: 1px solid rgba(239, 68, 68, 0.25);
    flex-shrink: 0;
}

/* The pill survives to the narrowest layout — it states what the page promises,
   so it is the last thing to go, not the first. Title and ghost link go instead. */
@media (max-width: 820px) {
    .rb-public-title,
    .rb-cta-ghost { display: none; }
    .rb-privacy-pill { padding: 5px 10px; font-size: 11px; }
    .rb-privacy-pill .rb-pill-long  { display: none; }
    .rb-privacy-pill .rb-pill-short { display: inline; }
}
@media (max-width: 400px) {
    .rb-privacy-pill .rb-pill-short { display: none; }  /* icon-only; tooltip carries it */
}

@media print {
    .rb-public-header,
    .rb-local-warning { display: none !important; }
}
