/* css/3-components.css */

/* ============================================================
   DESIGN TOKEN MIGRATION - IN PROGRESS
   
   STATUS: Partial migration complete
   - Utility classes exist (.u-hidden)
   - Many hard-coded hex colors remain (200+ instances)
   - TODO: Replace all hex/rgba with tokens from css/1-base.css
   - TODO: Add additional utility classes as needed
   
   Use tokens from css/1-base.css instead of hard-coded values.
   Allowed exceptions: literal 1px borders, calc() with tokens
   ============================================================ */

/* ========================================================================== */
/* CORE COMPONENTS - Shared UI Element Classes */
/* ========================================================================== */

/* ========================================================================== */
/* UTILITY CLASSES (u-*) - Minimal set for inline style migration */
/* ========================================================================== */

/* State: Hidden (replaces display: none inline styles) */
.is-hidden {
    display: none !important;
}

/* Legacy alias for backwards compatibility */
.u-hidden {
    display: none !important;
}

/* Display utilities */
.u-flex {
    display: flex;
}

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

/* Centered content */
.u-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Interactive cursor */
.u-clickable {
    cursor: pointer;
}

/* Text utilities */
.u-text-muted {
    color: var(--color-text-secondary);
}

.u-text-subtle {
    color: #ccc;
    font-size: 12px;
}

.u-text-label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
}

.u-text-semi-bold {
    font-weight: 500;
}

.u-text-sm {
    font-size: 0.9em;
}

.u-text-xs {
    font-size: 0.85em;
}

.u-text-note {
    color: #888;
    line-height: 1.4;
}

/* Spacing utilities */
.u-mt-12 {
    margin-top: 12px;
}

.u-mt-8 {
    margin-top: 8px;
}

.u-mb-8 {
    margin-bottom: 8px;
}

.u-ml-8 {
    margin-left: 8px;
}

.u-p-12 {
    padding: 12px;
}

.u-p-4-0 {
    padding: 4px 0;
}

.u-pt-8 {
    padding-top: 8px;
}

/* Border utilities */
.u-border-bottom {
    border-bottom: 1px solid #e0e0e0;
}

.u-border-top-double {
    border-top: 2px solid #ddd;
}

/* Background utilities */
.u-bg-light {
    background: #f9f9f9;
    border-radius: 6px;
}

/* Transition guard: prevents accidental clicks during modal transitions */
/* Applied to app background (header, main-content) but NOT to modals */
body.is-transitioning .header,
body.is-transitioning .main-content,
body.is-transitioning .sidebar {
    pointer-events: none !important;
}

/* ========================================================================== */
/* COMPONENT CLASSES (c-*) - Reusable semantic components */
/* ========================================================================== */

/* Auth deep link message (appears in auth modal) */
.c-auth-deeplink-message {
    text-align: center;
    color: var(--color-brand-primary);
    margin: 10px 0 -10px;
    font-size: 0.9em;
}

/* Legal consent banner (fixed bottom notification) */
.c-legal-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-brand-primary);
    color: var(--color-text-inverse);
    padding: 20px;
    box-shadow: 0 -2px 10px var(--color-overlay-dark-20);
    z-index: var(--z-canvas-overlay);
}

/* Auth form components */
.c-auth-radio-label {
    display: flex;
    align-items: flex-start;
    font-weight: 400;
    margin: 0;
    gap: 10px;
}

.c-auth-radio-input {
    margin: 3px 0 0 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.c-auth-checkbox-label {
    display: flex;
    align-items: flex-start;
    font-weight: 400;
    margin: 0;
    cursor: pointer;
    gap: 10px;
}

.c-auth-checkbox-input {
    margin: 3px 0 0 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.c-auth-checkbox-text {
    font-size: 0.9em;
}

.c-auth-error-inline {
    margin: 0;
    color: var(--color-status-error);
    font-size: 0.85em;
}

.c-auth-section-label {
    font-size: 0.95em;
    color: var(--color-text-secondary);
    margin: 0 0 10px 0;
}

.c-link-primary {
    color: var(--color-brand-primary);
    text-decoration: none;
    font-size: 0.9em;
}

.c-link-primary-underline {
    color: var(--color-brand-primary);
    text-decoration: underline;
}

.c-asterisk-required {
    color: var(--color-status-error);
}

/* Signup birthdate (18+ gate): keep month/day/year controls in a single row and
   use the established edc sizing instead of generic form-group 100% widths. */
#signup-birthdate .edc-date-inputs {
    flex-wrap: nowrap;
    align-items: center;
}

#signup-birthdate .edc-select,
#signup-birthdate .edc-input {
    width: auto;
    flex: 0 0 auto;
}

#signup-birthdate .edc-date-month {
    min-width: 110px;
}

.c-legal-agreement-box {
    background: var(--color-bg-secondary);
    border: 2px solid var(--color-border-light);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
}

.c-legal-box-title {
    font-size: 0.95em;
    color: var(--color-text-secondary);
    margin: 0 0 12px 0;
    font-weight: 600;
}

.c-legal-trigger {
    margin-left: 20px;
    margin-right: 8px;
    cursor: pointer;
}

.c-legal-trigger-icon {
    width: 24px;
    height: 24px;
    color: var(--color-text-secondary);
    opacity: 0.7;
}

.c-legal-banner-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.c-legal-banner-textwrap {
    flex: 1;
    min-width: 250px;
}

.c-legal-banner-heading {
    margin: 0 0 8px 0;
    font-size: 1.05em;
    font-weight: 600;
}

.c-legal-banner-desc {
    margin: 0;
    font-size: 0.95em;
    opacity: 0.95;
}

.c-legal-banner-btn-primary {
    padding: 10px 20px;
    background: var(--color-surface-1);
    color: var(--color-brand-primary);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95em;
}

.c-legal-banner-btn-secondary {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: var(--color-text-inverse);
    border: 2px solid var(--color-surface-1);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95em;
}

.c-auth-helper-with-margin {
    margin: 6px 0 0 0;
    font-size: 0.85em;
    color: var(--color-text-tertiary);
}

/* Alert message boxes - Base class */
.c-alert {
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9em;
    margin: 10px 0;
}

/* Alert variants */
.c-alert-error {
    background: var(--color-status-error-bg);
    color: var(--color-status-error);
    border-left: 4px solid var(--color-status-error);
}

.c-alert-success {
    background: var(--color-status-success-bg);
    color: var(--color-status-success);
    border-left: 4px solid var(--color-status-success);
}

.c-alert-warning {
    background: var(--color-alert-warning-bg);
    color: var(--color-warning);
    border-left: 4px solid var(--color-warning);
}

/* Delete account modal components */
.c-delete-warning {
    background: #fff3cd;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #e74c3c;
    color: #333;
    margin: 0 0 var(--panel-space-5, 20px) 0;
}

.c-delete-description {
    color: #666;
    line-height: 1.6;
}

.c-delete-description p {
    margin: 0;
}

.c-delete-description ul {
    margin: var(--panel-space-2, 8px) 0 var(--panel-space-4, 16px);
    padding-left: calc(var(--panel-space-6, 24px) + var(--panel-space-1, 4px));
}

.c-delete-error {
    color: #e74c3c;
    text-align: center;
}

.c-legal-support-link {
    color: var(--color-primary);
}

/* Helper text (form hints, descriptions) */
.c-helper-text {
    color: var(--color-text-tertiary);
    font-size: 0.9em;
    margin-top: 5px;
    display: block;
}

/* Email verification status components */
.c-email-verified {
    color: #22c55e;
}

.c-email-verification-status {
    color: #6b7280;
    margin-bottom: 8px;
}

.c-email-verification-status .unverified {
    color: #f59e0b;
}

.c-email-verification-status .date {
    margin-left: 8px;
    color: #6b7280;
}

.c-email-verification-status .helper {
    margin-left: 8px;
}

.c-email-verification-message {
    margin-top: 8px;
}

/* Meta text (secondary info like dates, file sizes) */
.c-meta-text {
    color: var(--color-text-tertiary);
    font-size: 0.85em;
}

/* Modal/section title reset */
.c-modal-title {
    margin: 0;
}

/* Modal scaffolding components */
.c-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-16);
}

.c-modal-header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-8);
    flex-shrink: 0; /* Prevent actions from disappearing */
}

/* Header action button (edit, etc.) */
.c-modal-header-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-tertiary);
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.c-modal-header-btn:hover {
    background: var(--color-bg-secondary);
    color: var(--color-primary);
}

.yrh-prompt-input,
.yrh-prompt-textarea {
    box-sizing: border-box;
}

@media (min-width: 769px) {
    .yrh-prompt-content--reflection {
        padding-top: 8px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        padding-bottom: 8px !important;
    }

    .yrh-prompt-textarea--reflection {
        padding: 8px 10px 12px 10px !important;
        resize: none !important;
    }

    .yrh-prompt-textarea--reflection:focus,
    .yrh-prompt-input--reflection:focus {
        outline: none !important;
        box-shadow: none !important;
        border-color: #ddd !important;
        -webkit-appearance: none;
        appearance: none;
    }

    .yrh-prompt-actions--reflection {
        gap: var(--panel-space-3, 12px) !important;
        justify-content: flex-end !important;
        align-items: center !important;
        margin-top: 11px !important;
    }

    .yrh-prompt-action-btn--reflection {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: none !important;
        border: none !important;
        cursor: pointer !important;
        padding: 4px 6px !important;
        margin: 0 !important;
        min-width: 44px !important;
        min-height: 31px !important;
        font-size: 15px !important;
        font-weight: 400 !important;
        color: var(--color-text-secondary) !important;
        -webkit-tap-highlight-color: transparent !important;
        border-radius: 8px !important;
        white-space: nowrap !important;
        box-shadow: none !important;
        text-transform: lowercase;
    }

    .yrh-prompt-action-btn--reflection:hover,
    .yrh-prompt-action-btn--reflection:focus-visible {
        background: transparent !important;
        color: var(--color-text-secondary) !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
    }

    .yrh-prompt-action-btn--reflection:active {
        opacity: 0.6;
    }
}

.c-modal-header-btn svg {
    width: 18px;
    height: 18px;
}

/* When close button is inside header actions, use relative positioning */
.c-modal-header-actions .c-modal-close-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    margin-left: 0;
}

.c-modal-close-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    color: var(--color-text-tertiary);
    flex-shrink: 0;
    padding: 0;
    z-index: 10;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    line-height: 1;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.c-modal-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.08);
    color: var(--color-text-secondary);
}

.c-modal-close-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-primary);
}

/* Neutralize icon-hover inside close buttons — button itself handles hover */
.c-modal-close-btn .icon-hover {
    opacity: 0.7;
    background-color: transparent !important;
    border-radius: 0;
    transition: opacity 0.15s ease;
}

.c-modal-close-btn:hover .icon-hover {
    opacity: 1;
    background-color: transparent !important;
}

.c-modal-buttons-spaced {
    gap: 10px;
    margin-top: 20px;
}

.c-modal-buttons-row {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: flex-end;
}


.c-modal-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.c-modal-icon-btn-relative {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    position: relative;
}

.c-modal-empty-state {
    text-align: center;
    padding: 30px;
}

.c-modal-loading-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-tertiary);
}

.c-modal-title-error {
    margin: 0;
    color: var(--color-status-error);
    text-align: center;
}

/* Password reset link styling */
.c-password-reset-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.9em;
    transition: color 0.2s ease;
}

.c-password-reset-link:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* Modal sizing classes */
.c-modal-size-sm {
    max-width: 450px;
}

.c-modal-size-md {
    max-width: 500px;
}

.c-modal-size-lg-scroll {
    width: min(var(--yrh-apple-modal-width, 620px), 95vw);
    max-width: var(--yrh-apple-modal-max-width, 680px);
    height: 85vh;
    height: 85dvh;
    max-height: calc(100dvh - 80px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
}

/* Fixed header for modals with sticky footer */
.c-modal-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-16);
    padding: var(--spacing-20) var(--yrh-apple-list-padding-x, 20px) var(--spacing-16);
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
    justify-content: space-between;
    position: relative;
}

.c-modal-header-saving-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-width: 20px;
    min-height: 20px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: opacity 0.16s ease;
    z-index: 2;
}

