/* css/6-canvas.css */

/* ============================================================
   DESIGN TOKEN MIGRATION - TODO
   
   STATUS: Not started
   - Many hard-coded hex colors remain (30+ instances)
   - Many hard-coded rgba overlays remain
   - TODO: Replace all hex/rgba with tokens from css/1-base.css
   
   Use tokens from css/1-base.css instead of hard-coded values.
   Allowed exceptions: literal 1px borders, calc() with tokens
   ============================================================ */

/* === MAIN CANVAS CARD CONTAINER === */
.main-canvas {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: none; /* Outer shadow handled by layout.css */
    border-radius: 0; /* Parent handles radius */
    background: white;
    overflow: hidden;
    max-width: 100%;
}

/* Canvas Header Row */
.main-canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--color-surface-3);
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border-medium);
    gap: 12px;
}

/* LEFT GROUP: Context (menu, timeline, view mode) */
.canvas-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto; /* Don't grow or shrink */
    min-width: 0;
}

/* CENTER GROUP: Reserved for future use - centered in remaining space */
.canvas-header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1; /* Grow to fill space between left and right */
    min-width: 0;
}

/* RIGHT GROUP: Modifiers (filters, layout options) */
.canvas-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto; /* Don't grow or shrink */
    justify-content: flex-end;
    min-width: 0;
}

/* Desktop-only additions (hidden by default so iPhone behavior is unchanged) */
#canvas-you-btn-desktop,
.canvas-header-center {
    display: none;
}

/* Add Event button style - matches Event Manager em-action-btn-primary */
.canvas-add-event-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    margin-left: 8px; /* Extra gap from zoom controls */
    border: 1px solid var(--color-primary, #6366f1);
    border-radius: 8px;
    background: var(--color-primary, #6366f1);
    color: white;
    font-size: 0.875em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.canvas-add-event-btn:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.canvas-add-event-btn svg {
    flex-shrink: 0;
    fill: white;
}

/* ═══════════════════════════════════════════════════════════════════════════
   UNIFIED ADD BUTTON - Primary creation entry point for Canvas
   ═══════════════════════════════════════════════════════════════════════════ */

/* Container for button + dropdown positioning */
.canvas-add-container {
    position: relative;
    display: inline-flex;
}

/* Primary "+ Add" button - Tinted/subtle primary style */
.canvas-add-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px 0 12px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--color-primary, #6366f1);
    font-size: 0.875em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.canvas-add-primary:hover {
    background: rgba(99, 102, 241, 0.14);
    border-color: rgba(99, 102, 241, 0.3);
}

.canvas-add-primary:focus-visible {
    outline: 2px solid var(--color-primary, #6366f1);
    outline-offset: 2px;
    background: rgba(99, 102, 241, 0.12);
}

.canvas-add-primary:active {
    background: rgba(99, 102, 241, 0.16);
    transform: translateY(0);
}

.canvas-add-primary svg {
    flex-shrink: 0;
    stroke: currentColor;
}

.canvas-add-primary span {
    line-height: 1;
}

/* Dropdown menu */
.canvas-add-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 140px;
    padding: 6px 0;
    background: var(--color-bg-primary, white);
    border: 1px solid var(--color-border-light, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 100;
}

.canvas-add-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown menu items */
.canvas-add-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--color-text-primary, #1f2937);
    font-size: 0.875em;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.canvas-add-dropdown-item:hover {
    background: var(--color-bg-secondary, #f3f4f6);
}

.canvas-add-dropdown-item:focus-visible {
    outline: 2px solid var(--color-primary, #6366f1);
    outline-offset: -2px;
    background: var(--color-bg-secondary, #f3f4f6);
}

/* Visual separation from filter controls */
.canvas-add-container + #canvas-default-actions {
    margin-left: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--color-border-lighter, #e5e7eb);
}


/* Ensure right group children display properly */
.canvas-header-right #canvas-default-actions {
    display: flex;
    gap: 10px;
}


/* Responsive: on smaller screens, allow wrapping if needed */
@media (max-width: 900px) {
    .main-canvas-header {
        gap: 12px;
    }
    
    .timeline-picker-pill {
        flex: 0 1 auto;
        width: fit-content;
        max-width: 220px;
    }
    
    /* Collapse Add button to icon-only on smaller screens */
    .canvas-add-primary span {
        display: none;
    }
    
    .canvas-add-primary {
        padding: 0 10px;
        gap: 0;
    }
}

/* Further responsive adjustments for tablet/small desktop */
@media (max-width: 1024px) {
    .main-canvas-header {
        gap: 10px;
    }
    
    .canvas-header-left {
        gap: 6px;
    }
    
    .canvas-header-center {
        gap: 6px;
    }
    
    .canvas-header-right {
        gap: 6px;
    }
    
    .timeline-picker-pill {
        flex: 0 1 auto;
        width: fit-content;
        max-width: 200px;
    }
}

/* Canvas body (scrollable area with canvas) */
.main-canvas-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: white;
    padding: 3.75px 5px 5px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.canvas-startup-shell {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
    opacity: 1;
    visibility: visible;
    transition: opacity 180ms ease, visibility 180ms ease;
    background: #fff;
}

#canvas-wrapper.canvas-startup-complete .canvas-startup-shell {
    opacity: 0;
    visibility: hidden;
}

.canvas-startup-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, 0.08);
    border-top-color: #999;
    border-radius: 50%;
    animation: canvas-startup-spin 0.7s linear infinite;
}

@keyframes canvas-startup-spin {
    to { transform: rotate(360deg); }
}

/* Desktop: contextual Clear · Clear All · Reset (mirrors iPhone strip) */
body.desktop-contextual-utils-enabled #canvas-reset-view-btn {
    display: none;
}

