:root { --primary: #007aff; --accent: #ff3b30; --bg-color: #f5f7fa; --panel-bg: rgba(255, 255, 255, 0.95); }
body { margin: 0; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: var(--bg-color); height: 100dvh; display: flex; flex-direction: column; user-select: none; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.view { display: flex; flex-direction: column; height: 100%; width: 100%; position: relative; }

#menu-view { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, #e0f7fa 0%, #ffffff 100%); display: flex; justify-content: center; align-items: center; z-index: 100; }
.menu-content { text-align: center; width: 85%; max-width: 400px; display: flex; flex-direction: column; gap: 15px; }
.logo { font-size: 4rem; margin-bottom: 5px; } h1 { color: #333; margin: 0; }
.menu-btn { padding: 20px; border: none; border-radius: 12px; cursor: pointer; text-align: left; background: white; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 4px 10px rgba(0,0,0,0.08); transition: transform 0.1s, background 0.2s; }
.menu-btn:active { transform: scale(0.98); background: #f0f8ff; }
.menu-btn span { font-size: 1.2rem; font-weight: bold; color: #333; } .menu-btn small { color: #888; font-size: 0.85rem; }

header { flex-shrink: 0; padding: 12px 15px; background: white; display: flex; align-items: center; gap: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); z-index: 20; }
.back-btn { background: none; border: none; color: var(--primary); font-size: 1rem; cursor: pointer; font-weight: bold; padding: 5px 10px; }
.title { font-weight: bold; color: #333; font-size: 1.1rem; flex-grow: 1; text-align: center; }
.header-actions { display: flex; gap: 8px; }
.header-action-btn { padding: 6px 12px; border-radius: 20px; border: none; color: white; font-weight: bold; cursor: pointer; font-size: 0.85rem; transition: filter 0.2s; white-space: nowrap; }
.header-action-btn.add { background: var(--primary); } .header-action-btn.reset { background: #ff9500; } .header-action-btn:active { filter: brightness(0.9); }

.side-menu { position: absolute; top: 70px; left: 15px; display: flex; flex-direction: column; gap: 10px; z-index: 40; }
.shape-btn { padding: 10px 15px; border: 1px solid #ddd; background: white; border-radius: 8px; cursor: pointer; color: #666; font-size: 0.85rem; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: all 0.2s; min-width: 60px; }
.shape-btn.active { background: #eef6ff; border-color: var(--primary); color: var(--primary); font-weight: bold; transform: translateX(5px); }

.lab-stage { flex: 1; position: relative; overflow: hidden; background-color: white; display: flex; justify-content: center; align-items: center; padding: 20px; cursor: grab; }
.lab-stage:active { cursor: grabbing; }
.responsive-svg { display: block; width: 100%; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 5px 10px rgba(0,0,0,0.1)); }
.glass-border { fill: none; stroke: #333; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.pour-zone { cursor: pointer; fill: transparent; transition: fill 0.2s; }
.pour-zone:hover { fill: rgba(0, 122, 255, 0.2) !important; } .pour-zone:active { fill: rgba(0, 122, 255, 0.4) !important; }

.controls { flex-shrink: 0; background: var(--panel-bg); padding: 20px; border-radius: 20px 20px 0 0; box-shadow: 0 -5px 20px rgba(0,0,0,0.08); z-index: 30; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.slider-row { display: flex; align-items: center; gap: 15px; color: #555; } input[type=range] { flex: 1; height: 30px; }
.toggle-switch { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; cursor: pointer; } .toggle-switch input { display: none; }
.toggle-switch .slider { width: 36px; height: 20px; background-color: #ccc; border-radius: 20px; position: relative; transition: .3s; }
.toggle-switch .slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 2px; bottom: 2px; background-color: white; border-radius: 50%; transition: .3s; }
.toggle-switch input:checked + .slider { background-color: var(--accent); } .toggle-switch input:checked + .slider::before { transform: translateX(16px); }

.horizon-line { position: absolute; width: 100%; height: 2px; background: var(--accent); top: 50%; cursor: ns-resize; z-index: 50; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.horizon-line::before { content: ''; position: absolute; top: -15px; bottom: -15px; left: 0; right: 0; }
.line-handle { position: absolute; right: 10px; top: 4px; background: var(--accent); color: white; font-size: 10px; padding: 2px 6px; border-radius: 4px; pointer-events: none; white-space: nowrap; }
.hint-overlay { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,0.9); padding: 8px 15px; border-radius: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); color: #555; font-size: 0.9rem; pointer-events: none; z-index: 40; }

.bottle-draggable { cursor: ns-resize; transition: filter 0.2s; pointer-events: all; }
.bottle-hit-area { fill: transparent; stroke: none; pointer-events: all; }
.bottle-draggable:hover .bottle-glass { stroke: var(--primary); stroke-width: 6; } .bottle-draggable:active .bottle-glass { stroke: var(--primary); stroke-width: 6; }

.floating-panel { position: absolute; top: 70px; left: 15px; background: rgba(255, 255, 255, 0.95); border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); z-index: 50; text-align: left; max-width: 240px; border-left: 5px solid #007aff; transition: all 0.3s ease; overflow: hidden; }
.panel-header { padding: 10px 15px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; background: rgba(0,0,0,0.02); }
.status-row { display: flex; align-items: center; gap: 6px; font-weight: bold; color: #333; font-size: 0.9rem; }
.toggle-icon { font-size: 0.8rem; color: #888; transition: transform 0.3s; }
.panel-content { padding: 0 15px 12px 15px; opacity: 1; max-height: 200px; transition: all 0.3s ease; }
.panel-content small { color: #666; font-size: 0.85rem; line-height: 1.6; display: block; margin-top: 5px; border-top: 1px solid #eee; padding-top: 5px; }
.floating-panel.collapsed .panel-content { max-height: 0; padding-bottom: 0; opacity: 0; }
.floating-panel.collapsed .toggle-icon { transform: rotate(-90deg); }

.tube-handle { cursor: grab; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); }
.tube-handle:active { cursor: grabbing; transform: scale(1.05); }

.flow-anim { animation: tubeFlow 1s linear infinite; }
@keyframes tubeFlow { to { stroke-dashoffset: -20; } }
#outflow-stream { pointer-events: none; animation: streamFlow 0.4s linear infinite; }
@keyframes streamFlow { to { stroke-dashoffset: -15; } }

@media (max-width: 480px) {
    .floating-panel { top: 65px; left: 10px; max-width: 200px; }
    .status-row { font-size: 0.85rem; }
}