
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #c77dff;
    --primary-dark: #9d4edd;
    --primary-light: #e0aaff;
    --accent: #7b2cbf;
    --bg-gradient-start: #FDEBFF;
    --bg-gradient-end: #E0C3FC;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-dark: #2d2d2d;
    --text-muted: #666;
    --border: #e8e0f0;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Hiragino Sans', 'Noto Sans JP', -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-dark);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* バブル背景 */
.bg-bubbles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    list-style: none;
}

.bg-bubbles li {
    position: absolute;
    display: block;
    width: 40px;
    height: 40px;
    background-color: rgba(199, 125, 255, 0.12);
    bottom: -160px;
    animation: float-up 20s infinite;
    border-radius: 50%;
}

.bg-bubbles li:nth-child(1) { left: 5%; width: 50px; height: 50px; animation-delay: 0s; }
.bg-bubbles li:nth-child(2) { left: 15%; width: 80px; height: 80px; animation-delay: 2s; animation-duration: 17s; }
.bg-bubbles li:nth-child(3) { left: 30%; animation-delay: 4s; }
.bg-bubbles li:nth-child(4) { left: 45%; width: 60px; height: 60px; animation-duration: 22s; }
.bg-bubbles li:nth-child(5) { left: 60%; width: 30px; height: 30px; animation-delay: 1s; }
.bg-bubbles li:nth-child(6) { left: 75%; width: 100px; height: 100px; animation-delay: 3s; }
.bg-bubbles li:nth-child(7) { left: 85%; width: 70px; height: 70px; animation-delay: 5s; }
.bg-bubbles li:nth-child(8) { left: 50%; width: 20px; height: 20px; animation-delay: 8s; animation-duration: 30s; }
.bg-bubbles li:nth-child(9) { left: 92%; width: 45px; height: 45px; animation-delay: 6s; }

@keyframes float-up {
    0% { transform: translateY(0) rotate(0deg); opacity: 0.6; }
    100% { transform: translateY(-1200px) rotate(720deg); opacity: 0; }
}

/* メインコンテナ */
.main-container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    max-width: 1920px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 10px 20px;
    gap: 8px;
}

/* ヘッダー */
.app-header {
    text-align: center;
    flex-shrink: 0;
    position: relative;
}

.measurement-dates {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    gap: 16px;
    font-size: 1.2rem;
}

.date-item {
    color: var(--text-muted);
    font-weight: 500;
}

.date-item.current {
    color: var(--primary-dark);
    font-weight: 600;
}

.app-title {
    font-size: 2.0rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.app-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* 部位選択ナビ（一行配置・タッチ対応） */
.area-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.nav-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-left: 2px;
}

.area-btn-group {
    display: flex;
    gap: 6px;
}

.area-btn {
    flex: 1;
    padding: 8px 4px;
    border: 2px solid #ccc;
    border-radius: 10px;
    background: #f0f0f0;
    color: #aaa;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: not-allowed;
    transition: all 0.2s;
    text-align: center;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}

.area-btn:active {
    transform: none;
}

.area-btn.measured {
    background: #f0e6ff;
    border-color: var(--primary);
    color: var(--primary-dark);
    cursor: pointer;
    opacity: 1;
}

.area-btn.measured:active {
    transform: scale(0.95);
}

.area-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 3px 12px rgba(199, 125, 255, 0.4);
    border-color: var(--primary-dark);
    opacity: 1;
    cursor: pointer;
}

/* 画像タイプナビ（部位ごとの測定画像ボタン） */
.image-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.image-btn-group {
    display: flex;
    gap: 4px;
    height: 60px;
    font-size: 1.6rem;
}

.image-type-btn {
    flex: 1;
    padding: 8px 4px;
    border: 1.5px solid var(--primary-light);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--primary-dark);
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-type-btn:active {
    transform: scale(0.93);
}

.image-type-btn:hover {
    background: var(--primary-light);
    color: white;
}

/* コンテンツエリア */
.content-area {
    flex: 1;
    display: grid;
    grid-template-columns: 480px 1fr;
    gap: 14px;
    min-height: 0;
    overflow: hidden;
}

/* 左カラム：グラフ */
.chart-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-top: 32px;
}

.chart-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border);
}

.chart-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 2px;
}

.chart-title-sm {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--accent);
}

.chart-desc, .chart-desc-sm {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.chart-wrap {
    width: 100%;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-wrap canvas {
    max-width: 100%;
    max-height: 100%;
}

.chart-wrap-sm {
    height: 100px;
}

.chart-wrap-sm canvas {
    max-width: 100%;
    max-height: 100%;
}

/* 広告バナー */
.promo-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #fff8f0, #fff0e6);
    border-radius: 12px;
    padding: 14px 16px;
    border: 1px solid #f0d8c0;
}

.promo-qr {
    width: 72px;
    height: 72px;
    border-radius: 6px;
    flex-shrink: 0;
    object-fit: contain;
}

.promo-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.promo-main {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.4;
}

.promo-sub {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.chart-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 6px;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.current {
    background: rgba(99, 102, 241, 0.7);
}

.legend-dot.previous {
    background: rgba(244, 114, 182, 0.7);
}

/* 右カラム：レコメンド */
.recommend-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 4px;
}

.recommend-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

/* ローディング */
.recommend-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* レコメンドカード */
.recommend-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.recommend-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.recommend-card.has-recommend {
    border-left: 3px solid var(--warning);
}

.recommend-card.good {
    border-left: 3px solid var(--success);
}

.card-col-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    width: 240px;
}