.c-modal-header-saving-indicator:not(.is-visible) {
    visibility: hidden;
}

.c-modal-header-saving-indicator.is-visible {
    opacity: 1;
    visibility: visible;
}

.c-modal-header-saving-indicator .edc-spinner {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.c-modal-header h2,
.c-modal-header input {
    flex: 1 1 auto;
    min-width: 0; /* Allow text to truncate if needed */
    margin: 0;
}

/* Clamp user-provided modal header titles to 2 lines.
   This is intentionally opt-in via class, so it does not affect other modals. */
.yrh-user-modal-title-clamp {
    overflow: hidden;
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.2;
    max-height: 3.6em;
}

.yrh-user-modal-title-fixed-2l {
    min-height: 1.2em;
    max-height: 3.6em;
}

/* Scrollable body for modals with sticky footer */
.c-modal-scroll-body {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px var(--yrh-apple-list-padding-x, 20px);
    min-height: 0;
}

/* Sticky footer for modals with sticky footer */
.c-modal-sticky-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-16);
    padding: var(--spacing-16) var(--yrh-apple-list-padding-x, 20px);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-primary);
    flex-shrink: 0;
}

/* Footer metadata text (left-aligned) */
.c-modal-sticky-footer .event-card-last-edited {
    flex: 0 0 auto;
    font-size: 0.85em;
    color: var(--color-text-muted);
}

/* Footer action buttons container (right-aligned) */
.c-modal-sticky-footer .c-modal-footer-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-8);
    margin-left: auto;
}

/* Optional left-side footer container (pairs with .c-modal-footer-actions) */
.c-modal-sticky-footer .c-modal-footer-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-8);
}

/* When no actions container, buttons still align right */
.c-modal-sticky-footer > .btn {
    margin-left: auto;
}

.c-modal-size-wide {
    max-width: 95%;
    width: 1200px;
    max-height: 85vh;
}

.c-modal-scroll {
    max-height: 90vh;
    overflow-y: auto;
}

.c-section-heading {
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #333;
}

.c-modal-centered {
    justify-content: center;
    align-items: center;
}

/* Menu link styling */
.c-menu-link {
    display: block;
    padding: 10px 15px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.15s ease;
}

.c-menu-link:hover {
    background-color: var(--color-surface-4);
}

/* Menu action button styling */
.c-menu-action-btn {
    width: 100%;
    padding: 12px;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    color: #333;
    font-size: 0.95em;
}

.c-menu-action-btn:hover {
    background-color: var(--color-surface-4);
}

/* Sort controls container */
.c-sort-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.c-sort-controls label {
    margin: 0;
    white-space: nowrap;
    font-weight: 300;
}

.c-sort-controls select {
    margin: 0;
    font-weight: 300;
}

/* File label display (upload file names) */
.c-file-label {
    margin-left: 10px;
    color: var(--color-text-secondary);
}

.c-file-upload-form {
    display: block;
}

.c-upload-textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    box-sizing: border-box;
    resize: vertical;
    max-height: 150px;
}

.c-upload-progress {
    margin: 15px 0;
}

.c-upload-progress p {
    margin-top: 5px;
    font-size: 0.9em;
    color: #666;
}

/* Empty state containers */
.c-empty-state,
.members-empty-state,
.timelines-empty-state,
.photos-empty-state,
.files-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
    text-align: center;
}

/* --- Icon Hover Behavior --- */
.icon-hover {
    transition: opacity 0.15s ease, background-color 0.15s ease;
    opacity: 0.7;
    cursor: pointer;
}

.icon-hover:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.08);
    border-radius: 6px;
}

/* --- Base Button --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    gap: 6px;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* --- Button Variants --- */
.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a6fd6 0%, #6e4294 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}

.btn-secondary {
    background-color: #f9fafb;
    border-color: #d0d7de;
    color: #374151;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #f2f3f5;
    border-color: #c5ccd3;
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.btn-secondary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
    box-shadow: var(--shadow-sm);
}

.btn-danger:hover:not(:disabled) {
    background: #e63c32;
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.btn-danger:active:not(:disabled) {
    transform: translateY(0);
}

/* Text-based danger button - subtle destructive action */
.btn-text-danger {
    background: transparent;
    color: var(--color-danger);
    border: none;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.btn-text-danger:hover:not(:disabled) {
    background: rgba(244, 67, 54, 0.1);
    color: #e63c32;
}

.btn-text-danger:active:not(:disabled) {
    background: rgba(244, 67, 54, 0.15);
}

.btn-text-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Text-based muted button - subtle non-destructive action (used for iPhone Archive links) */
.btn-text-muted {
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
    padding: 8px 0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-text-muted:hover:not(:disabled),
.btn-text-muted:focus-visible:not(:disabled) {
    color: var(--color-text-primary);
    text-decoration: underline;
}

.btn-text-muted:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Generic Card --- */
.card {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.card:hover {
    border-color: var(--color-border-medium);
    box-shadow: var(--shadow-md);
}

.card.elevated {
    box-shadow: var(--shadow-lg);
}

/* --- Badge --- */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    white-space: nowrap;
    background: var(--color-bg-secondary);
    color: var(--color-text-secondary);
}

.badge-primary {
    background: var(--color-primary);
    color: var(--color-text-on-brand);
}

.badge-danger {
    background: var(--color-danger);
    color: var(--color-text-on-brand);
}

.badge-success {
    background: var(--color-success);
    color: var(--color-text-on-brand);
}

.badge-warning {
    background: var(--color-warning);
    color: var(--color-text-on-brand);
}

/* ========================================================================== */
/* CORE COMPONENT USAGE GUIDE
 * 
 * These core classes provide the foundation for all UI components:
 * 
 * .u-hidden
 *   - Utility class for hiding elements with !important
 * 
 * .btn (base) + variant classes
 *   - Use .btn as the foundation for all buttons
 *   - Add .btn-primary, .btn-secondary, or .btn-danger for styling
 *   - All sizing and padding comes from .btn; variants only change colors/shadows
 *   - Example: <button class="btn btn-primary">Click me</button>
 * 
 * .card (generic container)
 *   - Use for any card-like container (sections, boxes, etc.)
 *   - Add .elevated modifier for increased shadow
 *   - Includes base padding, border, and hover effects
 * 
 * .badge (small labels) + variant classes
 *   - Use .badge for small inline labels and status indicators
 *   - Add .badge-primary, .badge-danger, .badge-success, or .badge-warning
 *   - Use for tags, status labels, plan indicators, etc.
 * 
 * REFACTORING PATTERN:
 *   1. Extract shared visual properties to the base class
 *   2. Keep layout-specific rules in component-specific classes
 *   3. Example: items can inherit card styling while keeping layout rules
 *   4. Use modifier classes (.btn-primary) instead of creating new button types
 * 
 * ========================================================================== */
/* ========================================================================== */

/* --- Base Icon Circles --- */
.account-icon-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--color-bg-tertiary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23888'%3E%3Cpath d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3E%3C/svg%3E");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid var(--color-border-lighter);
}

/* --- Additional Button Styles --- */
/* .btn-add extends .btn - use with class="btn btn-add" */
.btn-add {
    background: white;
    border: 2px solid var(--color-text-secondary);
    color: var(--color-text-secondary);
    padding: var(--spacing-lg) 24px;
}

.btn-add:hover:not(:disabled) {
    background: var(--color-text-secondary);
    color: white;
    transform: translateY(-1px);
}

/* .btn-small is a specialized button for compact UI (friend list, controls, etc.) */
/* Extends .btn - use with class="btn btn-small" or standalone for legacy support */
.btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: white;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-sm);
    border: none;
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn-small:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

.btn-small.edit {
    background: var(--color-success);
}
.btn-small.edit:hover {
    background: var(--color-success);
}
.btn-small.delete {
    background: var(--color-danger);
}
.btn-small.delete:hover {
    background: var(--color-danger);
}
.btn-small.accept {
    background: var(--color-success);
}
.btn-small.accept:hover {
    background: var(--color-success);
}
.btn-small.decline {
    background: var(--color-disabled);
}
.btn-small.decline:hover {
    background: var(--color-disabled);
}
.btn-small.remove {
    background: var(--color-danger);
}
.btn-small.remove:hover {
    background: var(--color-danger);
}
.btn-small.view {
    background: var(--color-info);
}
.btn-small.view:hover {
    background: var(--color-info);
}

.btn-clear-focus {
    background: transparent;
    border: none;
    color: var(--color-primary);
    padding: 0;
    margin-left: 2px;
    font-size: 12px;
    font-weight: var(--font-weight-normal);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}
.btn-clear-focus:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.clear-selection-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    color: #666;
    border: 1px solid rgba(0, 0, 0, 0.2);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.clear-selection-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border-color: rgba(0, 0, 0, 0.2);
}

#focusModeDisplay {
    display: flex;
    align-items: center;
    gap: 4px;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: transparent;
    padding: 3px 8px;
    border-radius: var(--radius-md);
    box-shadow: none;
}

#focusText {
    font-weight: 500;
    font-size: 12px;
    color: #999;
    white-space: nowrap;
}

#focusText .focus-value {
    color: #666;
    font-weight: 600;
}

/* --- Forms & Inputs --- */
.form-group {
    margin-bottom: var(--spacing-xl);
}

.form-group label:not(.c-auth-radio-label):not(.c-auth-checkbox-label) {
    display: block;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-bold);
}

.form-group input:not([type="radio"]):not([type="checkbox"]),
.form-group select,
.em-edit-form-group input[type="text"],
.em-edit-form-group input[type="date"],
.em-edit-form-group select {
    width: 100%;
    padding: var(--padding-input);
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-md);
    font-size: 0.95em;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: var(--font-family-base);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.em-edit-form-group input:focus,
.em-edit-form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.form-group input:disabled,
.form-group select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--color-disabled-bg);
}

.form-group input.error,
.form-group select.error,
.form-group input[aria-invalid="true"],
.form-group select[aria-invalid="true"] {
    border-color: var(--color-status-error);
}

.form-group input.error:focus,
.form-group select.error:focus,
.form-group input[aria-invalid="true"]:focus,
.form-group select[aria-invalid="true"]:focus {
    box-shadow: var(--shadow-focus-error);
}

/* --- Native Form Controls (Safari-first normalization; keep native behavior) --- */
/* Radios: normalize size + baseline alignment without replacing native UI */
input[type="radio"] {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    accent-color: var(--color-primary);
}

/* Common pattern: radio inside label (ensure consistent spacing to text) */
label > input[type="radio"] {
    margin: 0 var(--spacing-sm) 0 0;
}

/* Selects: keep native dropdown arrow; normalize height and text alignment */
.form-group select,
.em-edit-form-group select {
    -webkit-appearance: menulist;
    appearance: menulist;
    min-height: 42px;
    line-height: 1.2;
}

/* Time picker dropdowns */
.form-group > div[style*="display: flex"] > select {
    border: 2px solid var(--color-border-light) !important;
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    font-size: 1em;
    background-color: white;
    box-sizing: border-box;
}

/* Date/Time picker inputs */
.form-group > div[style*="display: flex"] > input[type="text"] {
    border: 2px solid var(--color-border-light) !important;
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    font-size: 1em;
    background-color: white;
    box-sizing: border-box;
}

.form-group textarea,
.em-edit-form-group textarea {
    width: 100%;
    padding: var(--padding-input);
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-md);
    font-size: 0.95em;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: var(--font-family-base);
    line-height: 1.5;
    resize: vertical;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group textarea:focus,
.em-edit-form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.em-edit-title-input {
    resize: none;
    overflow-y: hidden;
    line-height: 1.4;
    font-weight: 600;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.form-group textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--color-disabled-bg);
    resize: none;
}

.form-group textarea.error,
.form-group textarea[aria-invalid="true"] {
    border-color: var(--color-status-error);
}

.form-group textarea.error:focus,
.form-group textarea[aria-invalid="true"]:focus {
    box-shadow: var(--shadow-focus-error);
}

/* Textarea height override for event manager */
.em-edit-form-group textarea {
    min-height: 80px;
}