body.desktop-contextual-utils-enabled #clearSelectionBtn {
    display: none;
}

.desktop-contextual-utils {
    position: absolute;
    left: 50%;
    bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-width: 220px;
    z-index: var(--z-sidebar-popover);

    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(2px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.desktop-contextual-utils.is-visible {
    opacity: 0.92;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.desktop-contextual-utils .desktop-contextual-btn {
    background: transparent;
    border: none;
    padding: 10px 10px;
    min-height: 40px;
    line-height: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    opacity: 0.82;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.desktop-contextual-utils .desktop-contextual-sep {
    opacity: 0.82;
    font-size: 16px;
    color: var(--color-text-secondary);
    user-select: none;
}

.desktop-contextual-btn.is-hidden,
.desktop-contextual-sep.is-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

.desktop-contextual-clear:active,
.desktop-contextual-clear-all:active {
    transform: scale(0.985);
    opacity: 0.72;
}

/* ═══════════════════════════════════════════════════════════════════════════
   VIEW MODE CLASSES
   These classes are applied to #canvas-wrapper (.main-canvas-body) by JS.
   Since the timeline is canvas-drawn, the actual layout changes happen
   in the canvas drawing code (5B-canvas-core.js) by reading currentViewMode.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Standard view mode - default layout (timeline axis centered) */
#canvas-wrapper.view-mode-standard {
    /* Default layout - no changes needed */
}

/* Alternate view mode - events above, dates axis at bottom */
#canvas-wrapper.view-mode-alternate {
    /* Canvas drawing code reads currentViewMode to position the axis lower */
}

/* Fixes z-index clipping issue when dropdown is open */
.main-canvas.dropdown-active {
    overflow: visible;
}

/* Drawing canvas: fill the wrapper and disable default touch gestures.
   Scoped to #canvas-wrapper so PDF viewer / other canvases keep their
   own explicit dimensions and native touch behaviour. */
#canvas-wrapper canvas {
    display: block;
    background-color: #fefefe;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: auto;
    touch-action: none;
}

.canvas-callout-title-host {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 3;
}

.canvas-callout-title {
    position: absolute;
    box-sizing: border-box;
    overflow: hidden;
    color: #1a1a1a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
    font-weight: 600;
    text-align: center;
    pointer-events: none;
}

.canvas-callout-title-lines {
    width: 100%;
    will-change: transform;
}

.canvas-callout-title-line {
    display: block;
    width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

canvas:active {
    cursor: grabbing !important;
}

/* --- Canvas Overlays (Headers, Zoom) --- */

/* Canvas Context Switcher Badge - Paired Filter Control */
.canvas-context-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 6px 10px;
    background: #fafafa;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    cursor: default;
    transition: all 0.15s ease;
    margin-right: 8px;
    flex-shrink: 0;
}

.canvas-context-badge:hover {
    background: #fafafa;
    border-color: #d0d0d0;
}

.canvas-context-badge:focus {
    outline: none;
}

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

.canvas-context-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    line-height: 24px;
}

/* Header additions for canvas shell are desktop-only by default */
.canvas-top-brand-icon,
.canvas-top-brand-btn,
#canvas-friend-actions {
    display: none;
}

/* Desktop refinement pass: header comfort, floating add, sidebar search divider, tutorial access via brand icon. */
.canvas-add-fab {
    display: none;
}

/* Tablet and desktop share the same expansive canvas shell.
    The shell mode, not pointer type, decides whether iPad uses desktop chrome. */
