/**
 * Saved profiles panel — accents use dusty blue from site palette (#9ec3e2 family), not red.
 */
:root {
    --saved-charts-accent: #6d8fa3;
    --saved-charts-accent-hover: #7fa3b8;
    --saved-charts-accent-muted: rgba(109, 143, 163, 0.16);
    --saved-charts-accent-focus: rgba(109, 143, 163, 0.45);
}

/* Slim launcher pinned flush to the right edge (narrow vertical pill — icon only) */
.saved-charts-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10050;
    margin: 0;
    padding: 14px 0;
    width: 36px;
    min-height: 64px;
    border: none;
    border-radius: 10px 0 0 10px;
    background: #2d2d2d;
    color: #fffef7;
    box-shadow: -2px 2px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, width 0.2s ease;
}

.saved-charts-tab:hover {
    background: var(--saved-charts-accent-hover);
    width: 40px;
}

.saved-charts-tab[aria-expanded="true"] {
    background: var(--saved-charts-accent);
}

.saved-charts-tab-icon {
    line-height: 1;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.saved-charts-tab-icon .saved-charts-icon-svg {
    width: 21px;
    height: 21px;
    display: block;
}

.saved-charts-fab {
    display: none;
    position: fixed;
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px));
    z-index: 10050;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: #2d2d2d;
    color: #fffef7;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}

.saved-charts-fab:hover {
    background: var(--saved-charts-accent-hover);
}

.saved-charts-fab.is-open {
    background: var(--saved-charts-accent);
}

.saved-charts-fab-icon {
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.saved-charts-fab-icon .saved-charts-icon-svg {
    width: 24px;
    height: 24px;
    display: block;
}

@media (max-width: 768px) {
    .saved-charts-tab {
        display: none;
    }

    .saved-charts-fab {
        display: flex;
    }
}

.saved-charts-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10040;
    background: rgba(45, 45, 45, 0.25);
}

.saved-charts-backdrop.is-open {
    display: block;
}

.saved-charts-sheet {
    position: fixed;
    top: 0;
    right: 0;
    width: min(340px, 92vw);
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 10045;
    background: #fffef7;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.28s ease;
    display: flex;
    flex-direction: column;
    font-family: 'Montserrat', system-ui, sans-serif;
}

.saved-charts-sheet.is-open {
    transform: translateX(0);
}

@media (max-width: 768px) {
    .saved-charts-sheet {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: min(92vh, calc(100dvh - env(safe-area-inset-top, 0px)));
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.14);
        transform: translateY(100%);
        transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .saved-charts-sheet.is-open {
        transform: translateY(0);
    }

    .saved-charts-body-scroll {
        padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    }
}

.saved-charts-header {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 12px 16px;
    border-bottom: 1px solid #e8e4dc;
}

.saved-charts-header h2 {
    margin: 0;
    padding: 0;
    min-width: 0;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.25;
    color: #2d2d2d;
}

.saved-charts-close {
    position: static;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: rgba(255, 254, 247, 0.96);
    color: #2d2d2d;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.saved-charts-close:hover {
    background-color: rgba(235, 230, 215, 0.98);
}

.saved-charts-close:focus-visible {
    outline: 2px solid #9ec3e2;
    outline-offset: 2px;
}

.saved-charts-hint {
    margin: 10px 16px 16px;
    font-size: 14px;
    color: #444;
    line-height: 1.55;
}

.saved-charts-body-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 24px;
}

.saved-charts-section {
    flex-shrink: 0;
    padding: 0 0 8px;
}

.saved-charts-section-title {
    margin: 12px 18px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #888;
}