/* --- Radio Buttons --- */
.radio-group {
    display: flex;
    gap: 20px;
}
.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
}
.radio-option input[type="radio"] {
    width: auto;
}
.radio-option label {
    margin-bottom: 0;
    font-weight: normal;
    color: var(--color-text-primary);
}

/* Compact inline radio group for Create Timeline modal */
.radio-group-compact {
    display: flex;
    gap: 16px;
    align-items: center;
}

.radio-option-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.radio-option-compact input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary);
    margin: 0;
}

.radio-option-compact label {
    margin: 0;
    font-size: 0.9em;
    font-weight: normal;
    color: var(--color-text-primary);
    cursor: pointer;
    user-select: none;
}

/* --- Tag Input --- */
.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    padding: 8px 12px; 
    border: 2px solid #ddd;
    border-radius: 10px;
    cursor: text; 
}

.tag-input-container:focus-within {
    border-color: var(--color-primary); 
}

.tag-input-container .tag {
    display: inline-flex;
    align-items: center;
    background-color: var(--color-primary);
    color: white;
    padding: 5px 10px;
    border-radius: var(--radius-xs);
    font-size: 0.9em;
    font-weight: 500;
}

.tag-input-container .tag .tag-remove-btn {
    background: none;
    border: none;
    color: white;
    font-weight: bold;
    margin-left: 8px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 1.1em;
}

#timeline-tag-input,
#event-tag-input,
#linked-events-tag-input,
#tmCreateTagInput {
    flex-grow: 1;
    border: none;
    outline: none;
    padding: 5px 0; 
    font-size: 1em;
    min-width: 150px;
    background: transparent;
}

/* --- Color Picker --- */
.color-picker-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 10px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    cursor: pointer;
    border: 3px solid var(--color-bg-tertiary);
    transition: all var(--transition-fast);
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary);
}

/* --- Kebab Menus / Profile Headers --- */
.profile-header,
#accountModal .profile-header,
#timelineModal .profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    justify-content: space-between;
}

#accountModal .profile-header h2,
#timelineModal .profile-header h2 {
    margin-bottom: 0;
    font-size: 1.8em;
    word-wrap: break-word;
    flex-grow: 1;
}

/* Timeline Modal: Inline Name Input (matches Create Event pattern) */
#timelineModal .c-modal-header-with-photo,
#editTimelineModal .c-modal-header-with-photo {
    flex: 1 1 auto;
    min-width: 0;
}

#timelineModal .timeline-title-editor-surface,
#editTimelineModal .timeline-title-editor-surface {
    width: 100%;
}

#timelineModal .timeline-modal-name-input,
#timelineModal .c-modal-header .timeline-modal-name-input,
#editTimelineModal .timeline-modal-name-input,
#editTimelineModal .c-modal-header .timeline-modal-name-input {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    padding: 0;
    font-size: 1.3em;
    font-weight: 600;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--color-text-primary);
    line-height: 1.2;
    box-shadow: none;
}

#timelineModal .timeline-modal-name-input:focus,
#timelineModal .c-modal-header .timeline-modal-name-input:focus,
#editTimelineModal .timeline-modal-name-input:focus,
#editTimelineModal .c-modal-header .timeline-modal-name-input:focus {
    outline: none;
    border: none;
    background: transparent;
}

#timelineModal .timeline-modal-name-input::placeholder,
#timelineModal .c-modal-header .timeline-modal-name-input::placeholder,
#editTimelineModal .timeline-modal-name-input::placeholder,
#editTimelineModal .c-modal-header .timeline-modal-name-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.7;
}

#accountModal .profile-header h2 {
    margin-left: 0;
}

/* MODIFIED: Timeline Kebab IDs */
.profile-options-container,
#timeline-options-container,
.tm-options-container {
    position: relative;
    flex-shrink: 0;
}

#global-user-menu-wrapper.profile-options-container {
    padding: 0;
    margin: 0;
}

.profile-options-btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.profile-options-btn:hover {
    background-color: var(--color-bg-tertiary);
}

.profile-options-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--color-text-secondary);
}

/* MODIFIED: Timeline Kebab IDs */
.profile-options-menu,
#account-options-menu,
#timeline-options-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--color-bg-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: var(--z-modal-datepicker);
    min-width: 180px;
    width: auto;
    overflow: hidden;
    padding: 5px 0;
    margin-top: 8px;
    backdrop-filter: none;
}


/* Add extra room so the tail doesn't overlap menu items */


/* Tail is drawn INSIDE the menu box so it never clips */


/* MODIFIED: Timeline Kebab IDs */
.profile-options-menu.show,
#account-options-menu.show,
#timeline-options-menu.show {
    display: block;
}

/* MODIFIED: Timeline Kebab IDs */
.profile-options-menu button,
#account-options-menu button,
#timeline-options-menu button {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 10px 15px;
    text-align: left;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    white-space: nowrap;
}

/* MODIFIED: Timeline Kebab IDs */
.profile-options-menu button:hover,
#account-options-menu button:hover,
#timeline-options-menu button:hover {
    background-color: var(--color-bg-secondary);
}

/* Delete option buttons - base danger styling */
.profile-delete-option {
    color: var(--color-danger);
}

/* Override: neutral styling for remove friend (non-destructive action) */
#profile-options-menu .profile-delete-option {
    color: #333;
}

/* Account menu legal links (neutral styling) */
#account-options-menu .account-menu-legal {
    color: var(--color-text-secondary);
}

.c-account-success-message {
    color: green;
    text-align: center;
    min-height: 20px;
}

#event-details-options-menu button,
#timeline-options-menu button {
    color: #333;
}

/* --- Notification Badge --- */
.notification-badge {
    position: absolute;
    top: 0;
    right: 2px;
    width: 8px;
    height: 8px;
    background-color: var(--color-status-error, #e74c3c);
    border-radius: 50%;
    border: 2px solid var(--color-bg-primary, white);
    display: none;
    z-index: 10;
    pointer-events: none;
}

.notification-badge.is-visible {
    display: block;
}

/* Inline notification badge for section headers */
#pending-requests-badge {
    position: relative;
    top: auto;
    right: auto;
    display: none;
    margin-left: 8px;
    vertical-align: middle;
}

#pending-requests-badge.is-visible {
    display: inline-block;
}

/* --- Misc Components --- */
.details-divider {
    border: none;
    border-top: 1px solid var(--color-border-light);
    margin-bottom: 20px;
}

/* --- Event Attachments --- */
.attachments-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border-light);
}

.attachments-section h4 {
    font-size: 0.95em;
    color: var(--color-text-primary);
    margin: 0 0 15px 0;
    font-weight: 600;
}

.attachment-upload {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#eventAttachmentInput {
    display: none;
}

.attachment-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    color: var(--color-text-primary);
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.attachment-upload-btn:hover {
    background: var(--color-bg-tertiary, rgba(0,0,0,0.02));
    border-color: var(--color-border-secondary);
}

.attachment-upload-btn:disabled {
    color: var(--color-border-light);
    cursor: not-allowed;
}

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-primary);
}

.attachment-icon {
    font-size: 1.5em;
    flex-shrink: 0;
}

.attachment-thumbnail {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-name {
    display: block;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    word-break: break-word;
    overflow-wrap: break-word;
    font-size: 0.95em;
}

.attachment-name:hover {
    text-decoration: underline;
}

.attachment-meta {
    font-size: 0.85em;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.attachment-delete-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--color-danger);
    font-size: 1.3em;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s, color 0.2s;
}

.attachment-delete-btn:hover {
    transform: scale(1.2);
    color: #b71c1c;
}


/* Usage Summary & Progress Bar */
.usage-summary {
    margin: 12px 0;
}

.usage-bar {
    width: 100%;
    height: 24px;
    background: var(--color-bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 8px;
    border: 1px solid var(--color-border-light);
    position: relative;
}

.usage-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 12px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: white;
    font-size: 0.75em;
    font-weight: 600;
}

.usage-bar.usage-warning .usage-fill {
    background: linear-gradient(90deg, var(--color-warning) 0%, #f57c00 100%);
}

.usage-bar.usage-critical .usage-fill {
    background: linear-gradient(90deg, var(--color-danger) 0%, #d32f2f 100%);
}

.usage-status {
    font-size: 0.8em;
    color: var(--color-text-secondary);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.usage-status.warning {
    color: var(--color-warning);
    font-weight: 500;
}

.usage-status.critical {
    color: var(--color-danger);
    font-weight: 600;
}

/* Limit Warning Banners */
.limit-warning-banner {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid;
}

.limit-warning-banner.info {
    background: #e3f2fd;
    border-left-color: var(--color-info);
    color: var(--color-info);
}

.limit-warning-banner.warning {
    background: #fff3e0;
    border-left-color: var(--color-warning);
    color: var(--color-warning);
}

.limit-warning-banner.critical {
    background: #ffebee;
    border-left-color: var(--color-danger);
    color: var(--color-danger);
}

.limit-warning-banner-icon {
    font-size: 1.2em;
    flex-shrink: 0;
    margin-top: 2px;
}

.limit-warning-banner-content {
    flex: 1;
    line-height: 1.4;
}

.limit-warning-banner-content p {
    margin: 0 0 8px 0;
    font-size: 0.9em;
}

.limit-warning-banner-action {
    margin-top: 8px;
}

.limit-warning-banner-action .btn-small {
    font-size: 0.75em;
    padding: 6px 12px;
}

/* Plan Badges */
.plan-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    letter-spacing: var(--letter-spacing-ui);
}

.plan-badge.free {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-dark);
}

.plan-badge.digital-you {
    background: var(--gradient-primary);
    color: white;
}

.plan-badge.digital-legacy {
    background: var(--gradient-premium);
    color: white;
}

.plan-badge.clickable {
    cursor: pointer;
    transition: all 0.2s;
}

.plan-badge.clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Plan Indicator in Headers */


/* Storage Indicator */
.storage-indicator {
    margin: 16px 0;
}

.storage-label {
    font-size: 0.9em;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
}

.storage-label-text {
    flex: 1;
}

.storage-label-value {
    font-weight: 600;
    color: var(--color-text-primary);
}

.storage-bar {
    width: 100%;
    height: 20px;
    background: var(--color-bg-tertiary);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--color-border-light);
}

.storage-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 10px;
    transition: width 0.3s ease;
}

.storage-bar.storage-warning .storage-fill {
    background: linear-gradient(90deg, var(--color-warning) 0%, #f57c00 100%);
}

.storage-bar.storage-critical .storage-fill {
    background: linear-gradient(90deg, var(--color-danger) 0%, #d32f2f 100%);
}

.storage-status {
    font-size: 0.75em;
    color: var(--color-text-muted);
    margin-top: 4px;
    text-align: right;
}

/* Feature Availability Badges */
.feature-availability {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 500;
}

.feature-availability.available {
    background: #e8f5e9;
    color: var(--color-success);
}

.feature-availability.available::before {
    content: "✓";
    font-weight: bold;
}

.feature-availability.unavailable {
    background: #ffebee;
    color: #c62828;
}

.feature-availability.unavailable::before {
    content: "✗";
    font-weight: bold;
}

.feature-unavailable-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    margin: 12px 0;
    background: #fff3e0;
    border-left: 3px solid var(--color-warning);
    border-radius: 4px;
    color: var(--color-warning);
    font-size: 0.9em;
}

.feature-unavailable-message .icon {
    font-size: 1.2em;
}

.feature-unavailable-message .message {
    flex: 1;
}

.feature-unavailable-message .upgrade-link {
    white-space: nowrap;
    margin-left: auto;
}

/* Member Limit Display */
.member-usage-display {
    font-size: 0.85em;
    color: var(--color-text-secondary);
    margin: 8px 0;
    padding: 8px;
    background: var(--color-bg-secondary);
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.member-usage-display.warning {
    background: #fff3e0;
    color: var(--color-warning);
}

.member-usage-display.critical {
    background: #ffebee;
    color: var(--color-danger);
}

.member-slots-remaining {
    font-weight: 600;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .limit-warning-banner {
        flex-direction: column;
    }
    
    .plan-badge {
        font-size: 0.8em;
        padding: 4px 8px;
    }
}


/* Settings section - similar to .card but with custom radius and no hover effects */
.settings-section {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.settings-section h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.1em;
    color: var(--color-text-primary);
    border-bottom: 2px solid var(--color-bg-secondary);
    padding-bottom: 8px;
}

.settings-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--color-bg-secondary);
    padding-bottom: 8px;
}

