/* ページ全体のスタイル */
body {
    min-height: max(884px, 100dvh);
    background-color: #f6f7f7;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    color: #1d283a;
}

/* メインコンテナ */
.main-container {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    margin: 0 auto;
    background-color: #ffffff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding-bottom: 96px;
    overflow-x: hidden;
}

/* ヘッダーセクション */
.header-section {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0.5rem;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid #f3f4f6;
}

.page-title {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: #1d283a;
}

/* No Data Message */
.no-data {
    text-align: center;
    padding: 60px 20px;
    font-size: 0.875rem;
    color: #9ca3af;
    font-weight: 500;
}

.profile-section {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
}

.avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background-image: url("https://lh3.googleusercontent.com/aida-public/AB6AXuAUlrywLqoMPsg9IIRIdiLRg7DXo4scpcL7xY2zgxioD9ZRqpbJJcUioNQXhfz4Bu1Lo15XRYZFQNGb6x6scxmp7lxtHgmsbSU1t0IsORRW3NYyJ0wQqNaU3loh6IZqcay8H7GmGSW2nOolljiATmUc-00x_HXS1NhEhs_Xu2yf7m1zesrP6kccPHdjkFb3kHJx6uQkwYbAMvRss3V_RZ2imjQ47W3JRAl3ObPfSicFTwHzSeBeGlOyVrtRHuhBVvl54vJZrEnxYtxg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid #e5e7eb;
}

/* セグメントコントロール */
.segment-control {
    display: flex;
    padding: 0.75rem 1rem;
    background-color: #ffffff;
}

.segment-control-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 2.75rem;
    background-color: #f3f4f6;
    border-radius: 0.75rem;
    padding: 0.25rem;
}

.segment-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 0.5rem;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.segment-option.active {
    background-color: #1d283a;
    color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.segment-option input.hidden {
    display: none;
}

/* サマリーカード */
.summary-cards {
    display: flex;
    overflow-x: auto;
    padding: 0.5rem 1rem;
    gap: 0.75rem;
}

.summary-cards::-webkit-scrollbar {
    display: none;
}

.summary-cards {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.summary-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 140px;
    padding: 1rem;
    background-color: #ffffff;
    border-radius: 0.75rem;
    border: 1px solid #f3f4f6;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.summary-card .material-symbols-outlined {
    font-size: 1.5rem;
}

.summary-card .icon-blue {
    color: #3b82f6;
}

.summary-card .icon-green {
    color: #10b981;
}

.summary-card .icon-purple {
    color: #8b5cf6;
}

.summary-card .icon-orange {
    color: #fb923c;
}

.card-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
}

.card-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1d283a;
}

/* チャートセクション */
.chart-section {
    padding: 1rem 1rem 0;
}

.chart-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.chart-title {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.25;
    color: #1d283a;
}

.chart-stats {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.chart-main-value {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: #1d283a;
}

.chart-change {
    font-size: 0.875rem;
    font-weight: 600;
}

.chart-change.positive {
    color: #10b981;
}

.chart-change.negative {
    color: #ef4444;
}

.chart-period {
    font-size: 0.75rem;
    color: #9ca3af;
}

.chart-visual {
    position: relative;
    width: 100%;
    height: 220px;
    background-color: #f9fafb;
    border-radius: 0.75rem;
    padding: 1rem;
    overflow: hidden;
    border: 1px solid #f3f4f6;
}

.chart-svg {
    overflow: visible;
}

.grid-line {
    color: #e5e7eb;
}

.chart-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}

.chart-label {
    font-size: 0.625rem;
    font-weight: 500;
    color: #9ca3af;
}

.chart-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    padding: 0 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.legend-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
}

.legend-dot.blue {
    background-color: #3b82f6;
}

.legend-dot.green {
    background-color: #10b981;
}

.legend-text {
    font-size: 0.625rem;
    font-weight: 500;
    color: #6b7280;
}

/* 睡眠ステージセクション */
.sleep-stages-section {
    padding: 1rem 1rem 0;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.25;
    color: #1d283a;
    margin-bottom: 1rem;
}

.donut-card {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 1.5rem;
    background-color: #ffffff;
    border-radius: 0.75rem;
    border: 1px solid #f3f4f6;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.donut-chart {
    position: relative;
    width: 8rem;
    height: 8rem;
}

.donut-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.donut-center {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.donut-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
}

.donut-value {
    font-size: 0.875rem;
    font-weight: 700;
    color: #1d283a;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.donut-legend-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 0.125rem;
}

.donut-legend-dot.light-sleep {
    background-color: #6366f1;
}

.donut-legend-dot.deep-sleep {
    background-color: #1d283a;
}

.donut-legend-dot.rem-sleep {
    background-color: #3b82f6;
}

