.profile-details {
    display: flex;
    flex: 1 1 100%;
    flex-direction: column;
    gap: 0.375rem;
}

@media (max-width: 640px) {
    .profile-details {
        flex-direction: column;
        gap: 1rem;
    }
}

.profile-username-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.profile-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0px;
}

.profile-user-title {
    /* Auto layout */

    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0px;
}

.form-section.form-section--wide {
    max-width: 640px;
}

.form-section--wide .form {
    max-width: 640px;
}

/* --- SKIN PROFILE SECTION (detail view) --- */

.profile-skin-section {
    padding: 1.5rem 0;
}

/* --- ROUTINE SECTION (profile detail, read-only) --- */

.profile-routine-section {
    padding: 1.5rem 0 0.5rem;
}

.routine-section-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Collapse the label's own bottom margin — the row gap handles spacing */
.routine-section-head .skin-section-label {
    margin: 0;
}

/* Compact the "Edit" link so it sits inline with the label */
.routine-section-head .button {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    line-height: 1.6;
}

/*
 * Read-only card variant.
 * The interactive .product-card keeps top padding tight because the hidden
 * .card-edit and .card-remove buttons sit in the top-right corner and need
 * room to appear on hover. Without those elements we add a touch more top
 * padding so the step badge doesn't feel cramped.
 */
.product-card--readonly {
    padding-top: 0.75rem;
}

@keyframes card-place {
    0%   { opacity: 0; transform: translateY(14px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0)    scale(1);    }
}

@keyframes card-remove {
    0%   { opacity: 1; transform: translateY(0)    scale(1);    }
    100% { opacity: 0; transform: translateY(14px) scale(0.96); }
}

.product-card--new {
    animation: card-place 280ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.product-card--removing {
    animation: card-remove 220ms cubic-bezier(0.4, 0, 1, 1) both;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .product-card--new,
    .product-card--removing {
        animation: none;
    }
}

@media (max-width: 640px) {
    .profile-routine-section {
        padding: 1rem 0 0.25rem;
    }
}

.skin-section-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--lightMint);
    letter-spacing: 0.08em;
    margin: 0 0 1rem 0;
}

/* Unified card wrapping all skin data */
.skin-profile-card {
    background-color: var(--darkestGrape);
    border: 1px solid var(--darkerGrape);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Each row: label on left, value on right */
.skin-card-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1rem;
}

.skin-card-label {
    flex: 0 0 5.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--grape);
    padding-top: 0.25rem;
}

.skin-card-value {
    flex: 1;
}

/* Prevent the global .tags margin-top from adding space inside the card */
.skin-profile-card .tags {
    margin-top: 0;
}

@media (max-width: 640px) {
    .profile-skin-section {
        padding: 1rem 0;
    }

    .skin-profile-card {
        padding: 1rem;
        gap: 0.75rem;
    }

    .skin-card-row {
        flex-direction: column;
        gap: 0.125rem;
    }

    .skin-card-label {
        flex: 0 0 auto;
        padding-top: 0;
    }
}

/* Skin type: icon + name inline */
.skin-type-value {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--lightestGrape);
}

.skin-type-value svg {
    flex-shrink: 0;
    color: var(--lightMint);
}

/* Outline variant for skin goals tags (distinguishes from skin concerns) */
.tag.tag-outline {
    background-color: transparent;
    color: var(--lightMint);
    border: 1px solid var(--lightMint);
}

.tag.tag-outline:hover {
    background-color: var(--lightMint);
    color: var(--darkestGrape);
    border-color: var(--lightMint);
}

/* --- SKIN PROFILE SECTION (update form) --- */

/*
 * Two-column inline field layout for the 640px-wide update/create form.
 * Used to pair: First name + Last name, Birthday + Country.
 * At or below 640px the two cells stack to a single column so the layout
 * stays comfortable on small screens without horizontal scrolling.
 */
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

/* Each cell inside a field-row is a regular field-group — reset its own
   bottom margin because the row grid handles vertical rhythm instead. */
.field-row > .field-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

@media (max-width: 640px) {
    .field-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    /* Restore individual bottom margin when stacked */
    .field-row > .field-group {
        margin-bottom: 1.5rem;
    }
}

.skin-section-heading {
    margin-top: 1.5rem;
    margin-bottom: 0.25rem;
}