.settings-section-header h3 {
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.settings-section-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-section-actions .btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.storage-section-content,
.plan-section-content,
.info-section-content,
.upgrade-section-content {
    padding: 8px 0;
}

/* Plan Badge Large */
.plan-badge-large {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    letter-spacing: var(--letter-spacing-ui);
    text-align: center;
    margin-bottom: 16px;
}

.plan-badge-large.free {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border: 2px solid var(--color-border-dark);
}

.plan-badge-large.digital-you {
    background: var(--gradient-primary);
    color: white;
}

.plan-badge-large.digital-legacy {
    background: var(--gradient-premium);
    color: white;
}

/* Plan Features List */
.plan-features {
    margin-top: 12px;
}

.plan-features h4 {
    margin: 12px 0 8px 0;
    color: var(--color-text-primary);
    font-size: 0.95em;
}

.plan-features ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.plan-features li {
    padding-left: 24px;
    position: relative;
    color: var(--color-text-secondary);
    font-size: 0.9em;
    line-height: 1.4;
}

.plan-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--color-success);
    font-weight: bold;
}


.detail-item {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-bg-secondary);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--color-text-secondary);
    min-width: 120px;
    font-size: 0.9em;
}

.detail-value {
    color: var(--color-text-primary);
    flex: 1;
    word-break: break-word;
}


/* Upgrade Section */
.upgrade-section {
    background: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-bg-tertiary) 100%);
    border: 2px solid #ffc107;
}

.upgrade-suggestion {
    padding: 8px 0;
}

.upgrade-suggestion p {
    margin: 0 0 12px 0;
    color: var(--color-text-primary);
    font-size: 0.95em;
}

.upgrade-suggestion ul {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.upgrade-suggestion li {
    padding-left: 24px;
    position: relative;
    color: #555;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Danger Zone Section */
.settings-section.danger-zone {
    background: linear-gradient(135deg, #fff5f5 0%, #ffebee 100%);
    border: 2px solid #ef5350;
}

.settings-section.danger-zone h3 {
    color: #c62828;
    border-bottom-color: #ffcdd2;
}

.danger-zone-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.danger-zone-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #ffcdd2;
}

.danger-zone-row:last-child {
    border-bottom: none;
}

.danger-zone-info {
    flex: 1;
}

.danger-zone-info h4 {
    margin: 0 0 4px 0;
    font-size: 0.95em;
    color: var(--color-text-primary);
    font-weight: 600;
}

.danger-zone-info p {
    margin: 0;
    font-size: 0.85em;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

.danger-zone-row button {
    flex-shrink: 0;
    min-width: 140px;
}

@media (max-width: 600px) {
    .danger-zone-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .danger-zone-row button {
        width: 100%;
    }
}

/* Active takes precedence over unread */


.upgrade-suggestion li::before {
    content: "→";
    position: absolute;
    left: 6px;
    color: #ffc107;
    font-weight: bold;
}

/* Responsive Settings */
@media (max-width: 768px) {
    
    
    .settings-section {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .plan-badge-large {
        padding: 10px 20px;
        font-size: 1em;
    }
    
    .detail-item {
        flex-direction: column;
        gap: 4px;
    }
    
    .detail-label {
        min-width: auto;
    }
}


/* Lifecycle actions section in Settings */
.lifecycle-actions-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

.danger-zone {
    border: 2px solid var(--color-danger);
    background: #ffebee;
}

.danger-zone h3 {
    color: #c62828;
    margin-top: 0;
}

.lifecycle-action-button {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    width: 100%;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.2s;
    gap: 8px;
}

.lifecycle-action-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.lifecycle-action-button:active:not(:disabled) {
    transform: translateY(0);
}

.lifecycle-action-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.lifecycle-action-button.transfer {
    background: #ffc107;
    color: #333;
}

.lifecycle-action-button.transfer:hover:not(:disabled) {
    background: #ffb300;
}

.lifecycle-action-button.delete {
    background: var(--color-danger);
    color: white;
}

.lifecycle-action-button.delete:hover:not(:disabled) {
    background: #d32f2f;
}

.lifecycle-action-button.leave {
    background: var(--color-danger);
    color: white;
}

.lifecycle-action-button.leave:hover:not(:disabled) {
    background: #d32f2f;
}

/* Transfer ownership modal */
#transferOwnershipModal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: var(--z-tooltip);
}

#transferOwnershipModal .modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

#transferOwnershipModal h2 {
    margin-top: 0;
    color: #333;
}

.transfer-member-option {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.transfer-member-option:hover {
    background: #f5f5f5;
}

.transfer-member-option input[type="radio"] {
    margin-right: 12px;
    cursor: pointer;
}

.transfer-member-info {
    flex: 1;
}

.transfer-member-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.transfer-member-email {
    font-size: 0.85em;
    color: #999;
}

.transfer-member-role {
    display: inline-block;
    font-size: 0.75em;
    color: #999;
    margin-left: 4px;
}

/* Transfer warning box */
.transfer-warning {
    background: #fff3e0;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid #ff9800;
    margin: 16px 0;
    font-size: 0.9em;
    color: #e65100;
}

.transfer-warning strong {
    color: #e65100;
    display: block;
    margin-bottom: 8px;
}

.transfer-warning ul {
    list-style: none;
    padding-left: 12px;
    margin: 0;
}

.transfer-warning li {
    padding: 2px 0;
}

.transfer-warning li::before {
    content: "• ";
    margin-right: 6px;
}

/* ========================================================================== */
/* --- Utility Classes --- */ */
/* ========================================================================== */

/**
 * Hidden utility class
 * Use this class to hide elements instead of inline style.display = 'none'
 * This provides a single source of truth for visibility management
 */

/* ========================================================================== */
/* --- Cluster Event Selection Popup --- */
/* ========================================================================== */

/**
 * Popup container for selecting events within a cluster
 * Positioned absolutely relative to the canvas wrapper
 */
.cluster-popup {
    position: fixed;
    z-index: var(--z-modal-bulk-upload);
    background: var(--color-bg-primary, #fff);
    border: 1px solid var(--color-border-light, #e0e0e0);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.15));
    min-width: 220px;
    max-width: 280px;
    /* Keep visible for arrow pseudo-element */
    overflow: visible;
}

/* Inner wrapper clips scrollbar to border-radius */
.cluster-popup-content {
    border-radius: var(--radius-lg, 12px);
    overflow: hidden;
}

.cluster-popup-list {
    /* Max height for 4 items fully visible */
    max-height: 248px;
    overflow-y: auto;
    padding: 10px 0;
}

.cluster-popup-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid var(--color-border-light, #f0f0f0);
}

.cluster-popup-item:last-child {
    border-bottom: none;
}

.cluster-popup-item:hover {
    background-color: var(--color-surface-4);
}

.cluster-popup-item-name {
    font-size: 0.95em;
    font-weight: 500;
    color: var(--color-text-primary, #333);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cluster-popup-item-date {
    font-size: 0.8em;
    color: var(--color-text-tertiary, #888);
}

/* Arrow/caret pointing to the cluster */
.cluster-popup::before,
.cluster-popup::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
    pointer-events: none;
}

/* Right-opening: popup to right of circle, arrow on LEFT edge pointing left */
/* Border triangle (outer layer) */
.cluster-popup.popup-right::before {
    top: var(--arrow-y, 28px);
    left: 0;
    margin-left: -13px;
    transform: translateY(-50%);
    border-width: 13px 13px 13px 0;
    border-color: transparent var(--color-border-light, #e0e0e0) transparent transparent;
    z-index: 1;
}

/* Fill triangle (inner layer, on top) */
.cluster-popup.popup-right::after {
    top: var(--arrow-y, 28px);
    left: 0;
    margin-left: -12px;
    transform: translateY(-50%);
    border-width: 12px 12px 12px 0;
    border-color: transparent #ffffff transparent transparent;
    z-index: 2;
}

/* Left-opening: popup to left of circle, arrow on RIGHT edge pointing right */
/* Border triangle (outer layer) */
.cluster-popup.popup-left::before {
    top: var(--arrow-y, 28px);
    right: 0;
    margin-right: -13px;
    transform: translateY(-50%);
    border-width: 13px 0 13px 13px;
    border-color: transparent transparent transparent var(--color-border-light, #e0e0e0);
    z-index: 1;
}

/* Fill triangle (inner layer, on top) */
.cluster-popup.popup-left::after {
    top: var(--arrow-y, 28px);
    right: 0;
    margin-right: -12px;
    transform: translateY(-50%);
    border-width: 12px 0 12px 12px;
    border-color: transparent transparent transparent #ffffff;
    z-index: 2;
};
    border-width: 11px 0 11px 11px;
    border-color: transparent transparent transparent var(--color-bg-primary, #fff);
    z-index: 2;
}
.cluster-popup::after {
    display: none;
}
/* ========================================================================== */
/* --- Billing Toast & Banner Notifications --- */
/* ========================================================================== */

/**
 * Billing Toast - Temporary notification for billing actions/errors
 * Slides in from top-right, auto-dismisses (except errors)
 */
.billing-toast {
    position: fixed;
    top: -200px;
    right: 20px;
    z-index: var(--z-toast-billing);
    min-width: 320px;
    max-width: 480px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    padding: 16px;
    padding-right: 52px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid;
    transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.billing-toast.show {
    top: 80px;
}

.billing-toast--error {
    border-left-color: var(--color-danger);
    background: #ffebee;
}

.billing-toast--warning {
    border-left-color: var(--color-warning);
    background: #fff3e0;
}

.billing-toast--info {
    border-left-color: var(--color-info);
    background: #e3f2fd;
}

.billing-toast--success {
    border-left-color: var(--color-success);
    background: #e8f5e9;
}

.billing-toast__icon {
    font-size: 24px;
    flex-shrink: 0;
}

.billing-toast__content {
    flex: 1;
    min-width: 0;
}

.billing-toast__message {
    font-size: 0.95em;
    color: var(--color-text-primary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.billing-toast__action {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.billing-toast__action:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.billing-toast__close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all 0.2s;
}

.billing-toast__close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--color-text-primary);
}

/**
 * Billing Banner - Persistent warning shown at top of page
 * Used for ongoing billing issues (past_due, cancel_at_period_end)
 */
.billing-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid var(--color-border-light);
    border-left: 4px solid;
    box-shadow: var(--shadow-xs);
}

.billing-banner--warning {
    border-left-color: var(--color-warning);
    background: #fff8e1;
}

.billing-banner--info {
    border-left-color: var(--color-info);
    background: #e3f2fd;
}

.billing-banner__icon {
    font-size: 20px;
    flex-shrink: 0;
}

.billing-banner__message {
    flex: 1;
    font-size: 0.9em;
    color: var(--color-text-primary);
    line-height: 1.4;
}

.billing-banner__action {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.billing-banner__action:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.billing-banner__close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all 0.2s;
    margin-left: 12px;
}

.billing-banner__close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--color-text-primary);
}

/* ============================================================
   TOOLBAR COMPONENTS
   For table/list header scaffolding cleanup
   ============================================================ */

.c-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 15px;
}

.c-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.c-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.c-sortable-header {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
}

.c-sortable-th {
    cursor: pointer;
    user-select: none;
}

.c-bordered-panel {
    border: 1px solid #ddd;
    border-radius: 6px;
}

.c-promo-section {
    background: #fafbfc;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
}

.c-dev-tools-section {
    background: #fff8e1;
    border: 1px dashed #f0ad4e;
    border-radius: 6px;
}

.c-dev-text {
    color: #8a6d3b;
}

.c-promo-input {
    border: 1px solid #ccc;
    border-radius: 4px;
}

.c-promo-heading {
    color: #333;
}

.c-error-note {
    color: #e74c3c;
}

.c-date-label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 600;
}

.c-filter-linked-events {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    min-height: 240px;
}

.c-filter-linked-events p {
    color: #888;
}

.c-legal-reaccept-content {
    max-width: 600px;
}

.c-legal-reaccept-links {
    margin: 25px 0;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.c-legal-reaccept-link {
    color: #667eea;
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid #667eea;
    border-radius: 6px;
}

.c-legal-reaccept-consent {
    margin: 25px 0;
    text-align: left;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.c-legal-reaccept-consent label {
    display: block;
    cursor: pointer;
}

.c-legal-reaccept-consent label:not(:last-child) {
    margin-bottom: 15px;
}

.c-legal-reaccept-consent input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
}

.c-legal-reaccept-error {
    color: #dc3545;
}

.c-legal-doc-content {
    max-height: 80vh;
    overflow-y: auto;
    max-width: 700px;
}

.c-legal-draft-notice {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px;
    margin: 15px 0;
    font-size: 0.9em;
    color: #856404;
}

.c-legal-doc-text {
    font-size: 0.95em;
    line-height: 1.6;
    color: #555;
}

.c-legal-doc-text ul {
    margin: 10px 0;
    padding-left: 20px;
}

.c-legal-warning-box {
    background: #fff3cd;
    padding: 10px;
    border-radius: 5px;
    margin: 15px 0;
}

.c-legal-doc-footer {
    margin-top: 30px;
}

/* Legal content modal (Terms/Privacy/Cancellation) - uses clean modal contract shell */
.modal-content.c-legal-content-modal {
    width: 90%;
    max-width: 900px;
}

.modal-content.c-legal-content-modal .c-modal-scroll-body {
    padding: var(--panel-space-5, 20px) var(--panel-space-6, 24px);
}

/* Minimal, calm footer: subtle divider, no heavy background */
.modal-content.c-legal-content-modal .c-modal-sticky-footer {
    background: transparent;
    padding: var(--panel-space-3, 12px) var(--panel-space-6, 24px);
}

/* Content typography - scrolling handled by .c-modal-scroll-body */
.c-legal-page-content {
    padding: 0;
    font-size: 0.95em;
    line-height: 1.7;
}

.c-upgrade-age-notice {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.c-upgrade-age-notice > div:first-child {
    display: flex;
    gap: 15px;
}

.c-upgrade-age-notice > div:first-child > span:first-child {
    font-size: 2em;
}

.c-upgrade-age-notice p:first-of-type {
    font-size: 1.1em;
}

.c-upgrade-age-notice p:last-of-type {
    color: #666;
    line-height: 1.6;
}

/* ========================================================================== */\n/* --- Legal Page Components (Phase 2 Regression Cleanup) --- */
/* ========================================================================== */

.legal-footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--color-border-light);
    color: var(--color-text-secondary);
    font-size: 0.85em;
}

.legal-footer a {
    color: var(--color-primary);
    text-decoration: none;
}

.legal-copyright {
    margin-top: 15px;
    color: var(--color-text-tertiary);
}

/* Verify email page */
.verify-redirect-text {
    color: var(--color-text-muted);
    font-size: 14px;
    margin-top: 10px;
}

.verify-continue-btn {
    margin-top: 15px;
}

/* Bulk import summary */
.bulk-summary-container {
    padding: 20px;
    background: var(--color-surface-2);
    border-radius: 8px;
    margin: 20px 0;
}

.bulk-summary-title {
    margin: 0 0 15px 0;
    color: var(--color-status-success);
}

.bulk-summary-metrics {
    margin-bottom: 15px;
}

.bulk-select-checkbox {
    margin-left: 5px;
}

/* Dev mode panel */
.dev-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: var(--z-modal-blocking);
}

.dev-panel-inner {
    background: #f0f0f0;
    border: 2px solid #999;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    max-width: 250px;
}

.dev-panel-title {
    margin: 0 0 10px 0;
    font-size: 0.85em;
    color: var(--color-text-secondary);
    font-weight: bold;
}

.dev-panel-button {
    width: 100%;
    padding: 10px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
}

.dev-panel-message {
    margin: 8px 0 0 0;
    font-size: 0.75em;
    color: var(--color-text-secondary);
    min-height: 16px;
}

/* CTA button centered */
.cta-centered {
    max-width: 300px;
    margin: 0 auto;
}
/* Migration Backfill UI Utility Classes */
.u-bg-warning-light { background-color: #fff3cd; }
.u-border-warning { border-color: #ffc107; }
.u-border-l-4 { border-left-width: 4px; }
.u-max-h-300 { max-height: 300px; }
.u-w-80 { width: 80px; }
.u-w-120 { width: 120px; }
.u-w-full { width: 100%; }
.u-bg-dark { background-color: #2d3748; }
.u-color-light { color: #f7fafc; }
.u-border-dark { border-color: #4a5568; }

/* ========================================================================== */
/* HOME PAGE - Phase 2: Orientation Dashboard */
/* ========================================================================== */

/* Container & Layout */
#home-page-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: var(--spacing-xl) var(--spacing-lg) var(--spacing-xl);
    /* Softer, desaturated gradient - less intense than original brand gradient */
    background: linear-gradient(180deg, 
        hsl(233, 35%, 68%) 0%,      /* Lighter, desaturated lavender at top */
        hsl(233, 38%, 58%) 100%);   /* Medium desaturated blue-purple at bottom */
    color: var(--color-text-inverse);
    overflow: visible;
}

.home-page-content {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding-bottom: var(--spacing-xl);
}

/* Main content area - no longer needs flexbox since rail is removed */
.home-content-main {
    /* Normal block flow */
}

/* Hero Section - Hidden in Phase 1 (branding already in global header) */
.home-hero {
    display: none;
}

.home-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    letter-spacing: var(--letter-spacing-ui);
}

.home-subtitle {
    font-size: 1.125rem;
    font-weight: 400;
    opacity: 0.85;
    margin-bottom: 0;
}

/* Quick Actions - Calm ghost buttons on gradient surface */
.home-quick-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-bottom: var(--spacing-sm);
}

.home-quick-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    /* Ghost button styling */
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--color-text-inverse);
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.home-quick-actions .btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: none;
    transform: none;
}

.home-quick-actions .btn:active:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
    box-shadow: none;
}

.home-quick-actions .btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Section Layout */
.home-section {
    margin-bottom: var(--spacing-lg);
}

/* ========================================================================== */
/* HOME PAGE - Phase A: Wrap-only Carousel Rows */
/* ========================================================================== */

/* Canonical Home card sizing tokens (scoped to Home only) */
#home-page-container {
    --home-card-w: 360px;
    --home-card-h: 140px;
    --home-card-gap: 12px;
    --home-arrow-w: 44px;
}

/* Canonical horizontal track for ALL Home carousel rows */
#home-page-container .home-carousel-track {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: var(--home-card-gap);
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--spacing-sm);
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

