/* 電車吃漢 · 品牌主題與 UX 元件 */
:root {
    --font-sans: 'Noto Sans TC', 'Microsoft JhengHei', 'PingFang TC', 'Segoe UI', sans-serif;
    --brand-rail: #003366;
    --brand-veg: #5a9e6f;
    --brand-accent: #f5a623;
    --brand-bg: #f4f7fb;
    --brand-surface: rgba(255, 255, 255, 0.97);
    --brand-text: #152536;
    --brand-muted: #4a5d6e;
    --brand-border: #dde4ec;
    --brand-gradient: linear-gradient(135deg, #003366 0%, #1a5276 50%, #5a9e6f 100%);
    --shadow-sm: 0 2px 8px rgba(0, 51, 102, 0.08);
    --shadow-md: 0 8px 24px rgba(0, 51, 102, 0.12);
    --radius: 16px;
    --wheel-size: min(85vw, 400px);
    --map-height-desktop: 520px;
    --map-height-mobile: 40vh;
    --text-xs: 0.8125rem;
    --text-sm: 0.9375rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.3125rem;
    --text-2xl: 1.5625rem;
    --line-height-body: 1.65;
    --line-height-heading: 1.35;
    --letter-spacing-body: 0.012em;
    --nav-height: 60px;
    --touch-min: 44px;
    --color-success: #5a9e6f;
    --color-danger: #c0392b;
    --color-warning: #f5a623;
}

[data-theme="dark"] {
    --brand-bg: #0f1419;
    --brand-surface: #1a2332;
    --brand-text: #e8edf2;
    --brand-muted: #9aa8b5;
    --brand-border: #2d3a4a;
    --brand-gradient: linear-gradient(135deg, #0a2540 0%, #1a5276 50%, #3d7a55 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
}

body {
    background: var(--brand-bg) !important;
    color: var(--brand-text);
    font-family: var(--font-sans) !important;
    font-size: var(--text-base);
    line-height: var(--line-height-body);
    letter-spacing: var(--letter-spacing-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.container {
    background: var(--brand-surface) !important;
    box-shadow: var(--shadow-md) !important;
    color: var(--brand-text);
}

h1, h2, h3, h4 {
    line-height: var(--line-height-heading);
    letter-spacing: 0.02em;
}

h1, h3, h4 {
    color: var(--brand-rail) !important;
}

h2 { color: var(--brand-rail); font-weight: 700; }

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
    color: var(--brand-text) !important;
}

.app-header { text-align: center; margin-bottom: 8px; }
.app-brand { font-size: var(--text-sm); color: var(--brand-veg); font-weight: 700; letter-spacing: 0.06em; margin-bottom: 4px; }
.app-subtitle { color: var(--brand-muted); font-size: var(--text-base); margin-top: 6px; font-weight: 500; }

.journey-dashboard {
    background: var(--brand-bg);
    border: 1px solid var(--brand-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
}
.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#progressText { font-weight: 700; color: var(--brand-rail); font-size: var(--text-sm); }
[data-theme="dark"] #progressText { color: var(--brand-text); }

.progress-track {
    position: relative;
    height: 14px;
    background: var(--brand-border);
    border-radius: 7px;
    overflow: visible;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-rail), var(--brand-veg)) !important;
    border-radius: 7px;
    transition: width 0.6s ease;
}
.milestone-mark {
    position: absolute;
    top: -3px;
    width: 4px;
    height: 20px;
    background: var(--brand-accent);
    border-radius: 2px;
    transform: translateX(-50%);
    opacity: 0.6;
}

.rule-info-btn {
    background: none;
    border: 1px solid var(--brand-border);
    border-radius: 20px;
    padding: 6px 14px;
    min-height: var(--touch-min);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--brand-muted);
    cursor: pointer;
}
.rule-info-btn:hover { border-color: var(--brand-veg); color: var(--brand-veg); }
.rule-tooltip {
    margin-top: 10px;
    padding: 12px 14px;
    background: var(--brand-surface);
    border: 1px solid var(--brand-border);
    border-radius: 10px;
    font-size: 0.85em;
    color: var(--brand-muted);
    line-height: 1.6;
}
.rule-tooltip.hidden { display: none; }

/* 伺服器狀態 */
.status-box { line-height: 1.7; }
.status-box p { margin: 0 0 8px; }
.status-box p:last-child { margin-bottom: 0; }
.status-ok { color: var(--brand-veg); font-weight: 600; }
.status-err { color: #e74c3c; font-weight: 600; }
.status-warn { color: var(--brand-accent); font-weight: 600; }
.status-muted { color: var(--brand-muted); font-size: var(--text-sm); line-height: 1.6; }

.wheel-wrapper {
    width: var(--wheel-size) !important;
    height: var(--wheel-size) !important;
}
.wheel-center-label { color: var(--brand-muted) !important; }
.wheel-center-station { color: var(--brand-rail) !important; }
.wheel-center.pulse { animation: center-pulse 1s ease infinite; }
@keyframes center-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.03); }
}