html.yrh-shell-desktop .main-canvas-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: var(--z-header);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    height: var(--desktop-canvas-header-height, var(--yrh-shell-header-height, 58px));
    padding: 6px var(--yrh-shell-inline-gutter, 24px);
    box-sizing: border-box;
    background: var(--color-bg-primary, #ffffff);
    border-bottom: 1px solid var(--color-border-medium);
    box-shadow: none;
    overflow: visible;
}

html.yrh-shell-desktop .main-canvas-header > * {
    position: relative;
    z-index: 1;
}

html.yrh-shell-desktop .sidebar,
html.yrh-shell-desktop .sidebar-content,
html.yrh-shell-desktop .sidebar-sort-controls,
html.yrh-shell-desktop .sidebar-filter-panel,
html.yrh-shell-desktop .sidebar-filter-panel-inner {
    background: #ffffff;
}

html.yrh-shell-desktop .sidebar-filter-panel {
    display: none !important;
}

html.yrh-shell-desktop .sidebar {
    border-left-color: var(--color-border-lightest);
    box-shadow: -1px 0 6px var(--color-overlay-dark-05, rgba(0, 0, 0, 0.05));
}

html.yrh-shell-desktop .sidebar-sort-controls {
    border-bottom-color: var(--color-border-lightest);
}

html.yrh-shell-desktop .header {
    display: none;
}

html.yrh-shell-desktop #canvas-sidebar-toggle-btn {
    display: none !important;
}

html.yrh-shell-desktop .canvas-header-left {
    justify-self: start;
    min-width: 0;
}

html.yrh-shell-desktop .canvas-header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    gap: 8px;
    min-width: 0;
    pointer-events: none;
    color: var(--color-text-muted);
    opacity: 0.28;
}

html.yrh-shell-desktop .canvas-header-center-watermark {
    width: 22px;
    height: 22px;
}

html.yrh-shell-desktop .canvas-header-center-wordmark {
    font-family: var(--font-family-base);
    font-size: 18px;
    font-weight: 650;
    letter-spacing: 0.04em;
    color: currentColor;
    opacity: 1;
    line-height: 1;
    white-space: nowrap;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

html.yrh-shell-desktop .canvas-header-right {
    justify-self: end;
    min-width: 0;
}

html.yrh-shell-desktop #canvas-you-btn-desktop {
    display: inline-flex;
    flex: 0 0 auto;
}

html.yrh-shell-desktop #canvas-friend-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

html.yrh-shell-desktop #canvas-avatar-btn {
    display: none;
}

html.yrh-shell-desktop .main-canvas-header #canvas-default-actions {
    display: none;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
}

html.yrh-shell-desktop .main-canvas-header #canvas-add-container {
    display: inline-flex;
}

html.yrh-shell-desktop .main-canvas-header #canvas-add-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-secondary);
    box-shadow: none;
    cursor: pointer;
}

html.yrh-shell-desktop .main-canvas-header #canvas-add-primary:hover {
    background: var(--color-overlay-dark-05);
}

html.yrh-shell-desktop .main-canvas-header #canvas-add-primary:focus-visible {
    outline: 2px solid var(--color-border-light);
    outline-offset: 2px;
    background: var(--color-overlay-dark-05);
}

html.yrh-shell-desktop .main-canvas-header #canvas-add-primary span {
    display: none;
}

html.yrh-shell-desktop .main-canvas-header #canvas-add-primary svg {
    width: 18px;
    height: 18px;
}

html.yrh-shell-desktop .main-canvas-header .timeline-picker-pill {
    height: 34px;
    background: var(--color-overlay-dark-03, rgba(0, 0, 0, 0.03));
    border: 1px solid var(--color-border-lightest);
    border-radius: 999px;
    max-width: 340px;
    min-width: 0;
}

html.yrh-shell-desktop .main-canvas-header .timeline-picker-pill:hover {
    background: var(--color-overlay-dark-05);
    border-color: var(--color-border-lighter);
}

html.yrh-shell-desktop .main-canvas-header .timeline-picker-trigger {
    padding: 0 10px 0 12px;
}

html.yrh-shell-desktop .main-canvas-header .timeline-picker-trigger-label {
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
}

html.yrh-tier-desktop[data-layout-input="touch"] .main-canvas-header {
    padding: 8px var(--yrh-shell-inline-gutter, 28px);
}

/* Tablet (iPad): header extends behind status bar — add safe-area padding */
html.yrh-shell-tablet .main-canvas-header {
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    height: calc(var(--yrh-shell-header-height, 64px) + env(safe-area-inset-top, 0px));
}