#home-page-container .home-carousel-track::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Canonical fixed-size tile footprint for ALL Home carousel items */
#home-page-container .home-carousel-tile {
    flex: 0 0 var(--home-card-w);
    width: var(--home-card-w);
    height: var(--home-card-h);
    overflow: hidden;
    border-radius: var(--radius-md);
    box-sizing: border-box;
    scroll-snap-align: start;
}

/* Legacy .home-carousel-card class - remap to tile */
#home-page-container .home-carousel-card {
    flex: 0 0 var(--home-card-w);
    width: var(--home-card-w);
    height: var(--home-card-h);
    overflow: hidden;
    border-radius: var(--radius-md);
    box-sizing: border-box;
    scroll-snap-align: start;
}

/* Prevent text from changing card size */
#home-page-container .home-carousel-card .home-timeline-card-name {
    -webkit-line-clamp: 1;
}

#home-page-container .home-carousel-card .home-timeline-card-meta,
#home-page-container .home-carousel-card .home-recent-item-name,
#home-page-container .home-carousel-card .home-recent-item-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#home-page-container .home-carousel-card .home-recent-item-meta {
    flex-wrap: nowrap;
}

.home-carousel-row {
    margin-bottom: 24px;
}

.home-carousel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.home-section-header-text {
    flex: 1 1 auto;
}

.home-carousel-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Phase C: minimal, link-like 'View all' control */
.home-carousel-view-all {
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--color-text-inverse);
    opacity: 0.8;
    text-transform: lowercase;
    letter-spacing: var(--letter-spacing-ui);
    cursor: pointer;
}

.home-carousel-view-all:hover:not(:disabled) {
    opacity: 1;
    text-decoration: underline;
}

.home-carousel-view-all:disabled {
    opacity: 0.45;
    cursor: default;
}

/* Proxy action buttons in headers: match Home ghost-button treatment */
.home-carousel-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--color-text-inverse);
    box-shadow: none;
}

.home-carousel-actions .btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: none;
    transform: none;
}

#home-page-container .home-carousel-body {
    display: grid !important;
    grid-template-columns: var(--home-arrow-w) 1fr var(--home-arrow-w) !important;
    column-gap: 10px !important;
    align-items: start !important;
}

#home-page-container .home-carousel-arrow {
    flex: 0 0 auto;
    cursor: pointer;
    user-select: none;
    background: transparent;
    border: none;
    color: var(--color-text-inverse);
    border-radius: var(--radius-sm);
    width: var(--home-arrow-w);
    padding: 10px 0;
    line-height: 1;
    margin-top: calc(var(--home-card-h) / 2 - 18px); /* Center arrow vertically with card */
    opacity: 0.35;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

/* Wake up arrows when hovering anywhere in the carousel row */
#home-page-container .home-carousel-row:hover .home-carousel-arrow:not(:disabled):not(.is-disabled) {
    opacity: 0.65;
}

#home-page-container .home-carousel-arrow:hover {
    opacity: 0.85;
    background: rgba(255, 255, 255, 0.08);
}

#home-page-container .home-carousel-arrow:focus-visible {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

#home-page-container .home-carousel-arrow:disabled,
#home-page-container .home-carousel-arrow.is-disabled {
    opacity: 0.12;
    pointer-events: none;
    cursor: default;
}

/* Phase C: simple empty state inside a carousel viewport */
.home-carousel-empty {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: var(--spacing-sm);
    max-width: 520px;
}

.home-carousel-empty-title {
    font-weight: 500;
    text-transform: none;
}

.home-carousel-empty-detail {
    opacity: 0.85;
}

.home-carousel-empty .btn {
    align-self: flex-start;
}

.home-carousel-viewport {
    flex: 1 1 auto;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Home: apply consistent inset once at viewport level */
#home-page-container .home-carousel-viewport {
    padding: var(--spacing-sm);
    box-sizing: border-box;
    /* Prevent scroll-snap from offsetting by the padding amount */
    scroll-padding-left: var(--spacing-sm);
}

/* Home: avoid double inset for empty state blocks */
#home-page-container .home-carousel-viewport .home-carousel-empty {
    padding: 0;
}

.home-carousel-viewport::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Timeline grid: neutralize columns ONLY inside carousel viewport */
/* Timelines track */
#home-page-container .home-carousel-viewport #home-timelines-grid {
    display: flex !important;
    flex-direction: row;
    gap: var(--home-card-gap) !important;
    padding: 0;
    column-count: initial;
    column-width: auto;
    column-gap: initial;
    justify-content: flex-start;
    align-items: stretch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Fallback: if flex gap isn't supported, use margins to keep tiles separated */
@supports not (gap: 12px) {
    #home-page-container .home-carousel-viewport #home-timelines-grid {
        gap: 0 !important;
    }

    #home-page-container .home-carousel-viewport #home-timelines-grid .home-timeline-card {
        margin-right: var(--home-card-gap);
    }

    #home-page-container .home-carousel-viewport #home-timelines-grid .home-timeline-card:last-child {
        margin-right: 0;
    }
}

#home-page-container .home-carousel-viewport #home-timelines-grid::-webkit-scrollbar {
    display: none;
}

/* Unified carousel card sizing - applies to all .home-card in carousel viewports */
#home-page-container .home-carousel-viewport .home-card {
    flex: 0 0 var(--home-card-w);
    width: var(--home-card-w);
    min-width: var(--home-card-w);
    height: var(--home-card-h);
    margin-bottom: 0;
    scroll-snap-align: start;
}