/* Checkbox group: flex-wrap layout for multi-select fields */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.5rem;
}

.checkbox-option {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--lightestGrape);
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    border: 1px solid var(--darkerGrape);
    transition: border-color 0.2s ease, color 0.2s ease;
    /* Reset label defaults from main.css */
    margin: 0;
}

.checkbox-option:hover {
    border-color: var(--lightMint);
    color: var(--lightMint);
}

/* Constrain the checkbox input within the option row */
.checkbox-option input[type="checkbox"] {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--lightMint);
}


/* --- UPDATE PROFILE FORM layout --- */

.update-profile-form .field-group {
    margin-bottom: 1.5rem;
}

.update-profile-form .form {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
}

.update-profile-form .skin-section-heading {
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--darkerGrape);
}

.update-profile-form .button[type="submit"] {
    margin-top: 2rem;
}


/* ==========================================================================
   MY ROUTINE PAGE — Shelf v3
   ========================================================================== */

.routine-page {
    width: 100%;
}

/* ---- Slot section ---- */

.slot-section {
    margin-bottom: 2.5rem;
}

.slot-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.slot-icon {
    color: var(--lightMint);
    display: flex;
    align-items: center;
}

.slot-label {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--lightMint);
}

.slot-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--lightGrape);
    background: var(--darkestGrape);
    border: 1px solid var(--darkerGrape);
    border-radius: 999px;
    padding: 0.125rem 0.5rem;
}

/* Chevron nav — desktop hover only */
.slot-nav {
    margin-left: auto;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity .2s;
}

.slot-section:hover .slot-nav {
    opacity: 1;
}

.chevron-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 1px solid var(--darkerGrape);
    border-radius: 5px;
    background: var(--darkestGrape);
    color: var(--grape);
    cursor: pointer;
    transition: color .15s, border-color .15s;
}

.chevron-btn:hover {
    color: var(--lightMint);
    border-color: var(--lightGrape);
}

.chevron-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Hide chevrons on touch screens */
@media (hover: none) {
    .slot-nav { display: none; }
}

/* ---- Shelf track ---- */

.shelf-track {
    position: relative;
}

/* Fade masks toggled by JS */
.shelf-track::before,
.shelf-track::after {
    content: '';
    pointer-events: none;
    position: absolute;
    top: 0;
    bottom: 5px;
    width: 3.5rem;
    z-index: 2;
    opacity: 0;
    transition: opacity .25s;
}

.shelf-track::before {
    left: 0;
    background: linear-gradient(to right, var(--darkestestestGrape), transparent);
}

.shelf-track::after {
    right: 0;
    background: linear-gradient(to left, var(--darkestestestGrape), transparent);
}

.shelf-track.fade-left::before  { opacity: 1; }
.shelf-track.fade-right::after  { opacity: 1; }

/* Horizontal scroll container */
.shelf-scroll {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0.25rem 1.375rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-behavior: smooth;
    min-height: calc(148px + 0.75rem + 1.375rem);
}

.shelf-scroll::-webkit-scrollbar { display: none; }

/* The plank the cards sit on */
.shelf-plank {
    height: 5px;
    background: linear-gradient(to bottom, var(--darkerGrape), var(--darkestGrape));
    border-radius: 0 0 4px 4px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

/* ---- Drawer slot variant ---- */

.slot-section--drawer .slot-icon,
.slot-section--drawer .slot-label {
    color: var(--lightGrape);
}

.slot-section--drawer .slot-count {
    color: var(--darkGrape);
    background: transparent;
    border-color: var(--darkestGrape);
}

.slot-section--drawer .product-card {
    background: var(--darkestestestGrape);
    border-color: var(--darkestGrape);
    opacity: 0.85;
}

.slot-section--drawer .product-card:hover {
    border-color: var(--grape);
    opacity: 1;
    transform: none;
    box-shadow: none;
}

.slot-section--drawer .card-icon {
    color: var(--grape);
    background: var(--darkestestGrape);
}

.slot-section--drawer .card-name {
    color: var(--lightGrape);
}

.slot-section--drawer .card-brand {
    color: var(--grape);
}

.slot-hint-primary {
    font-size: 0.75rem;
    color: var(--grape);
    margin: -4px 0 4px 0;
}

.slot-hint-secondary {
    display: flex;
    align-items: flex-start;
    gap: 0.3rem;
    font-size: 0.6875rem;
    color: var(--darkGrape);
    opacity: 0.7;
    margin: 0 0 10px 0;
    line-height: 1.5;
}

.slot-hint-secondary svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.shelf-plank--drawer {
    background: linear-gradient(to bottom, var(--darkestGrape), transparent);
    box-shadow: none;
    opacity: 0.5;
}

.add-card--drawer {
    border-color: var(--darkestGrape);
    color: var(--darkGrape);
}

.add-card--drawer:hover {
    border-color: var(--darkerGrape);
    color: var(--lightGrape);
    background: transparent;
}

/* ---- Product card ---- */

.product-card {
    position: relative;
    flex: 0 0 130px;
    min-height: 148px;
    background: var(--darkestGrape);
    border: 1px solid var(--darkerGrape);
    border-radius: 10px;
    padding: 0.625rem 0.625rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    scroll-snap-align: start;
    transition: border-color .2s, transform .2s, box-shadow .2s;
}

.product-card:hover {
    border-color: var(--grape);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.35);
}