html.yrh-tier-desktop[data-layout-input="touch"] .main-canvas-header .timeline-picker-pill {
    height: 40px;
    max-width: 400px;
}

html.yrh-tier-desktop[data-layout-input="touch"] .main-canvas-header .timeline-picker-trigger {
    padding: 0 14px 0 16px;
}

html.yrh-tier-desktop[data-layout-input="touch"] .main-canvas-header .timeline-picker-trigger-label {
    font-size: 14px;
}

html.yrh-tier-desktop[data-layout-input="touch"] .main-canvas-header #canvas-add-primary,
html.yrh-tier-desktop[data-layout-input="touch"] .header-utility-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
}

html.yrh-tier-desktop[data-layout-input="touch"] .main-canvas-body {
    padding: 8px 10px 10px;
}

/* Tablet (iPad): canvas fills edge-to-edge, no white margin */
html.yrh-shell-tablet .main-canvas-body {
    padding: 0;
}

html.yrh-shell-desktop .canvas-add-fab {
    display: none !important;
}

html.yrh-shell-desktop .header-utility-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    color: var(--color-text-secondary);
}

html.yrh-shell-desktop .header-utility-btn:hover {
    background: var(--color-overlay-dark-05);
}

html.yrh-shell-desktop .header-utility-btn:focus-visible {
    outline: 2px solid var(--color-border-light);
    outline-offset: 2px;
    background: var(--color-overlay-dark-05);
}

html.yrh-shell-desktop .header-utility-btn.is-active {
    background: var(--color-overlay-dark-06, rgba(0, 0, 0, 0.06));
}

html.yrh-shell-desktop .canvas-icon-for-header {
    position: relative;
    width: 32px;
    height: 32px;
    background-image: none;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    overflow: visible;
}

html.yrh-shell-desktop .canvas-you-icon {
    border-radius: 50%;
    background-color: #eceff3;
    background-image: var(--yrh-startup-you-icon-image, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='20' fill='%23eceff3'/%3E%3C/svg%3E"));
}

html.yrh-shell-desktop .canvas-you-icon .yrh-profile-photo-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    object-fit: cover;
    pointer-events: none;
    transform: translateZ(0);
    backface-visibility: hidden;
}

html.yrh-shell-desktop .canvas-library-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

html.yrh-shell-desktop .canvas-library-icon .bnav-icon {
    position: static;
    width: 26px;
    height: 26px;
    display: block;
    overflow: visible;
    stroke: var(--color-text-secondary);
    fill: none;
    flex-shrink: 0;
}

html.yrh-shell-desktop .canvas-you-icon::before,
html.yrh-shell-desktop .canvas-account-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    background-color: var(--color-text-secondary);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

html.yrh-shell-desktop .canvas-you-icon::before,
html.yrh-shell-desktop .canvas-account-icon::before {
    content: none;
    display: none;
}

html.yrh-shell-desktop .canvas-account-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

html.yrh-shell-desktop .canvas-account-icon .bnav-icon {
    position: static;
    width: 24px;
    height: 24px;
    display: block;
    overflow: visible;
    stroke: #666;
    fill: none;
    flex-shrink: 0;
}

html.yrh-shell-desktop .header-utility-btn.is-active .canvas-library-icon .bnav-icon {
    stroke: var(--color-primary);
}

html.yrh-shell-desktop .header-utility-btn.is-active .canvas-account-icon .bnav-icon {
    stroke: var(--color-primary);
}

html.yrh-shell-desktop .header-utility-btn.is-active .canvas-you-icon {
    box-shadow: inset 0 0 0 1.5px var(--color-primary);
}