.button-primary {
    background: var(--brand-gradient) !important;
    box-shadow: var(--shadow-sm);
    min-width: 160px;
    min-height: var(--touch-min);
    font-size: var(--text-base);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.button-primary:disabled { opacity: 0.7; cursor: wait; }
.button-primary[aria-busy="true"] .btn-label { opacity: 0.7; }
.btn-spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
}
.btn-spinner.hidden { display: none; }
@keyframes btn-spin { to { transform: rotate(360deg); } }

.button-secondary {
    background: transparent !important;
    color: var(--brand-rail) !important;
    border: 2px solid var(--brand-rail) !important;
    box-shadow: none !important;
}
[data-theme="dark"] .button-secondary { color: var(--brand-veg) !important; border-color: var(--brand-veg) !important; }

.result-header { background: var(--brand-gradient) !important; }
.result-station-name { font-size: 1.8em; font-weight: 700; margin: 8px 0; }
.result-city { opacity: 0.9; font-size: 1em; }

.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}
.chip {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.35);
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85em;
    cursor: pointer;
    transition: background 0.2s;
}
.chip:hover { background: rgba(255,255,255,0.35); }

.result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.btn-share, .btn-share-img {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background: rgba(255,255,255,0.25);
    color: white;
    cursor: pointer;
    font-size: 0.9em;
}
.btn-share:hover, .btn-share-img:hover { background: rgba(255,255,255,0.4); }

.result-map-container {
    height: var(--map-height-desktop) !important;
    min-height: 280px !important;
}

.poi-grid { display: flex; flex-direction: column; gap: 12px; }
.poi-card {
    display: flex;
    gap: 14px;
    background: var(--brand-surface);
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    padding: 14px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}
.poi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.poi-card-thumb {
    width: 96px; height: 96px;
    border-radius: 10px;
    background: var(--brand-bg);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5em; flex-shrink: 0;
    overflow: hidden;
}
.poi-card-thumb.poi-thumb-fallback {
    background: linear-gradient(135deg, var(--brand-rail), var(--brand-veg));
}
.poi-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.poi-card-body { flex: 1; min-width: 0; }
.poi-card-name { font-weight: 700; font-size: var(--text-base); color: var(--brand-text); margin-bottom: 4px; }
.poi-card-meta { font-size: var(--text-sm); color: var(--brand-muted); margin-bottom: 6px; line-height: 1.5; }
.poi-card-link {
    display: inline-block;
    font-size: 0.8em;
    color: var(--brand-veg);
    text-decoration: none;
    font-weight: 600;
}
.poi-card-link:hover { text-decoration: underline; }
.poi-card-rating { font-size: 0.95em; color: var(--brand-accent); white-space: nowrap; }

.history-section.collapsible { margin-top: 32px; }
.history-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: var(--brand-bg);
    border: 1px solid var(--brand-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 600;
    color: var(--brand-rail);
}
.history-toggle .chevron { margin-left: auto; transition: transform 0.2s; }
.history-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.history-count {
    background: var(--brand-veg);
    color: white;
    font-size: 0.75em;
    padding: 2px 8px;
    border-radius: 10px;
}
.history-body { padding: 16px 0 0; }
.history-body.hidden { display: none; }
.history-cards { display: flex; flex-direction: column; gap: 10px; }
.history-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--brand-surface);
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    flex-wrap: wrap;
}
.history-card-info { flex: 1; min-width: 140px; }
.history-card-station { font-weight: 700; color: var(--brand-rail); font-size: 1.05em; }
[data-theme="dark"] .history-card-station { color: var(--brand-text); }
.history-card-meta { font-size: 0.85em; color: var(--brand-muted); margin-top: 4px; }
.history-card-actions { display: flex; gap: 8px; }

.settings-fab {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    top: auto !important;
    z-index: 1500;
    width: 52px; height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--brand-gradient) !important;
    color: white;
    font-size: 1.4em;
    box-shadow: var(--shadow-md);
    cursor: pointer;
}
.setting-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; cursor: pointer; }