/* Legacy selector for any remaining .home-timeline-card */
#home-page-container .home-carousel-viewport #home-timelines-grid .home-timeline-card {
    flex: 0 0 var(--home-card-w);
    width: var(--home-card-w);
    min-width: var(--home-card-w);
    height: var(--home-card-h);
    margin-bottom: 0;
    scroll-snap-align: start;
}

/* Events row: same track pattern as other rows */
.home-carousel-row#home-recent-section {
    max-width: none;
}

/* Legacy selector for any remaining .home-recent-item */
#home-page-container .home-carousel-viewport #home-recent-activity .home-recent-item {
    flex: 0 0 var(--home-card-w);
    width: var(--home-card-w);
    min-width: var(--home-card-w);
    height: var(--home-card-h);
    scroll-snap-align: start;
}

.home-section-header {
    margin-bottom: var(--spacing-md);
}

.home-section-title {
    font-size: 0.9375rem;
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 0.04em;
    color: var(--color-text-inverse);
    opacity: 0.85;
    margin: 0;
}

.home-section-subtitle {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--color-text-inverse);
    opacity: 0.7;
    margin: 4px 0 0 0;
    text-transform: lowercase;
    letter-spacing: 0.03em;
}

/* Spotlight Section */
.home-spotlight-section {
    margin-bottom: var(--spacing-xl);
}

.home-spotlight-container {
    display: flex;
    justify-content: flex-start;
}

.home-spotlight-container .home-card {
    --spotlight-card-w: 440px;
    --spotlight-card-h: 200px;
    flex: 0 0 var(--spotlight-card-w);
    width: var(--spotlight-card-w);
    height: var(--spotlight-card-h);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.home-spotlight-container .home-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

#home-recent-section .home-section-title {
    font-size: 0.9375rem;
    font-weight: 500;
    opacity: 0.85;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOME CARD CONTRACT - 4-Zone Unified Structure
   All Home cards (timelines, events) follow this vertical zone structure:
   1) Title (max 2 lines, ellipsis)
   2) Primary Meta (single line, type-specific identity context)
   3) Secondary Meta (max 2 lines, situational context)
   4) Footer (ownership/relationship info)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Base card - applies to all Home cards */
.home-card {
    background: var(--color-surface-1);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
    color: var(--color-text-primary);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-left: 3px solid transparent; /* Reserve space for type accent */
}

/* Body wrapper for card content (zones 1-4). Footer row is a separate bottom strip. */
.home-card-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0; /* Allow flex children to clamp/ellipsis properly */
}

/* Dedicated bottom row: memory strip (left) + go-to chip slot (right) */
.home-card-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm); /* Dedicated spacing from body content */
    padding-top: 0;
}

.home-card-memory-strip {
    display: flex;
    align-items: flex-end;
    flex: 1 1 auto;
    min-height: 28px;
    overflow: hidden;
    pointer-events: none;
}

.home-card-footer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
}

/* Type-specific left border accents - subtle visual rhythm */
.home-card--timeline {
    border-left-color: rgba(108, 117, 224, 0.35); /* Purple for timelines */
}

.home-card--event {
    border-left-color: rgba(52, 211, 153, 0.35); /* Green for events */
}

.home-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

/* Strengthen accent on hover for subtle feedback */
.home-card--timeline:hover {
    border-left-color: rgba(108, 117, 224, 0.55);
}

.home-card--event:hover {
    border-left-color: rgba(52, 211, 153, 0.55);
}

/* Optional color accent bar (top edge) */
.home-card-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    opacity: 0.55;
}

/* Zone container - ensures consistent spacing */
.home-card-zone {
    display: block;
    width: 100%;
}

/* ZONE 1: Title - max 2 lines, heavier weight */
.home-card-zone--title {
    margin-bottom: 4px;
}

.home-card-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-primary);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* ZONE 2: Primary Meta - single line, identity context */
.home-card-zone--primary-meta {
    min-height: 1.4em; /* Fixed height for single line */
    margin-bottom: var(--spacing-xs);
}

.home-card-primary-meta {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ZONE 3: Secondary Meta - max 2 lines, contextual */
.home-card-zone--secondary-meta {
    min-height: 1.4em; /* Minimum single line height */
    margin-bottom: var(--spacing-xs);
    flex: 1 1 auto; /* Allow to grow and take remaining space */
}

.home-card-secondary-meta {
    font-size: 0.75rem;
    color: var(--color-text-tertiary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Subtle emphasis for recent activity (last 24 hours) - non-decorative signal */
.home-card[data-recent="true"] .home-card-secondary-meta {
    color: var(--color-text-secondary);
    opacity: 0.95;
}

/* Home timeline card hierarchy: active timelines read stronger; empty timelines recede */
#home-page-container .home-card--timeline[data-has-activity="true"] .home-card-title {
    opacity: 1;
}

#home-page-container .home-card--timeline[data-has-activity="true"] .home-card-primary-meta {
    opacity: 0.9;
}

#home-page-container .home-card--timeline[data-has-activity="true"] .home-card-secondary-meta {
    opacity: 0.85;
}

#home-page-container .home-card--timeline:not([data-has-activity="true"]) .home-card-title {
    opacity: 0.78;
}

#home-page-container .home-card--timeline:not([data-has-activity="true"]) .home-card-primary-meta {
    opacity: 0.72;
}

#home-page-container .home-card--timeline:not([data-has-activity="true"]) .home-card-secondary-meta {
    opacity: 0.62;
}

#home-page-container .home-card--timeline:not([data-has-activity="true"]) .home-card-footer {
    opacity: 0.6;
}

/* Very subtle accent bar opacity boost for recent items */
.home-card[data-recent="true"] .home-card-accent {
    opacity: 0.7;
}

/* ZONE 4: Footer - ownership/relationship, quiet */
.home-card-zone--footer {
    min-height: 1.2em; /* Reserve space even when empty */
    margin-top: auto; /* Push to bottom */
    padding-bottom: var(--spacing-sm); /* Keep footer text clear of memory strip */
}

.home-card-footer {
    font-size: 0.6875rem;
    color: var(--color-text-tertiary);
    line-height: 1.2;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.8;
}

/* Empty footer still reserves space */
.home-card-footer:empty::before {
    content: '\00a0'; /* Non-breaking space */
    visibility: hidden;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MEMORY IMAGE CLUSTER - Subtle visual texture for Home cards
   Displays 2-4 overlapping circular images in the bottom footer row.
   Design rules:
   - Low opacity (10-25%) so images remain secondary to text
   - Slight blur/desaturation for "memory texture" feel
   - No hover effects, no animations (Phase 1)
   - Never overlaps or competes with text content
   ═══════════════════════════════════════════════════════════════════════════ */

.memory-image-cluster {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px; /* Small gap between images */
    pointer-events: none; /* Don't interfere with card clicks */
    z-index: 0;
}

.memory-cluster-img {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    background: var(--color-surface-2);
    flex-shrink: 1; /* Allow shrinking if needed */
}

/* Only overlap on very narrow cards */
@media (max-width: 520px) {
    .memory-image-cluster {
        gap: 0;
    }

    .memory-cluster-img + .memory-cluster-img {
        margin-left: -6px;
    }
}

.memory-cluster-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 1;
    filter: none;
}

/* Spotlight variation: slightly higher opacity for richer feel */
.memory-cluster--spotlight .memory-cluster-img img {
    opacity: 1;
}

#home-page-container .home-carousel-viewport .memory-cluster-img {
    width: 24px;
    height: 24px;
}

/* Spotlight card has more room - larger cluster allowed */
.home-spotlight-container .memory-cluster-img {
    width: 34px;
    height: 34px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOME CARD SIZE CONSTRAINTS (Carousel Context)
   Cards must maintain fixed dimensions within carousel viewports
   ═══════════════════════════════════════════════════════════════════════════ */

/* Timeline cards in carousel */
#home-page-container .home-carousel-viewport .home-card--timeline,
#home-page-container .home-carousel-viewport .home-card--event {
    flex: 0 0 var(--home-card-w);
    width: var(--home-card-w);
    min-width: var(--home-card-w);
    height: var(--home-card-h);
    scroll-snap-align: start;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOME CARD SELECTION STATE
   Visual feedback when a card is selected via single-click
   ═══════════════════════════════════════════════════════════════════════════ */

.home-card.is-selected {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

/* Ensure selection state doesn't affect card dimensions */
.home-card.is-selected {
    transform: translateY(-2px);
}

/* Focus visible for keyboard navigation */
.home-card:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOME CARD CHIP - "Go to Canvas" action button
   
   Appears on selected cards only. Replaces the previous floating action rail.
   Lightweight, unobtrusive, positioned within the card.
   ═══════════════════════════════════════════════════════════════════════════ */

.home-card-chip {
    /* Positioning - placed in footer row (no absolute overlay) */
    position: static;
    
    /* Visual styling - compact, subtle chip */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    
    /* Colors - subtle, secondary appearance */
    background: rgba(var(--color-primary-rgb, 108, 117, 224), 0.12);
    color: var(--color-primary);
    
    /* Shape */
    border: 1px solid rgba(var(--color-primary-rgb, 108, 117, 224), 0.25);
    border-radius: 50%; /* Circular */
    
    /* Effects - minimal shadow */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    
    /* Interaction */
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Layering */
    z-index: 10;
}

.home-card-chip svg {
    display: block;
    flex-shrink: 0;
    opacity: 0.85;
}

.home-card-chip:hover {
    background: rgba(var(--color-primary-rgb, 108, 117, 224), 0.2);
    border-color: rgba(var(--color-primary-rgb, 108, 117, 224), 0.4);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.home-card-chip:hover svg {
    opacity: 1;
}

.home-card-chip:active {
    transform: scale(0.95);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.home-card-chip:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOME TIMELINE CHOOSER
   
   Lightweight popover for selecting which timeline to view when an event belongs
   to multiple timelines. Appears when clicking the "Go to Canvas" chip on multi-
   timeline events.
   ═══════════════════════════════════════════════════════════════════════════ */

.home-timeline-chooser {
    /* Positioning - fixed, positioned dynamically via JS */
    position: fixed;
    z-index: 1000; /* Above cards, below modals */
    
    /* Layout */
    min-width: 180px;
    max-width: 280px;
    
    /* Visual styling - calm, secondary surface */
    background: var(--color-bg-secondary, #ffffff);
    border: 1px solid var(--color-border-light, #e0e0e0);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15),
                0 1px 3px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    padding: var(--spacing-xs, 8px);
    
    /* Animation */
    animation: chooserFadeIn 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chooserFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.home-timeline-chooser-header {
    /* Typography - small, quiet header */
    font-size: 0.75em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary, #666666);
    
    /* Spacing */
    padding: var(--spacing-xs, 8px) var(--spacing-sm, 12px);
    margin-bottom: var(--spacing-xs, 8px);
    
    /* Visual separator */
    border-bottom: 1px solid var(--color-border-light, #e0e0e0);
}

.home-timeline-chooser-list {
    /* Reset list styles */
    list-style: none;
    margin: 0;
    padding: 0;
}

.home-timeline-chooser-item {
    /* Layout */
    display: block;
    width: 100%;
    padding: var(--spacing-sm, 12px);
    
    /* Typography */
    font-size: 0.95em;
    color: var(--color-text-primary, #333333);
    text-align: left;
    
    /* Visual */
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 6px);
    
    /* Interaction */
    cursor: pointer;
    transition: background-color 0.12s ease;
    
    /* Accessibility */
    outline: none;
}

.home-timeline-chooser-item:hover,
.home-timeline-chooser-item:focus {
    background: var(--color-hover-bg, rgba(0, 0, 0, 0.05));
}

.home-timeline-chooser-item:active {
    background: var(--color-active-bg, rgba(0, 0, 0, 0.1));
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOME ACTION RAIL (DEPRECATED - Removed in favor of on-card chip)
   
   The following styles are preserved but unused. Can be removed in future cleanup.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Make home-page-container a positioning context */
#home-page-container {
    position: relative;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LEGACY HOME CARD STYLES (Preserved for backward compatibility)
   These may be deprecated once all cards migrate to 4-zone contract
   ═══════════════════════════════════════════════════════════════════════════ */

/* Timeline Cards Grid - Masonry-lite Layout */
.home-timelines-grid {
    column-count: auto;
    column-width: 220px;
    column-gap: var(--spacing-xl);
}

.home-timeline-card {
    background: var(--color-surface-1);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
    color: var(--color-text-primary);
    break-inside: avoid;
    margin-bottom: 0;
    display: inline-block;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.home-timeline-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

/* Optional color accent bar */
.home-timeline-card-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    opacity: 0.55;
}

.home-timeline-card-header {
    margin-bottom: var(--spacing-xs);
}

.home-timeline-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 var(--spacing-xs) 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.home-timeline-card-badge {
    display: inline-block;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--color-text-secondary);
    margin-top: var(--spacing-xs);
}

.home-timeline-card-meta {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    line-height: 1.3;
}

.home-timeline-card-tags {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
    opacity: 1;
    overflow: hidden;
}

.home-timeline-card-tag {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.625rem;
    font-weight: 500;
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

/* Recent Activity List - Collapsible Footer */
.home-recent-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: var(--spacing-sm) 0;
    user-select: none;
}

.home-recent-section-header:hover .home-section-title {
    opacity: 1;
}

.home-recent-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.875rem;
    color: var(--color-text-inverse);
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.home-recent-toggle-icon {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

.home-recent-section-header.is-expanded .home-recent-toggle-icon {
    transform: rotate(180deg);
}

.home-recent-activity {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 0;
    color: var(--color-text-inverse);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.home-recent-activity.is-expanded {
    max-height: none;
    padding: var(--spacing-sm);
    overflow: visible;
}

/* Home override: events row uses simple track layout (no slab) */
#home-page-container .home-carousel-viewport #home-recent-activity {
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin: 0;
    max-height: none;
    overflow: visible;
    transition: none;
    display: flex;
    flex-direction: row;
    gap: var(--home-card-gap);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Home: prevent expanded-state padding from shifting the first tile */
#home-page-container .home-carousel-viewport #home-recent-activity.is-expanded {
    padding: 0 !important;
    overflow: visible !important;
}

#home-page-container .home-carousel-viewport #home-recent-activity::-webkit-scrollbar {
    display: none;
}

/* Home event tiles: styled as cards matching timeline cards */
#home-page-container .home-carousel-viewport .home-recent-item {
    background: var(--color-surface-1);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin: 0;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
    color: var(--color-text-primary);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: var(--spacing-xs);
    transition: all 0.2s ease;
}

#home-page-container .home-carousel-viewport .home-recent-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    background: var(--color-surface-1);
}

/* Hide the icon in card view, content fills card */
#home-page-container .home-carousel-viewport .home-recent-item .home-recent-item-icon {
    display: none;
}

#home-page-container .home-carousel-viewport .home-recent-item .home-recent-item-content {
    width: 100%;
    min-width: 0;
}

#home-page-container .home-carousel-viewport .home-recent-item .home-recent-item-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#home-page-container .home-carousel-viewport .home-recent-item .home-recent-item-meta {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    opacity: 1;
}

.home-recent-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.home-recent-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.home-recent-item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Home override: no borders between event tiles */
#home-page-container .home-carousel-viewport .home-recent-item:not(:last-child) {
    border-bottom: 0;
}

.home-recent-item-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    font-size: 0.8125rem;
    color: var(--color-text-inverse);
}

.home-recent-item-content {
    flex: 1;
    min-width: 0;
}

.home-recent-item-name {
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--color-text-inverse);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-recent-item-meta {
    font-size: 0.6875rem;
    color: var(--color-text-inverse);
    opacity: 0.7;
    display: flex;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
}

.home-recent-item-date {
    color: inherit;
}

.home-recent-item-timeline {
    color: inherit;
}

/* Empty States */
.home-empty-state {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    text-align: center;
    color: var(--color-text-primary);
}

.home-empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.home-empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-sm);
}