.saved-charts-section--profiles {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.saved-charts-list-wrap {
    flex: 0 0 auto;
    overflow: visible;
    padding: 0 12px 12px;
}

.saved-charts-list-wrap--profiles {
    padding: 0 14px 16px;
    box-sizing: border-box;
}

.saved-charts-empty {
    padding: 16px 8px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

.saved-charts-empty--profiles {
    font-size: 13px;
}

.saved-charts-row {
    display: block;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid #e8e4dc;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.saved-charts-row--couple:hover {
    border-color: var(--saved-charts-accent);
    box-shadow: 0 2px 8px var(--saved-charts-accent-muted);
}

.saved-charts-row--natal:hover {
    border-color: var(--saved-charts-accent);
    box-shadow: 0 2px 8px var(--saved-charts-accent-muted);
}

.saved-charts-row-title {
    font-weight: 600;
    font-size: 14px;
    color: #2d2d2d;
    margin-bottom: 4px;
}

.saved-charts-row-meta {
    font-size: 11px;
    color: #888;
}

.saved-charts-row-remove {
    float: right;
    margin: -4px -4px 0 8px;
    padding: 4px 8px;
    font-size: 11px;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
}

.saved-charts-row-remove:hover {
    color: var(--saved-charts-accent);
    background: var(--saved-charts-accent-muted);
}

.saved-charts-row-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.saved-charts-cross {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.saved-charts-cross-btn {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #e0dcd4;
    background: #faf8f3;
    color: #2d2d2d;
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.saved-charts-cross-btn:hover {
    border-color: var(--saved-charts-accent);
    background: #fff;
    color: var(--saved-charts-accent);
}

.saved-charts-profile-card {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fafaf8;
    border: 1px solid #e8e4dc;
    border-radius: 8px;
    box-sizing: border-box;
}

.saved-charts-profile-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
    align-items: center;
    column-gap: 8px;
    min-width: 0;
}

.saved-charts-profile-name {
    margin: 0;
    min-width: 0;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
    color: #2d2d2d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-charts-profile-details {
    font-size: 13px;
    color: #444;
    margin-top: 8px;
    line-height: 1.45;
    word-break: break-word;
}

.saved-charts-profile-sep {
    color: #aaa;
    font-weight: 400;
    padding: 0 3px;
}

.saved-charts-profile-remove {
    justify-self: end;
    width: 40px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #666;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.saved-charts-profile-remove:hover {
    color: var(--saved-charts-accent);
    background: var(--saved-charts-accent-muted);
}

.saved-charts-profile-remove:focus-visible {
    outline: 2px solid var(--saved-charts-accent-focus);
    outline-offset: 1px;
}

/* Sidebar on desktop: denser cards so more profiles fit without scrolling */
@media (min-width: 769px) {
    .saved-charts-profile-card {
        padding: 6px 10px;
        margin-bottom: 5px;
    }

    .saved-charts-profile-name {
        font-size: 14px;
        line-height: 1.15;
    }

    .saved-charts-profile-details {
        margin-top: 4px;
        font-size: 12px;
        line-height: 1.28;
    }

    .saved-charts-profile-remove {
        width: 34px;
        height: 30px;
        font-size: 22px;
    }
}

/* Profile picker: input + dropdown trigger sit in a row — control is just after the name field */
.saved-profile-input-wrap {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.saved-profile-input-wrap > input[type="text"],
.saved-profile-input-wrap > input[type="number"] {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    box-sizing: border-box;
}

.saved-profile-trigger-wrap {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    align-self: center;
}

.saved-profile-trigger-wrap .saved-profile-trigger,
.saved-profile-trigger-wrap .saved-profile-menu {
    pointer-events: auto;
}

.saved-profile-trigger {
    position: relative;
    width: 26px;
    height: 26px;
    padding: 0;
    margin: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fafaf8;
    color: #2d2d2d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.saved-profile-trigger:hover {
    border-color: var(--saved-charts-accent);
    background: #fff;
}

.saved-profile-trigger:focus {
    outline: 2px solid var(--saved-charts-accent-focus);
    outline-offset: 1px;
}

.saved-profile-trigger-chevron {
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 5px 4px 0 4px;
    border-color: #555 transparent transparent transparent;
}

.saved-profile-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: auto;
    z-index: 60;
    min-width: 220px;
    max-width: min(320px, calc(100vw - 24px));
    max-height: 260px;
    overflow-y: auto;
    padding: 6px 0;
    margin: 0;
    list-style: none;
    background: #fff;
    border: 1px solid #e8e4dc;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    font-family: 'Montserrat', system-ui, sans-serif;
    font-size: 13px;
}

.saved-profile-menu[hidden] {
    display: none !important;
}

.saved-profile-menu-empty {
    padding: 10px 12px;
    color: #888;
    font-size: 12px;
}

.saved-profile-menu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    margin: 0;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: #2d2d2d;
    font: inherit;
}

.saved-profile-menu-item:hover {
    background: var(--saved-charts-accent-muted);
}

.saved-profile-menu-item-name {
    font-weight: 600;
}

.saved-profile-menu-item-meta {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}
