/* Golden Hour Manuscript Base Tokens additions */
--km-surface-glass: rgba(255, 253, 249, 0.95);
--glass-bg: var(--km-surface-glass);
--shadow-float: 0 8px 30px rgba(44, 58, 71, 0.08);
}

/* ChatStage & StudioActionTray */
[data-component="chat-stage"] .chat-container {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

[data-component="chat-stage"] .msg-bubble {
    background: #fff;
    border: 1px solid var(--km-border);
    border-radius: 12px;
    padding: 20px;
    line-height: 1.6;
    position: relative;
}

[data-component="chat-stage"] .msg-bubble::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 20px;
    width: 3px;
    height: 40px;
    background: var(--km-teal);
    border-radius: 0 4px 4px 0;
}

[data-component="chat-stage"] .interactive-key {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--km-accent-light);
    color: var(--km-teal);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

[data-component="chat-stage"] .interactive-key:hover {
    background: #fff;
    border-color: var(--km-teal);
    box-shadow: 0 2px 8px rgba(42, 75, 89, 0.15);
    transform: translateY(-1px);
}

[data-component="studio-tray"] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed var(--km-border);
}

[data-component="studio-tray"] .tray-actions {
    display: flex;
    gap: 8px;
}

[data-component="studio-tray"] .tray-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--km-text-light);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