.home-empty-state-text {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-lg);
    line-height: 1.5;
}

.home-empty-state-action {
    display: inline-block;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .home-timelines-grid {
        column-width: 240px;
    }
}

@media (max-width: 768px) {
    #home-page-container {
        padding: var(--spacing-md) var(--spacing-sm) var(--spacing-xl);
    }
    
    .home-timelines-grid {
        column-count: 2;
        column-width: auto;
    }
    
    .home-quick-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .home-quick-actions .btn {
        justify-content: center;
        /* Ensure ghost styling persists on mobile */
        background: transparent;
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
    
    /* Recent Activity full width on mobile */
    #home-recent-section {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .home-timelines-grid {
        column-count: 1;
    }
}

/* ========================================================================== */
/* ═══════════════════════════════════════════════════════════════════════════
   CANVAS CONTEXT SWITCHER OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */

.canvas-context-switcher {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

.canvas-context-switcher-content {
    background: var(--color-surface-1);
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.canvas-context-switcher-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: var(--panel-space-4, 16px) var(--panel-space-6, 24px);
    padding-right: calc(var(--panel-space-6, 24px) + 40px);
    border-bottom: 1px solid var(--panel-border-subtle, var(--color-border-lighter));
    flex-shrink: 0;
    position: relative;
}

.canvas-context-switcher-title {
    font-size: var(--panel-font-title-size, 1.35em);
    font-weight: var(--panel-font-title-weight, 600);
    color: var(--panel-text, var(--color-text-primary));
    margin: 0;
    text-transform: lowercase;
    flex: 1;
}

.canvas-context-switcher-search-row {
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.canvas-context-switcher-search-input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    outline: none;
    transition: all 0.15s ease;
}

.canvas-context-switcher-search-input::placeholder {
    color: var(--color-text-muted);
}

.canvas-context-switcher-search-input:focus {
    background: white;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.canvas-context-switcher-close {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    font-size: 1.1em;
    color: var(--color-text-tertiary);
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
    padding: 0;
    z-index: 2;
}

.canvas-context-switcher-close:hover {
    background-color: rgba(0, 0, 0, 0.08);
    color: var(--color-text-secondary);
}

.canvas-context-switcher-body {
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
    max-height: calc(90vh - 100px);
    padding: 8px 0;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--yrh-scrollbar-thumb) var(--yrh-scrollbar-track);
}

.canvas-context-switcher-body::-webkit-scrollbar {
    width: var(--yrh-scrollbar-size);
}

.canvas-context-switcher-body::-webkit-scrollbar-track {
    background: var(--yrh-scrollbar-track);
}

.canvas-context-switcher-body::-webkit-scrollbar-thumb {
    background: var(--yrh-scrollbar-thumb);
    border-radius: var(--yrh-scrollbar-thumb-radius);
    border: var(--yrh-scrollbar-thumb-border) solid transparent;
    background-clip: content-box;
}

.canvas-context-switcher-body::-webkit-scrollbar-thumb:hover {
    background: var(--yrh-scrollbar-thumb-hover);
    border: var(--yrh-scrollbar-thumb-border) solid transparent;
    background-clip: content-box;
}

.canvas-context-switcher-list {
    padding: 12px;
}

.canvas-context-switcher-section {
    /* No extra margin */
}

.canvas-context-switcher-section-you {
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.canvas-context-switcher-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-12);
    border: 2px solid var(--color-border-light);
    border-radius: 8px;
    background: var(--color-bg-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    margin-bottom: 8px;
}

.canvas-context-switcher-item:hover {
    background: var(--color-bg-tertiary);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-primary-sm);
}

.canvas-context-switcher-item.is-active {
    background: rgba(102, 126, 234, 0.08);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-primary-sm);
}

.canvas-context-switcher-item-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.canvas-context-switcher-item-avatar-initials {
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1em;
    font-weight: 600;
}

.canvas-context-switcher-item-info {
    flex: 1;
    min-width: 0;
}

.canvas-context-switcher-item-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 0 2px 0;
}

.canvas-context-switcher-item.is-active .canvas-context-switcher-item-name {
    font-weight: 600;
    color: var(--color-text-primary);
}

.canvas-context-switcher-item-meta {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    .canvas-context-switcher {
        align-items: flex-end;
        padding: 0;
    }

    .canvas-context-switcher-content {
        max-width: 100%;
        max-height: 80vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TIMELINE PICKER MODAL - Selection-only modal for canvas timeline filter
   ═══════════════════════════════════════════════════════════════════════════ */

/* Pill container that holds both trigger and info icon */
.timeline-picker-pill {
    display: inline-flex;
    align-items: center;
    height: 36px;
    background: #f9f9f9;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    width: fit-content;
    transition: all 0.15s ease;
    overflow: hidden;
}

.timeline-picker-pill:hover {
    background: #f0f0f0;
    border-color: #b0b0b0;
}

/* Show focus ring only for keyboard focus (prevents "sticky" rings after mouse clicks). */
.timeline-picker-pill:has(:focus-visible) {
    background: white;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Trigger button inside the pill (takes up most of the space) */
.timeline-picker-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0 8px 0 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    overflow: hidden;
}

.timeline-picker-trigger:focus {
    outline: none;
}

.timeline-picker-trigger-icon {
    display: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gradient-primary);
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 650;
    line-height: 1;
    letter-spacing: 0.4px;
    color: white;
    text-transform: uppercase;
}

.timeline-picker-trigger-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 24px;
    text-align: left;
    min-width: 0;
}

.timeline-picker-trigger-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-picker-trigger-stack {
    display: none;
    align-items: center;
    flex-shrink: 0;
    margin-left: 2px;
}

.timeline-picker-trigger-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 650;
    line-height: 1;
    letter-spacing: 0.3px;
    color: white;
    text-transform: uppercase;
    border: 2px solid var(--panel-bg, #fff);
    box-sizing: content-box;
}

.timeline-picker-trigger-avatar + .timeline-picker-trigger-avatar {
    margin-left: -6px;
}

.timeline-picker-trigger-more {
    font-size: 11px;
    font-weight: 500;
    color: #777;
    margin-left: 4px;
    flex-shrink: 0;
}

/* Embedded info button inside timeline picker pill (legacy — desktop) */
.timeline-info-btn-embedded {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 8px;
    margin-right: 4px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
    color: #999;
    font-size: 0.85em;
    font-weight: 400;
}

.timeline-info-btn-embedded:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #666;
}

.timeline-info-btn-embedded:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 1px;
    color: #666;
}

/* ── Timeline Caret (▾) button ── */
.timeline-caret-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 8px;
    margin-right: 4px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
    color: #333;
    font-size: 17px;
    font-weight: 400;
}

.timeline-caret-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #666;
}

.timeline-caret-btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 1px;
    color: #666;
}

/* ── Timeline Location Back Button (base / desktop: hidden) ── */
.timeline-location-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #333;
    flex-shrink: 0;
}

.timeline-location-back-btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 1px;
}

/* Overlay backdrop */
.timeline-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1200; /* Above modal-nested (1050) and other nested modals (1100) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

/* Modal content container */
.timeline-picker-content {
    background: var(--color-surface-1);
    border-radius: var(--radius-lg);
    max-width: 480px;
    width: 100%;
    /* Keep the modal at a stable height so expanding filters pushes the list down
       instead of resizing the whole modal (matches tall "group" modal feel). */
    height: 85vh;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Sheet handle: hidden by default (desktop); shown on iPhone via 8-iphone.css */
.timeline-picker-sheet-handle {
    display: none;
}

/* Header row */
.timeline-picker-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--panel-space-3, 12px);
    padding: var(--panel-space-4, 16px) var(--panel-space-6, 24px);
    padding-right: calc(var(--panel-space-6, 24px) + 40px);
    border-bottom: 1px solid var(--panel-border-subtle, var(--color-border-lighter));
    flex-shrink: 0;
    position: relative;
}

.timeline-picker-title {
    font-size: var(--panel-font-title-size, 1.35em);
    font-weight: var(--panel-font-title-weight, 600);
    color: var(--panel-text, var(--color-text-primary));
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.timeline-picker-header-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}

.timeline-picker-profile-context {
    margin-top: -2px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
}

