/*
 * BuildCV section editor - phone app presentation layer.
 * Loaded after each section's page-local CSS. Desktop is intentionally untouched.
 */

@media (max-width: 720px) {
    html:has(.bs-page),
    body:has(.bs-page) {
        background: #edf1f7;
    }

    body:has(.bs-page) .site-footer,
    body:has(.cv-builder) .site-footer {
        display: none;
    }

    /* Shared Builder Studio shell */
    .bs-page {
        display: block !important;
        min-height: 100dvh;
        background: #edf1f7 !important;
    }

    .bs-sidebar {
        position: fixed !important;
        inset: 0 auto 0 0;
        width: min(300px, 86vw) !important;
        height: 100dvh !important;
        border-radius: 0 28px 28px 0;
        box-shadow: 24px 0 60px rgba(11, 27, 58, .24);
    }

    .bs-toggle {
        position: fixed !important;
        top: max(14px, env(safe-area-inset-top)) !important;
        right: 16px !important;
        left: auto !important;
        width: 44px !important;
        height: 44px !important;
        border-radius: 14px !important;
        background: #0b1b3a !important;
        box-shadow: 0 8px 20px rgba(11, 27, 58, .22) !important;
    }

    .bs-page.is-open .bs-toggle {
        right: 16px !important;
        left: auto !important;
        background: #2347ff !important;
    }

    .bs-main {
        display: block !important;
        width: 100%;
        padding: max(78px, calc(env(safe-area-inset-top) + 66px)) 14px calc(112px + env(safe-area-inset-bottom)) !important;
    }

    .bs-main::before,
    .cv-builder-main::before {
        content: "BuildCV";
        position: fixed;
        top: max(18px, env(safe-area-inset-top));
        left: 16px;
        z-index: 25;
        color: #0b1b3a;
        font: 800 1.05rem/1 'Sora', Inter, system-ui, sans-serif;
        letter-spacing: -.05em;
    }

    .bs-main-inner {
        width: 100% !important;
        max-width: 680px !important;
        margin: 0 auto;
    }

    .bs-head {
        margin-bottom: 16px !important;
        padding: 20px 18px 19px;
        border: 1px solid #dce3ef;
        border-radius: 24px;
        background: linear-gradient(145deg, #fff 0%, #f9faff 100%);
        box-shadow: 0 8px 24px rgba(11, 27, 58, .06);
    }

    .bs-head .bs-eyebrow {
        margin-bottom: 14px !important;
        padding: 7px 11px;
        font-size: .62rem;
        letter-spacing: .1em;
    }

    .bs-head h1 {
        font-size: clamp(1.9rem, 9vw, 2.45rem) !important;
        line-height: 1.08 !important;
        letter-spacing: -.05em;
    }

    .bs-head .bs-sub {
        max-width: 42ch;
        margin-top: 11px;
        font-size: .9rem;
        line-height: 1.55;
    }

    .bs-error-banner {
        margin: 12px 0 16px;
        border-radius: 16px;
    }

    .bs-form {
        width: 100%;
        padding: 20px 16px;
        border: 1px solid #dce3ef;
        border-radius: 24px;
        background: #fff;
        box-shadow: 0 8px 24px rgba(11, 27, 58, .06);
    }

    .bs-photo-row {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 18px !important;
        margin-bottom: 22px !important;
        text-align: center;
    }

    .bs-photo-block {
        gap: 11px !important;
    }

    .bs-photo {
        width: 116px !important;
        height: 116px !important;
        border-width: 3px;
        box-shadow: 0 10px 24px rgba(35, 71, 255, .14);
    }

    .bs-photo-btn {
        min-height: 44px;
        padding: 0 16px;
        border-radius: 12px !important;
    }

    .bs-name-grid,
    .bs-grid-2 {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
        padding-top: 0 !important;
    }

    .bs-field {
        margin-bottom: 17px !important;
    }

    .bs-field label {
        margin-bottom: 8px !important;
        font-size: .8rem !important;
    }

    .bs-page input[type="text"],
    .bs-page input[type="tel"],
    .bs-page input[type="email"],
    .bs-page input[type="date"],
    .bs-page input[type="number"],
    .bs-page input[type="month"],
    .bs-page input[type="search"],
    .bs-page select,
    .bs-page textarea {
        min-height: 54px;
        font-size: 16px !important;
        border-radius: 14px !important;
    }

    .bs-page textarea {
        min-height: 150px;
        padding: 15px 16px;
        line-height: 1.55;
    }

    .bs-form-section,
    .bs-summary-card,
    .bs-skills-editor {
        margin: 0 0 14px;
        padding: 18px 16px !important;
        border-radius: 20px !important;
        box-shadow: none !important;
    }

    .bs-form-section-head,
    .bs-summary-card-head {
        gap: 10px;
        margin-bottom: 18px !important;
    }

    .bs-form-section-head h2,
    .bs-summary-card-head h2 {
        font-size: 1.05rem;
    }

    .bs-step-badge {
        width: 30px;
        height: 30px;
        flex: 0 0 30px;
    }

    .bs-actions {
        position: sticky;
        bottom: max(10px, env(safe-area-inset-bottom));
        z-index: 12;
        display: grid !important;
        grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
        gap: 9px !important;
        margin: 20px -6px 0 !important;
        padding: 10px !important;
        border: 1px solid #dce3ef;
        border-radius: 18px;
        background: rgba(255, 255, 255, .94);
        box-shadow: 0 10px 28px rgba(11, 27, 58, .14);
        backdrop-filter: blur(14px);
    }

    .bs-actions .bs-btn {
        width: 100%;
        min-width: 0 !important;
        height: 50px !important;
        padding: 0 12px !important;
        border-radius: 13px !important;
        font-size: .84rem;
    }

    /* Saved experience and education entries */
    .bs-exp-list,
    .bs-edu-list {
        margin-bottom: 14px;
        padding: 16px;
        border: 1px solid #dce3ef;
        border-radius: 22px;
        background: #f8faff;
    }

    .bs-exp-list-head,
    .bs-edu-list-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 12px;
    }

    .bs-exp-list-head h2,
    .bs-edu-list-head h2 {
        font-size: 1rem;
    }

    .bs-exp-card,
    .bs-edu-card {
        display: grid !important;
        grid-template-columns: 38px minmax(0, 1fr) !important;
        gap: 11px !important;
        margin-bottom: 10px;
        padding: 15px !important;
        border: 1px solid #e0e6f0 !important;
        border-radius: 17px !important;
        background: #fff !important;
        box-shadow: 0 4px 12px rgba(11, 27, 58, .04) !important;
    }

    .bs-exp-icon,
    .bs-edu-icon {
        width: 38px !important;
        height: 38px !important;
        border-radius: 12px !important;
    }

    .bs-exp-title,
    .bs-edu-title {
        font-size: .95rem !important;
        line-height: 1.25 !important;
    }

    .bs-exp-employer,
    .bs-edu-school {
        margin-top: 3px !important;
        font-size: .8rem !important;
    }

    .bs-exp-meta,
    .bs-edu-meta {
        flex-wrap: wrap;
        gap: 6px 10px !important;
        margin-top: 8px !important;
        font-size: .72rem !important;
    }

    .bs-exp-actions,
    .bs-edu-actions {
        grid-column: 1 / -1;
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px !important;
        padding-top: 10px;
        border-top: 1px solid #edf0f5;
    }

    .bs-exp-btn,
    .bs-edu-btn {
        min-height: 42px !important;
        justify-content: center;
        border-radius: 11px !important;
    }

    /* Summary, skills and helper tools */
    .bs-summary-card-head {
        align-items: flex-start !important;
        flex-direction: column;
    }

    .bs-summary-ai-tools,
    .bs-skills-toolbar {
        align-items: stretch !important;
        flex-direction: column;
        gap: 9px !important;
    }

    .bs-summary-ai-button,
    .bs-enhance-btn {
        width: 100%;
        min-height: 46px;
    }

    .bs-skills-editor {
        display: block !important;
    }

    .bs-skills-side {
        margin: 0 0 14px;
        padding: 14px !important;
        border-radius: 16px !important;
    }

    .bs-skills-content {
        min-width: 0;
    }

    .bs-skill-chip {
        min-height: 38px;
        padding: 8px 11px !important;
        border-radius: 999px !important;
    }

    .bs-summary-option,
    .bs-summary-tip {
        border-radius: 16px !important;
    }

    /* Full-screen dialogs feel native on a phone. */
    .bs-modal-overlay,
    .bs-photo-adjust {
        padding: 12px !important;
    }

    .bs-modal,
    .bs-pa-dialog {
        width: 100% !important;
        max-width: none !important;
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        border-radius: 22px !important;
    }
}

