/* --- 1. Global Setup (Centered) --- */
body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-size: cover;
    color: #333;
    perspective: 1000px;
    overflow: hidden;
}

/* --- 2. Main Containers --- */
.main-stack-wrapper {
    position: relative;
    width: 720px;
    height: 540px;
    transform: translate3D(20px, 30px, 0);
}

.note-stack-container {
    position: absolute;
    isolation: isolate;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* --- 3. Individual Note Styling (Frosted Glass Effect) --- */
.frosted-note {
    position: absolute;
    width: 640px;
    height: 480px;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);

    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(3px) saturate(100%);
    -webkit-backdrop-filter: blur(3px) saturate(100%);

    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.3s ease-out,
        z-index 0s;

    display: flex;
    flex-direction: column;
    transform: translate(0, 0) rotate(0deg);
    cursor: pointer;

    z-index: 1;
}

@media screen and (max-width: 767px) {
    .frosted-note {
        width: 87%;
    }

    .main-stack-wrapper {
        width: 90%;
    }
}

/* --- FIXED: Sticky Note Tab Styling (Frosted Glass Restored) --- */
.note-tab {
    position: absolute;
    top: -37px;

    background: rgba(255, 255, 255, 0.4);

    padding: 5px 12px;
    border-radius: 8px 8px 0 0;
    font-size: 16px;
    font-weight: bold;
    color: #444;

    box-shadow: none;
    border: none;

    z-index: 1;
    cursor: pointer;
    pointer-events: auto;
    /* Ensure clicks are possible */
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 150px;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Title/Body Styling (Unchanged) */
.frosted-note h3 {
    margin-top: 0;
    padding-top: 5px;
    font-size: 1.6em;
    color: #000000;
    flex-shrink: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.7);
    text-align: center;
}

.note-body {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 5px;
}

/* Styles for Gold Price Note (Note 2) */
#chart-controls {
    display: flex;
    justify-content: space-around;
    padding: 5px 0 20px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.7);
}

#chart-controls button {
    font-size: 12px;
    padding-top: 1px;
    width: 120px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media screen and (max-width: 767px) {
    #chart-controls button {
        width: 90px;
    }
}

#chart-controls button.active {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* MODIFIED: Chart area now only sets container size, canvas handles rendering */
#chart-area {
    height: 280px;
    margin-bottom: 10px;
    position: relative;
    /* Important for chart responsiveness */
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    padding: 5px;
}

#chart-debug-data {
    font-size: 0.8em;
    padding: 5px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
    max-height: 80px;
    overflow-y: auto;
}

#chart-debug-data ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

#chart-debug-data li {
    margin-bottom: 2px;
    border-bottom: 1px dotted rgba(0, 0, 0, 0.1);
}

/* Styles for Trending Data Note (Note 1) */
.trending-platform {
    margin-bottom: 20px;
}

.trending-platform h4 {
    margin: 5px 0;
    color: #1a0dab;
    font-size: 1.1em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 5px;
}

.trending-platform ol {
    padding-left: 20px;
    margin: 5px 0;
    list-style-type: none;
    counter-reset: trend-counter;
}

.trending-platform ol li {
    counter-increment: trend-counter;
    margin-bottom: 5px;
    font-size: 0.95em;
}

.trending-platform ol li::before {
    content: counter(trend-counter) ". ";
    font-weight: bold;
    color: #000;
    margin-right: 5px;
}

.trending-platform ol li a {
    text-decoration: none;
    color: #444;
}

.trending-platform ol li a:hover {
    text-decoration: underline;
    color: #000;
}

/* --- 4. Layering and Initial Positions (Horizontal Staggering) --- */
/* All notes are top-aligned. Tabs are independently positioned horizontally. */

/* Note 2 (Top) */
.frosted-note[data-note="2"] {
    transform: translate(20px, 0px);
    z-index: 2;
}

.frosted-note[data-note="2"] .note-tab {
    left: 20px;
}

/* Note 1 (Bottom) */
.frosted-note[data-note="1"] {
    transform: translate(20px, 0px);
    z-index: 1;
}

.frosted-note[data-note="1"] .note-tab {
    left: 140px;
}

/* --- 5. Active State --- */
.frosted-note.active {
    z-index: 100 !important;
    background: rgba(200, 200, 200, 0.5);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);

    transform: translate(0px, 0px) scale(1.02);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

/* Tab Hover/Active State */
.note-tab:hover,
.note-tab.active-tab {
    z-index: 101 !important;
    /* Slightly higher than active note body */
    background: rgba(255, 255, 255, 0.6);
    color: #000;
}

#chart-debug-data::-webkit-scrollbar {
    width: 4px;
}

#chart-debug-data::-webkit-scrollbar-track {
    background-color: #1b1f22;
}

#chart-debug-data::-webkit-scrollbar-thumb {
    background: #4e4e4e;
    border-radius: 2px
}

.note-body::-webkit-scrollbar {
    width: 4px;
}

.note-body::-webkit-scrollbar-track {
    background-color: #1b1f22;
}

.note-body::-webkit-scrollbar-thumb {
    background: #4e4e4e;
    border-radius: 2px
}

.stickies_icon {
    display: block;
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 4rem;
    height: 4rem;
    cursor: pointer;
    text-indent: 4rem;
    overflow: hidden;
    white-space: nowrap;
    background-size: 20px 20px;
    background-repeat: no-repeat;
    background-position: center;
}

.stickies_icon:before {
    -moz-transition: background-color 0.2s ease-in-out;
    -webkit-transition: background-color 0.2s ease-in-out;
    -ms-transition: background-color 0.2s ease-in-out;
    transition: background-color 0.2s ease-in-out;
    content: '';
    display: block;
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 100%;
    background-color: var(--background-color);
}

.stickies_icon:hover:before {
    background-color: rgba(255, 255, 255, 0.15);
}

.stickies_icon:active:before {
    background-color: rgba(255, 255, 255, 0.3);
}

@media screen and (max-width: 736px) {

    .stickies_icon:before {
        top: 0.875rem;
        left: 0.875rem;
        width: 2.25rem;
        height: 2.25rem;
        background-size: 14px 14px;
    }

}