.donut-legend-dot.awake {
    background-color: #fbbf24;
}

.donut-legend-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: #4b5563;
}

/* 週間パターンセクション */
.weekly-patterns-section {
    padding: 1rem 1rem 1.5rem;
}

.section-subtitle {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

.bar-chart-wrapper {
    display: flex;
    align-items: stretch;
}

.bar-chart-y-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
}

.bar-chart-y-label span {
    font-size: 0.625rem;
    font-weight: 500;
    color: #9ca3af;
}

.bar-chart-x-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 0.5rem;
}

.bar-chart-x-label span {
    font-size: 0.625rem;
    font-weight: 500;
    color: #9ca3af;
}

.bar-chart {
    flex: 1;
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 12rem;
    padding: 1rem 1.5rem 1.5rem;
    background-color: #ffffff;
    border-radius: 0.75rem;
    border: 1px solid #f3f4f6;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.average-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(
        to right,
        #10b981,
        #10b981 4px,
        transparent 4px,
        transparent 8px
    );
    z-index: 1;
    pointer-events: none;
}

.average-label {
    position: absolute;
    right: 8px;
    top: -20px;
    font-size: 0.625rem;
    font-weight: 700;
    color: #10b981;
    background-color: #ffffff;
    padding: 2px 4px;
    border-radius: 2px;
}

.bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    max-width: 50px;
}

.bar {
    position: relative;
    width: 100%;
    max-width: 40px;
    background-color: #e5e7eb;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    min-height: 8px;
    transition: all 0.2s ease;
}

.bar:hover {
    transform: scaleY(1.05);
    filter: brightness(1.1);
}

.bar-value {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: #1d283a;
    white-space: nowrap;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.bar-value.below {
    color: #ea580c;
}

.bar.primary .bar-value {
    color: #1d283a;
}

.bar.below-average {
    background: linear-gradient(to top, #fdba74 0%, #fb923c 100%);
}

.bar:not(.below-average):not(.primary) {
    background: linear-gradient(to top, #93c5fd 0%, #3b82f6 100%);
}

.bar.primary:not(.below-average) {
    background: linear-gradient(to top, #4b5563 0%, #1d283a 100%);
}

.bar.primary {
    background-color: #1d283a;
}

.bar-label {
    font-size: 0.625rem;
    font-weight: 700;
    color: #9ca3af;
}

.bar-label.primary {
    color: #1d283a;
}

/* ボトムナビゲーション */
.bottom-navigation {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0.75rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid #f3f4f6;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.2s ease;
    border: none;
    background: none;
    font-family: inherit;
}

.nav-item:hover {
    color: #1d283a;
}

.nav-item.active {
    color: #1d283a;
}

.nav-item .material-symbols-outlined {
    font-size: 1.5rem;
}

.nav-item.active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
}

.nav-item span:not(.material-symbols-outlined) {
    font-size: 0.625rem;
}

.nav-item.active span:not(.material-symbols-outlined) {
    font-weight: 700;
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #16181c;
        color: #ffffff;
    }

    .main-container {
        background-color: #16181c;
    }

    .page-title {
        color: #ffffff;
    }

    .segment-control {
        background-color: #16181c;
    }

    .segment-control-inner {
        background-color: #1f2937;
    }

    .chart-main-value {
        color: #ffffff;
    }

    .chart-title {
        color: #ffffff;
    }

    .section-title {
        color: #ffffff;
    }

    .donut-value {
        color: #ffffff;
    }

    .donut-legend-text {
        color: #d1d5db;
    }

    .summary-card {
        background-color: #1f2937;
        border-color: #374151;
    }

    .card-value {
        color: #ffffff;
    }

    .chart-visual {
        background-color: rgba(17, 24, 39, 0.5);
        border-color: #1f2937;
    }

    .grid-line {
        color: #1f2937;
    }

    .donut-card {
        background-color: #1f2937;
        border-color: #374151;
    }

    .bar-chart {
        background-color: #1f2937;
        border-color: #374151;
    }

    .bar {
        background-color: #374151;
    }

    .bar:not(.below-average):not(.primary) {
        background: linear-gradient(to top, #1e40af 0%, #3b82f6 100%);
    }

    .bar.primary {
        background-color: #1d283a;
    }

    .bar.below-average {
        background: linear-gradient(to top, #c2410c 0%, #ea580c 100%);
    }

    .average-label {
        background-color: #1f2937;
        color: #10b981;
    }

    .section-subtitle {
        color: #9ca3af;
    }

    .bottom-navigation {
        background-color: rgba(22, 24, 28, 0.95);
        border-top-color: #1f2937;
    }

    .nav-item.active {
        color: #ffffff;
    }
}