@media (max-width: 420px) {
    .bs-main {
        padding-inline: 10px !important;
    }

    .bs-head,
    .bs-form {
        border-radius: 20px;
    }

    .bs-head {
        padding-inline: 16px;
    }

    .bs-form {
        padding-inline: 13px;
    }

    .bs-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .cv-builder .builder-actions {
        grid-template-columns: 1fr;
    }

    .cv-builder .action-group {
        grid-template-columns: .7fr 1.3fr;
    }
}

/* Onboarding flow: compact app-like stepper and one focused question card. */
@media (max-width: 720px) {
    body:has(.ob) {
        background: #edf1f7;
    }

    body:has(.ob) .site-header,
    body:has(.ob) .site-footer {
        display: none !important;
    }

    .ob {
        display: block !important;
        min-height: 100dvh !important;
        padding: max(14px, env(safe-area-inset-top)) 12px calc(20px + env(safe-area-inset-bottom)) !important;
        background: #edf1f7 !important;
    }

    .ob .wrap {
        display: block !important;
        width: 100% !important;
        max-width: 560px !important;
        margin: 0 auto;
    }

    .ob .side {
        display: block !important;
        padding: 15px 16px 13px !important;
        border-radius: 22px !important;
        box-shadow: 0 8px 22px rgba(11, 27, 58, .14);
    }

    .ob .side h2 {
        font-size: 1.12rem;
    }

    .ob .bar {
        height: 7px;
        margin: 12px 0 14px !important;
    }

    .ob .steps {
        display: flex !important;
        align-items: center;
        gap: 7px;
        margin: 0;
    }

    .ob .steps li {
        display: flex !important;
        align-items: center;
        justify-content: center;
        flex: 1 1 0;
        min-width: 0;
        padding: 0 !important;
    }

    .ob .steps li > div {
        display: none;
    }

    .ob .steps b {
        width: 28px;
        height: 28px;
        border-width: 1px;
        font-size: .78rem;
    }

    .ob .back {
        margin-top: 11px !important;
        padding-top: 0 !important;
        font-size: .78rem;
    }

    .ob .main {
        margin-top: 12px;
        padding: 22px 16px 24px !important;
        border-radius: 24px !important;
        box-shadow: 0 8px 24px rgba(11, 27, 58, .07);
    }

    .ob .count {
        display: inline-flex;
        align-items: center;
        min-height: 28px;
        padding: 5px 10px;
        border-radius: 999px;
        background: #eeedff;
        font-size: .75rem;
    }

    .ob h1 {
        margin-top: 14px !important;
        max-width: none !important;
        font-size: clamp(2rem, 10vw, 2.7rem) !important;
        line-height: 1.04 !important;
    }

    .ob .lede {
        margin-top: 12px;
        font-size: .9rem;
        line-height: 1.55;
    }

    .ob .opts,
    .ob .opts-1,
    .ob .opts-2,
    .ob .opts-3 {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        margin-top: 22px !important;
    }

    .ob .opt,
    .ob .opts-1 .opt,
    .ob .opts-3 .opt {
        width: 100%;
        min-height: 86px;
        padding: 13px 12px !important;
        gap: 12px !important;
        border: 1px solid #dce3ef;
        border-radius: 17px !important;
        background: #f7f9fc;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .ob .opt:active {
        transform: scale(.985);
        border-color: var(--blue);
        background: #eef2ff;
    }

    .ob .ico,
    .ob .opts-1 .ico,
    .ob .opts-3 .ico {
        width: 46px !important;
        height: 46px !important;
        flex-basis: 46px;
        border-radius: 14px;
        font-size: 1.35rem !important;
    }

    .ob .txt strong,
    .ob .opts-1 .txt strong,
    .ob .opts-3 .txt strong {
        font-size: 1rem !important;
        line-height: 1.18;
    }

    .ob .txt span,
    .ob .opts-3 .txt span {
        margin-top: 4px;
        font-size: .78rem !important;
        line-height: 1.35;
    }

    .ob .arr,
    .ob .opts-3 .arr {
        display: grid !important;
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }

    .ob .arr svg { width: 15px; height: 15px; }
}

