:root {
    --primary: #2563eb;
    --bg: #f8fafc;
    --seat-unknown: #cbd5e1;
    --seat-busy: #64748b;
    --seat-free: rgba(16, 185, 129, 0.8);
    --seat-border: rgba(255, 255, 255, 0.4);
    --plug-color: #3b82f6;
    --light-glow: rgba(253, 224, 71, 0.4);
    --tooltip-bg: rgba(15, 23, 42, 0.9);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    margin: 0; padding: 0;
    height: 100vh; height: 100dvh;
    overflow: hidden;
    display: flex; flex-direction: column;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.header { flex-shrink: 0; z-index: 50; background: #fff; padding: 12px 30px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.05); padding-top: max(12px, env(safe-area-inset-top)); }
.title { font-weight: 700; color: #1e293b; font-size: 20px; letter-spacing: -.5px; }
.title-container { display: flex; align-items: center; gap: 10px; }
.github-link { color: #1e293b; display: flex; align-items: center; transition: color 0.2s; }
.github-link:hover { color: #2563eb; }
.github-icon { width: 20px; height: 20px; fill: currentColor; }
.reload-btn { background: #fff; border: 1px solid #cbd5e1; padding: 6px 16px; border-radius: 6px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; color: #475569; transition: all .2s; }
.reload-btn:hover { background: #f1f5f9; border-color: #94a3b8; }
.reload-btn:active { transform: translateY(1px); }
.controls { flex-shrink: 0; background: #fff; padding: 15px 30px; border-bottom: 1px solid #e2e8f0; display: grid; grid-template-columns: 200px 1fr 200px; gap: 30px; align-items: center; z-index: 40; }
.date-sel { padding: 6px 10px; border-radius: 6px; border: 1px solid #cbd5e1; font-size: 14px; width: 100%; outline: 0; cursor: pointer; }
.slider-container { display: flex; flex-direction: column; gap: 5px; }
.time-label { text-align: center; font-weight: 600; color: var(--primary); font-size: 14px; margin-bottom: 5px; }
.slider-wrap { position: relative; height: 30px; cursor: pointer; touch-action: none; }
.track { position: absolute; top: 50%; width: 100%; height: 6px; background: #e2e8f0; border-radius: 3px; transform: translateY(-50%); }
.fill { position: absolute; top: 50%; height: 6px; background: var(--primary); transform: translateY(-50%); border-radius: 3px; }
.thumb { position: absolute; top: 50%; width: 20px; height: 20px; background: #fff; border: 2px solid var(--primary); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 1px 3px rgba(0,0,0,.2); z-index: 10; pointer-events: none; }
.now-marker { position: absolute; top: -5px; bottom: -5px; width: 2px; background: red; z-index: 5; pointer-events: none; display: none; transition: left 0.3s ease; }
.now-label { position: absolute; top: -12px; left: -50%; transform: translateX(-25%); font-size: 10px; color: red; font-weight: 700; }
.legend-btn-wrap { display: flex; justify-content: flex-end; }
.legend-btn { background: #f8fafc; border: 1px solid #e2e8f0; padding: 8px 16px; border-radius: 8px; font-weight: 600; color: #475569; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 14px; transition: all 0.2s; }
.legend-btn:hover { background: #f1f5f9; border-color: #cbd5e1; color: #1e293b; }

.viewport { flex: 1; position: relative; background: #e2e8f0; overflow: hidden; touch-action: none; cursor: grab; }
.viewport:active { cursor: grabbing; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

#canvasTooltip { position: fixed; background: var(--tooltip-bg); color: #fff; padding: 6px 10px; border-radius: 4px; font-size: 14px; font-weight: 600; white-space: nowrap; pointer-events: none; z-index: 1000; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); transform: translate(-50%, -100%); margin-top: -10px; opacity: 0; transition: opacity 0.15s ease; }
#canvasTooltip.visible { opacity: 1; }

.action-bar { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); left: 16px; right: 16px; margin: 0 auto; max-width: 360px; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); padding: 20px; border-radius: 16px; box-shadow: 0 10px 25px -5px rgba(0,0,0,.15), 0 8px 10px -6px rgba(0,0,0,.1); transform: translateY(calc(100% + 32px)); opacity: 0; pointer-events: none; transition: transform .3s cubic-bezier(.16, 1, .3, 1), opacity .3s ease; z-index: 9999; display: flex; flex-direction: column; }
.action-bar.visible { transform: translateY(0); opacity: 1; pointer-events: auto; }
.action-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.action-title { font-size: 18px; font-weight: 700; color: #1e293b; margin: 0; }
.action-close { background: transparent; border: none; color: #94a3b8; cursor: pointer; padding: 4px; border-radius: 50%; transition: all 0.2s; display: flex; justify-content: center; align-items: center; width: 28px; height: 28px; }
.action-close:hover { background: #f1f5f9; color: #1e293b; }
.action-details { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.action-availability { font-size: 14px; font-weight: 600; }
.action-amenities { display: flex; gap: 8px; align-items: center; }
.action-btn { border: none; padding: 14px 24px; border-radius: 10px; font-weight: 600; font-size: 16px; cursor: pointer; width: 100%; transition: all 0.2s; text-align: center; }
.action-btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 6px -1px rgba(37,99,235,.3); }
.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.btn-disabled { background: #e2e8f0; color: #94a3b8; cursor: not-allowed; pointer-events: none; }

.toast { position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-20px); background: #ef4444; color: #fff; padding: 10px 20px; border-radius: 20px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: all .3s ease; z-index: 2000; box-shadow: 0 10px 15px -3px rgba(0,0,0,.2); }
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer-bar { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255, 255, 255, 0.9); border-top: 1px solid #e2e8f0; display: flex; align-items: stretch; z-index: 500; backdrop-filter: blur(4px); font-size: 13px; }
.footer-link { flex: 1; display: flex; align-items: center; padding: 10px 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); color: #64748b; text-decoration: none; transition: color 0.2s; font-weight: 500; }
.footer-link:hover { color: var(--primary); }
.footer-link-left { justify-content: flex-end; padding-right: 8px; }
.footer-link-right { justify-content: flex-start; padding-left: 8px; }
.footer-separator { display: flex; align-items: center; color: #cbd5e1; padding: 10px 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.bmc-footer-link { color: #d97706; font-weight: 600; }
.bmc-footer-link:hover { color: #b45309; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); z-index: 10000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; padding: 20px; }
.modal-overlay.visible { opacity: 1; pointer-events: auto; }
.modal-content { background: #fff; border-radius: 16px; width: 100%; max-width: 500px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); transform: scale(0.95); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); overflow: hidden; }
.modal-overlay.visible .modal-content { transform: scale(1); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 18px; color: #1e293b; }
.modal-close { background: transparent; border: none; font-size: 24px; color: #64748b; cursor: pointer; padding: 4px; border-radius: 6px; line-height: 1; transition: all 0.2s; }
.modal-close:hover { background: #f1f5f9; color: #ef4444; }
.modal-body { display: flex; padding: 24px; gap: 30px; }
.legend-list { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.leg-interactive { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: background 0.2s; color: #475569; font-weight: 500; font-size: 14px; }
.leg-interactive:hover, .leg-interactive:active { background: #f1f5f9; color: #1e293b; }
.swatch { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; }
.sw-plug { border: 2px solid var(--plug-color); }
.sw-light { background: #fef08a; border: 1px solid #eab308; }
.sw-unknown { background: var(--seat-unknown); }
.sw-busy { background: var(--seat-busy); }
.sw-free { background: var(--seat-free); }

.legend-showcase { width: 140px; background: #e2e8f0; border-radius: 12px; display: flex; align-items: center; justify-content: center; padding: 20px; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05); }
#demoCanvas { width: 80px; height: 80px; display: block; }

@media (max-width: 768px) {
    .header { padding: 10px 15px; padding-top: max(10px, env(safe-area-inset-top)); }
    .title { font-size: 16px; }
    .reload-btn span:first-child { display: none; }
    .controls { grid-template-columns: 1fr auto; grid-template-areas: "date legend" "slider slider"; gap: 12px; padding: 15px; height: auto; }
    .controls > div:first-child { grid-area: date; }
    .date-sel { height: 36px; box-sizing: border-box; padding: 0 10px; }
    .legend-btn { height: 36px; box-sizing: border-box; width: auto; justify-content: center; padding: 0 12px; font-size: 13px; background: transparent; border: 1px solid #cbd5e1; margin: 0; }
    .slider-container { grid-area: slider; flex-direction: row; align-items: center; gap: 15px; }
    .slider-wrap { flex: 1; }
    .time-label { margin-bottom: 0; order: 2; min-width: 85px; text-align: right; }
    .legend-btn-wrap { grid-area: legend; justify-content: flex-end; }
    .modal-body { flex-direction: column-reverse; align-items: center; gap: 20px; max-height: 70vh; overflow-y: auto; }
    .legend-list { width: 100%; }
    .legend-showcase { width: 100%; height: 144px; flex-shrink: 0; box-sizing: border-box; }
}