/* DESKTOP-ONLY LAYOUT ADJUSTMENTS */
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    /* Full-width, fixed top bar across canvas + sidebar */
    .main-canvas-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        z-index: var(--z-header);

        /* 3-zone desktop header: Left (You + Timeline), Center (watermark), Right (Account) */
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        align-items: center;

        height: var(--desktop-canvas-header-height, 58px);
        padding: 6px 14px;
        box-sizing: border-box;

        /* Quiet, place-like chrome */
        background: var(--color-bg-primary, #ffffff);
        border-bottom: 1px solid var(--color-border-medium);

        /* Allow dropdowns (e.g., Add menu) to render outside the fixed header. */
        position: fixed;
        overflow: visible;
    }

    /* Disable the watermark layer — center uses the regular logo instead. */
    .main-canvas-header::before {
        content: none;
    }

    /* Ensure header content sits above the watermark layer */
    .main-canvas-header > * {
        position: relative;
        z-index: 1;
    }

    /* Desktop: force sidebar slab to pure white (override gray panel tone) */
    .sidebar,
    .sidebar-content,
    .sidebar-sort-controls,
    .sidebar-filter-panel,
    .sidebar-filter-panel-inner {
        background: #ffffff;
    }

    /* Desktop no longer has a dedicated attributes-panel trigger.
       Keep the sidebar to search + theme + sort + results, and prevent the
       orphaned panel fragment from colliding with the first event row. */
    .sidebar-filter-panel {
        display: none !important;
    }

    .sidebar {
        border-left-color: var(--color-border-lightest);
        box-shadow: -1px 0 6px var(--color-overlay-dark-03, rgba(0, 0, 0, 0.03));
    }

    /* Desktop: keep expanded filter panel flat (no heavy panel shadow) */
    .sidebar-filter-panel.is-open {
        box-shadow: none;
        border-top-color: var(--color-border-lightest);
        border-bottom-color: var(--color-border-lightest);
    }

    .sidebar-filter-panel::before {
        background: #ffffff;
        border-left-color: var(--color-border-lightest);
        border-top-color: var(--color-border-lightest);
    }

    .sidebar-sort-controls {
        border-bottom-color: var(--color-border-lightest);
    }

    /* Hide the old global marketing header on desktop */
    .header { display: none; }

    /* Hide header toggle affordance on desktop; sidebar edge tab owns layout collapse. */
    #canvas-sidebar-toggle-btn { display: none !important; }

    /* Make main canvas header visually lighter and less elevated */
    .main-canvas-header { box-shadow: none; }

    /* Small brand icon shown on desktop only */
    .canvas-top-brand-icon {
        display: inline-block;
        width: 24px;
        height: 24px;
        object-fit: contain;
        margin-right: 8px;
        flex-shrink: 0;
        border-radius: 4px;
    }

    .canvas-top-brand-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        margin: 0;
        border: none;
        background: transparent;
        cursor: pointer;
        border-radius: 6px;
    }

    /* Desktop header spec: keep header minimal (watermark carries the brand) */
    #canvas-getting-started-trigger {
        display: none;
    }

    .canvas-top-brand-btn:focus-visible {
        outline: 2px solid var(--color-border-light);
        outline-offset: 2px;
    }

    /* 3-zone alignment */
    .canvas-header-left {
        justify-self: start;
        min-width: 0;
    }

    .canvas-header-center {
        display: flex;
        align-items: center;
        justify-content: center;
        justify-self: center;
        gap: 8px;
        min-width: 0;
        pointer-events: none;
        color: var(--color-text-muted);
        opacity: 0.28;
    }

    .canvas-header-center-watermark {
        width: 22px;
        height: 22px;
    }

    .canvas-header-center-marker {
        display: block;
        width: 22px;
        height: 22px;
        flex: 0 0 auto;
        stroke: var(--color-text-tertiary);
        stroke-width: 1.6;
        stroke-linecap: round;
        stroke-linejoin: round;
        opacity: 0.34;
    }

    .canvas-header-center-wordmark {
        font-family: var(--font-family-base);
        font-size: 18px;
        font-weight: 650;
        letter-spacing: 0.04em;
        color: currentColor;
        opacity: 1;
        line-height: 1;
        white-space: nowrap;
        -webkit-font-smoothing: antialiased;
        text-rendering: geometricPrecision;
    }

    .canvas-header-right {
        justify-self: end;
        min-width: 0;
    }

    /* Desktop-only You icon (life scope) */
    #canvas-you-btn-desktop {
        display: inline-flex;
        flex: 0 0 auto;
    }


    /* Utility icon group shown on desktop only */
    #canvas-friend-actions {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    /* Desktop: keep only Account on the right */
    #canvas-avatar-btn {
        display: none;
    }

    .main-canvas-header #canvas-default-actions {
        display: none;
    }

    /* Desktop: creation lives in the header left cluster (near the timeline selector).
       Breakpoint toggle lives here (css/6-canvas.css): desktop uses header +, not the old floating FAB. */
    .main-canvas-header #canvas-add-container {
        display: inline-flex;
    }

    /* Desktop: calm icon-only + button (no CTA glow). */
    .main-canvas-header #canvas-add-primary {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0;
        margin: 0;
        border: none;
        border-radius: 8px;
        background: transparent;
        color: var(--color-text-secondary);
        box-shadow: none;
        cursor: pointer;
    }

    .main-canvas-header #canvas-add-primary:hover {
        background: var(--color-overlay-dark-05);
    }

    .main-canvas-header #canvas-add-primary:focus-visible {
        outline: 2px solid var(--color-border-light);
        outline-offset: 2px;
        background: var(--color-overlay-dark-05);
    }

    .main-canvas-header #canvas-add-primary span {
        display: none;
    }

    .main-canvas-header #canvas-add-primary svg {
        width: 18px;
        height: 18px;
    }

    /* Remove the separator that was specifically for the header Add button */
    .main-canvas-header #canvas-default-actions {
        margin-left: 0;
        padding-left: 0;
        border-left: 0;
    }

    /* Timeline selector: compact, subordinate, and width-capped */
    .main-canvas-header .timeline-picker-pill {
        height: 34px;
        background: var(--color-overlay-dark-03, rgba(0, 0, 0, 0.03));
        border: 1px solid var(--color-border-lightest);
        border-radius: 999px;
        max-width: 340px;
        min-width: 0;
    }

    .main-canvas-header .timeline-picker-pill:hover {
        background: var(--color-overlay-dark-05);
        border-color: var(--color-border-lighter);
    }

    .main-canvas-header .timeline-picker-pill:has(:focus-visible) {
        background: var(--color-overlay-dark-03, rgba(0, 0, 0, 0.03));
        border-color: var(--color-border-light);
        box-shadow: 0 0 0 3px var(--color-overlay-dark-05);
    }

    .main-canvas-header .timeline-picker-trigger {
        padding: 0 10px 0 12px;
    }

    .main-canvas-header .timeline-picker-trigger-label {
        color: var(--color-text-secondary);
        font-size: 13px;
        font-weight: 500;
    }

    .main-canvas-header .timeline-info-btn-embedded:focus-visible {
        outline: 2px solid var(--color-border-light);
        outline-offset: 1px;
    }

    /* iPhone-only utility header — hidden globally from 8-iphone.css base rules.
       No per-breakpoint hide needed here. */

    /* Legacy floating FAB retired on desktop (creation is in the header). */
    .canvas-add-fab {
        display: none !important;
    }

    /* Desktop-only: Getting Started modal */
    .desktop-getting-started-overlay {
        position: fixed;
        inset: 0;
        z-index: var(--z-modal);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 24px;
        background: rgba(0, 0, 0, 0.22);
    }

    .desktop-getting-started-panel {
        width: min(520px, 92vw);
        background: var(--color-bg-primary, #ffffff);
        border: 1px solid var(--color-border-light);
        border-radius: 14px;
        box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
        overflow: hidden;
    }

    .desktop-getting-started-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        border-bottom: 1px solid var(--color-border-light);
        background: var(--color-surface-4);
    }

    .desktop-getting-started-title {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
        color: var(--color-text-primary);
    }

    .desktop-getting-started-close {
        width: 34px;
        height: 34px;
        border: none;
        border-radius: 10px;
        background: transparent;
        cursor: pointer;
        color: var(--color-text-secondary);
        font-size: 22px;
        line-height: 1;
    }

    .desktop-getting-started-close:hover {
        background: var(--color-overlay-dark-05);
    }

    .desktop-getting-started-body {
        padding: 14px 16px 16px;
        color: var(--color-text-primary);
    }

    .desktop-getting-started-intro {
        margin: 0 0 12px;
        color: var(--color-text-secondary);
        font-size: 14px;
        line-height: 1.45;
    }

    .desktop-getting-started-section-title {
        font-size: 13px;
        font-weight: 600;
        color: var(--color-text-muted);
        margin-bottom: 8px;
        text-transform: none;
    }

    .desktop-getting-started-list {
        margin: 0;
        padding-left: 18px;
        color: var(--color-text-primary);
        font-size: 14px;
        line-height: 1.5;
    }

    .header-utility-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border-radius: 8px;
        border: none;
        background: transparent;
        cursor: pointer;
        padding: 0;
        color: var(--color-text-secondary);
    }

    .header-utility-btn:hover {
        background: var(--color-overlay-dark-05);
    }

    .header-utility-btn:focus-visible {
        outline: 2px solid var(--color-border-light);
        outline-offset: 2px;
        background: var(--color-overlay-dark-05);
    }

    /* Match legacy icon circles exactly (without labels) */
    .canvas-icon-for-header {
        position: relative;
        width: 32px;
        height: 32px;
        background-image: none;
        background-position: center;
        background-repeat: no-repeat;
        background-size: cover;
        overflow: visible;
    }

    .canvas-you-icon {
        border-radius: 50%;
        background-color: #eceff3;
        background-image: var(--yrh-startup-you-icon-image, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='20' fill='%23eceff3'/%3E%3C/svg%3E"));
    }

    .canvas-you-icon .yrh-profile-photo-img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        display: block;
        border-radius: inherit;
        object-fit: cover;
        pointer-events: none;
        transform: translateZ(0);
        backface-visibility: hidden;
    }

    .canvas-you-icon::before,
    .canvas-account-icon::before {
        content: '';
        position: absolute;
        inset: 0;
        margin: auto;
        width: 18px;
        height: 18px;
        background-color: var(--color-text-secondary);
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-size: contain;
        mask-size: contain;
    }

    .canvas-you-icon::before {
        content: none;
        display: none;
    }

    /* When a real profile photo or initials are set, JS paints the surface directly. */
    .canvas-you-icon.has-photo::before {
        display: none;
    }

    .canvas-account-icon::before {
        content: none;
        display: none;
    }

    .canvas-account-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: visible;
    }

    .canvas-account-icon .bnav-icon {
        position: static;
        width: 24px;
        height: 24px;
        display: block;
        overflow: visible;
        stroke: #666;
        fill: none;
        flex-shrink: 0;
    }
}