[data-component="studio-tray"] .tray-btn:hover {
    background: #fff;
    border-color: var(--km-border);
    color: var(--km-teal);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

[data-component="studio-tray"] .karma-cost {
    font-size: 0.75rem;
    color: var(--km-amber);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* FloatingInputIsland */
[data-component="floating-input-island"] .input-wrapper {
    display: flex;
    align-items: flex-end;
    height: 100%;
    padding: 20px;
}

[data-component="floating-input-island"] .input-island {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    padding: 8px 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

[data-component="floating-input-island"] .island-btn {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

[data-component="floating-input-island"] .btn-plus {
    background: #f0f0f0;
    color: var(--km-text);
    font-size: 1.2rem;
}

[data-component="floating-input-island"] .btn-send {
    background: var(--km-teal);
    color: #fff;
}

[data-component="floating-input-island"] .island-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 4px;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 120px;
    color: var(--km-text);
}

[data-component="floating-input-island"] .island-input::placeholder {
    color: #999;
}

/* Dashboard + ContextPeek */
[data-component="dashboard"] .mini-dash {
    background: #fff;
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    border-bottom: 1px solid var(--km-border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

[data-component="dashboard"] .chart-chip {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--km-border);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--km-text-light);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

[data-component="dashboard"] .chart-chip.active {
    background: var(--km-teal);
    color: #fff;
    border-color: var(--km-teal);
}

[data-component="dashboard"] .chart-chip.pulse {
    animation: pulseBorder 2s infinite;
    border-color: var(--km-amber);
}

@keyframes pulseBorder {
    0% {
        box-shadow: 0 0 0 0 rgba(207, 144, 3, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(207, 144, 3, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(207, 144, 3, 0);
    }
}

[data-component="context-peek"] .context-peek-area {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
}

/* Context Peek — "Whispered Annotation" Refinement */
.context-peek-card {
    background: rgba(250, 247, 242, 0.98) !important; /* Manuscript Ivory, Solid for performance */
    border: 1px solid rgba(207, 144, 3, 0.3) !important;
    border-radius: 8px;
    padding: 14px 18px;
    width: 240px;
    box-shadow: 0 12px 32px rgba(28, 28, 21, 0.15);
    position: fixed;
    transform: translateY(10px);
    opacity: 0;
    transition: transform 0.05s ease-out, opacity 0.05s ease-out;
    z-index: 12000;
    pointer-events: none;
    color: #333333;
}

.context-peek-card.active {
    opacity: 1;
    transform: translateY(0);
}

.peek-header {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--km-amber);
    margin-bottom: 4px;
    font-weight: 800;
    border-bottom: 1px solid rgba(207, 144, 3, 0.2);
    padding-bottom: 4px;
}

.peek-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.1rem;
    color: var(--km-teal);
    margin: 6px 0 4px 0;
    font-weight: 700;
}

.peek-desc {
    font-size: 0.85rem;
    color: #4A4A4A;
    /* Dark enough for readability, softer than black */
    line-height: 1.5;
    margin: 0;
}

/* ============================================================
   Invocation Panel (Experience Modal Refinement)
   - "Same stream, different form"
   - Tonal layering instead of borders
   - Premium Sacred UI
   ============================================================ */

/* Overlay / Backdrop */
[data-mounted="proto-experience-modal"] {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(18, 25, 33, 0);
    /* NO backdrop-filter — full-screen blur is a GPU killer */
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.08s ease, visibility 0.08s ease, background 0.08s ease;
}

[data-mounted="proto-experience-modal"].active {
    opacity: 1;
    visibility: visible;
    background: rgba(18, 25, 33, 0.5);
}

/* The Modal Surface (Inner Card) */
[data-mounted="proto-experience-modal"] .bottom-sheet {
    border-radius: 24px 24px 0 0;
    padding: 0;
    box-shadow: 0 -16px 48px rgba(28, 28, 21, 0.15);
    width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 8px);
    transform: translateY(100%);
    /* GPU-primed compositor-only animation — no layout/paint cost */
    will-change: transform;
    transition: transform 0.1s cubic-bezier(0.33, 1, 0.68, 1);
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #FAF7F2;
    /* Solid Ivory — no blur needed, overlay handles dim */
}

[data-mounted="proto-experience-modal"].active .bottom-sheet {
    transform: translateY(0);
}

[data-mounted="proto-experience-modal"] .sheet-handle {
    width: 48px; height: 5px;
    background: #e6e2d8;
    border-radius: 10px;
    margin: 16px auto 8px auto;
}

[data-mounted="proto-experience-modal"] .sheet-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #9ea7a7;
    font-size: 1.2rem;
    z-index: 10;
    border-radius: 50%;
    transition-property: background-color, color, transform;
    transition-duration: 90ms;
    transition-timing-function: ease-out;
}

[data-mounted="proto-experience-modal"] .sheet-close:hover {
    background: rgba(0, 66, 66, 0.05);
    color: var(--km-teal);
    transform: scale(1.02);
}

[data-mounted="proto-experience-modal"] .sheet-content {
    padding: 8px 24px 40px 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

/* Title — Premium Scholarly Header */
[data-mounted="proto-experience-modal"] .sheet-title {
    font-family: 'Cinzel Decorative', serif;
    color: var(--km-teal);
    font-size: 1.5rem;
    margin: 0;
    text-align: center;
    letter-spacing: -0.5px;
}

/* Setting group */
[data-mounted="proto-experience-modal"] .setting-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

[data-mounted="proto-experience-modal"] .group-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

[data-mounted="proto-experience-modal"] .group-label {
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--km-amber);
}

[data-mounted="proto-experience-modal"] .icon-gold {
    color: var(--km-amber);
    font-size: 1.25rem;
}

/* Segmented Control — Premium Pills */
[data-mounted="proto-experience-modal"] .segment-control {
    display: flex;
    background: #fdf9ee;
    border-radius: 14px;
    padding: 6px;
    gap: 6px;
}

[data-mounted="proto-experience-modal"] .segment-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    cursor: pointer;
    border-radius: 10px;
    user-select: none;
    /* Only compositor-friendly properties — no box-shadow, no background transition */
    transition: transform 75ms ease-out, background-color 75ms ease-out, border-color 75ms ease-out, color 75ms ease-out;
    background: transparent;
    border: 1px solid transparent;
}

[data-mounted="proto-experience-modal"] .btn-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--km-teal);
}

[data-mounted="proto-experience-modal"] .btn-subtext {
    font-size: 0.7rem;
    color: #6f7979;
    font-weight: 500;
    margin-top: 2px;
}

[data-mounted="proto-experience-modal"] .segment-btn.active {
    background: #e9c349;
    /* Secondary Fixed Dim */
    border-color: rgba(207, 144, 3, 0.1);
    transform: scale(1.02);
    /* Selected Ritual Feel */
}

[data-mounted="proto-experience-modal"] .segment-btn.active .btn-text {
    color: #241a00;
}