.milestone-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--brand-rail);
    color: white;
    padding: 14px 24px;
    border-radius: 30px;
    box-shadow: var(--shadow-md);
    z-index: 3000;
    font-weight: 600;
    animation: toast-in 0.4s ease;
}
.milestone-toast.hidden { display: none; }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.achievement-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 20, 40, 0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 4000;
    padding: 20px;
}
.achievement-overlay.hidden { display: none; }
.achievement-card {
    background: var(--brand-surface);
    border-radius: 24px;
    padding: 40px 32px;
    text-align: center;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}
.achievement-icon { font-size: 4em; margin-bottom: 16px; }
.achievement-actions { display: flex; gap: 10px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }

.tab-button[aria-selected="true"] {
    color: var(--brand-rail) !important;
    border-bottom-color: var(--brand-veg) !important;
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.hidden { display: none !important; }
.loading-text, .empty-state { text-align: center; padding: 24px; color: var(--brand-muted); font-style: italic; }

@media (prefers-reduced-motion: reduce) {
    .wheel, .wheel-spinning, .progress-bar, .poi-card, .milestone-toast { transition: none !important; animation: none !important; }
    .wheel-center.pulse { animation: none !important; }
}

body.reduce-motion .wheel,
body.reduce-motion .wheel-spinning,
body.reduce-motion .fireworks-container { transition: none !important; animation: none !important; }
body.reduce-motion .wheel-center.pulse { animation: none !important; }
body.reduce-motion .fireworks-container { display: none !important; }

@media (max-width: 768px) {
    .container { padding: 20px !important; }
    h1 { font-size: 1.8em !important; }
    .result-map-container {
        height: var(--map-height-mobile) !important;
        min-height: 200px !important;
    }
    .result-info {
        height: auto !important;
        min-height: 360px !important;
    }
    .tabs-container { scroll-snap-type: x mandatory; }
    .tab-button { scroll-snap-align: start; min-width: 90px !important; }
    .quick-chips { gap: 6px; }
    .chip { font-size: 0.8em; padding: 6px 10px; }
    .settings-fab { bottom: 16px !important; right: 16px !important; }
}

[data-theme="dark"] .tab-content,
[data-theme="dark"] .result-info,
[data-theme="dark"] .history-card,
[data-theme="dark"] .poi-card,
[data-theme="dark"] .journey-dashboard {
    background: var(--brand-surface);
    color: var(--brand-text);
}

/* 環島地圖 */
.island-map-section { margin-bottom: 28px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-header h2 { font-size: 1.15em; margin: 0; color: var(--brand-rail); }
.map-legend { font-size: 0.85em; color: var(--brand-muted); }
.island-map-container { position: relative; border: 1px solid var(--brand-border); border-radius: var(--radius); overflow: hidden; background: var(--brand-bg); }
.island-map-canvas { width: 100%; height: auto; display: block; cursor: crosshair; }
.map-tooltip { position: absolute; background: var(--brand-rail); color: #fff; padding: 4px 10px; border-radius: 6px; font-size: 0.8em; pointer-events: none; z-index: 10; white-space: nowrap; }
.map-hint { font-size: 0.8em; color: var(--brand-muted); margin-top: 8px; text-align: center; }
.leaflet-map-host { width: 100%; height: 420px; min-height: 280px; z-index: 1; }
.leaflet-map-host .leaflet-control-attribution { font-size: 10px; }
.progress-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 進度同步 */
.sync-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.sync-overlay.hidden { display: none; }
.sync-card { background: var(--brand-surface); border-radius: var(--radius); padding: 24px; max-width: 420px; width: 100%; position: relative; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.sync-close { position: absolute; top: 12px; right: 12px; border: none; background: none; font-size: 1.5em; cursor: pointer; color: var(--brand-muted); line-height: 1; }
.sync-card h2 { margin: 0 0 8px; font-size: 1.2em; color: var(--brand-rail); }
.sync-desc { font-size: 0.9em; color: var(--brand-muted); margin-bottom: 16px; }
.sync-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.sync-tab { flex: 1; padding: 8px; border: 1px solid var(--brand-border); border-radius: 8px; background: var(--brand-bg); cursor: pointer; font-size: 0.9em; }
.sync-tab.active { border-color: var(--brand-veg); background: var(--brand-surface); font-weight: 600; }
.sync-code-area { width: 100%; box-sizing: border-box; font-family: monospace; font-size: 0.75em; padding: 10px; border: 1px solid var(--brand-border); border-radius: 8px; margin-bottom: 10px; resize: vertical; }
#syncQrCanvas { display: block; margin: 0 auto 12px; border: 1px solid var(--brand-border); border-radius: 8px; }

/* 抽籤模式 */
.draw-mode-section { margin-bottom: 24px; }
.draw-mode-section h2 { font-size: 1.15em; margin-bottom: 12px; color: var(--brand-rail); }
.draw-mode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.draw-mode-btn { padding: 10px 12px; border: 1px solid var(--brand-border); border-radius: 10px; background: var(--brand-surface); cursor: pointer; text-align: left; transition: border-color 0.2s, box-shadow 0.2s; }
.draw-mode-btn.active { border-color: var(--brand-veg); box-shadow: 0 0 0 2px rgba(90,158,111,0.25); }
.draw-mode-label { display: block; font-weight: 600; font-size: 0.9em; color: var(--brand-rail); }
.draw-mode-desc { display: block; font-size: 0.75em; color: var(--brand-muted); margin-top: 2px; }
.draw-mode-hint { font-size: 0.85em; color: var(--brand-muted); margin-top: 10px; }

/* 車站資訊卡 */
.station-info-card { line-height: 1.7; }
.station-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.station-tag { background: var(--brand-bg); border: 1px solid var(--brand-border); padding: 2px 10px; border-radius: 12px; font-size: 0.8em; color: var(--brand-veg); }
.station-intro { margin-bottom: 16px; }
.station-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.station-facts dt { font-size: 0.75em; color: var(--brand-muted); }
.station-facts dd { font-weight: 600; margin: 0; }
.station-links { display: flex; flex-wrap: wrap; gap: 10px; }
.station-links a { font-size: 0.85em; color: var(--brand-veg); text-decoration: none; }
.station-links a:hover { text-decoration: underline; }

/* 行程串聯 */
.trip-section { margin-bottom: 20px; }
.trip-section h4 { margin-bottom: 10px; }
.trip-link { display: block; padding: 8px 0; color: var(--brand-veg); text-decoration: none; font-size: 0.9em; }
.trip-link:hover { text-decoration: underline; }
.trip-nearby-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--brand-border); font-size: 0.9em; }
.trip-link-sm { color: var(--brand-veg); font-size: 0.85em; text-decoration: none; }

/* 今日行程 checklist */
.trip-checklist { margin-top: 8px; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--brand-border); font-size: 0.9em; }
.checklist-item.done label span { text-decoration: line-through; color: var(--brand-muted); }
.checklist-item label { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; }
.btn-nearby-spin { margin-top: 12px; width: 100%; }

/* 鍵盤 focus */
:focus-visible { outline: 2px solid var(--brand-veg); outline-offset: 2px; }

/* 素食路線 */
.btn-generate-route { margin-bottom: 16px; }
.veg-route-list { padding-left: 20px; }
.veg-route-step { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--brand-border); }
.route-time { display: inline-block; background: var(--brand-accent); color: #fff; padding: 2px 8px; border-radius: 8px; font-size: 0.8em; margin-right: 8px; }
.route-source { font-size: 0.85em; color: var(--brand-muted); margin-bottom: 12px; }

/* POI 篩選 */
.poi-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.poi-filter-btn { padding: 6px 12px; border: 1px solid var(--brand-border); border-radius: 16px; background: var(--brand-surface); font-size: 0.8em; cursor: pointer; }
.poi-filter-btn.active { background: var(--brand-veg); color: #fff; border-color: var(--brand-veg); }
.poi-filter-group-label { font-size: 0.75em; color: var(--brand-muted); align-self: center; margin-right: 2px; }
.veg-badge { display: inline-block; background: rgba(90,158,111,0.15); color: var(--brand-veg); padding: 2px 8px; border-radius: 8px; font-size: 0.75em; margin-bottom: 4px; }
.photo-attribution { font-size: 0.65em; color: var(--brand-muted); }

/* 成就面板 */
.achievement-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--brand-border); }
.achievement-item.unlocked { opacity: 1; }
.achievement-item-icon { font-size: 1.5em; }
.achievement-item-title { font-weight: 600; font-size: 0.9em; }
.achievement-item-desc { font-size: 0.75em; color: var(--brand-muted); }
.achievement-item-bar { height: 4px; background: var(--brand-border); border-radius: 2px; margin: 6px 0; }
.achievement-item-bar div { height: 100%; background: var(--brand-veg); border-radius: 2px; }