@media (max-width: 380px) {
    .ob { padding-inline: 8px !important; }
    .ob .main { padding-inline: 13px !important; }
    .ob .opt,
    .ob .opts-1 .opt,
    .ob .opts-3 .opt { min-height: 82px; }
}

/* Tip screens: put the live CV preview first on phones. */
@media (max-width: 720px) {
    body:has(.tips-shell) {
        background: #edf1f7;
    }

    body:has(.tips-shell) .site-header,
    body:has(.tips-shell) .site-footer {
        display: none !important;
    }

    .tips-shell {
        display: flex !important;
        flex-direction: column;
        min-height: 100dvh;
        overflow: visible !important;
        background: #edf1f7 !important;
    }

    .tips-sidebar {
        position: sticky;
        top: 0;
        order: 0;
        z-index: 20;
        width: 100%;
        min-height: 58px;
        flex: 0 0 auto;
        flex-direction: row !important;
        align-items: center !important;
        padding: 9px 12px !important;
        background: #0b1b3a !important;
        border: 0 !important;
        box-shadow: 0 6px 18px rgba(11, 27, 58, .18);
    }

    .tips-brand {
        flex: 0 0 auto;
        flex-direction: row !important;
        align-items: center;
        gap: 4px !important;
        margin: 0 12px 0 0 !important;
    }

    .tips-nav {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        justify-content: flex-start;
        gap: 6px;
        width: auto;
        min-width: 0;
        overflow-x: auto;
        padding: 0 !important;
        scrollbar-width: none;
    }

    .tips-nav::-webkit-scrollbar { display: none; }

    .tips-nav-item {
        flex: 0 0 38px;
        width: 38px !important;
        height: 38px !important;
        border-radius: 11px !important;
    }

    .tips-nav-item.is-active { background: #ffd23f !important; color: #0b1b3a !important; }
    .tips-nav-item.is-active::before { display: none; }
    .tips-nav-item::after { display: none !important; }

    .tips-preview {
        display: flex !important;
        order: 1;
        width: 100%;
        min-height: 0;
        padding: 16px 14px 20px !important;
        background: #2347ff !important;
        border-radius: 0 !important;
    }

    .tips-preview-paper {
        width: min(100%, 430px) !important;
        max-width: 430px !important;
        margin: 0 auto;
        border-radius: 8px !important;
        box-shadow: 0 22px 45px rgba(4, 12, 50, .38);
    }

    .tips-main {
        order: 2;
        width: 100%;
        min-width: 0;
        padding: 20px 14px calc(104px + env(safe-area-inset-bottom)) !important;
        background: #edf1f7;
    }

    .tips-content {
        max-width: 680px;
        margin: 0 auto;
        padding: 20px 16px 22px;
        border: 1px solid #dce3ef;
        border-radius: 22px;
        background: #fff;
        box-shadow: 0 8px 24px rgba(11, 27, 58, .07);
    }

    .tips-eyebrow { margin-bottom: 9px; font-size: .78rem; }
    .tips-heading { margin-bottom: 18px; font-size: 1.85rem !important; line-height: 1.08; }
    .tips-callout { margin-bottom: 20px; }
    .tips-callout-body p { font-size: .85rem; line-height: 1.5; }
    .tips-steps { gap: 10px; margin-bottom: 20px; }
    .tips-step-body p { font-size: .8rem; line-height: 1.45; }
    .tips-actions {
        position: sticky;
        bottom: max(10px, env(safe-area-inset-bottom));
        z-index: 10;
        display: grid !important;
        grid-template-columns: .8fr 1.2fr;
        gap: 8px !important;
        margin: 18px -6px 0 !important;
        padding: 10px;
        border: 1px solid #dce3ef;
        border-radius: 17px;
        background: rgba(255,255,255,.94);
        box-shadow: 0 10px 26px rgba(11,27,58,.13);
        backdrop-filter: blur(12px);
    }

    .tips-btn { width: 100%; min-width: 0 !important; height: 50px !important; padding: 0 10px; font-size: .84rem !important; }
    .tips-meta { margin-top: 14px; font-size: .75rem; }
}

@media (max-width: 420px) {
    .tips-preview { padding-inline: 8px !important; }
    .tips-content { padding-inline: 13px; }
}

/* Additional sections uses the older .cv-builder shell. */
@media (max-width: 700px) {
    html:has(.cv-builder),
    body:has(.cv-builder) {
        background: #edf1f7;
    }

    .cv-builder,
    .cv-builder.is-sidebar-open {
        display: block !important;
        min-height: 100dvh;
        background: #edf1f7 !important;
    }

    .cv-builder-sidebar {
        position: fixed !important;
        inset: 0 auto 0 0;
        width: min(292px, 86vw) !important;
        height: 100dvh !important;
        z-index: 30;
        border-radius: 0 28px 28px 0;
        transform: translateX(-100%);
    }

    .cv-builder.is-sidebar-open .cv-builder-sidebar {
        transform: translateX(0) !important;
    }

    .cv-builder-main,
    .cv-builder-content {
        width: 100% !important;
        padding: max(78px, calc(env(safe-area-inset-top) + 66px)) 14px calc(112px + env(safe-area-inset-bottom)) !important;
    }

    .cv-builder-main > *,
    .cv-builder-content > * {
        max-width: 680px;
        margin-inline: auto;
    }

    .cv-builder-preview {
        display: none !important;
    }

    .cv-builder .sidebar-toggle {
        position: fixed !important;
        top: max(14px, env(safe-area-inset-top)) !important;
        right: 16px !important;
        left: auto !important;
        width: 44px;
        height: 44px;
        border-radius: 14px;
        z-index: 40;
        background: #0b1b3a;
        color: #fff;
        box-shadow: 0 8px 20px rgba(11, 27, 58, .22);
    }

    .cv-builder.is-sidebar-open .sidebar-toggle {
        right: 16px !important;
        left: auto !important;
        background: #2347ff;
    }

    .cv-builder-main .builder-main-inner {
        width: 100% !important;
        max-width: 680px !important;
    }

    .cv-builder .builder-section-top {
        padding: 20px 18px;
        border: 1px solid #dce3ef;
        border-radius: 24px;
        background: #fff;
        box-shadow: 0 8px 24px rgba(11, 27, 58, .06);
    }

    .cv-builder .builder-section-top h1 {
        font-size: clamp(1.85rem, 9vw, 2.4rem);
        line-height: 1.08;
        letter-spacing: -.05em;
    }

    .cv-builder .builder-subline {
        margin-top: 10px;
        font-size: .9rem;
        line-height: 1.55;
    }

    .cv-builder .section-tabs {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        margin: 14px 0;
        padding: 2px 2px 8px;
        scrollbar-width: none;
    }

    .cv-builder .section-tabs::-webkit-scrollbar {
        display: none;
    }

    .cv-builder .section-tab {
        flex: 0 0 auto;
        min-height: 42px;
        padding: 10px 14px;
        border-radius: 999px;
        white-space: nowrap;
    }

    .cv-builder .personal-form {
        margin-top: 0;
    }

    .cv-builder .section-card {
        padding: 18px 16px;
        border-radius: 22px;
        background: #fff;
        box-shadow: 0 8px 24px rgba(11, 27, 58, .06);
    }

    .cv-builder .section-card-head {
        align-items: flex-start;
        gap: 10px;
    }

    .cv-builder .section-card-head h2 {
        font-size: 1.05rem;
    }

    .cv-builder .structured-entry-grid {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    .cv-builder .structured-entry-field-wide {
        grid-column: auto;
    }

    .cv-builder .structured-entry-field input,
    .cv-builder .structured-entry-field select,
    .cv-builder .structured-entry-field textarea,
    .cv-builder .form-field textarea {
        min-height: 54px;
        font-size: 16px;
        border-radius: 14px;
    }

    .cv-builder .structured-entry-field textarea,
    .cv-builder .form-field textarea {
        min-height: 150px;
        line-height: 1.55;
    }

    .cv-builder .structured-entry-add-button {
        width: 100%;
        min-height: 48px;
        border-radius: 13px;
    }

    .cv-builder .builder-actions {
        position: sticky;
        bottom: max(10px, env(safe-area-inset-bottom));
        z-index: 12;
        display: grid !important;
        grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
        gap: 8px;
        margin: 18px -4px 0;
        padding: 10px;
        border: 1px solid #dce3ef;
        border-radius: 18px;
        background: rgba(255,255,255,.94);
        box-shadow: 0 10px 28px rgba(11, 27, 58, .14);
        backdrop-filter: blur(14px);
    }

    .cv-builder .action-group {
        display: grid;
        grid-template-columns: .7fr 1.3fr;
        gap: 8px;
    }

    .cv-builder .btn-back,
    .cv-builder .btn-skip,
    .cv-builder .btn-continue {
        width: 100%;
        min-height: 50px;
        padding: 0 10px;
        border-radius: 13px;
        font-size: .84rem;
    }

    .cv-builder .builder-form,
    .cv-builder .form-section,
    .cv-builder .section-card,
    .cv-builder .additional-section {
        border-radius: 20px;
    }

    .cv-builder input,
    .cv-builder select,
    .cv-builder textarea {
        min-height: 54px;
        font-size: 16px !important;
        border-radius: 14px !important;
    }
}
