* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #2E3440;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #ECEFF4;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: visible;
}

.header {
    background: #5E81AC;
    color: #ECEFF4;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 28px;
    margin-bottom: 10px;
}

.header p {
    opacity: 0.9;
    font-size: 14px;
}

.instructions {
    background: rgba(236, 239, 244, 0.2);
    padding: 15px 20px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: left;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.instructions summary {
    cursor: pointer;
    user-select: none;
    list-style: none;
    padding: 5px 0;
    transition: opacity 0.2s;
}

.instructions summary::-webkit-details-marker {
    display: none;
}

.instructions summary::before {
    content: '▶ ';
    display: inline-block;
    transition: transform 0.2s;
    color: #ECEFF4;
}

.instructions[open] summary::before {
    transform: rotate(90deg);
}

.instructions summary:hover {
    opacity: 0.8;
}

.instructions strong {
    color: #ECEFF4;
    font-size: 15px;
}

.instructions ol {
    margin: 10px 0 0 0;
    padding-left: 20px;
    color: #D8DEE9;
    font-size: 13px;
    line-height: 1.6;
}

.instructions li {
    margin: 5px 0;
}

.instructions code {
    background: rgba(46, 52, 64, 0.6);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #88C0D0;
}

/* Spoiler styles */
.spoiler {
    background: #2E3440;
    color: #2E3440;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.spoiler:hover,
.spoiler.revealed {
    color: #D8DEE9;
    background: rgba(46, 52, 64, 0.6);
}

.upload-section {
    padding: 40px;
    text-align: center;
    border-bottom: 2px solid #D8DEE9;
}

.file-input-wrapper {
    position: relative;
    display: inline-block;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-label {
    display: inline-block;
    padding: 15px 40px;
    background: #88C0D0;
    color: #2E3440;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.file-input-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(136, 192, 208, 0.4);
    background: #81A1C1;
}

.file-name {
    margin-top: 15px;
    color: #4C566A;
    font-size: 14px;
}

.schema-section {
    padding: 40px;
    display: none;
}

.schema-section.visible {
    display: block;
}

.schema-tree {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.8;
}

.schema-item {
    margin-left: 20px;
}

.key {
    color: #81A1C1;
    font-weight: bold;
}

.type {
    color: #B48EAD;
    font-style: italic;
}

.array-marker {
    color: #A3BE8C;
    font-weight: bold;
}

.object-marker {
    color: #D08770;
    font-weight: bold;
}

.stats {
    background: #E5E9F0;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #5E81AC;
    margin-bottom: 5px;
}

.stat-label {
    color: #4C566A;
    font-size: 14px;
}

.collapsible {
    cursor: pointer;
    user-select: none;
}

.collapsible:hover {
    background: #D8DEE9;
}

.collapsed > .children {
    display: none;
}

.toggle {
    display: inline-block;
    width: 16px;
    color: #4C566A;
    font-weight: bold;
}

.example-value {
    color: #4C566A;
}

.item-count {
    color: #8FBCBB;
    font-style: italic;
}

.view-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.view-btn {
    padding: 10px 25px;
    border: 2px solid #5E81AC;
    background: transparent;
    color: #5E81AC;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.view-btn:hover {
    background: #E5E9F0;
}

.view-btn.active {
    background: #5E81AC;
    color: #ECEFF4;
}

.text-schema-container {
    display: none;
}

.text-schema-container.visible {
    display: block;
}

.text-schema-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.text-schema-header h3 {
    color: #2E3440;
    margin: 0;
}

.copy-btn {
    padding: 8px 20px;
    background: #A3BE8C;
    color: #2E3440;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: #8FBCBB;
    transform: translateY(-1px);
}

.copy-btn:active {
    transform: translateY(0);
}

.copy-btn.copied {
    background: #88C0D0;
}

.text-schema-output {
    background: #2E3440;
    color: #D8DEE9;
    padding: 20px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

/* Analysis View Styles */
.analysis-container {
    display: none;
}

.analysis-container.visible {
    display: block;
}

.analysis-config {
    background: #E5E9F0;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.config-hint {
    font-size: 12px;
    color: #2E3440;
    background: #D8DEE9;
    padding: 10px 12px;
    border-radius: 6px;
    margin-top: 10px;
    line-height: 1.5;
}

.config-hint strong {
    color: #5E81AC;
    display: block;
    margin-bottom: 4px;
}

.config-label {
    color: #2E3440;
    font-weight: 600;
}

.session-timeout-input {
    padding: 10px 15px;
    border: 2px solid #5E81AC;
    border-radius: 6px;
    background: #ECEFF4;
    color: #2E3440;
    font-size: 14px;
    width: 100px;
}

.session-timeout-input:focus {
    outline: none;
    border-color: #81A1C1;
}

.analyze-btn {
    padding: 10px 25px;
    background: #5E81AC;
    color: #ECEFF4;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.analyze-btn:hover {
    background: #81A1C1;
    transform: translateY(-1px);
}

.analyze-btn:active {
    transform: translateY(0);
}

.analyze-btn:disabled {
    background: #D8DEE9;
    cursor: not-allowed;
    transform: none;
    color: #4C566A;
}

.analysis-stats {
    background: #E5E9F0;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.analysis-stat-item {
    text-align: center;
}

.analysis-stat-item.highlighted {
    background: #88C0D0;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 8px rgba(136, 192, 208, 0.3);
}

.analysis-stat-item.highlighted .analysis-stat-value {
    color: #2E3440;
    font-size: 32px;
}

.analysis-stat-item.highlighted .analysis-stat-label {
    color: #2E3440;
    font-weight: 600;
}

.analysis-stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #5E81AC;
    margin-bottom: 5px;
}

.analysis-stat-label {
    color: #4C566A;
    font-size: 13px;
}

.chart-container {
    background: #ECEFF4;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

#sessionChart {
    max-height: 400px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .instructions {
        text-align: left;
        padding: 12px 15px;
    }

    .instructions ol {
        padding-left: 15px;
    }

    .analysis-config {
        flex-direction: column;
        align-items: stretch;
    }

    .session-timeout-input {
        width: 100%;
    }

    .analyze-btn {
        width: 100%;
    }

    .analysis-stats {
        grid-template-columns: 1fr;
    }

    .privacy-notice {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        margin: 0 20px 20px 20px;
    }

    .privacy-icon {
        font-size: 20px;
    }

    .privacy-text {
        font-size: 12px;
    }
}

/* Date Range Picker Styles */
.date-range-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 15px;
    width: 100%;
}

.date-input {
    padding: 8px 12px;
    border: 2px solid #5E81AC;
    border-radius: 6px;
    background: #ECEFF4;
    color: #2E3440;
    font-size: 14px;
}

.date-input:focus {
    outline: none;
    border-color: #81A1C1;
}

.apply-filter-btn {
    padding: 8px 20px;
    background: #88C0D0;
    color: #2E3440;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.apply-filter-btn:hover {
    background: #81A1C1;
    transform: translateY(-1px);
}

.apply-filter-btn:active {
    transform: translateY(0);
}

.apply-filter-btn:disabled {
    background: #D8DEE9;
    cursor: not-allowed;
    transform: none;
    color: #4C566A;
}

/* Heatmap Styles */
.heatmap-section {
    background: #ECEFF4;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.heatmap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.heatmap-header h3 {
    color: #2E3440;
    margin: 0;
}

.heatmap-controls {
    display: flex;
    gap: 10px;
}

.heatmap-view-btn {
    padding: 6px 15px;
    border: 2px solid #5E81AC;
    background: transparent;
    color: #5E81AC;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.heatmap-view-btn:hover {
    background: #E5E9F0;
}

.heatmap-view-btn.active {
    background: #5E81AC;
    color: #ECEFF4;
}

.heatmap-container {
    display: grid;
    gap: 2px;
    margin-bottom: 15px;
}

/* Aggregated view: 2 rows x 24 columns (hour labels + cells) */
.heatmap-container.aggregated {
    grid-template-columns: repeat(24, 1fr);
    grid-template-rows: auto 1fr;
}

/* Daily view: N rows x 24 columns (with day label column) */
.heatmap-container.daily {
    grid-template-columns: auto repeat(24, 1fr);
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
}

.heatmap-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    color: #2E3440;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.heatmap-day-label {
    padding: 8px;
    font-size: 12px;
    font-weight: bold;
    color: #4C566A;
    display: flex;
    align-items: center;
}

.heatmap-hour-label {
    padding: 4px;
    font-size: 11px;
    color: #4C566A;
    text-align: center;
    font-weight: 600;
    position: sticky;
    top: 0;
    background: #ECEFF4;
    z-index: 5;
    border-bottom: 2px solid #D8DEE9;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #4C566A;
}

.legend-label {
    font-weight: 600;
}

.legend-gradient {
    width: 200px;
    height: 20px;
    background: linear-gradient(to right, #ECEFF4, #D8DEE9, #81A1C1, #5E81AC);
    border-radius: 4px;
    border: 1px solid #D8DEE9;
}

.legend-min, .legend-max {
    font-size: 11px;
}

/* Responsive heatmap adjustments */
@media (max-width: 768px) {
    .date-range-group {
        flex-direction: column;
        align-items: stretch;
    }

    .date-input {
        width: 100%;
    }

    .apply-filter-btn {
        width: 100%;
    }

    .heatmap-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .heatmap-cell {
        font-size: 9px;
    }

    .legend-gradient {
        width: 150px;
    }
}

/* GitHub-style heatmap */
.github-heatmap-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.github-year-section {
    background: #E5E9F0;
    padding: 15px;
    border-radius: 8px;
}

.github-year-header {
    font-size: 14px;
    font-weight: bold;
    color: #2E3440;
    margin-bottom: 10px;
}

.github-month-labels {
    display: grid;
    grid-template-columns: 30px repeat(53, 12px);
    gap: 3px;
    margin-bottom: 5px;
}

.github-month-label {
    font-size: 10px;
    color: #4C566A;
    font-weight: 600;
}

.github-heatmap-grid {
    display: grid;
    grid-template-columns: 30px repeat(53, 12px);
    grid-template-rows: repeat(7, 12px);
    gap: 3px;
}

.github-day-label {
    font-size: 9px;
    color: #4C566A;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 5px;
}

.github-heatmap-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.github-heatmap-cell:hover {
    transform: scale(1.5);
    z-index: 10;
    box-shadow: 0 0 0 2px #2E3440;
}

.github-heatmap-cell.empty {
    background: #ECEFF4;
    border: 1px solid #D8DEE9;
}

.github-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin-top: 10px;
    font-size: 11px;
    color: #4C566A;
}

.github-legend-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* GitHub heatmap responsive adjustments */
@media (max-width: 1024px) {
    .github-month-labels {
        grid-template-columns: 25px repeat(53, 10px);
    }

    .github-heatmap-grid {
        grid-template-columns: 25px repeat(53, 10px);
        grid-template-rows: repeat(7, 10px);
    }

    .github-heatmap-cell {
        width: 10px;
        height: 10px;
    }

    .github-legend-box {
        width: 10px;
        height: 10px;
    }
}

@media (max-width: 768px) {
    .github-month-labels {
        grid-template-columns: 20px repeat(53, 8px);
        gap: 2px;
    }

    .github-heatmap-grid {
        grid-template-columns: 20px repeat(53, 8px);
        grid-template-rows: repeat(7, 8px);
        gap: 2px;
    }

    .github-heatmap-cell {
        width: 8px;
        height: 8px;
    }

    .github-day-label {
        font-size: 8px;
    }

    .github-month-label {
        font-size: 9px;
    }

    .github-legend {
        font-size: 10px;
    }

    .github-legend-box {
        width: 8px;
        height: 8px;
    }

    .github-year-section {
        padding: 10px;
    }
}

/* Section Layout Styles (New Tab System) */
.stats-section,
.chart-section,
.hourly-heatmap-section,
.daily-heatmap-section,
.detailed-heatmap-section {
    background: #E5E9F0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    position: relative;
}

/* Sticky Header Wrapper */
.sticky-header-wrapper {
    position: relative;
    top: 0;
    z-index: 20;
    background: #E5E9F0;
    padding-bottom: 10px;
    margin-bottom: 0;
    border-radius: 8px 8px 0 0;
}

.sticky-header-wrapper.is-sticky {
    position: sticky;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sticky-header-wrapper h3 {
    color: #2E3440;
    font-size: 18px;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 10px;
}

/* Hide legend by default in sticky wrapper, show when stuck */
.sticky-header-wrapper .heatmap-legend {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #D8DEE9;
}

.sticky-header-wrapper.is-sticky .heatmap-legend {
    display: flex;
}

/* Hide "Activity Level:" label when sticky - it's intuitive */
.sticky-header-wrapper.is-sticky .heatmap-legend .legend-label {
    display: none;
}

/* Tab Controls */
.section-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #D8DEE9;
    padding-bottom: 10px;
}

.section-tab {
    background: transparent;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #4C566A;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: background 0.2s, color 0.2s;
}

.section-tab:hover {
    background: #D8DEE9;
    color: #2E3440;
}

.section-tab.active {
    background: #5E81AC;
    color: #ECEFF4;
}

/* Tab Content */
.tab-content {
    background: white;
    border-radius: 8px;
    padding: 20px;
    min-height: 200px;
}

/* Stats Grid for Text Statistics Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* Updated Config Section for Re-analyze */
.analysis-config .config-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.analysis-config .date-range-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Responsive Tab System */
@media (max-width: 768px) {
    .section-tabs {
        flex-wrap: wrap;
    }

    .section-tab {
        padding: 8px 15px;
        font-size: 13px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .tab-content {
        padding: 15px;
    }

    /* Sticky header responsive adjustments */
    .sticky-header-wrapper h3 {
        font-size: 16px;
    }

    .sticky-header-wrapper .heatmap-legend {
        font-size: 10px;
        gap: 5px;
    }

    .sticky-header-wrapper .legend-gradient {
        width: 120px;
        height: 16px;
    }

    /* Sticky hour labels on mobile */
    .heatmap-hour-label {
        font-size: 9px;
        padding: 2px;
    }

    /* Adjust detailed heatmap height on mobile */
    .heatmap-container.daily {
        max-height: 400px;
    }

    /* Spinner responsive adjustments */
    .spinner {
        width: 50px;
        height: 50px;
    }

    .spinner-text {
        font-size: 14px;
    }
}

/* Privacy Notice Styles */
.privacy-notice {
    background: #EBCB8B;
    color: #2E3440;
    padding: 20px;
    margin: 0 40px 20px 40px;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    border-left: 4px solid #D08770;
    border-bottom: 2px solid #D8DEE9;
    border-radius: 0;
}

.privacy-icon {
    font-size: 24px;
    line-height: 1;
    flex-shrink: 0;
}

.privacy-text {
    font-size: 13px;
    line-height: 1.6;
}

.privacy-text strong {
    color: #2E3440;
    font-weight: 700;
    display: inline;
}

/* Spinner Styles */
.spinner-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(46, 52, 64, 0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
}

.spinner-overlay.visible {
    display: flex;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #D8DEE9;
    border-top: 4px solid #88C0D0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner-text {
    color: #ECEFF4;
    font-size: 16px;
    font-weight: 600;
}

/* Footer Styles */
.footer {
    background: #2E3440;
    color: #D8DEE9;
    padding: 30px 20px;
    text-align: center;
    margin-top: 40px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-content p {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.6;
}

.footer-content p:first-child {
    font-weight: 600;
    color: #88C0D0;
}
