:root { 
    --hour-width: 32px; 
    --total-width: calc(var(--hour-width) * 216); 
    --label-box-width: 100px; 
    --nav-height: 60px;
}
body { font-family: sans-serif; background: #f0f2f5; margin: 0; padding-top: calc(var(--nav-height) + 10px); }

/* ボタン配置とタブ */
.control-wrapper {
    position: fixed; top: 0; left: 0; right: 0; height: var(--nav-height);
    background: white; border-bottom: 1px solid #ddd; padding: 0 10px;
    display: flex; gap: 8px; align-items: center; z-index: 1000;
    overflow: hidden; 
}
.scroll-tabs {
    display: flex; gap: 8px; overflow-x: auto; white-space: nowrap; padding: 5px 0;
    flex-grow: 1; -webkit-overflow-scrolling: touch;
    align-items: center;
    scroll-behavior: smooth;
}
.scroll-tabs::-webkit-scrollbar { display: none; }

.btn {
    padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer;
    font-weight: bold; font-size: 14px; transition: 0.2s; flex-shrink: 0;
}

/* 配色ルール */
.btn-gps, .btn-map-view { 
    background: #e9ecef; color: #495057; border: 1px solid #ced4da; 
}
.btn-location { 
    background: #ffffff; color: #495057; border: 1px solid #ced4da; 
}
.btn.active { 
    background: #007bff !important; 
    color: white !important; 
    border: 1px solid #0056b3 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn-add { 
    background: #ffffff; color: #6c757d; border: 1px solid #ced4da;
    font-size: 18px; padding: 4px 15px; 
}

/* サイドバーヘッダーの調整 */
.sidebar-header { 
    font-weight: bold; 
    margin-bottom: 20px; 
    border-bottom: 1px solid #eeeeee; 
    padding-bottom: 15px; 
    flex-shrink: 0; 
}

/* 閉じるボタンのホバー */
.close-sidebar:hover {
    color: #dc3545; 
    transition: 0.2s;
}

/* サイドバー */
.menu-trigger {
    font-size: 24px; background: none; border: none; cursor: pointer; padding: 0 10px; flex-shrink: 0;
}
.sidebar {
    position: fixed; top: 0; 
    left: -250px; 
    width: 210px; height: 100%;
    background: #ffffff; color: #333333; transition: 0.3s; z-index: 2500; 
    padding: 20px; 
    box-shadow: none; 
    box-sizing: border-box; 
    display: flex;
    flex-direction: column; 
    /* サイドバー自体で溢れた分をスクロール可能にする */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.sidebar.open { 
    left: 0; 
    box-shadow: 2px 0 10px rgba(0,0,0,0.1); 
}
/* コンテンツエリアの高さ制限をなくし、自然に伸ばす */
.sidebar-content { flex-grow: 0; } 
.sidebar .btn { width: 100%; margin-bottom: 15px; text-align: left; }

.sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.6); 
    backdrop-filter: blur(2px); 
    z-index: 2400;
}

.sidebar-qr-area {
    /* margin-top: auto を廃止し、ボタンの下に自然に配置 */
    margin-top: 10px;
    padding: 15px 0;
    text-align: center;
    border-top: 1px solid #eeeeee;
    flex-shrink: 0;
}
.sidebar-qr-area p { font-size: 11px; color: #555555; margin-bottom: 8px; font-weight: bold; }
#sidebar-qrcode { 
    display: inline-block; 
    background: white; 
    padding: 8px; 
    border-radius: 4px;
    border: 1px solid #dddddd; 
}
#sidebar-qrcode img { display: block; width: 120px; height: 120px; }

.btn-wind-config { background: #6f42c1 !important; color: white !important; }
.btn-detailSettings { background: #29b227 !important; color: white !important; }
.btn-reset { background: #dc3545 !important; color: white !important; }

.current-pos-label { display: none; }

/* モーダル */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.7); 
    backdrop-filter: blur(3px); 
    z-index: 3000; justify-content: center; align-items: center;
}
.modal-content {
    background: white; width: 95%; max-width: 900px; height: 85%; border-radius: 12px;
    display: flex; flex-direction: column; overflow: hidden; position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); 
}