.setting-row select { margin-left: auto; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--brand-border); }

/* Phase A · 首屏 hero 與折疊區 */
.hero-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}
.hero-section .wheel-container { margin-bottom: 0; }
.hero-section .action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 8px;
}

.collapsible-section {
    margin-bottom: 24px;
    border: 1px solid var(--brand-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--brand-bg);
}
.section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: var(--brand-rail);
}
[data-theme="dark"] .section-toggle { color: var(--brand-text); }
.section-toggle .chevron { transition: transform 0.2s; font-size: 0.85em; color: var(--brand-muted); }
.section-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.section-body { padding: 0 18px 18px; }
.section-body.hidden { display: none; }

/* 結果 reveal */
.result-reveal.result-reveal-play {
    animation: result-reveal-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes result-reveal-in {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.result-prefix {
    font-size: 0.85em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.85;
    margin-bottom: 4px;
}

/* Tab 面板 */
.tab-content[hidden] { display: none !important; }
.tab-content.active { display: block; }
.tab-title { font-size: var(--text-lg); font-weight: 700; margin: 0 0 12px; color: var(--brand-rail); }
[data-theme="dark"] .tab-title { color: var(--brand-text); }
.trip-route-block {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--brand-border);
}

/* 探索 segmented control */
.poi-segment {
    display: flex;
    gap: 6px;
    padding: 4px;
    background: var(--brand-bg);
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    margin-bottom: 12px;
}
.poi-segment-btn {
    flex: 1;
    padding: 12px 8px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--brand-muted);
    font-size: var(--text-sm);
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    min-height: var(--touch-min);
}
.poi-segment-btn.active,
.poi-segment-btn[aria-selected="true"] {
    background: var(--brand-surface);
    color: var(--brand-rail);
    box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .poi-segment-btn.active { color: var(--brand-text); }
.poi-panels { min-height: 120px; }
.poi-panel { display: none; }
.poi-panel.active { display: block; }

/* POI 卡片升級 */
.poi-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
}
.poi-card-head .poi-card-name { margin-bottom: 0; flex: 1; }
.poi-card-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.poi-dist-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.75em;
    font-weight: 600;
    background: rgba(0, 51, 102, 0.08);
    color: var(--brand-rail);
}
[data-theme="dark"] .poi-dist-badge {
    background: rgba(255, 255, 255, 0.08);
    color: var(--brand-text);
}
.poi-status-open {
    font-size: 0.75em;
    font-weight: 600;
    color: var(--brand-veg);
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(90, 158, 111, 0.12);
}
.poi-status-closed {
    font-size: 0.75em;
    font-weight: 600;
    color: #c0392b;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(192, 57, 43, 0.1);
}

