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

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
}

#app {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    display: flex;
    flex-direction: column;
}

/* ── 工具列 ── */
#toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 12px;
    background: #2c3e50;
    color: #ecf0f1;
    z-index: 1000;
    flex-shrink: 0;
}

#app-title {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

#toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.control-group label {
    font-size: 13px;
    color: #bdc3c7;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.control-group select,
.control-group input[type="text"] {
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #546e7a;
    background: #34495e;
    color: #ecf0f1;
    outline: none;
}

.control-group select:focus,
.control-group input:focus {
    border-color: #3498db;
}

.control-group button {
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 4px;
    border: none;
    background: #3498db;
    color: white;
    cursor: pointer;
}

.control-group button:hover {
    background: #2980b9;
}

/* ── 地圖容器 ── */
#map-container {
    display: flex;
    flex: 1 1 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

#map-left, #map-right {
    flex: 1;
    position: relative;
    min-width: 0;
}

#divider {
    width: 4px;
    background: #2c3e50;
    cursor: col-resize;
    flex-shrink: 0;
    z-index: 500;
    position: relative;
}

#divider::after {
    content: '⟨⟩';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ecf0f1;
    font-size: 12px;
    pointer-events: none;
}

.map-label {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44, 62, 80, 0.85);
    color: #ecf0f1;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    z-index: 400;
    pointer-events: none;
}

/* ── 狀態列 ── */
#statusbar {
    height: 24px;
    padding: 0 12px;
    background: #1a252f;
    color: #7f8c8d;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}


.hidden {
    display: none !important;
}

/* ── 超出圖層範圍提示 ── */
#out-of-bounds-notice {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(44, 62, 80, 0.92);
    color: #ecf0f1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 450;
    max-width: 260px;
    line-height: 1.5;
    border-left: 3px solid #e67e22;
    pointer-events: auto;
}

#out-of-bounds-notice #oob-fly-link {
    display: block;
    margin-top: 4px;
    color: #3498db;
    text-decoration: underline;
    cursor: pointer;
}

#out-of-bounds-notice #oob-fly-link:hover {
    color: #5dade2;
}

/* ── 自製下拉選單 ── */
#basemap-select-wrapper {
    position: relative;
    display: inline-block;
}

.custom-select-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #546e7a;
    background: #34495e;
    color: #ecf0f1;
    cursor: pointer;
    white-space: nowrap;
    min-width: 200px;
    justify-content: space-between;
    user-select: none;
}

.custom-select-btn:hover {
    border-color: #3498db;
}

.custom-select-btn.open {
    border-color: #3498db;
}

.cs-arrow {
    font-size: 10px;
    color: #bdc3c7;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.custom-select-btn.open .cs-arrow {
    transform: rotate(180deg);
}

.custom-select-panel {
    position: fixed;
    background: #263545;
    border: 1px solid #546e7a;
    border-radius: 6px;
    z-index: 9999;
    min-width: 230px;
    max-height: 420px;
    overflow-y: auto;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.cs-group {
    font-size: 11px;
    color: #7f8c8d;
    padding: 10px 12px 4px;
    letter-spacing: 0.04em;
    cursor: default;
    border-top: 1px solid #2c3e50;
}

.cs-group:first-child {
    border-top: none;
}

.cs-option {
    font-size: 13px;
    padding: 6px 14px;
    color: #ecf0f1;
    cursor: pointer;
    white-space: nowrap;
}

.cs-option:hover {
    background: #2e4460;
}

.cs-option.cs-selected {
    color: #3498db;
    background: #1e3347;
}

.cs-option.cs-out-of-range {
    color: #4a6272;
    opacity: 0.55;
}

.cs-option.cs-out-of-range:hover {
    background: #2e4460;
    opacity: 0.75;
}

/* ── 地圖內搜尋框 ── */
.map-search {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 400;
    width: 240px;
}

.search-input-row {
    display: flex;
    gap: 0;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.map-search input[type="text"] {
    flex: 1;
    font-size: 13px;
    padding: 6px 10px;
    border: none;
    background: rgba(30, 44, 58, 0.92);
    color: #ecf0f1;
    outline: none;
    min-width: 0;
}

.map-search input[type="text"]::placeholder {
    color: #7f8c8d;
}

.map-search input[type="text"]:focus {
    background: rgba(30, 44, 58, 1);
}

.map-search button {
    font-size: 13px;
    padding: 6px 10px;
    border: none;
    background: rgba(52, 152, 219, 0.85);
    color: white;
    cursor: pointer;
    flex-shrink: 0;
}

.map-search button:hover {
    background: rgba(41, 128, 185, 0.95);
}

.search-results {
    margin-top: 4px;
    background: rgba(30, 44, 58, 0.96);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    max-height: 280px;
    overflow-y: auto;
}

.search-result-item {
    padding: 8px 12px;
    font-size: 12px;
    color: #ecf0f1;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    line-height: 1.4;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(52, 152, 219, 0.3);
}

.search-result-item .result-name {
    font-weight: 600;
}

.search-result-item .result-type {
    color: #7f8c8d;
    font-size: 11px;
    margin-top: 2px;
}

.search-no-result {
    padding: 10px 12px;
    font-size: 12px;
    color: #7f8c8d;
    text-align: center;
}

/* ── 對位準心（滑鼠移動時顯示在對側地圖） ── */
.map-crosshair {
    position: absolute;
    pointer-events: none;
    z-index: 450;
    display: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(231, 76, 60, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -50%);
}

/* 水平線 */
.map-crosshair::before {
    content: '';
    position: absolute;
    width: 28px;
    height: 2px;
    background: rgba(231, 76, 60, 0.85);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

/* 垂直線 */
.map-crosshair::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 28px;
    background: rgba(231, 76, 60, 0.85);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

/* ── 1915 行政區標籤 ── */
.hist-label {
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
    white-space: nowrap;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans TC', sans-serif;
    color: #1a1a1a;
    text-shadow:
        -1px -1px 0 rgba(255,255,255,0.85),
         1px -1px 0 rgba(255,255,255,0.85),
        -1px  1px 0 rgba(255,255,255,0.85),
         1px  1px 0 rgba(255,255,255,0.85);
}

.hist-cho-label {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.hist-shitcho-label {
    font-size: 13px;
    font-weight: 600;
}

.hist-ku-label {
    font-size: 11px;
    font-weight: 400;
    color: #333;
}