.search-bar { padding: 10px; background: #fff; border-bottom: 1px solid #ddd; display: flex; gap: 8px; z-index: 2100; }
.search-input { flex-grow: 1; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
#map-canvas { flex-grow: 1; width: 100%; background-color: #f8f8f8 !important; }

/* コンパス */
.compass-container {
    position: relative; width: 320px; height: 320px; margin: 40px auto;
    background: #f8f9fa; border-radius: 50%; border: 2px solid #ddd;
}
.compass-label {
    position: absolute; width: 60px; height: 30px; display: flex; align-items: center;
    justify-content: center; font-size: 12px; font-weight: bold; cursor: pointer;
    border-radius: 4px; background: #fff; border: 1px solid #ccc; transition: 0.2s;
    user-select: none;
}
.compass-label.active { background: #6f42c1; color: white; border-color: #5a32a3; }
.compass-center {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; font-size: 14px; color: #666;
}

/* 地図最大化のためのフッター調整 */
.modal-footer { 
    padding: 6px 8px; 
    display: flex; 
    flex-wrap: wrap; 
    justify-content: space-between; 
    align-items: center;
    gap: 4px; 
    background: #f8f9fa; 
    border-top: 1px solid #ddd;
}
.modal-footer .guide-text {
    font-size: 11px;
    color: #888;
    width: 100%; 
    text-align: left;
    margin-bottom: 2px;
    padding-left: 4px;
}
.modal-footer .btn {
    padding: 8px 2px; 
    height: auto;
    min-height: 0;
    flex: 1; 
    font-size: 12px; 
    white-space: nowrap; 
    text-align: center;
}

/* グラフ（余白修正版） */
.main-card { 
    max-width: 1500px; margin: auto; background: white; 
    border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); 
    overflow: hidden;
}
.scroll-container { overflow-x: auto; position: relative; }

/* 修正箇所：width削除、display変更で余白を自動解消 */
.chart-stage { 
    display: inline-block; 
    position: relative; 
    padding: 20px 0 80px var(--label-box-width); 
    pointer-events: auto; 
    min-width: 100%;
}
.chart-section { 
    margin-bottom: -1px; 
    position: relative; 
    background: #fff; 
    border: 1px solid #ddd; 
    border-radius: 0; 
    width: 100%; 
}
.section-weather { height: 80px; border: none; margin-bottom: 0px; }
.section-wind { height: 280px; margin-bottom: 0px; }
.section-temp, .section-marine { height: 160px; margin-bottom: 0px; }

.sticky-label {
    position: sticky; left: 0; top: 0; width: var(--label-box-width);
    height: 100%; background: rgba(255,255,255,0.8); z-index: 50;
    pointer-events: none; float: left;
    margin-right: calc(var(--label-box-width) * -1); margin-left: calc(var(--label-box-width) * -1); 
}
.y-axis-title { padding: 5px 8px; font-size: 14px; font-weight: bold; color: #111; line-height: 1.2; }

svg { width: 100%; display: block; overflow: visible; }
.grid-day { stroke: #666; stroke-width: 2; } 
.grid-3h { stroke: #ccc; stroke-width: 1; }  
.grid-y-sub { stroke: #e0e0e0; stroke-width: 1; } 
.label-time { font-size: 16px; fill: #333; font-weight: bold; }

.date-container { position: absolute; height: 30px; bottom: -30px; left: 0; width: 100%; pointer-events: none; z-index: 10; }
.sticky-date {
    position: absolute; bottom: 0; font-size: 22px; font-weight: bold;
    background: rgba(255,255,255,0.8); padding: 0 10px; border-radius: 4px;
    color: #000; white-space: nowrap;
}

.line-temp-air { stroke: #ff4500; stroke-width: 4; fill: none; }
.line-temp-sea { stroke: #00ced1; stroke-width: 4; fill: none; }
.line-wave { stroke: #2ca02c; stroke-width: 4; fill: none; }
.line-tide { stroke: #1e90ff; stroke-width: 3; fill: none; }
.wind-arrow { fill: #00d4ff; stroke: #008eb3; stroke-width: 1; }

.y-axis-values {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    font-size: 14px;
    font-weight: bold;
    color: #444;
}

.y-max {
    position: absolute;
    top: -10px;
    right: 5px;
}

.y-min {
    position: absolute;
    bottom: 10px; /* 下部ラベルと重ならないように調整 */
    right: 5px;
}

/* ツールチップ */
.tooltip {
    position: fixed; background: rgba(0,0,0,0.85); color: white;
    padding: 12px 16px; border-radius: 8px; font-size: 14px;
    pointer-events: none; display: none; z-index: 4000; line-height: 1.8;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); backdrop-filter: blur(4px);
    white-space: nowrap;
}
.tooltip b { display: block; margin-bottom: 6px; font-size: 16px; border-bottom: 1px solid #666; padding-bottom: 2px; }
.tooltip .spot-name-tip { 
    color: #00d4ff; 
    font-size: 16px; 
    font-weight: bold; 
    /* 破線をここから削除 */
    border-bottom: none; 
    margin-bottom: 0px; 
    padding-bottom: 0px; 
    display: block; 
}

/* 緯度経度表示：ここに破線と余白を設定 */
.tooltip .coord-tip {
    display: block;
    font-size: 14px;
    color: #aaa;
    border-bottom: 1px dashed #666; /* 破線を場所の下（緯度経度の下）に配置 */
    margin-bottom: 6px;
    padding-bottom: 4px;
    line-height: 1.2;
}

.icon-box { display: inline-block; width: 24px; text-align: center; vertical-align: middle; margin-right: 4px; }
.legend-bar { display: inline-block; width: 12px; height: 12px; vertical-align: middle; }
.legend-line { display: inline-block; width: 16px; height: 3px; vertical-align: middle; }

#hover-guide { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,0,0,0.3); display: none; pointer-events: none; z-index: 5; }
.footer-info { 
    max-width: 1500px; margin: 1px auto; padding: 1px; font-size: 12px; 
    color: #666; line-height: 1.6; border-top: 1px solid #ddd;
}

/* 詳細設定専用のコンテンツ調整 */
.view-settings-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    background: #ffffff;
}

/* 各設定項目のグループ化 */
.config-group {
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.config-label-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.config-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

.config-value {
    font-size: 14px;
    font-family: monospace;
    color: #6f42c1;
    font-weight: bold;
}

/* スライダーのカスタマイズ */
.config-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: #e9ecef;
    border-radius: 3px;
    outline: none;
}

.config-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #6f42c1;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* 既存のフッターとの整合性 */
.modal-footer .btn-apply {
    background: #6f42c1 !important;
    color: white !important;
    flex: 2; 
}

/* 風速凡例専用のスタイル */
.legend-wind-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    margin-top: 5px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 5px;
}

.legend-wind-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-wind-rect {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

.legend-wind-label {
    color: #333;
    font-weight: bold;
}

/* 汎用ダイアログ用追加スタイル（修正版） */
.btn-save { background: #007bff !important; color: white !important; }
.btn-danger-outline { 
    background: #fff !important; 
    color: #dc3545 !important; 
    border: 1px solid #dc3545 !important; 
    font-size: 11px !important; 
    flex: 0.8 !important; 
    margin-right: auto; /* 削除ボタンを左寄りに配置 */
}
.btn-secondary { background: #6c757d !important; color: white !important; }

/* style.css への追記・修正 */
#common-modal-header {
    padding: 12px 15px; /* 上下を少し詰め、タイトルの存在感を適正化 */
    text-align: center;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

#common-modal-title {
    font-size: 17px; /* 18pxよりさらに1px下げ、UIに馴染ませる */
    font-weight: bold;
    line-height: 1.4;
}

#common-modal-message {
    font-size: 12px; /* メッセージはさらに小さくして対比を強調 */
    color: #666;
    margin-top: 5px;
}