/* POI skeleton */
.poi-skeleton-list { display: flex; flex-direction: column; gap: 12px; }
.poi-skeleton-card {
    display: flex;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    background: var(--brand-surface);
}
.poi-skeleton-thumb {
    width: 96px; height: 96px;
    border-radius: 10px;
    flex-shrink: 0;
    background: linear-gradient(90deg, var(--brand-border) 25%, var(--brand-bg) 50%, var(--brand-border) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s ease infinite;
}
.poi-skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.poi-skeleton-lines span {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--brand-border) 25%, var(--brand-bg) 50%, var(--brand-border) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s ease infinite;
}
.poi-skeleton-lines span:nth-child(1) { width: 70%; }
.poi-skeleton-lines span:nth-child(2) { width: 45%; }
.poi-skeleton-lines span:nth-child(3) { width: 55%; }
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Legacy 紫色覆蓋 */
.wheel {
    border-color: var(--brand-rail) !important;
    box-shadow: var(--shadow-md) !important;
}
.pointer { border-bottom-color: var(--brand-accent) !important; }
.button:not(.button-primary):not(.button-secondary) {
    background: var(--brand-gradient) !important;
    box-shadow: var(--shadow-sm) !important;
}
.tab-button { color: var(--brand-muted) !important; }
.tab-button.active,
.tab-button[aria-selected="true"] {
    color: var(--brand-rail) !important;
    border-bottom-color: var(--brand-veg) !important;
}
[data-theme="dark"] .tab-button.active { color: var(--brand-text) !important; }