[data-mounted="proto-experience-modal"] .segment-btn.active .btn-subtext {
    color: #574500;
}

[data-mounted="proto-experience-modal"] .segment-btn:hover:not(.active) {
    background: #ffffff;
    border-color: rgba(0, 66, 66, 0.1);
    transform: translateY(-1px);
}

/* Tab Style for Depth */
[data-mounted="proto-experience-modal"] .segment-control.tab-style {
    background: #f7f3e8;
}

[data-mounted="proto-experience-modal"] .tab-style .segment-btn {
    padding: 14px 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: #6f7979;
}

[data-mounted="proto-experience-modal"] .tab-style .segment-btn.active {
    background: #ffffff;
    color: var(--km-teal);
}

/* Generate Button — Premium CTA */
[data-mounted="proto-experience-modal"] .footer-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding-top: 8px;
}

[data-mounted="proto-experience-modal"] .generate-btn {
    width: 100%;
    background: linear-gradient(135deg, #004242 0%, #005b5c 100%);
    color: #fdf9ee;
    border: none;
    border-radius: 16px;
    padding: 18px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 66, 66, 0.2);
    /* compositor-only: no box-shadow transition */
    transition: transform 90ms ease-out, opacity 90ms ease-out;
    opacity: 1;
}

[data-mounted="proto-experience-modal"] .generate-btn:hover {
    transform: scale(0.98);
    opacity: 0.9;
}

[data-mounted="proto-experience-modal"] .karma-cost-label {
    font-size: 0.75rem;
    color: #6f7979;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* DESKTOP OVERRIDE: Shift to Floating Card */
@media (min-width: 1024px) {
    [data-mounted="proto-experience-modal"] {
        justify-content: center;
        align-items: center;
    }

    [data-mounted="proto-experience-modal"] .bottom-sheet {
        width: 420px;
        max-height: min(90dvh, 860px);
        border-radius: 24px;
        transform: scale(0.92) translateY(20px);
        opacity: 0;
        /* Explicitly override base transition to include opacity */
        will-change: transform, opacity;
        transition: transform 0.15s cubic-bezier(0.33, 1, 0.68, 1), opacity 0.12s ease;
    }

    [data-mounted="proto-experience-modal"].active .bottom-sheet {
        transform: scale(1) translateY(0);
        opacity: 1;
    }

    [data-mounted="proto-experience-modal"] .sheet-handle {
        display: none;
    }

    [data-mounted="proto-experience-modal"] .sheet-content {
        padding-top: 40px;
    }
}



/* StageView */
[data-component="stage-view"] {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
}

[data-component="stage-view"] .stage-container {
    flex: 1;
    background: linear-gradient(135deg, var(--km-bg-sidebar) 0%, #F5EFE1 100%);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    height: 100%;
    width: 100%;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-component="stage-view"] .stage-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center,
            rgba(0, 0, 0, 0.05),
            transparent 70%);
    pointer-events: none;
}

[data-component="stage-view"] .stage-container.active {
    transform: translateY(0);
}

.stage-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.stage-close {
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--km-muted);
}

.stage-close:hover {
    color: var(--km-amber);
}

.narration-strip {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.85); /* Solid background for performance */
    color: #fff;
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 30%;
    z-index: 100;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.narration-strip .subtitle {
    font-family: var(--km-font-sans, sans-serif);
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    overflow-y: auto;
    width: 100%;
    max-width: 800px;
    margin-bottom: 8px;
}

.state-feedback.hidden {
    display: none;
}

/* Concept Slides — Scholarly Presentation Layer */
.concept-slide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 80%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.concept-slide.active {
    opacity: 1;
}

.slide-icon {
    font-family: 'Material Symbols Outlined';
    font-size: 4rem;
    color: var(--km-teal);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 2.2rem;
    color: var(--km-teal);
    margin: 0;
}

.slide-desc {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--km-amber);
    max-width: 500px;
    word-wrap: break-word;
    /* Fix Overflow */
}

.state-feedback {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--km-teal);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    animation: pulseFade 2s infinite;
    z-index: 20;
}

@keyframes pulseFade {
    0% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.8;
    }
}