.timeline-picker-profile-context:focus-visible {
    outline: 2px solid var(--color-primary, #667eea);
    outline-offset: 2px;
    border-radius: 6px;
}

#timeline-picker-modal .timeline-picker-sticky-footer {
    padding-bottom: calc(var(--spacing-16, 16px) + env(safe-area-inset-bottom, 0px));
}

.timeline-picker-profile-dropdown {
    padding: 8px 12px;
    border-bottom: 0;
    flex-shrink: 0;
}

.timeline-picker-divider {
    height: 1px;
    background: var(--panel-border-subtle, var(--color-border-lighter));
    margin: 8px 0;
}

.timeline-picker-close {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    font-size: 1.1em;
    color: var(--color-text-tertiary);
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
    line-height: 1;
    transition: background-color 0.15s ease, color 0.15s ease;
    z-index: 2;
}

.timeline-picker-close:hover {
    background-color: rgba(0, 0, 0, 0.08);
    color: var(--color-text-secondary);
}

.timeline-picker-search {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    font-size: 0.9375rem;
    background: #fafafa;
    color: var(--color-text-primary);
    outline: none;
    transition: all 0.15s ease;
}

.timeline-picker-search::placeholder {
    color: #999;
}

.timeline-picker-search:focus {
    background: white;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Filter Panel - matches sidebar filter panel styling */
.timeline-picker-filter-panel {
    padding: 0;
    margin: 0;
    background: var(--color-bg-primary);
    border-bottom: 0;
    position: relative;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.2s ease, opacity 0.2s ease, padding 0.2s ease;
    box-shadow: none;
}

.timeline-picker-filter-panel:not(.is-hidden) {
    max-height: 400px;
    opacity: 1;
    padding: 0 20px;
    margin-top: 4px;
    border-top: 1px solid var(--color-border-light);
    border-bottom: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-xs);
    /* Allow caret to render outside the panel bounds */
    overflow: visible;
}

/* Caret / anchor indicator - points to filter button */
.timeline-picker-filter-panel::before {
    content: '';
    position: absolute;
    top: -5px;
    left: var(--timeline-picker-caret-left, 50%);
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: var(--color-bg-primary);
    border-left: 1px solid var(--color-border-light);
    border-top: 1px solid var(--color-border-light);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1;
}

.timeline-picker-filter-panel:not(.is-hidden)::before {
    opacity: 1;
}

.timeline-picker-filter-panel-inner {
    overflow: auto;
    min-height: 0;
    max-height: min(340px, 55vh);
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

/* Clear button positioned at top right of filter panel */
.timeline-picker-filter-clear-top {
    position: absolute;
    top: 12px;
    right: 20px;
    z-index: 1;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.8em;
    cursor: pointer;
    padding: 0;
    font-family: var(--font-family-base);
}

.timeline-picker-filter-clear-top:hover:not(:disabled) {
    color: var(--color-primary);
    text-decoration: underline;
}

.timeline-picker-filter-clear-top:focus {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
}

.timeline-picker-filter-clear-top:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.timeline-picker-filter-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-picker-filter-section:last-child {
    margin-bottom: 0;
}

.timeline-picker-filter-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.timeline-picker-filter-title {
    font-size: 0.85em;
    font-weight: 400;
    color: var(--color-text-muted);
    text-transform: lowercase;
}

/* Legacy clear button styles (kept for backwards compatibility) */
.timeline-picker-filter-clear {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-size: 0.8em;
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.timeline-picker-filter-clear:hover {
    color: var(--color-text-primary);
}

.timeline-picker-filter-clear:focus {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
}

/* Checkbox group for attributes */
.timeline-picker-filter-checkbox-group {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px 12px;
    padding: 4px 3px;
}

.timeline-picker-filter-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88em;
    color: var(--color-text-primary);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.timeline-picker-filter-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.timeline-picker-filter-checkbox-label:hover {
    color: var(--color-text-primary);
}

.timeline-picker-filter-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 3px;
}

.timeline-picker-filter-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 9px;
    border-radius: 999px;
    border: 1px solid var(--color-border-light);
    background: var(--color-brand-primary-10, #e3f2fd);
    color: var(--color-text-primary);
    font-size: 0.8em;
    font-family: var(--font-family-base);
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.timeline-picker-filter-chip:hover {
    background: var(--color-surface-4);
    border-color: var(--color-border-strong, var(--color-border-medium));
}

.timeline-picker-filter-chip[aria-pressed="true"] {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.timeline-picker-filter-chip:focus {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.timeline-picker-filter-tag-row {
    border: 1px solid var(--color-border-medium);
    border-radius: 10px;
    background: var(--color-bg-secondary);
    overflow: hidden; /* ensures rounded corners aren't clipped by scrollbar */
}

.timeline-picker-filter-tag-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    max-height: 92px; /* ~2 rows of chips + scroll */
    overflow-y: auto;
    overflow-x: hidden;
}

.timeline-picker-filter-hint {
    font-size: 0.85em;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Scrollable list body */
.timeline-picker-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--yrh-scrollbar-thumb) var(--yrh-scrollbar-track);
}

.timeline-picker-body::-webkit-scrollbar {
    width: var(--yrh-scrollbar-size);
}

.timeline-picker-body::-webkit-scrollbar-track {
    background: var(--yrh-scrollbar-track);
    margin: 4px 0;
}

.timeline-picker-body::-webkit-scrollbar-thumb {
    background: var(--yrh-scrollbar-thumb);
    border-radius: var(--yrh-scrollbar-thumb-radius);
    border: var(--yrh-scrollbar-thumb-border) solid transparent;
    background-clip: padding-box;
}

.timeline-picker-body::-webkit-scrollbar-thumb:hover {
    background: var(--yrh-scrollbar-thumb-hover);
    border: var(--yrh-scrollbar-thumb-border) solid transparent;
    background-clip: padding-box;
}

/* ─────────────────────────────────────────────────────────────────────────
   Calm Timeline Picker (visual only)
   Scope these overrides to the timelines selection modal.
   ───────────────────────────────────────────────────────────────────────── */

#timeline-picker-modal .timeline-picker-list {
    padding: 0;
}

/* Profile section: add a single subtle divider only when expanded */
#timeline-picker-modal #timeline-picker-profile-dropdown {
    padding: 0;
    border-bottom: 0;
}

#timeline-picker-modal #timeline-picker-profile-dropdown[aria-hidden="false"] {
    border-bottom: 1px solid var(--panel-border-subtle, var(--color-border-lighter));
    padding-bottom: 8px;
    margin-bottom: 8px;
}

/* Remove spreadsheet-like dividers between rows (keep only the single divider element) */
#timeline-picker-modal .timeline-picker-list .sl-row {
    border-top: 0 !important;
    border-bottom: 0 !important;
}

/* Remove any bottom-most closing divider */
#timeline-picker-modal .timeline-picker-list .sl-row:last-child {
    border-bottom: 0 !important;
}

/* Increase breathing room + consistent insets */
#timeline-picker-modal .timeline-picker-list .sl-row {
    padding: 18px 20px;
    padding-left: 24px;
}

/* Selected: ambient + calm (no left accent rail; rely on background + typography) */
#timeline-picker-modal .timeline-picker-list .sl-row.sl-selected {
    background: rgba(102, 126, 234, 0.055);
    box-shadow: none;
}

#timeline-picker-modal .timeline-picker-list .sl-row.sl-selected:hover:not(.sl-disabled) {
    background: rgba(102, 126, 234, 0.065);
}

/* Typography hierarchy: special rows slightly lighter than timeline names */
#timeline-picker-modal .timeline-picker-sections .sl-row[data-value^="mode:"] .sl-title {
    font-weight: 520;
}

#timeline-picker-modal .timeline-picker-sections .sl-row[data-value^="tl:"] .sl-title {
    font-weight: 560;
    opacity: 0.95;
}

/* Selected timeline rows: gently grounded (slightly heavier, full opacity) */
#timeline-picker-modal .timeline-picker-sections .sl-row.sl-selected[data-value^="tl:"] .sl-title {
    font-weight: 610;
    opacity: 1;
}

.timeline-picker-sections {
    display: flex;
    flex-direction: column;
}

.timeline-picker-section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 400;
    color: var(--color-text-muted);
}

.timeline-picker-section-toggle:hover {
    background: var(--yrh-apple-row-hover-bg);
}

.timeline-picker-section-toggle:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: -2px;
    border-radius: 8px;
}

.timeline-picker-section-count {
    margin-left: auto;
    color: var(--color-text-tertiary);
}

.timeline-picker-section-caret {
    color: var(--color-text-tertiary);
    transition: transform 0.15s ease;
}

.timeline-picker-section.is-collapsed .timeline-picker-section-caret {
    transform: rotate(-90deg);
}

.timeline-picker-section.is-collapsed .timeline-picker-list {
    display: none;
}

.timeline-picker-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual timeline row */
.timeline-picker-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-12);
    border: 2px solid var(--color-border-light);
    border-radius: 8px;
    background: var(--color-bg-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.timeline-picker-item:last-child {
    /* No special styling needed with gap */
}

.timeline-picker-item:hover {
    background: var(--color-bg-tertiary);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-primary-sm);
}

.timeline-picker-item.is-active {
    background: rgba(102, 126, 234, 0.08);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-primary-sm);
}

.timeline-picker-item.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--color-bg-primary);
    border-color: var(--color-border-lighter);
}

.timeline-picker-item.is-disabled:hover {
    background: var(--color-bg-primary);
    border-color: var(--color-border-lighter);
    box-shadow: none;
}

/* Timeline avatar (circle) */
.timeline-picker-item-color {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.1em;
}

/* Timeline info column */
.timeline-picker-item-info {
    flex: 1;
    min-width: 0;
}

/* Timeline Picker: per-row "open" action (does not change selection) */
.timeline-picker-open-btn {
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--color-border-light);
    background: transparent;
    color: var(--color-text-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 400;
}

.timeline-picker-open-btn:hover {
    color: var(--color-primary);
    border-color: rgba(102, 126, 234, 0.35);
    background: rgba(102, 126, 234, 0.08);
}

.timeline-picker-open-btn:active {
    transform: scale(0.98);
}

.timeline-picker-open-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.timeline-picker-item-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-picker-item-meta {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.timeline-picker-item-associated {
    font-size: 0.75rem;
    font-style: italic;
    color: var(--color-text-muted);
    position: absolute;
    right: var(--spacing-12);
    top: 50%;
    transform: translateY(-50%);
}

/* Empty state */
.timeline-picker-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.9375rem;
}

.timeline-picker-empty .btn-text-link {
    margin-top: 8px;
    color: var(--color-primary);
    background: none;
    border: none;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9375rem;
}

/* Special items (All, None) - maintain standard weight */

/* Filter button in search row */
.timeline-picker-filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    width: 36px;
    height: 36px;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

.timeline-picker-filter-btn svg {
    width: 18px;
    height: 18px;
    color: var(--color-text-primary);
}

.timeline-picker-filter-btn:hover {
    background: var(--color-bg-secondary);
    border-color: var(--color-primary);
}

.timeline-picker-filter-btn:focus {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.timeline-picker-filter-btn[aria-expanded="true"] {
    background: var(--color-bg-secondary);
    border-color: var(--color-primary);
}

.timeline-picker-search-row {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

/* When the filter panel is open, let the panel provide the top divider (avoids a double bar). */
.timeline-picker-search-row.is-filter-open {
    border-bottom: 0;
}

.timeline-picker-search {
    flex: 1;
}

/* Active Filters Indicator (shown when panel collapsed) */
.timeline-picker-active-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(99, 102, 241, 0.08);
    border-bottom: 1px solid var(--color-border-light);
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.timeline-picker-active-filters-label {
    color: var(--color-text-secondary);
    font-weight: 600;
    text-transform: lowercase;
}

.timeline-picker-active-filters-text {
    color: var(--color-text-primary);
    flex: 1;
}

.timeline-picker-active-filters-clear {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color var(--transition-fast);
}

.timeline-picker-active-filters-clear:hover {
    color: var(--color-text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .timeline-picker-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .timeline-picker-content {
        max-width: 100%;
        height: 85vh;
        max-height: 85vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .timeline-picker-trigger {
        max-width: 200px;
        min-width: 100px;
    }
}


/* Responsive Design */