@media (max-width: 768px) {
    .poi-segment-btn { font-size: 0.82em; padding: 9px 6px; }
    .poi-card-thumb { width: 80px; height: 80px; }
    .poi-skeleton-thumb { width: 80px; height: 80px; }
    .section-body { padding: 0 12px 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .result-reveal.result-reveal-play,
    .poi-skeleton-thumb,
    .poi-skeleton-lines span { animation: none !important; }
}
body.reduce-motion .result-reveal.result-reveal-play,
body.reduce-motion .poi-skeleton-thumb,
body.reduce-motion .poi-skeleton-lines span { animation: none !important; }

/* Phase B · App 級導覽與設計系統 */
.icon { display: block; flex-shrink: 0; }
.mobile-only { display: none !important; }
.desktop-only-inline { display: inline-block; }

.progress-narrative {
    margin-top: var(--space-2, 8px);
    font-size: var(--text-sm);
    color: var(--brand-rail);
    font-weight: 700;
}
.progress-narrative.hidden { display: none; }
.progress-subtext {
    margin-top: var(--space-2, 8px);
    font-size: var(--text-xs);
    color: var(--brand-veg);
    font-weight: 600;
}
.progress-subtext.hidden { display: none; }

.draw-mode-chips-wrap { width: 100%; max-width: 640px; margin-top: 12px; padding: 0 8px; }
.draw-mode-chips {
    display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
    padding-bottom: 4px; scrollbar-width: none;
}
.draw-mode-chips::-webkit-scrollbar { display: none; }
.draw-mode-chip {
    flex-shrink: 0; scroll-snap-align: start;
    padding: 8px 12px; border: 1px solid var(--brand-border); border-radius: 20px;
    background: var(--brand-surface); color: var(--brand-muted);
    font-size: var(--text-sm); font-weight: 600; cursor: pointer;
}
.draw-mode-chip.active {
    border-color: var(--brand-veg); color: var(--brand-rail);
    background: rgba(90, 158, 111, 0.1); box-shadow: 0 0 0 2px rgba(90, 158, 111, 0.2);
}
.draw-mode-hint-inline { text-align: center; font-size: var(--text-xs); color: var(--brand-muted); margin-top: 8px; }

.result-sticky-header { position: sticky; top: 0; z-index: 50; }

.map-modal { position: fixed; inset: 0; z-index: 5000; display: flex; align-items: flex-end; justify-content: center; }
.map-modal.hidden { display: none !important; }
.map-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 20, 40, 0.55); }
.map-modal-sheet {
    position: relative; width: 100%; max-width: 900px; max-height: 92vh;
    background: var(--brand-surface); border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-md);
    animation: sheet-up 0.3s ease;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.map-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px; border-bottom: 1px solid var(--brand-border);
}
.map-modal-header h2 { margin: 0; font-size: var(--text-lg); color: var(--brand-rail); }
.map-modal-close {
    border: none; background: var(--brand-bg); border-radius: 50%;
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.map-modal-frame { width: 100%; height: min(70vh, 560px); border: none; flex: 1; }

.btn-view-map {
    display: inline-flex; align-items: center; gap: 8px; width: 100%; justify-content: center;
    margin-bottom: 16px; padding: 12px; border: 1px solid var(--brand-border); border-radius: 12px;
    background: var(--brand-bg); color: var(--brand-rail); font-weight: 600; font-size: var(--text-sm); cursor: pointer;
}

.result-bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 4000; display: none;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--brand-surface);
    border-top: 1px solid var(--brand-border); box-shadow: 0 -4px 16px rgba(0, 51, 102, 0.08);
}
.bottom-nav-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: none; background: transparent; color: var(--brand-muted);
    font-size: var(--text-xs); font-weight: 700; cursor: pointer;
    padding: 6px 0; min-height: var(--nav-height);
}
.bottom-nav-btn .icon { width: 24px; height: 24px; }
.bottom-nav-btn.active { color: var(--brand-rail); }