.card-col-center {
    flex: 1;
    min-width: 0;
}

.card-col-right {
    flex-shrink: 0;
}

/* 詳細レコメンドボタン */
.detail-recommend-btn {
    padding: 20px 18px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    background: linear-gradient(135deg, #f8f0ff, #e8d5f5);
    color: var(--primary-dark);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.detail-recommend-btn:active {
    transform: scale(0.95);
}

.detail-recommend-btn:hover {
    background: var(--primary);
    color: white;
}

.detail-recommend-btn.disabled {
    background: #f0f0f0;
    border-color: #ccc;
    color: #aaa;
    cursor: not-allowed;
    opacity: 0.5;
}

.detail-recommend-btn.disabled:hover {
    background: #f0f0f0;
    color: #aaa;
}

.detail-recommend-btn.disabled:active {
    transform: none;
}

/* レコメンド詳細モーダル */
.recommend-modal-content {
    max-width: 600px;
}

.recommend-modal-body {
    padding: 16px 0;
}

.recommend-modal-body p {
    font-size: 1.4rem;
    line-height: 1.8;
    color: var(--text-dark);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-label {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-dark);
}

.card-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.card-help .tooltip {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    background: var(--text-dark);
    color: white;
    font-size: 1.4rem;
    font-weight: 400;
    padding: 8px 12px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.card-help.show-tooltip .tooltip {
    display: block;
}

.card-status {
    font-size: 1.1rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.card-status.improved {
    background: #d4edda;
    color: #155724;
}

.card-status.declined {
    background: #fff3cd;
    color: #856404;
}

.card-status.stable {
    background: #e2e3e5;
    color: #383d41;
}

.card-summary {
    font-size: 1.3rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.card-recommend {
    font-size: 1.4rem;
    color: var(--primary-dark);
    font-weight: 500;
    line-height: 1.5;
    padding: 6px 10px;
    background: #f8f0ff;
    border-radius: 6px;
    display: none;
}

.card-recommend.visible {
    display: block;
}

/* サマリーボックス */
.summary-box {
    background: linear-gradient(135deg, #f8f0ff, #e8d5f5);
    border-radius: 10px;
    padding: 12px 16px;
    border: 1px solid var(--primary-light);
    flex-shrink: 0;
}

.summary-box h4 {
    font-size: 1.2rem;
    color: var(--accent);
    margin-bottom: 6px;
}

.summary-box p {
    font-size: 1.4rem;
    color: var(--text-dark);
    line-height: 1.6;
}

/* 免責事項 */
.disclaimer {
    font-size: 0.7rem;
    color: #999;
    text-align: right;
    flex-shrink: 0;
    padding-top: 4px;
}

/* スクロールバー */
.recommend-section::-webkit-scrollbar,
.chart-section::-webkit-scrollbar {
    width: 5px;
}

.recommend-section::-webkit-scrollbar-thumb,
.chart-section::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 3px;
}

/* 画像モーダル */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.image-modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.image-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 2.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-close:hover {
    color: var(--text-dark);
}

.image-modal-title {
    font-size: 1.4rem;
    color: var(--accent);
    margin-bottom: 16px;
}

.image-modal-body {
    display: flex;
    justify-content: center;
}

.image-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
}

.image-compare-col {
    text-align: center;
}

.image-compare-col h4 {
    font-size: 1.4rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.image-compare-col img {
    width: 100%;
    max-width: 380px;
    border-radius: 8px;
    border: 1px solid var(--border);
    object-fit: contain;
}

.image-no-data {
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 1.3rem;
    background: #f5f5f5;
    border-radius: 8px;
}

/* ホーム画面（QR読み取り待機） */
.home-screen {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    padding: 60px 80px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.1);
    max-width: 600px;
}

.home-title {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.home-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 40px;
}

.home-qr-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.home-qr-icon {
    font-size: 4rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.home-status {
    font-size: 1.2rem;
    color: var(--text-dark);
    font-weight: 500;
}

.home-connect-btn {
    padding: 16px 32px;
    border: 2px solid var(--primary);
    border-radius: 12px;
    background: linear-gradient(135deg, #f8f0ff, #e8d5f5);
    color: var(--primary-dark);
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.home-connect-btn:active {
    transform: scale(0.95);
}

.home-connect-btn:hover {
    background: var(--primary);
    color: white;
}

.home-error {
    margin-top: 16px;
    font-size: 1rem;
    color: var(--danger);
}