.product-card:hover .card-remove {
    opacity: 1;
}

.card-step {
    position: absolute;
    top: 0.375rem;
    left: 0.375rem;
    width: 1.375rem;
    height: 1.375rem;
    background: var(--darkestestGrape);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--grape);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-edit {
    position: absolute;
    top: 0.25rem;
    right: 1.625rem; /* sits left of the remove button */
    width: 1.25rem;
    height: 1.25rem;
    color: var(--darkerGrape);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    opacity: 0;
    transition: opacity .15s, color .15s;
    text-decoration: none;
}

.card-edit:hover { color: var(--lightMint); }

.product-card:hover .card-edit { opacity: 1; }

.card-remove-form {
    margin: 0;
    padding: 0;
}

.card-remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 1.25rem;
    height: 1.25rem;
    background: transparent;
    border: none;
    color: var(--darkerGrape);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    opacity: 0;
    transition: opacity .15s, color .15s;
    padding: 0;
}

.card-remove:hover { color: var(--lightRed); }

/* ---- Add card ---- */

.add-card {
    flex: 0 0 130px;
    min-height: 148px;
    border: 1.5px dashed var(--darkerGrape);
    border-radius: 10px;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    color: var(--grape);
    cursor: pointer;
    scroll-snap-align: start;
    transition: border-color .2s, color .2s, background .2s;
    padding: 0;
}

.add-card:hover {
    border-color: var(--mint);
    color: var(--mint);
    background: rgba(161, 239, 125, 0.04);
}

.add-card span {
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

/* ---- Step edit page ---- */

.step-edit-product {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem 1.25rem;
    background: var(--darkestGrape);
    border: 1px solid var(--darkerGrape);
    border-radius: 10px;
    margin-bottom: 1.5rem;
}

.step-edit-product-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--lightestGrape);
}

.step-edit-product-brand {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--grape);
}

.card-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--darkestestGrape);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--darkerGrape);
    margin-top: 1rem;
    margin-bottom: 0.25rem;
    flex-shrink: 0;
}

.card-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--lightestGrape);
    text-align: center;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    width: 100%;
}

.card-name--linked {
    text-decoration: none;
    border-bottom: 1px solid var(--darkerGrape);
    transition: color .15s, border-color .15s;
}

.card-name--linked:hover,
.card-name--linked:focus-visible {
    color: var(--lightMint);
    border-bottom-color: var(--lightMint);
    outline: none;
}

.card-name--linked:focus-visible {
    outline: 2px solid var(--lightMint);
    outline-offset: 2px;
    border-radius: 2px;
}

.card-brand {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--lightGrape);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Mint dot signals a step has notes; tooltip shows the text on hover */
.card-notes-dot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--mint);
    margin-top: auto;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--darkestGrape);
    line-height: 1;
    user-select: none;
}

.card-notes-dot::before {
    content: "✎";
}

.card-notes-dot::after {
    content: attr(data-note);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    padding: 0.375rem 0.625rem;
    background: var(--darkestestGrape);
    border: 1px solid var(--darkerGrape);
    border-radius: 6px;
    color: var(--lightGrape);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: normal;
    text-align: left;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
    z-index: 10;
}

.card-notes-dot:hover::after,
.card-notes-dot:focus-visible::after {
    opacity: 1;
}