.confirm-modal {
    position: fixed; inset: 0; z-index: 6000;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.confirm-modal.hidden { display: none !important; }
.confirm-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 20, 40, 0.6); }
.confirm-modal-card {
    position: relative; background: var(--brand-surface); border-radius: var(--radius);
    padding: 24px; max-width: 400px; width: 100%; box-shadow: var(--shadow-md);
}
.confirm-modal-card h2 { margin: 0 0 12px; font-size: var(--text-xl); color: var(--brand-rail); }
.confirm-desc { font-size: var(--text-sm); color: var(--brand-muted); line-height: 1.6; margin-bottom: 16px; }
.confirm-input-label { display: block; font-size: var(--text-sm); margin-bottom: 16px; }
.confirm-input {
    display: block; width: 100%; margin-top: 8px; padding: 12px;
    border: 1px solid var(--brand-border); border-radius: 10px; box-sizing: border-box;
}
.confirm-actions { display: flex; gap: 12px; justify-content: flex-end; }
.btn-destructive { background: var(--color-danger) !important; color: #fff !important; border: none !important; }
.btn-destructive:disabled { opacity: 0.45; cursor: not-allowed; }

.onboarding-overlay {
    position: fixed; inset: 0; z-index: 7000; background: rgba(0, 20, 40, 0.65);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.onboarding-overlay.hidden { display: none !important; }
.onboarding-card {
    background: var(--brand-surface); border-radius: var(--radius); padding: 24px;
    max-width: 380px; width: 100%; box-shadow: var(--shadow-md);
}
.onboarding-step-indicator { font-size: var(--text-xs); color: var(--brand-muted); margin-bottom: 8px; }
.onboarding-card h2 { margin: 0 0 12px; font-size: var(--text-xl); color: var(--brand-rail); }
.onboarding-card p { font-size: var(--text-sm); color: var(--brand-muted); line-height: 1.7; margin-bottom: 24px; }
.onboarding-actions { display: flex; gap: 12px; justify-content: flex-end; }
body.modal-open { overflow: hidden; }

/* Phase C · 探索地圖、空狀態、分享模板 */
.explore-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 12px;
}
.explore-view-toggle {
    display: inline-flex; padding: 3px; background: var(--brand-bg);
    border: 1px solid var(--brand-border); border-radius: 10px;
}
.explore-view-btn {
    padding: 6px 14px; border: none; border-radius: 8px; background: transparent;
    color: var(--brand-muted); font-size: var(--text-sm); font-weight: 600; cursor: pointer;
}
.explore-view-btn.active { background: var(--brand-surface); color: var(--brand-rail); box-shadow: var(--shadow-sm); }
.explore-map-container {
    width: 100%; height: 320px; min-height: 240px;
    border: 1px solid var(--brand-border); border-radius: 12px; margin-bottom: 12px; overflow: hidden;
}
.explore-map-container.hidden { display: none !important; }
.poi-map-popup { font-size: var(--text-sm); line-height: 1.5; }
.poi-map-popup-meta { color: var(--brand-muted); margin: 4px 0 6px; }

.poi-source-badge { font-size: var(--text-xs); font-weight: 600; padding: 4px 10px; border-radius: 12px; }
.poi-source-badge.hidden { display: none; }
.poi-source-live { background: rgba(90, 158, 111, 0.12); color: var(--color-success); }
.poi-source-cache { background: rgba(245, 166, 35, 0.15); color: var(--color-warning); }

.poi-card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.poi-add-trip-btn {
    padding: 4px 10px; border: 1px solid var(--brand-veg); border-radius: 8px;
    background: transparent; color: var(--brand-veg); font-size: var(--text-xs); font-weight: 600; cursor: pointer;
}

.empty-state-card {
    text-align: center; padding: 24px 16px;
    border: 1px dashed var(--brand-border); border-radius: 12px; background: var(--brand-bg);
}
.empty-state-icon { color: var(--brand-muted); margin-bottom: 12px; }
.empty-state-title { font-weight: 600; color: var(--brand-text); margin-bottom: 8px; line-height: 1.5; }
.empty-state-desc { font-size: var(--text-sm); color: var(--brand-muted); margin-bottom: 12px; }
.empty-state-actions { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty-state-widen {
    display: inline-block; padding: 8px 16px; border-radius: 20px;
    border: 1px solid var(--brand-veg); background: rgba(90, 158, 111, 0.1);
    color: var(--brand-veg); font-size: var(--text-sm); font-weight: 600; cursor: pointer;
}
.empty-state-widen:hover { background: rgba(90, 158, 111, 0.18); }
.empty-state-cta {
    display: inline-block; padding: 8px 16px; border-radius: 20px;
    background: var(--brand-rail); color: #fff; text-decoration: none; font-size: var(--text-sm); font-weight: 600;
}

.checklist-custom { border-left: 3px solid var(--brand-veg); padding-left: 8px; }

.share-template-card { max-width: 440px; }
.share-template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.share-template-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 16px 8px; border: 1px solid var(--brand-border); border-radius: 12px;
    background: var(--brand-bg); cursor: pointer;
}
.share-template-name { font-weight: 700; color: var(--brand-rail); font-size: var(--text-sm); }
.share-template-desc { font-size: var(--text-xs); color: var(--brand-muted); }
.share-template-cancel { width: 100%; }

@media (max-width: 768px) {
    .mobile-only { display: flex !important; }
    body.result-nav-visible .result-bottom-nav { display: flex !important; }
    .desktop-only { display: none !important; }
    .desktop-only-inline { display: none !important; }
    .top-tabs { display: none !important; }
    .result-content.desktop-only-map { flex-direction: column !important; }
    .result-info { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px) !important; }
    body.result-nav-visible .settings-fab { bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px) !important; }
    .share-template-grid { grid-template-columns: 1fr; }
    .explore-map-container { height: 280px; }
}