/* === Legacy: Canvas dropdown (now hidden, kept for JS compatibility) === */
#canvasTimelineFilter {
    /* Hidden via .is-hidden class in HTML, styles preserved for backwards compatibility */
    height: 36px;
    padding: 6px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    background: #f9f9f9;
    cursor: pointer;
    box-shadow: none;
    position: relative; 
    z-index: var(--z-canvas-event);
    width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 24px;
}

/* Timeline name text display (alternative to dropdown) */
#canvasTimelineNameText {
    padding: 0 15px;
    font-weight: 500;
    color: var(--color-text-primary);
}

/* Container for buttons on the right - moved into header */
#canvas-action-buttons {
    display: flex;
    position: static;
    gap: 8px;
}

/* Show when sidebar is collapsed */
.main-container.sidebar-collapsed #canvas-action-buttons {
    display: flex; 
}

/* --- Time-from-now Chip (top-center canvas overlay) --- */
.time-from-now-chip {
    position: absolute;
    top: 12px;
    left: 50%;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    color: #888;
    border: 1px solid rgba(0, 0, 0, 0.10);
    padding: 4px 10px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: var(--font-weight-normal);
    line-height: 1.3;
    pointer-events: none;
    backdrop-filter: blur(4px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.time-from-now-chip.chip-hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
    pointer-events: none;
}

@keyframes collapsed-filter-chip-fly-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.collapsed-sidebar-filter-chip {
    display: none;
}

@media (min-width: 769px) {
    #canvas-sidebar-toggle-btn {
        display: none !important;
    }

    #sidebarToggleBtn {
        position: absolute;
        top: calc(var(--desktop-canvas-header-height, 58px) + 18px);
        right: calc(var(--yrh-sidebar-width, 400px) - 1px);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 22px;
        height: 48px;
        padding: 0;
        border: 1px solid rgba(15, 23, 42, 0.05);
        border-right: 1px solid rgba(15, 23, 42, 0.06);
        border-radius: 12px 0 0 12px;
        background: var(--color-surface-1, #ffffff);
        color: rgba(85, 85, 85, 0.48);
        cursor: pointer;
        z-index: var(--z-sidebar-overlay);
        box-shadow: -1px 0 2px rgba(15, 23, 42, 0.02);
        transition: right 0.28s ease, color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    }

    html.yrh-tier-desktop[data-layout-input="touch"] #sidebarToggleBtn {
        top: calc(var(--desktop-canvas-header-height, 64px) + 20px);
        width: 26px;
        height: 56px;
    }

    #sidebarToggleBtn:hover {
        color: rgba(85, 85, 85, 0.56);
        background: var(--color-surface-1, #ffffff);
        border-color: rgba(15, 23, 42, 0.07);
        box-shadow: -1px 0 3px rgba(15, 23, 42, 0.03);
    }

    #sidebarToggleBtn:focus-visible {
        outline: 2px solid var(--color-border-light);
        outline-offset: 2px;
        color: rgba(85, 85, 85, 0.6);
        background: var(--color-surface-1, #ffffff);
    }

    .main-container.sidebar-collapsed #sidebarToggleBtn {
        right: 0;
        border-right: 1px solid rgba(15, 23, 42, 0.06);
        border-radius: 12px 0 0 12px;
        box-shadow: -1px 0 3px rgba(15, 23, 42, 0.03);
    }

    .sidebar-edge-tab-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
    }

    .sidebar-edge-tab-chevron {
        width: 12px;
        height: 12px;
        transform: rotate(180deg);
        opacity: 0.82;
        transition: transform 0.22s ease;
    }

    html.yrh-tier-desktop[data-layout-input="touch"] .sidebar-edge-tab-chevron {
        width: 14px;
        height: 14px;
    }

    .sidebar-edge-tab-chevron path {
        stroke-width: 1.35;
    }

    .main-container.sidebar-collapsed .sidebar-edge-tab-chevron {
        transform: rotate(0deg);
    }

    .collapsed-sidebar-filter-chip {
        position: absolute;
        top: 18px;
        left: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 32px;
        max-width: min(320px, calc(100% - 56px));
        padding: 0 14px;
        border: 1px solid rgba(15, 23, 42, 0.06);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.82);
        color: rgba(107, 114, 128, 0.76);
        font-size: 12px;
        font-weight: 500;
        letter-spacing: 0.01em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        backdrop-filter: blur(12px);
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
        z-index: var(--z-canvas-overlay);
        opacity: 1;
        transform: translateX(-50%) translateY(0);
        will-change: opacity, transform;
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    .collapsed-sidebar-filter-chip:hover {
        color: rgba(107, 114, 128, 0.76);
    }

    .collapsed-sidebar-filter-chip:focus-visible {
        outline: 2px solid var(--color-border-light);
        outline-offset: 2px;
        color: rgba(107, 114, 128, 0.76);
    }

    .collapsed-sidebar-filter-chip.is-hidden {
        opacity: 0;
        transform: translateX(-50%) translateY(-8px);
        pointer-events: none;
        visibility: hidden;
    }

    .collapsed-sidebar-filter-chip:not(.is-hidden) {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
        visibility: visible;
        animation: collapsed-filter-chip-fly-in 0.3s ease;
    }
}