/* ---- Empty shelf state ---- */

.empty-shelf {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.25rem 1.25rem;
    color: var(--grape);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
}

/* ---- Write section — compact disclosures ---- */

.write-section {
    border-top: 1px solid var(--darkestGrape);
    padding-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.action-disclosure-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    border-radius: 8px;
    border: none;
    background: transparent;
    width: 100%;
    transition: background .15s;
    user-select: none;
    text-align: left;
}

.action-disclosure-btn:hover {
    background: rgba(255,255,255,0.03);
}

.action-disclosure-btn:hover .summary-icon {
    border-color: var(--lightGrape);
}

.action-disclosure-btn:hover .summary-label {
    color: var(--lightestGrape);
}

.summary-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 6px;
    background: var(--darkestGrape);
    border: 1px solid var(--darkerGrape);
    color: var(--lightMint);
    flex-shrink: 0;
    transition: border-color .15s;
}

.summary-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--lightGrape);
    flex: 1;
    transition: color .15s;
}

/* Field groups inside panels */
.step-edit-panel .field-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.875rem;
}

.step-edit-panel .field-group:last-of-type {
    margin-bottom: 0.875rem;
}

/* ---- Responsive ---- */

@media (max-width: 480px) {
    .slot-section { margin-bottom: 1.5rem; }
    .write-section { padding-top: 1rem; }
}

/* ==========================================================================
   STEP EDIT PANEL
   ========================================================================== */

.step-edit-panel {
    border: none;
    padding: 0;
    background: transparent;
    max-width: none;
    max-height: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    margin: 0;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.28s cubic-bezier(0.32, 0, 0.24, 1),
                opacity 0.28s ease;
}

.step-edit-panel.is-open {
    transform: translateY(0);
    opacity: 1;
}

.step-edit-panel::backdrop {
    background: rgba(30, 20, 35, 0.72);
    backdrop-filter: blur(2px);
}

.panel-inner {
    background: var(--darkestGrape);
    border: 1px solid var(--darkerGrape);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    padding: 1.25rem 1.25rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
}

.panel-inner::before {
    content: '';
    display: block;
    width: 2.5rem;
    height: 3px;
    background: var(--darkerGrape);
    border-radius: 2px;
    margin: -0.5rem auto 0;
    flex-shrink: 0;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--lightMint);
}

.panel-success {
    font-size: 0.8125rem;
    color: var(--mint);
    font-weight: 500;
}

/* ---- Product search (add-to-drawer panel) ---- */

.product-search-row {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: stretch;
}

.product-search-row input[type="search"] {
    flex: 1;
    min-width: 0;
}

.product-search-row .button {
    flex-shrink: 0;
}

.product-manual {
    margin-top: 1.25rem;
    border-top: 1px solid var(--darkerGrape);
    padding-top: 0.75rem;
}

.product-manual > summary {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--grape);
    cursor: pointer;
    list-style: none;
    display: inline-block;
    padding: 0;
    margin-bottom: 0;
    transition: color 0.15s ease;
}

.product-manual > summary::-webkit-details-marker { display: none; }
.product-manual > summary::marker               { content: none; }

.product-manual > summary:hover { color: var(--lightestGrape); }

.product-manual > summary:focus-visible {
    outline: 2px solid var(--lightMint);
    outline-offset: 2px;
    border-radius: 2px;
}

.product-manual[open] > summary { margin-bottom: 1rem; }

.panel-product-block {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

#panel-product-brand:empty {
    display: none;
}

@media (min-width: 768px) {
    .step-edit-panel {
        bottom: auto;
        top: 50%;
        left: 50%;
        right: auto;
        width: 400px;
        transform: translate(-50%, -48%) scale(0.97);
        transition: transform 0.22s cubic-bezier(0.32, 0, 0.24, 1),
                    opacity 0.22s ease;
    }

    .step-edit-panel.is-open {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    .step-edit-panel {
        border-radius: 16px;
    }

    .panel-inner {
        border-radius: 16px;
        border-bottom: 1px solid var(--darkerGrape);
        max-height: 80dvh;
        box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
        padding: 1.5rem 1.5rem 2rem;
    }

    .panel-inner::before {
        display: none;
    }
}

@media (min-width: 1200px) {
    .step-edit-panel {
        width: 520px;
    }
}