/* 手機優先（含 Samsung S25 等 ~360–430px 寬螢幕） */
@media (max-width: 480px) {
    :root {
        --text-xs: 0.8125rem;
        --text-sm: 0.9375rem;
        --text-base: 1.0625rem;
        --text-lg: 1.1875rem;
        --text-xl: 1.375rem;
        --text-2xl: 1.625rem;
        --nav-height: 64px;
        --wheel-size: min(88vw, 360px);
    }

    body {
        padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)) !important;
    }

    .container { padding: 16px !important; border-radius: 14px !important; }
    h1 { font-size: var(--text-2xl) !important; font-weight: 700 !important; margin-bottom: 16px !important; }

    .journey-dashboard { padding: 14px 16px; margin-bottom: 16px; }
    .progress-header { flex-direction: column; align-items: stretch; gap: 10px; }
    .progress-actions { justify-content: stretch; }
    .progress-actions .rule-info-btn { flex: 1; text-align: center; }

    .button-primary, .button-secondary {
        min-height: 48px;
        font-size: var(--text-base);
        padding: 12px 20px;
    }

    .hero-section { margin-bottom: 12px; }
    .draw-mode-chip {
        font-size: var(--text-sm);
        padding: 10px 14px;
        min-height: 40px;
    }

    .section-toggle, .history-toggle {
        font-size: var(--text-base);
        padding: 16px;
        min-height: 48px;
    }

    .result-station-name { font-size: var(--text-2xl) !important; }
    .result-header { padding: 24px 16px !important; }

    .poi-card { padding: 16px; gap: 12px; }
    .poi-card-thumb { width: 88px; height: 88px; }
    .poi-skeleton-thumb { width: 88px; height: 88px; }
    .poi-filter-btn {
        font-size: var(--text-sm);
        padding: 8px 14px;
        min-height: 36px;
    }

    .tab-title { font-size: var(--text-xl); margin-bottom: 14px; }
    .trip-section h4 { font-size: var(--text-lg); font-weight: 700; margin-bottom: 12px; }
    .checklist-item { font-size: var(--text-base); padding: 10px 0; min-height: 44px; }
    .trip-link, .trip-link-sm { font-size: var(--text-sm); }

    .settings-fab {
        width: 56px; height: 56px;
        bottom: max(16px, env(safe-area-inset-bottom)) !important;
        right: max(16px, env(safe-area-inset-right)) !important;
    }

    .settings-panel { font-size: var(--text-base); }
    .settings-section-title { font-size: var(--text-sm); font-weight: 700; }
    .setting-row { min-height: 44px; font-size: var(--text-base); }

    .milestone-toast {
        top: max(16px, env(safe-area-inset-top));
        font-size: var(--text-sm);
        max-width: calc(100vw - 32px);
        text-align: center;
    }

    .onboarding-card h2 { font-size: var(--text-xl); }
    .onboarding-card p { font-size: var(--text-base); }

    .empty-state-title { font-size: var(--text-base); }
    .empty-state-desc { font-size: var(--text-sm); }

    .poi-segment-btn { font-size: var(--text-xs); padding: 10px 4px; }
    .explore-view-btn { padding: 8px 16px; font-size: var(--text-sm); min-height: 40px; }
    .btn-view-map { font-size: var(--text-base); min-height: 48px; }
}

.manual-link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--brand-veg);
    background: rgba(90, 158, 111, 0.08);
    color: var(--brand-rail);
    font-size: var(--text-base);
    font-weight: 700;
    text-decoration: none;
    min-height: var(--touch-min);
}
.manual-link-btn:hover { background: rgba(90, 158, 111, 0.15); }
[data-theme="dark"] .manual-link-btn { color: var(--brand-text); }
@media (min-width: 769px) {
    .map-modal { align-items: center; }
    .map-modal-sheet { border-radius: var(--radius); max-height: 85vh; }
}