/* --- Comparison / Focus Bar --- */
.difference-text {
    font-size: 0.9em;
    line-height: 1.2; 
    color: #333;
    text-align: center;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word; 
}

.focus-mode-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background-color: #fff8e1; 
    border: 1px solid #ffe58f;
    border-radius: 8px;
    padding: 8px 20px;
    height: auto;
    white-space: nowrap;
}

.focus-mode-indicator span {
    font-weight: 600;
    color: #6d4c00;
}

.event-focus-btn {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(100, 100, 100, 0.4);
    color: #333;
    font-size: 13px;
    padding: 2px 8px;
    border-radius: 5px;
    cursor: pointer;
    z-index: var(--z-canvas-cluster);
    font-weight: 600;
}
.event-focus-btn:hover {
    background: rgba(255, 255, 255, 1);
}

/* --- Timeline Info Modal --- */
.timeline-info-field {
    margin-bottom: 16px;
    line-height: 1.6;
}

.timeline-info-field:last-child {
    margin-bottom: 0;
}

.timeline-info-field strong {
    display: inline-block;
    min-width: 90px;
    color: var(--color-text-primary, #1f2937);
    font-weight: 600;
}

.timeline-info-field span {
    color: var(--color-text-secondary, #4b5563);
}

/* --- Year Filter Chip (Sidebar) --- */
.year-filter-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin: 8px 16px 4px;
    background: rgba(255, 215, 0, 0.1); /* Light gold background */
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 6px;
    font-size: 0.875em;
    transition: all 0.2s ease;
}

.year-filter-chip.is-hidden {
    display: none;
}

.filter-chip-label {
    color: var(--color-text-secondary, #6b7280);
    font-weight: 500;
}

.filter-chip-value {
    color: var(--color-text-primary, #1f2937);
    font-weight: 600;
}

.filter-chip-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 2px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    color: var(--color-text-secondary, #6b7280);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-chip-clear:hover {
    background: rgba(0, 0, 0, 0.2);
    color: var(--color-text-primary, #1f2937);
}

/* --- Year Filter Toast (Collapsed Sidebar) --- */
.year-filter-toast {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-size: 0.85em;
    z-index: var(--z-canvas-overlay);
    animation: slideUp 0.3s ease-out;
}

.year-filter-toast.is-hidden {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.year-filter-toast-text {
    color: var(--color-text-primary, #1f2937);
}

.year-filter-toast-text strong {
    color: #b8860b; /* Dark gold for year emphasis */
    font-weight: 700;
}

.year-filter-toast-action {
    padding: 4px 10px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 4px;
    background: transparent;
    color: var(--color-primary, #6366f1);
    font-size: 0.8em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.year-filter-toast-action:hover {
    background: var(--color-primary, #6366f1);
    color: white;
}

.year-filter-toast-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text-secondary, #6b7280);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.year-filter-toast-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--color-text-primary, #1f2937);
}
