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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #000;
    color: #fff;
    overflow: hidden;
}

#canvas-container { width: 100vw; height: 100vh; position: relative; z-index: 0; }
#canvas-container canvas { position: absolute !important; top: 0; left: 0; z-index: 0 !important; }

/* ── Info panel ─────────────────────────────────── */
#info-panel {
    position: absolute; top: 20px; left: 20px;
    background: rgba(0,0,0,.7); padding: 20px; border-radius: 10px;
    font-size: 14px; line-height: 1.6; max-width: 300px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.1);
}
#info-panel h2 { font-size: 18px; color: #4a9eff; }
#info-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; margin-bottom: 15px; padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
#info-panel-content { transition: max-height .3s ease, opacity .3s ease; max-height: 1000px; opacity: 1; overflow: hidden; }
/* aperto: nessun taglio (con strumenti e Avanzate supera 1000 px); scorre il pannello, non il contenuto */
#info-panel-content:not(.collapsed) { max-height: none; overflow: visible; }
#info-panel-content.collapsed { max-height: 0; opacity: 0; }
#toggle-info-icon { font-size: 20px; user-select: none; transition: transform .3s; }
#toggle-info-icon.collapsed { transform: rotate(-90deg); }
.info-row {
    display: flex; justify-content: space-between; margin-bottom: 8px;
    padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.1);
}
.label { color: #aaa; }
.value { color: #fff; font-weight: bold; }
.value-input {
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 4px;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    padding: 2px 6px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}
.value-input:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.5);
}
.value-input:focus {
    background: rgba(74, 158, 255, 0.25);
    border-color: #4a9eff;
    box-shadow: 0 0 8px rgba(74, 158, 255, 0.4);
}
/* Date/time input specifics */
input[type="date"].value-input,
input[type="time"].value-input {
    font-family: 'Courier New', monospace;
}
input[type="date"].value-input::-webkit-calendar-picker-indicator,
input[type="time"].value-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* ── Connection status ──────────────────────────── */
#connection-status {
    position: absolute; top: 20px; right: 20px;
    padding: 10px 20px; border-radius: 5px;
    font-size: 14px; font-weight: bold;
    z-index: 9999;
}
.connected    { background: rgba(76,175,80,.8); }
.disconnected { background: rgba(244,67,54,.8); }
.connecting   { background: rgba(255,152,0,.8); }

/* ── Controls bar ───────────────────────────────── */
#controls {
    position: absolute; bottom: 20px; left: 20px;
    background: rgba(0,0,0,.7); padding: 15px; border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.1);
}
#controls button {
    background: #4a9eff; border: none; color: white;
    padding: 8px 16px; margin: 5px; border-radius: 5px;
    cursor: pointer; font-size: 14px; transition: background .3s;
}
#controls button:hover { background: #357abd; }
#controls label { display: block; margin: 10px 0 5px; font-size: 14px; color: #aaa; }
#controls input[type="range"] { width: 200px; }

/* ── Console log ────────────────────────────────── */
#console-log {
    position: absolute; bottom: 20px; right: 20px;
    background: rgba(0,0,0,.85); padding: 15px; border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.1);
    width: 533px; max-height: 300px; overflow-y: auto;
    font-family: 'Courier New', monospace; font-size: 14px;
    display: none;
    z-index: 1000;
}
#console-log.visible { display: block; }
#console-messages { max-height: 200px; overflow-y: auto; }
.console-message { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.05); line-height: 1.4; }
.console-message.info    { color: #4a9eff; }
.console-message.success { color: #4caf50; }
.console-message.warning { color: #ff9800; }
.console-message.error   { color: #f44336; }
.console-timestamp { color: #888; font-size: 14px; margin-right: 8px; }

/* ── Command input ──────────────────────────────── */
#command-input {
    flex: 1; background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2); color: white;
    padding: 6px 10px; border-radius: 4px;
    font-family: 'Courier New', monospace; font-size: 14px; outline: none;
}
#command-input:focus { border-color: #4a9eff; background: rgba(255,255,255,.15); }

/* ── Keyboard help ──────────────────────────────── */
#keyboard-help {
    display: none; position: absolute; bottom: 110px; left: 20px;
    background: rgba(0,0,0,.9); padding: 20px; border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.1);
    max-width: 380px; font-size: 14px;
}
#keyboard-help h3 { margin: 0 0 15px; color: #4a9eff; border-bottom: 1px solid rgba(255,255,255,.2); padding-bottom: 10px; }
#keyboard-help .kb-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 15px; line-height: 1.6; align-items: center; }
#keyboard-help .kb-key { color: #4a9eff; font-weight: bold; }
#keyboard-help .kb-key.kb-clickable {
    background: rgba(74, 158, 255, 0.15);
    border: 1px solid #4a9eff;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    min-width: 36px;
    text-align: center;
}
#keyboard-help .kb-key.kb-clickable:hover {
    background: rgba(74, 158, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.4);
}
#keyboard-help .kb-key.kb-clickable:active {
    transform: translateY(0);
    background: rgba(74, 158, 255, 0.5);
}
#keyboard-help .kb-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.1); color: #aaa; font-size: 14px; }

/* ── Dialog Popup ───────────────────────────────── */
#dialog-popup {
    display: none; position: absolute; z-index: 9999;
    background: rgba(20, 20, 30, 0.98); 
    border: 2px solid #4a9eff;
    border-radius: 12px;
    padding: 20px; max-width: 400px; min-width: 200px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px rgba(74,158,255,0.3);
    backdrop-filter: blur(10px);
    color: #fff; font-size: 14px; line-height: 1.6;
}
#dialog-popup.visible { display: block; }
#dialog-popup .dialog-close {
    position: absolute; top: 8px; right: 8px;
    width: 24px; height: 24px; border: none;
    background: rgba(255,255,255,0.1); color: #fff;
    border-radius: 50%; cursor: pointer;
    font-size: 16px; line-height: 24px; text-align: center;
    transition: background 0.2s;
}
#dialog-popup .dialog-close:hover { background: rgba(244,67,54,0.8); }
#dialog-popup .dialog-arrow {
    position: absolute; width: 0; height: 0;
    border: 10px solid transparent;
}
#dialog-popup .dialog-arrow.down { bottom: -20px; left: 50%; margin-left: -10px; border-top-color: #4a9eff; }
#dialog-popup .dialog-arrow.up { top: -20px; left: 50%; margin-left: -10px; border-bottom-color: #4a9eff; }
#dialog-popup .dialog-arrow.left { left: -20px; top: 50%; margin-top: -10px; border-right-color: #4a9eff; }
#dialog-popup .dialog-arrow.right { right: -20px; top: 50%; margin-top: -10px; border-left-color: #4a9eff; }
#dialog-popup .dialog-content { margin-top: 10px; }
#dialog-popup h3 { margin: 0 0 10px; color: #4a9eff; font-size: 16px; }
#dialog-popup p { margin: 8px 0; }
#dialog-popup strong { color: #5ac8ff; }

/* ── Location Dialog with Map ──────────────────────── */
#location-dialog {
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}
.location-dialog-content {
    background: rgba(20, 20, 30, 0.98);
    border: 2px solid #4a9eff;
    border-radius: 12px;
    padding: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px rgba(74,158,255,0.3);
}
.location-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}
.location-dialog-header h3 { margin: 0; color: #4a9eff; font-size: 18px; }
.location-inputs { display: flex; flex-direction: column; gap: 12px; margin: 15px 0; }
.input-group { display: flex; align-items: center; gap: 10px; }
.input-group label { min-width: 120px; color: #aaa; font-size: 14px; }
.input-group input, .input-group select {
    flex: 1; background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 4px; color: #fff; padding: 8px 12px;
    font-size: 14px; outline: none;
}
.input-group input:focus, .input-group select:focus { border-color: #4a9eff; box-shadow: 0 0 8px rgba(74, 158, 255, 0.4); }
.input-group select option { background: #1a1a2e; color: #fff; padding: 8px; }
.input-group select option:hover, .input-group select option:checked { background: #4a9eff; color: #fff; }
.location-dialog-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    margin-top: 20px; padding-top: 15px; border-top: 1px solid rgba(255,255,255,0.2);
}
.btn-cancel, .btn-confirm { padding: 10px 20px; border: none; border-radius: 6px; font-size: 14px; font-weight: bold; cursor: pointer; transition: all 0.2s; }
.btn-cancel { background: rgba(244,67,54,0.8); color: white; }
.btn-cancel:hover { background: rgba(244,67,54,1); transform: translateY(-1px); }
.btn-confirm { background: #4a9eff; color: white; }
.btn-confirm:hover { background: #357abd; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74, 158, 255, 0.4); }
#location-map { border: 2px solid rgba(74, 158, 255, 0.3); }
.clickable-location:hover { background: rgba(74, 158, 255, 0.1); border-color: rgba(74, 158, 255, 0.3); }
.clickable-location:active { background: rgba(74, 158, 255, 0.2); }

/* ═══════════════════════════════════════════════════════════════
   ── Chatbot Widget ──────────────────────────────────────────── */

#chatbot-widget {
    position: fixed !important;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 520px;
    max-width: calc(100vw - 40px);
    isolation: isolate;
}

/* ── Popup risposta ─────────────────────────────────────────── */
#chatbot-popup {
    width: 100%;
    background: rgba(10, 12, 24, 0.96);
    border: 1px solid rgba(74, 158, 255, 0.4);
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    backdrop-filter: blur(16px);
    box-shadow: 0 -4px 32px rgba(0,0,0,0.6), 0 0 24px rgba(74,158,255,0.15);
    display: none;
    flex-direction: column;
    max-height: 380px;
    overflow: hidden;
    animation: chatbot-slide-up 0.22s ease;
}

#chatbot-popup.chatbot-popup-visible { display: flex; }

@keyframes chatbot-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0);    }
}

#chatbot-popup-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; background: rgba(74, 158, 255, 0.08);
    border-bottom: 1px solid rgba(74, 158, 255, 0.2);
    font-size: 14px; font-weight: bold; color: #4a9eff; flex-shrink: 0;
}

#chatbot-popup-close {
    background: rgba(255,255,255,0.08); border: none; color: #aaa;
    width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
    font-size: 14px; line-height: 22px; text-align: center; transition: background 0.2s, color 0.2s; padding: 0;
}
#chatbot-popup-close:hover { background: rgba(244,67,54,0.7); color: #fff; }

#chatbot-messages {
    flex: 1; overflow-y: auto; padding: 14px 14px 8px;
    display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth;
}
#chatbot-messages::-webkit-scrollbar { width: 4px; }
#chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#chatbot-messages::-webkit-scrollbar-thumb { background: rgba(74,158,255,0.3); border-radius: 2px; }

/* ── Bubble messaggi (Fix Larghezza) ────────────────────────── */
.chatbot-bubble {
    max-width: 95%;              /* Si allarga quasi fino ai bordi per le spiegazioni lunghe */
    margin-right: 0 !important;  
    margin-left: 0 !important;   
    padding: 10px 14px;          
    border-radius: 12px;
    font-size: 14px;           
    line-height: 1.55;
    word-wrap: break-word;
    animation: chatbot-bubble-in 0.18s ease;
}

@keyframes chatbot-bubble-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1);    }
}

.chatbot-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2a5fa5, #1a4080);
    color: #e8f0ff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.chatbot-server {
    align-self: flex-start;
    background: rgba(255,255,255,0.07);
    color: #dde8ff;
    border: 1px solid rgba(74,158,255,0.18);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* ── Typing indicator ───────────────────────────────────────── */
#chatbot-typing { display: flex; align-items: center; gap: 5px; padding: 8px 16px 10px; flex-shrink: 0; }
#chatbot-typing.chatbot-hidden { display: none; }

.chatbot-dot { width: 7px; height: 7px; border-radius: 50%; background: #4a9eff; animation: chatbot-bounce 1.1s infinite ease-in-out; }
.chatbot-dot:nth-child(1) { animation-delay: 0s; }
.chatbot-dot:nth-child(2) { animation-delay: 0.18s; }
.chatbot-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes chatbot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Input bar ──────────────────────────────────────────────── */
#chatbot-bar {
    width: 100%; display: flex; align-items: center; gap: 0;
    background: rgba(10, 12, 24, 0.97); border: 1px solid rgba(74, 158, 255, 0.45);
    border-radius: 40px; padding: 6px 6px 6px 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 16px rgba(74,158,255,0.12);
    backdrop-filter: blur(16px);
}

#chatbot-toggle-btn {
    background: rgba(74,158,255,0.12); border: 1px solid rgba(74,158,255,0.35);
    color: #4a9eff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
    font-size: 17px; flex-shrink: 0; transition: background 0.2s, transform 0.15s;
    display: flex; align-items: center; justify-content: center; position: relative;
}
#chatbot-toggle-btn:hover { background: rgba(74,158,255,0.28); transform: scale(1.08); }
#chatbot-toggle-btn.chatbot-has-new::after {
    content: ''; position: absolute; top: 1px; right: 1px;
    width: 9px; height: 9px; background: #ff5252; border-radius: 50%; border: 2px solid #0a0c18;
}
#chatbot-toggle-icon { pointer-events: none; line-height: 1; }

#chatbot-input {
    min-width: 0; flex: 1; background: transparent; border: none; outline: none;
    color: #e8f0ff; font-size: 14px; padding: 0 10px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; caret-color: #4a9eff;
}
#chatbot-input::placeholder { color: rgba(170,190,255,0.45); }

#chatbot-mic-btn {
    background: transparent; border: none; font-size: 18px; 
    cursor: pointer; padding: 0 8px; flex-shrink: 0;
    width: 36px; height: 36px; display: flex; 
    align-items: center; justify-content: center; 
    transition: transform 0.2s, color 0.2s;
    color: #4a9eff;
}
#chatbot-mic-btn:hover { transform: scale(1.1); color: #fff; }
#chatbot-mic-btn.listening {
    animation: mic-pulse 1.2s infinite;
    color: #ff5252;
    filter: hue-rotate(-120deg) saturate(3);
}
@keyframes mic-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

#chatbot-send-btn {
    background: #4a9eff; border: none; color: #fff;
    width: 36px; height: 36px; border-radius: 50%; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(74,158,255,0.35);
}
#chatbot-send-btn:hover { background: #357abd; transform: scale(1.08); box-shadow: 0 4px 14px rgba(74,158,255,0.5); }
#chatbot-send-btn:active { transform: scale(0.96); }

/* Esempi di domande dentro la chat, solo finche' non c'e' nessun messaggio */
#chatbot-suggestions {
    display: flex; gap: 8px; padding: 0 14px 14px; flex-wrap: wrap; align-items: center;
}
#chatbot-suggestions p { width: 100%; margin: 0; font-size: 13px; color: #9fb0c8; }
#chatbot-messages:not(:empty) + #chatbot-suggestions { display: none; }
.chatbot-suggestion-btn {
    background: rgba(10, 12, 24, 0.85); border: 1px solid rgba(74, 158, 255, 0.35);
    color: #dde8ff; padding: 6px 14px; border-radius: 20px; font-size: 14px;
    cursor: pointer; backdrop-filter: blur(8px); transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.chatbot-suggestion-btn:hover { background: rgba(74, 158, 255, 0.2); border-color: #4a9eff; transform: translateY(-2px); }
    
/* ── Pulsante Guida in alto a dx ── */
#help-btn {
    position: absolute;
    top: 20px;
    right: 160px; /* <--- Posizionato esattamente tra connessione e menu IA */
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(74, 158, 255, 0.15);
    border: 1px solid rgba(74, 158, 255, 0.4);
    color: #4a9eff;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    z-index: 9999;
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#help-btn:hover {
    background: rgba(74, 158, 255, 0.3);
    transform: scale(1.1);
    color: #fff;
    box-shadow: 0 0 10px rgba(74, 158, 255, 0.5);
}

/* ── Finestra Modal Guida ── */
#help-modal {
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
}

.help-content {
    background: rgba(20, 20, 30, 0.95);
    border: 2px solid #4a9eff;
    border-radius: 12px;
    width: 90%;
    max-width: 550px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8), 0 0 20px rgba(74,158,255,0.2);
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.help-header h3 { margin: 0; color: #4a9eff; font-size: 20px; }

.help-body {
    padding: 20px; overflow-y: auto; color: #e8f0ff;
    font-size: 14.5px; line-height: 1.6;
}

.help-body::-webkit-scrollbar { width: 6px; }
.help-body::-webkit-scrollbar-thumb { background: rgba(74,158,255,0.4); border-radius: 3px; }

.help-body h4 {
    color: #5ac8ff; margin: 15px 0 8px 0; font-size: 16px;
    border-bottom: 1px dashed rgba(74, 158, 255, 0.2); padding-bottom: 4px;
}

.help-body h4:first-child { margin-top: 0; }
.help-body ul { margin: 0 0 15px 20px; padding: 0; }
.help-body li { margin-bottom: 6px; }
.help-body p { margin-bottom: 10px; }

/* ═══════════════════════════════════════════════════════════════
   ── UI v2: barra superiore, ricerca, dock, etichette, mobile ──── */

:focus-visible { outline: 2px solid #ffb74d; outline-offset: 2px; }

/* Barra in alto a destra: guida e stato connessione */
#top-bar {
    position: absolute; top: 20px; right: 20px; z-index: 9999;
    display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 360px);
}
#top-bar > #help-btn,
#top-bar > #connection-status { position: static; }
#top-bar > #help-btn { right: auto; top: auto; flex-shrink: 0; }

/* Selettore lingua */
#lang-btn, #account-btn {
    height: 36px; min-width: 36px; padding: 0 10px; border-radius: 18px; flex-shrink: 0;
    background: rgba(74, 158, 255, 0.15); border: 1px solid rgba(74, 158, 255, 0.4);
    color: #4a9eff; font-size: 13px; font-weight: bold; cursor: pointer;
    backdrop-filter: blur(5px); transition: all 0.2s;
}
#lang-btn:hover, #account-btn:hover { background: rgba(74, 158, 255, 0.3); color: #fff; box-shadow: 0 0 10px rgba(74, 158, 255, 0.5); }

/* Contenuti lunghi in due lingue: si mostra solo quella della pagina */
[data-lang][hidden] { display: none !important; }
#lang-btn { cursor: pointer; max-width: 150px; }

/* Stato connessione: pallino con tooltip */
#top-bar > #connection-status {
    width: 14px; height: 14px; padding: 0; border-radius: 50%; flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(0,0,0,.45);
}
#connection-status.connected    { background: #4caf50; }
#connection-status.disconnected { background: #f44336; }
#connection-status.connecting   { background: #ff9800; animation: conn-pulse 1s infinite; }
#connection-status.local        { background: #ff9800; }

/* ── Strumenti (planetarium-tools.js) ─── */
.visually-hidden { position:absolute !important; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
.time-steps { display:flex; gap:4px; padding:6px 0 10px; }
.time-steps button { flex:1; padding:5px 0; font-size:12px; border-radius:6px; border:1px solid rgba(74,158,255,.4); background:rgba(74,158,255,.1); color:#cfe3ff; cursor:pointer; }
.tools-grid { display:grid; grid-template-columns:1fr 1fr; gap:6px; padding:8px 0 12px; }
.tools-grid button { padding:8px 6px; font-size:13px; text-align:left; border-radius:8px; border:1px solid rgba(74,158,255,.4); background:rgba(74,158,255,.12); color:#e6eefc; cursor:pointer; }
.tools-grid button:hover, .time-steps button:hover { background:rgba(74,158,255,.28); }
#fov-ring { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); border:2px solid rgba(255,210,122,.75); border-radius:50%; pointer-events:none; z-index:5; }
#fov-ring::after { content:attr(data-label); position:absolute; top:-20px; left:50%; transform:translateX(-50%); color:#ffd27a; font-size:12px; }
#tour-card { position:fixed; left:50%; bottom:150px; transform:translateX(-50%); z-index:40; width:min(560px, calc(100vw - 20px)); padding:12px 14px; border-radius:12px; background:rgba(16,26,41,.95); border:1px solid rgba(74,158,255,.6); color:#e6eefc; }
#tour-card #tour-step { margin:0 0 4px; font-size:12px; color:#9fb0c8; }
#tour-card #tour-text { margin:0 0 10px; font-size:15px; line-height:1.4; }
.tour-actions { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.tour-actions button { padding:6px 10px; border-radius:6px; border:1px solid rgba(74,158,255,.5); background:rgba(74,158,255,.15); color:#e6eefc; cursor:pointer; }
.tour-actions button:disabled { opacity:.4; cursor:default; }
.tour-voice { margin-left:auto; font-size:13px; color:#cfe3ff; }
.dialog-ask { margin-top:8px; padding:6px 10px; border-radius:6px; border:1px solid rgba(74,158,255,.6); background:rgba(74,158,255,.18); color:#e6eefc; cursor:pointer; }
#planner-dialog { position:fixed; inset:0; background:rgba(0,0,0,.8); z-index:100000; align-items:center; justify-content:center; backdrop-filter:blur(5px); }
#planner-dialog .location-dialog-content { background:rgba(20,20,30,.98); border:2px solid #4a9eff; border-radius:12px; padding:20px; max-width:760px; width:94%; max-height:90vh; overflow-y:auto; color:#e6eefc; }
#planner-dialog .location-dialog-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; padding-bottom:10px; border-bottom:1px solid rgba(255,255,255,.2); }
#planner-dialog .location-dialog-header h3 { margin:0; color:#4a9eff; font-size:18px; }
#planner-csv { margin-right:8px; padding:5px 10px; border-radius:6px; border:1px solid rgba(74,158,255,.6); background:rgba(74,158,255,.15); color:#cfe3ff; cursor:pointer; }
.planner-table { width:100%; border-collapse:collapse; font-size:14px; }
.planner-table th { text-align:left; font-weight:600; color:#9fb0c8; padding:6px 4px; border-bottom:1px solid rgba(255,255,255,.2); }
.planner-table td { padding:6px 4px; border-bottom:1px solid rgba(255,255,255,.08); vertical-align:middle; }
.planner-table small { color:#9fb0c8; }
.planner-show { padding:4px 8px; border-radius:6px; border:1px solid rgba(74,158,255,.6); background:rgba(74,158,255,.15); color:#cfe3ff; cursor:pointer; }
.planner-summary, .planner-note { color:#cfe3ff; font-size:13px; }
@media (max-width: 768px) {
    #tour-card { bottom:206px; }
    .planner-table th:nth-child(3), .planner-table td:nth-child(3), .planner-table th:nth-child(4), .planner-table td:nth-child(4) { display:none; }
}
/* Visione notturna: tutto in rosso (moltiplica per il rosso puro), schermo piu' scuro */
body.night-red::after { content:''; position:fixed; inset:0; background:#ff1a00; mix-blend-mode:multiply; pointer-events:none; z-index:2147483647; }
body.night-red { filter:brightness(.8); }
#toggle-night[aria-pressed="true"] { background:rgba(255,40,0,.5); }
@keyframes conn-pulse { 50% { opacity: .35; } }

/* Striscia sempre visibile: data, ora, luogo, direzione di vista */
#status-strip {
    position: absolute; top: 68px; right: 20px;
    z-index: 900; display: flex; gap: 8px; align-items: center; white-space: nowrap;
    background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.12);
    border-radius: 20px; padding: 6px 16px; font-size: 14px; color: #dde8ff;
    backdrop-filter: blur(8px); pointer-events: none;
    font-variant-numeric: tabular-nums;
}
.strip-sep { opacity: .4; }

/* Dock strumenti */
#controls {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    max-width: calc(50vw - 280px); min-width: 0; padding: 8px 10px;
}
#controls button { margin: 0; display: inline-flex; align-items: center; gap: 6px; }
#controls button[aria-pressed="true"], #controls button.active { background: #ff9800; }
#keyboard-help { bottom: 76px; }
@media (min-width: 1101px) and (max-width: 1699px) { #controls .dock-text { display: none; } }

/* Etichette sul cielo */
#sky-labels { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
#sky-labels .sky-label {
    position: absolute; transform: translate(10px, -50%); white-space: nowrap;
    font-size: 14px; color: #fff; text-shadow: 0 0 4px #000, 0 0 8px #000;
}
#sky-labels .sky-label-eclipsed { opacity: .65; font-style: italic; }
#sky-labels .sky-label-star { font-size: 12px; color: #cfe3ff; }
#sky-labels .sky-label-dso { font-size: 11px; color: #ffd27a; }
#sky-labels .sky-label-satellite { font-size: 11px; color: #e8ecff; }
#sky-labels .sky-label-minor { font-size: 11px; color: #a8ffd9; }
#sky-labels .sky-label-const { font-size: 13px; color: #8fb0d8; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
#photo-credit { position: absolute; right: 12px; bottom: 96px; margin: 0; padding: 3px 8px; border-radius: 6px; background: rgba(7,12,24,.7); color: #9fb0c8; font-size: 11px; pointer-events: none; z-index: 6; }
.object-result small { opacity: 0.7; margin-left: 4px; }

/* Console */
.console-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.2);
}
.console-header h3 { margin: 0; font-size: 14px; }
.console-actions { display: flex; gap: 8px; }
.console-clear, .console-close {
    border: none; color: #fff; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 14px; min-height: 28px;
}
.console-clear { background: #f44336; }
.console-close { background: rgba(255,255,255,.1); font-size: 18px; line-height: 1; min-width: 28px; }
.console-input-row { display: flex; align-items: center; margin-top: 10px; }
.console-prompt { color: #4a9eff; font-weight: bold; margin-right: 8px; font-size: 14px; }

/* Modalità giroscopio: nasconde l'interfaccia di contorno */
body.gyro-active #top-bar, body.gyro-active #status-strip, body.gyro-active #controls,
body.gyro-active #sky-labels { display: none !important; }

#canvas-container canvas { touch-action: none; }
.satellite-search-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.satellite-search-form label { display: flex; flex-direction: column; gap: 6px; flex: 1 1 120px; min-width: 0; }
.satellite-search-form label:has(input) { flex-direction: row; align-items: center; flex-basis: 100%; }
.satellite-search-form select { min-height: 44px; max-width: 100%; color: inherit; background: #172638; border: 1px solid #526276; border-radius: 6px; padding: 8px; }

@media (prefers-reduced-motion: reduce) {
    #connection-status.connecting, .chatbot-dot, #chatbot-popup, .chatbot-bubble { animation: none; }
}

/* Tablet stretto */
@media (max-width: 1100px) {
    #status-strip .strip-view { display: none; }
    #top-bar { max-width: calc(100vw - 340px); }
    #controls { bottom: 130px; max-width: calc(100vw - 40px); }
    #keyboard-help { bottom: 190px; }
}

/* ── Smartphone ── */
@media (max-width: 768px) {
    #info-panel { top: 52px; left: 10px; max-width: calc(100vw - 20px); right: 10px; padding: 12px; }
    /* un solo scorrimento, quello del pannello (planetarium-ui.js ne limita l'altezza) */

    #top-bar {
        top: auto; right: 10px; left: 10px; bottom: 150px; max-width: none;
        justify-content: flex-end; flex-wrap: wrap;
    }
    #help-btn { width: 44px; height: 44px; }

    #status-strip { top: 10px; left: 10px; right: 10px; transform: none;
        justify-content: center; font-size: 14px; padding: 6px 10px; overflow: hidden; }
    #strip-place { overflow: hidden; text-overflow: ellipsis; }

    #controls {
        left: 10px; right: 10px; bottom: 76px; max-width: none; justify-content: space-between;
        padding: 6px 8px;
    }
    #controls button { padding: 10px 12px; min-height: 44px; }
    #controls .dock-text { display: none; }
    #controls input[type="range"] { flex: 1; min-width: 70px; width: auto; }
    #keyboard-help { left: 10px; right: 10px; bottom: 140px; max-width: none; max-height: 45vh; overflow-y: auto; }

    #console-log { width: auto; left: 10px; right: 10px; bottom: 140px; max-height: 45vh; }
    #console-messages { max-height: 25vh; }

    #chatbot-widget { bottom: 10px; max-width: calc(100vw - 20px); }
    #chatbot-popup { max-height: 50vh; }

    #dialog-popup { max-width: calc(100vw - 20px); }
    .location-dialog-content { width: 96%; padding: 14px; }
    #location-map { height: 260px !important; }
    .input-group { flex-direction: column; align-items: stretch; gap: 4px; }
    .input-group label { min-width: 0; }
    .help-content { width: 96%; }
}

/* ── Rifiniture dopo la verifica visiva ── */
/* Pannello dati chiuso: solo l'intestazione, senza riquadro vuoto sotto */
#info-panel:has(#info-panel-content.collapsed) #info-panel-header {
    margin-bottom: 0; padding-bottom: 0; border-bottom: none;
}
/* Aiuto tastiera a destra, sotto la striscia di stato: non copre il pannello dati */
@media (min-width: 769px) {
    #keyboard-help { left: auto; right: 20px; bottom: auto; top: 112px; max-height: calc(100vh - 340px); overflow-y: auto; }
    #console-log { width: min(533px, calc(50vw - 280px)); min-width: 320px; }
}
@media (min-width: 769px) and (max-width: 1100px) {
    #console-log { bottom: 190px; width: min(533px, calc(100vw - 40px)); }
    #keyboard-help { max-height: calc(100vh - 460px); }
}
@media (max-width: 768px) {
    #keyboard-help, #console-log { bottom: 270px; max-height: 38vh; }
}

/* ── Chat: icone SVG, stati, bersagli touch ── */
#chatbot-toggle-icon svg { display: block; }
#chatbot-toggle-icon .icon-close, #chatbot-toggle-icon.open .icon-chat { display: none; }
#chatbot-toggle-icon.open .icon-close { display: block; }
#chatbot-popup-close { display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 768px) {
    #chatbot-toggle-btn, #chatbot-send-btn, #chatbot-mic-btn { width: 44px; height: 44px; }
    #chatbot-popup-close { min-width: 44px; min-height: 44px; }
    .dialog-close { min-width: 44px; min-height: 44px; }
}

/* ── Etichette: tre stati distinguibili ── */
.label-state {
    font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
    background: rgba(255,255,255,.15); color: #cfd8ee; text-transform: uppercase; letter-spacing: .03em;
}
#controls #toggle-labels[data-level="1"] { background: rgba(255,152,0,.45); box-shadow: inset 0 0 0 1px #ff9800; }
#controls #toggle-labels[data-level="2"] { background: #ff9800; }
#toggle-labels[data-level="1"] .label-state { background: rgba(255,152,0,.9); color: #1a1000; }
#toggle-labels[data-level="2"] .label-state { background: #fff; color: #1a1000; }


/* Primary tasks remain keyboard accessible on compact screens. */
#info-panel-header { width:100%; background:none; color:inherit; font:inherit; border:0; border-bottom:1px solid #344150; text-align:left; }
.panel-heading { font-size:18px; color:#71b6ff; font-weight:600; }
button.clickable-location { width:100%; background:none; color:inherit; border:0; border-bottom:1px solid #344150; font:inherit; text-align:left; }
:focus-visible { outline:2px solid #90c9ff; outline-offset:3px; }
#info-panel { max-height:calc(100dvh - 140px); overflow:auto; }
#object-search-form { padding-bottom:12px; border-bottom:1px solid #344150; margin-bottom:10px; }
#object-search-form label { display:block; margin-bottom:5px; }
.search-row { display:flex; gap:6px; }
#object-search { min-width:0; width:100%; padding:8px; color:white; background:#101a29; border:1px solid #53677f; border-radius:5px; }
#object-point, #sky-retry, .object-result { padding:8px; color:white; background:#174d7d; border:1px solid #5c95c7; border-radius:5px; cursor:pointer; }
.object-result { display:block; width:100%; text-align:left; margin-top:4px; }
#search-feedback { font-size:12px; color:#b7cce0; }
#sky-brightness { width:85px; }
#sky-status, #place-hint { position:absolute; top:115px; right:20px; }
#sky-status { z-index:20; max-width:calc(100% - 40px); padding:9px 12px; border-radius:8px; background:#101a29; color:white; }
#sky-status[data-state="ready"] { display:none; }
#sky-status[data-state="local"] { border:1px solid #ff9800; }
/* cielo locale: il banner resta visibile, il suggerimento del luogo gli si affianca invece di coprirlo */
body.sky-local #place-hint { transform: translateY(calc(100% + 64px)); }
#selected-object { position:absolute; left:50%; top:52%; transform:translateX(-50%); padding:4px 10px; border:1px solid #efc86b; border-radius:12px; background:#101a29dc; pointer-events:none; }
.answer-sources { margin-top:10px; border-top:1px solid #53677f; padding-top:6px; font-size:12px; }
.answer-sources a { display:block; color:#9ccfff; margin:5px 0; overflow-wrap:anywhere; }
@media(max-width:768px) {
    #sky-status { top:118px; left:10px; right:10px; max-width:none; }
    #info-panel { max-height:calc(100dvh - 250px); }
    #info-panel-header { margin-bottom:0; }
    #object-point, .object-result { min-height:44px; }
}

/* Sensor guidance stays readable and operable in portrait and landscape. */
body.gyro-active #gyro-hud { width: min(360px, calc(100vw - 32px)); max-height: 45vh; overflow-y: auto; pointer-events: auto; }
#gyro-hud-inner { justify-content: center; }
#gyro-status, #gyro-guidance { margin: 6px 0; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,.8); color: #fff; font-size: 13px; }
#gyro-calibrate-btn { min-height: 44px; padding: 8px 14px; border: 1px solid #ff9800; border-radius: 8px; background: #222; color: #fff; }
#gyro-calibrate-btn:disabled, #gyro-shutter-btn:disabled { opacity: .45; cursor: default; }

#gyro-control[hidden] { display: none; }
body.gyro-active #info-panel, body.gyro-active #sky-status, body.gyro-active #selected-object { display: none !important; }
body.gyro-active #gyro-shutter-btn, body.gyro-active #gyro-exit-btn { bottom: max(24px, env(safe-area-inset-bottom)); }
#gyro-calibrate-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-height: 500px) and (orientation: landscape) {
    body.gyro-active #gyro-hud {
        left: max(16px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top));
        transform: none; width: min(320px, 40vw); max-height: calc(100dvh - 110px);
    }
}

/* Main actions and a persistent, readable simulation context. */
#top-bar { top: 16px; bottom: auto; right: 20px; left: auto; max-width: calc(100vw - 40px); }
#status-strip {
    top: 72px; left: 20px; right: 20px; width: auto; max-width: none;
    display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 12px 24px;
    padding: 10px 14px; border-radius: 12px; pointer-events: auto; white-space: normal;
    background: rgba(10, 17, 28, .92);
}
.context-time { display: flex; flex-direction: column; gap: 2px; }
#simulation-mode { font-size: 12px; font-weight: 600; color: #becfe3; }
#simulation-mode[data-mode="live"] { color: #86dfb1; }
#simulation-mode[data-mode="paused"], #simulation-mode[data-mode="simulated"] { color: #ffd18b; }
#strip-datetime { font-size: 13px; white-space: nowrap; }
#context-place { background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; min-height: 44px; }
.context-label { display: block; color: #becfe3; font-size: 11px; }
#strip-place { display: block; font-size: 13px; overflow: visible; }
#time-toggle { min-height: 44px; padding: 8px 14px; border: 1px solid #53677f; border-radius: 8px; color: #fff; background: #172a40; cursor: pointer; }
#time-toggle:disabled, #sky-now:disabled { opacity: .5; cursor: wait; }
#time-controls { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#speed-control { display: inline-flex; align-items: stretch; border: 1px solid #53677f; border-radius: 8px; overflow: hidden; background: #172a40; }
#speed-control button { min-height: 44px; min-width: 40px; padding: 0 8px; border: 0; background: transparent; color: #fff; cursor: pointer; font: inherit; display: grid; place-items: center; }
#speed-control button + button { border-left: 1px solid #3b4f66; }
#speed-control button:hover:not(:disabled) { background: #2c4663; }
#speed-control button:disabled { opacity: .5; cursor: wait; }
#speed-value { min-width: 78px; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#speed-value[data-reverse="true"] { color: #ffb3a3; }
#speed-value[data-paused="true"] { opacity: .65; }
.speed-reverse { display: flex; align-items: center; gap: 8px; padding: 2px 0 4px; font-size: 13px; color: #cfe3ff; cursor: pointer; user-select: none; }
.speed-reverse input { width: 16px; height: 16px; cursor: pointer; }
#info-panel { z-index: 30; top: 154px; left: 20px; right: auto; width: 332px; max-width: calc(100vw - 40px); padding: 16px; max-height: calc(100dvh - 250px); background: rgba(10,17,28,.92); }
.start-heading { font-size: 20px; font-weight: 600; }
.start-hint, .field-hint { color: #b7cce0; font-size: 12px; line-height: 1.5; }
#primary-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 12px 0; }
#primary-actions button { min-height: 64px; padding: 8px 5px; font: inherit; font-size: 13px; line-height: 1.4; color: #e6f1ff; background: #172a40; border: 1px solid #456587; border-radius: 9px; cursor: pointer; }
#primary-actions #sky-now { background: #20527d; border-color: #72b6ed; }
#primary-actions button:hover:not(:disabled) { background: #2c4663; }
#navigation-feedback:empty { display: none; }
#navigation-feedback { color: #c7e6d9; font-size: 12px; margin-bottom: 10px; }
#info-panel-header { min-height: 44px; margin: 0; padding: 6px 0; }
#info-panel-header .panel-heading { font-size: 14px; color: #c6def7; }
#info-panel-content { padding-top: 8px; }
#info-panel-content.collapsed { padding-top: 0; }
#object-search-form { margin-bottom: 4px; }
.field-hint { margin: 6px 0 12px; }
#advanced-settings { border-top: 1px solid #344150; margin-top: 8px; }
#advanced-settings summary { cursor: pointer; min-height: 44px; padding: 10px 0; color: #c6def7; }
#advanced-settings .advanced-content { padding-top: 6px; }
#advanced-settings #toggle-console { min-height: 44px; padding: 8px 12px; color: #fff; background: #172a40; border: 1px solid #53677f; border-radius: 8px; cursor: pointer; }
#sky-status, #place-hint { top: 154px; max-width: calc(100vw - 392px); }
/* Phones, portrait or landscape: compact context and actions so the sky stays visible. */
@media (max-width: 768px), (max-height: 500px) and (orientation: landscape) {
    #top-bar { top: 10px; right: 10px; left: auto; bottom: auto; }
    #status-strip { left: 10px; padding: 6px 10px; transform: none;
        display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; row-gap: 0; align-items: center; }
    .context-time { grid-column: 1; grid-row: 1; gap: 0; }
    #simulation-mode { font-size: 11px; }
    #strip-datetime { font-size: 12px; }
    #time-controls { grid-column: 2; grid-row: 1 / span 2; margin: 0; flex-direction: column; align-items: stretch; gap: 2px; }
    #time-toggle { margin: 0; padding: 2px 10px; min-height: 26px; font-size: 13px; }
    #speed-control button { min-height: 26px; min-width: 40px; padding: 0 6px; }
    #speed-value { min-width: 62px; font-size: 12px; }
    #context-place { grid-column: 1; grid-row: 2; min-height: 24px; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #context-place #strip-place { display: inline; font-size: 12px; }
    #context-place .context-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    #context-place::before { content: '📍 '; font-size: 11px; }
    #info-panel { left: 10px; padding: 8px 10px; }
    #info-panel-content { max-height: none; overflow: visible; }
    #info-panel-content.collapsed { max-height: 0; overflow: hidden; }
    /* The three actions explain themselves: the intro text is for wider screens. */
    .start-heading, .start-hint { display: none; }
    #primary-actions { margin: 0 0 4px; }
    #primary-actions button { min-height: 44px; padding: 4px; font-size: 12px; line-height: 1.25; }
    #info-panel-header { min-height: 36px; padding: 4px 0; }
}
@media (max-width: 768px) {
    #status-strip { top: 62px; right: 10px; }
    #info-panel { top: 136px; right: 10px; width: auto; max-width: none; max-height: calc(100dvh - 276px); }
    #sky-status, #place-hint { top: auto; bottom: 142px; left: 10px; right: 10px; max-width: none; }
    body.sky-local #place-hint { transform: translateY(calc(-100% - 70px)); }
}
@media (max-height: 600px) and (min-width: 769px) {
    #info-panel { max-height: calc(100dvh - 240px); }
}
/* Landscape phones of any width: context and actions on the left, chat and tools on the right. */
@media (max-height: 500px) and (orientation: landscape) {
    #top-bar { max-width: calc(50vw - 20px); }
    #status-strip { top: 10px; right: auto; width: calc(50vw - 20px); max-width: none; }
    #info-panel { top: 84px; right: auto; width: calc(50vw - 20px); max-width: none; max-height: calc(100dvh - 94px); }
    #chatbot-widget { left: auto; right: 10px; bottom: 10px; transform: none; width: calc(50vw - 20px); max-width: none; }
    #controls { left: auto; right: 10px; bottom: 76px; width: calc(50vw - 20px); max-width: none; }
    #controls .dock-text { display: none; }
    #sky-status, #place-hint { top: auto; bottom: 142px; left: auto; right: 10px; max-width: calc(50vw - 20px); }
    body.sky-local #place-hint { transform: translateY(calc(-100% - 70px)); }
}

/* ── Gyro Mode Button (nel panel) ─────────────────────────── */
#gyro-mode-btn, #events-btn {
    width: 100%;
    padding: 8px 12px;
    background: rgba(74, 158, 255, 0.15);
    border: 1px solid rgba(74, 158, 255, 0.4);
    border-radius: 6px;
    color: #4a9eff;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    text-align: center;
}
#gyro-mode-btn:hover, #events-btn:hover {
    background: rgba(74, 158, 255, 0.3);
    border-color: rgba(74, 158, 255, 0.7);
}
#gyro-mode-btn.active {
    background: rgba(255, 152, 0, 0.25);
    border-color: rgba(255, 152, 0, 0.7);
    color: #ff9800;
}

/* ── Account e crediti ─── */
#account-dialog {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8); z-index: 100000;
    align-items: center; justify-content: center; backdrop-filter: blur(5px);
}
#account-dialog .location-dialog-content {
    background: rgba(20, 20, 30, 0.98); border: 2px solid #4a9eff; border-radius: 12px;
    padding: 20px; max-width: 480px; width: 90%; max-height: 90vh; overflow-y: auto; color: #ddd;
}
#account-dialog .location-dialog-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.2);
}
#account-dialog .location-dialog-header h3 { margin: 0; color: #4a9eff; font-size: 18px; }
#account-dialog h4 { margin: 14px 0 6px; color: #4a9eff; }
#account-dialog input { width: 100%; box-sizing: border-box; padding: 8px; margin: 8px 0; border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.08); color: #fff; font-size: 16px; }
.account-action { padding: 8px 14px; border-radius: 6px; border: 1px solid #4a9eff; cursor: pointer;
    background: rgba(74,158,255,0.2); color: #fff; font-size: 14px; }
.account-action:hover:not(:disabled) { background: rgba(74,158,255,0.45); }
.account-action:disabled { opacity: 0.5; cursor: default; }
.account-action.secondary { margin-top: 16px; background: none; border-color: rgba(255,255,255,0.3); }
.account-balances { margin: 0; padding-left: 18px; }
.account-package { display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.1); }
.account-sub { color: #aaa; font-size: 12px; }
.account-note { margin: 0 0 8px; font-size: 13px; }
.account-note:empty { display: none; }
#account-dialog .dialog-close { width: 32px; height: 32px; padding: 0; border-radius: 6px; cursor: pointer;
    background: none; border: 1px solid rgba(255,255,255,0.3); color: #fff; font-size: 20px; line-height: 1; }
#account-dialog .dialog-close:hover { background: rgba(244,67,54,0.8); }
.account-note.ok { color: #6fdc8c; }
.account-note.error { color: #ff8a80; }

/* ── Eventi ─── (finestra definita qui: non dipende dal CSS in cache) */
#events-dialog {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8); z-index: 100000;
    align-items: center; justify-content: center; backdrop-filter: blur(5px);
}
#events-dialog .location-dialog-content {
    background: rgba(20, 20, 30, 0.98); border: 2px solid #4a9eff; border-radius: 12px;
    padding: 20px; max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto;
}
#events-dialog .location-dialog-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.2);
}
#events-dialog .location-dialog-header h3 { margin: 0; color: #4a9eff; font-size: 18px; }
#events-dialog .dialog-close { background:#172b40; color:#e6eefc; border:1px solid #42617c; border-radius:6px; min-width:40px; min-height:40px; cursor:pointer; }
/* Elenco eventi */
.event-item { padding: 10px 4px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.event-item:last-child { border-bottom: none; }
.event-name {
    background: none; border: none; padding: 0; cursor: pointer;
    color: #4a9eff; font-size: 16px; font-weight: bold; text-align: left;
}
.event-name:hover { color: #5ac8ff; text-decoration: underline; }
.event-description { margin-top: 3px; color: #aaa; font-size: 12px; }
.dso-mode-row { flex-wrap:wrap; gap:8px; }
#dso-mode { max-width:100%; min-width:0; background:#182838; color:#e6eefc; border:1px solid #55718d; border-radius:5px; padding:6px; font:inherit; }

/* Editable command scenarios share the Events window and remain usable at 320px. */
#events-dialog .location-dialog-content { box-sizing: border-box; max-width: 760px; }
.scenario-tabs, .scenario-actions { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.scenario-tabs button, .scenario-actions button, .scenario-copy, #scenario-playback button {
    font:inherit; border:1px solid #42617c; border-radius:6px; padding:8px 10px;
    background:#172b40; color:#e6eefc; cursor:pointer; min-height:40px;
}
.scenario-tabs [aria-selected="true"] { background:#284f73; border-color:#79c6ff; }
#scenarios-panel label { display:flex; flex-direction:column; gap:5px; margin:10px 0; min-width:0; }
#scenarios-panel input, #scenarios-panel textarea, #scenarios-panel select {
    box-sizing:border-box; width:100%; max-width:100%; min-width:0; background:#101c29;
    color:#edf3fa; border:1px solid #55718d; border-radius:5px; padding:8px; font:inherit;
}
#scenarios-panel textarea { resize:vertical; }
#scenario-commands { font-family:ui-monospace,monospace !important; line-height:1.5; tab-size:4; }
#scenarios-panel pre { white-space:pre-wrap; overflow-wrap:anywhere; font-size:12px; }
#scenarios-panel summary { cursor:pointer; padding:8px 0; }
.scenario-note, #scenarios-panel details p { color:#b6c9db; font-size:13px; line-height:1.5; }
#scenario-feedback { color:#ffe1a3; overflow-wrap:anywhere; }
.scenario-copy { margin-top:7px; font-size:12px; }
.scenario-actions button:disabled, .scenario-copy:disabled, #scenario-playback button:disabled { opacity:.5; cursor:default; }
#scenario-playback {
    position:fixed; top:64px; right:10px; z-index:10001; max-width:min(420px,calc(100vw - 20px));
    box-sizing:border-box; background:rgba(12,25,39,.96); border:1px solid #79c6ff;
    border-radius:8px; padding:10px; display:flex; flex-wrap:wrap; gap:6px; font-size:13px;
}
#scenario-playback[hidden], #scenarios-panel[hidden], #events-list[hidden] { display:none; }
#scenario-bar-status { flex-basis:100%; color:#d8eaff; }
#scenario-playback.has-event-timeline {
    top:auto; bottom:max(12px,env(safe-area-inset-bottom)); left:50%; right:auto; transform:translateX(-50%);
    width:min(640px,calc(100vw - 20px)); max-width:none; max-height:calc(100dvh - 110px); overflow:auto;
}
.has-event-timeline #scenario-bar-status, .has-event-timeline #scenario-bar-next, .has-event-timeline #scenario-bar-stop { display:none; }
#event-timeline { flex-basis:100%; min-width:0; }
#event-timeline[hidden], #event-timeline-body[hidden] { display:none; }
.event-timeline-header { display:flex; gap:6px; align-items:center; }
#event-timeline-toggle { flex:1; min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; text-align:left; }
#event-timeline-toggle::before { content:'▾ '; }
#event-timeline-toggle[aria-expanded="false"]::before { content:'▸ '; }
.event-timeline-points { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:4px; margin-top:6px; }
#event-timeline .event-timeline-points button { min-width:0; padding:5px 2px; }
#scenario-playback.has-event-timeline button { min-height:44px; }
#event-timeline .event-timeline-header > button:last-child { min-width:44px; flex:0 0 44px; padding:0; }
#event-timeline-range { width:100%; box-sizing:border-box; min-height:44px; margin:0; accent-color:#79c6ff; touch-action:pan-y; }
.event-timeline-controls { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.event-timeline-controls label { display:flex; align-items:center; gap:6px; min-height:44px; }
#event-timeline-time { margin-left:auto; font-size:12px; font-variant-numeric:tabular-nums; }
#event-timeline-status { margin:4px 0; font-size:12px; color:#ffd27a; }
#event-timeline-status:empty { display:none; }
body.mobile-layout #scenario-playback.has-event-timeline { top:auto; bottom:calc(var(--mobile-sheet-bottom) + 8px); left:10px; right:10px; width:auto; transform:none; max-height:calc(100dvh - var(--mobile-reserved-height) - 90px); }
body.mobile-layout #event-timeline-time { flex-basis:100%; margin:0; }
body.sky-only #scenario-playback, body.gyro-active #scenario-playback, body.mobile-keyboard-open #scenario-playback.has-event-timeline { display:none!important; }
body:has(#events-dialog[style*="flex"]) #scenario-playback.has-event-timeline { visibility:hidden; }
@media(max-height:500px) and (orientation:landscape) {
    body.mobile-layout #scenario-playback.has-event-timeline { right:calc(78px + env(safe-area-inset-right)); max-height:calc(100dvh - 90px); }
    body.mobile-layout #event-timeline-time { flex-basis:auto; margin-left:auto; }
}
#scenario-playback button { font-size:12px; }
@media(max-width:480px) {
    #events-dialog .location-dialog-content { width:calc(100% - 16px); padding:12px; }
    #scenario-playback { top:54px; }
}

/* ── Gyro HUD overlay ──────────────────────────────────────── */
#gyro-hud {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: none;
}
#gyro-hud-inner {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 152, 0, 0.5);
    border-radius: 20px;
    padding: 6px 18px;
    color: #ff9800;
    font-size: 15px;
    font-family: monospace;
    letter-spacing: 1px;
    display: flex;
    gap: 12px;
    align-items: center;
}
#gyro-hud-sep { opacity: 0.4; }

/* ── Mirino ────────────────────────────────────────────────── */
#gyro-crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    z-index: 999;
    pointer-events: none;
}
#gyro-crosshair .ch-h {
    position: absolute;
    top: 50%; left: 0;
    width: 100%; height: 1px;
    background: rgba(255, 152, 0, 0.7);
    transform: translateY(-50%);
}
#gyro-crosshair .ch-v {
    position: absolute;
    left: 50%; top: 0;
    height: 100%; width: 1px;
    background: rgba(255, 152, 0, 0.7);
    transform: translateX(-50%);
}
#gyro-crosshair .ch-circle {
    position: absolute;
    top: 50%; left: 50%;
    width: 30px; height: 30px;
    border: 1px solid rgba(255, 152, 0, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* ── Pulsante Shutter ──────────────────────────────────────── */
#gyro-shutter-btn {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255, 152, 0, 0.9);
    border: 3px solid #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.2s;
}
#gyro-shutter-btn:active {
    transform: translateX(-50%) scale(0.92);
    background: rgba(255, 100, 0, 0.95);
}
#gyro-shutter-btn.capturing {
    background: rgba(76, 175, 80, 0.9);
}

/* ── Pulsante Esci ─────────────────────────────────────────── */
#gyro-exit-btn {
    position: fixed;
    bottom: 90px;
    right: 16px;
    z-index: 1001;
    padding: 8px 14px;
    background: rgba(244, 67, 54, 0.85);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
#gyro-exit-btn:hover { background: rgba(244, 67, 54, 1); }

/* ── Flash di cattura ──────────────────────────────────────── */
#gyro-capture-flash {
    position: fixed;
    inset: 0;
    background: rgba(255, 152, 0, 0.25);
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

/* Avviso "luogo stimato" al primo avvio (planetarium-app.js, showPlaceHint) */
#place-hint { z-index:31; display:flex; align-items:center; gap:10px; padding:8px 8px 8px 12px; border-radius:8px; background:#101a29; border:1px solid rgba(74,158,255,.4); color:#e6eefc; font-size:14px; }
#place-hint button { font:inherit; cursor:pointer; border-radius:6px; }
#place-hint .place-hint-choose { padding:5px 10px; border:1px solid rgba(74,158,255,.6); background:rgba(74,158,255,.15); color:#9cc8ff; white-space:nowrap; }
#place-hint .place-hint-dismiss { width:28px; height:28px; border:none; background:transparent; color:#9fb0c8; font-size:18px; line-height:1; }

/* Collegamenti all'informativa privacy (guida, finestra di accesso) */
.help-privacy, .account-privacy { margin-top: 12px; font-size: 13px; }
.help-privacy a, .account-privacy a { color: #7fb8ff; }
#lang-btn option { color: #10151f; background: #fff; }

.planner-filters { display:flex; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.planner-filters label { display:flex; flex-direction:column; gap:4px; flex:1; min-width:110px; font-size:13px; }
.planner-filters select { background:#142337; color:#e6eefc; border:1px solid #4a9eff; border-radius:5px; padding:7px; }
.planner-assessment, .planner-window { display:block; margin-top:4px; max-width:290px; }

/* Telescopio ASCOM Alpaca (planetarium-telescope.js) */
#telescope-dialog { position:fixed; inset:0; background:rgba(0,0,0,.8); z-index:100000; align-items:center; justify-content:center; backdrop-filter:blur(5px); }
#telescope-dialog .location-dialog-content { background:rgba(20,20,30,.98); border:2px solid #4a9eff; border-radius:12px; padding:20px; max-width:560px; width:94%; max-height:90vh; overflow-y:auto; color:#e6eefc; box-sizing:border-box; }
#telescope-dialog .location-dialog-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; padding-bottom:10px; border-bottom:1px solid rgba(255,255,255,.2); }
#telescope-dialog .location-dialog-header h3 { margin:0; color:#4a9eff; font-size:18px; }
.telescope-config { display:flex; flex-wrap:wrap; gap:8px 12px; align-items:flex-end; }
.telescope-config label { display:flex; flex-direction:column; gap:4px; font-size:13px; color:#9fb0c8; }
.telescope-config label:first-child { flex:1 1 220px; }
.telescope-config input { padding:6px 8px; border-radius:6px; border:1px solid rgba(74,158,255,.5); background:rgba(0,0,0,.35); color:#e6eefc; font-size:14px; min-width:0; }
#telescope-device { width:70px; }
.telescope-config button, .telescope-controls button { padding:7px 12px; border-radius:6px; border:1px solid rgba(74,158,255,.6); background:rgba(74,158,255,.18); color:#cfe3ff; cursor:pointer; }
.telescope-controls button:disabled { opacity:.45; cursor:default; }
.telescope-controls { display:flex; flex-wrap:wrap; gap:8px 12px; align-items:center; margin:8px 0; }
#telescope-status { margin:10px 0 4px; font-size:14px; }
#telescope-status[data-state="error"], .telescope-note[data-state="error"] { color:#ff9a8a; }
#telescope-status[data-state="ok"], .telescope-note[data-state="ok"] { color:#9be29b; }
#telescope-position { margin:0; font-variant-numeric:tabular-nums; color:#cfe3ff; min-height:1.2em; }
.telescope-help { font-size:13px; color:#9fb0c8; margin:8px 0 0; }
.telescope-help code { color:#b9d4f5; }
.telescope-warning { color:#ffcf8a; }
.telescope-actions { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.telescope-note { margin:6px 0 0; font-size:13px; }
.telescope-note:empty { display:none; }

/* ── Scheda dell'oggetto (planetarium-card.js) ───────────────────────────── */
#dialog-popup.is-card { z-index: 10050; background: #12141e; width: 340px; max-width: calc(100vw - 24px); padding: 16px 16px 12px; line-height: 1.4; }
/* lo scorrimento sul contenuto, non sul riquadro: la freccia verso l'oggetto resta visibile */
#dialog-popup.is-card .dialog-content { margin-top: 0; max-height: calc(100vh - 72px); overflow-y: auto; }
.sky-card { display: flex; flex-direction: column; gap: 12px; }
.sky-card .card-head { display: flex; gap: 12px; align-items: center; padding-right: 26px; }
.sky-card .card-thumb { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 50%; }
.sky-card .card-planet { background-size: 200% 100%; background-position: center; box-shadow: inset -10px -8px 18px rgba(0,0,0,.65), 0 0 0 1px rgba(255,255,255,.12); }
.sky-card .card-planet.card-sun { box-shadow: 0 0 18px 4px rgba(255,190,80,.55); }
.sky-card .card-star { background: radial-gradient(circle, #fff 0 10%, var(--star) 24%, color-mix(in srgb, var(--star) 35%, transparent) 46%, transparent 70%); }
.sky-card .card-photo { object-fit: cover; border-radius: 10px; background: #000; }
.sky-card .card-icon { display: grid; place-items: center; color: #8fc3ff; background: rgba(74,158,255,.1); border-radius: 12px; }
.sky-card .card-titles { min-width: 0; }
#dialog-popup .sky-card h3 { margin: 0; font-size: 19px; line-height: 1.2; color: #fff; overflow-wrap: anywhere; }
#dialog-popup .sky-card p { margin: 0; }
.sky-card .card-subtitle { color: #9fb0c8; font-size: 13px; margin-top: 2px !important; }
.sky-card .card-status { font-size: 13px; margin-top: 6px !important; padding-left: 14px; position: relative; color: #c9d6e8; }
.sky-card .card-status::before { content: ''; position: absolute; left: 0; top: .45em; width: 8px; height: 8px; border-radius: 50%; background: #6b7a90; }
.sky-card .card-status[data-state="up"]::before { background: #4cd07d; box-shadow: 0 0 6px #4cd07d; }
.sky-card .card-status[data-state="day"]::before { background: #f2b84b; }
.sky-card .card-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; }
.sky-card .card-fact { background: rgba(255,255,255,.05); border-radius: 8px; padding: 7px 8px; display: flex; flex-direction: column; gap: 1px; }
#dialog-popup .sky-card .card-fact strong { color: #fff; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sky-card .card-fact span { color: #9fb0c8; font-size: 11.5px; }
.sky-card .card-bar { position: relative; height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); margin: 4px 0 6px; }
.sky-card .card-bar-up { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, #2f7fd8, #6fb6ff); }
.sky-card .card-bar-now { position: absolute; top: -4px; width: 2px; height: 14px; margin-left: -1px; background: #fff; border-radius: 1px; box-shadow: 0 0 4px rgba(255,255,255,.8); }
.sky-card .card-times { display: flex; justify-content: space-between; gap: 8px; }
.sky-card .card-times span { display: flex; flex-direction: column; }
.sky-card .card-times span:nth-child(2) { align-items: center; }
.sky-card .card-times span:last-child:not(:first-child) { align-items: flex-end; }
.sky-card .card-times small { color: #9fb0c8; font-size: 11.5px; }
#dialog-popup .sky-card .card-times strong { color: #fff; font-size: 15px; font-variant-numeric: tabular-nums; }
.sky-card .card-zone, .sky-card .card-day-note { color: #8ea2bb; font-size: 11.5px; margin-top: 4px !important; }
.sky-card .card-day-note { font-size: 13px; color: #c9d6e8; }
.sky-card .card-about { color: #c9d6e8; font-size: 13.5px; }
.sky-card .card-about a { color: #7fb8ff; }
.sky-card .card-warning { color: #ffcf8a; font-size: 13px; }
.sky-card .card-actions, .sky-card .card-lines, .sky-card .telescope-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.sky-card .card-actions .dialog-ask { margin-top: 0; }
.sky-card .card-secondary, .sky-card .card-toggle { padding: 6px 10px; border-radius: 6px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.06); color: #e6eefc; cursor: pointer; font: inherit; font-size: 13px; }
.sky-card .card-toggle[aria-pressed="true"] { border-color: #4a9eff; background: rgba(74,158,255,.25); }
.sky-card .card-lines > span { color: #9fb0c8; font-size: 13px; margin-right: 2px; }
.sky-card .card-details { border-top: 1px solid rgba(255,255,255,.1); padding-top: 8px; font-size: 12.5px; }
.sky-card .card-details summary { cursor: pointer; color: #9fb0c8; }
.sky-card .card-details dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 8px 0 0; }
.sky-card .card-details dt { color: #8ea2bb; }
.sky-card .card-details dd { margin: 0; color: #dce6f4; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sky-card .telescope-note { margin: 0; }
/* telefono: pannello che sale dal basso, non copre l'oggetto toccato */
@media (max-width: 768px) {
    #dialog-popup.is-card { position: fixed; left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; max-width: none;
        max-height: 72vh; overflow-y: auto; border-radius: 16px 16px 0 0; border-width: 2px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
    #dialog-popup.is-card .dialog-arrow { display: none; }
}

/* ── Meteo (planetarium-weather.js) ─────────────────────────────────────────── */
#weather-badge { align-self: center; font-size: 13px; white-space: nowrap; padding: 3px 8px; border-radius: 999px;
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); color: #dce6f4; cursor: default; }
#weather-badge[data-state="good"] { border-color: rgba(76,208,125,.5); }
#weather-badge[data-state="bad"] { border-color: rgba(242,184,75,.55); color: #ffd99a; }
.sky-card .card-status[data-state="cloudy"]::before { background: #8fa3bd; box-shadow: 0 0 6px rgba(143,163,189,.8); }
.planner-weather { margin: 4px 0 12px; }
.planner-weather-title, .planner-weather-none, .planner-weather-credit, .planner-weather-warning { margin: 4px 0; font-size: 12.5px; color: #9fb0c8; }
.planner-weather-warning { color: #ffcf8a; font-size: 13px; }
.planner-weather-credit { font-size: 11.5px; color: #7f92ab; }
.planner-weather-strip { display: flex; gap: 2px; align-items: stretch; height: 64px; }
.planner-weather-hour { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; position: relative; }
.planner-weather-bar { width: 100%; border-radius: 3px 3px 0 0; background: rgba(200,212,230,.55); }
.planner-weather-hour[data-state="good"] .planner-weather-bar { background: rgba(76,208,125,.55); }
.planner-weather-hour[data-state="bad"] .planner-weather-bar { background: rgba(160,172,190,.85); }
.planner-weather-icon { position: absolute; top: 0; font-size: 12px; line-height: 1; }
.planner-weather-hour small { font-size: 10.5px; color: #8ea2bb; font-variant-numeric: tabular-nums; }
@media (max-width: 768px) { #weather-badge { font-size: 12px; padding: 2px 8px; justify-self: start; width: max-content; max-width: 100%; } }

/* Voce (planetarium-voice.js) */
.voice-settings select, .voice-settings button { width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid rgba(74,158,255,.5); background: rgba(0,0,0,.35); color: #e6eefc; font: inherit; font-size: 13px; }
.voice-settings button { cursor: pointer; background: rgba(74,158,255,.18); }
.voice-settings select:disabled { opacity: .6; }
.voice-ai-note { color: #9fb0c8; font-size: 12px; align-self: center; }

/* ── Eclissi (planetarium-eclipse.js) ─────────────────────────────────────────── */
#eclipse-badge { align-self: center; font-size: 13px; white-space: nowrap; padding: 3px 8px; border-radius: 999px; background: rgba(20,12,36,.7);
    border: 1px solid rgba(190,150,255,.55); color: #e6d9ff; cursor: default; }
#eclipse-badge[data-state="total"] { border-color: #ffd37a; color: #fff1cf; box-shadow: 0 0 10px rgba(255,211,122,.45); }
@media (max-width: 768px) { #eclipse-badge { font-size: 12px; padding: 2px 8px; justify-self: start; width: max-content; max-width: 100%; } }
.event-group { margin: 14px 0 4px; font-size: 13px; color: #9fb0c8; text-transform: uppercase; letter-spacing: .04em; }
#eclipse-badge[data-state="lunar-total"] { border-color: #e8805a; color: #ffe0d2; box-shadow: 0 0 10px rgba(232,128,90,.45); }
.event-next { display: block; width: 100%; margin: 4px 0 8px; padding: 9px 12px; border-radius: 8px; border: 1px solid rgba(74,158,255,.6); background: rgba(74,158,255,.18);
    color: #e6eefc; font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.event-next:disabled { opacity: .6; cursor: progress; }
#eclipse-next-results { margin-bottom: 6px; color: #c8d6ea; font-size: 13px; }
.event-next-title { margin-bottom: 6px; }

/* ── Superficie lunare (planetarium-moon.js) ──────────────────────────────────── */
.sky-card .card-surface { border-radius: 10px; background: rgba(255,255,255,.06); border-left: 3px solid #cfd6e4; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.sky-card .surface-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
#dialog-popup .sky-card .surface-title strong { color: #fff; font-size: 16px; }
.sky-card .surface-title span { color: #b9c6da; font-size: 12.5px; }
.sky-card .surface-origin { color: #dce6f4; font-size: 12.5px; }
.sky-card .card-surface small { color: #8ea2bb; font-size: 11.5px; }
#moon-labels, #mars-labels { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
#moon-labels .moon-label, #mars-labels .moon-label { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; color: #e9eef7; font-size: var(--moon-font, 12px); line-height: 1;
    text-shadow: 0 0 3px #000, 0 0 3px #000, 0 1px 2px #000; letter-spacing: .02em; }
#moon-labels .moon-label-region, #mars-labels .moon-label-region { font-size: var(--moon-font-region, 14px); font-style: italic; letter-spacing: .08em; text-transform: uppercase; color: #bcd3f2; }
#moon-labels .moon-label-line, #mars-labels .moon-label-line { font-size: var(--moon-font, 11.5px); font-style: italic; color: #d6e2f5; }
#moon-labels .moon-label-dim, #mars-labels .moon-label-dim { opacity: .45; }

/* Equipment, observing sessions and the accessible night chart. */
#diary-dialog { position:fixed; inset:0; background:rgba(0,0,0,.8); z-index:100001; display:flex; align-items:center; justify-content:center; backdrop-filter:blur(5px); }
#diary-dialog .location-dialog-content { box-sizing:border-box; background:rgba(20,20,30,.98); border:2px solid #4a9eff; border-radius:12px; padding:20px; max-width:900px; width:94%; max-height:90dvh; overflow:auto; color:#e6eefc; }
#diary-dialog .location-dialog-header { display:flex; align-items:center; justify-content:space-between; }
#diary-dialog .location-dialog-header h3 { color:#4a9eff; }
#planner-dialog .location-dialog-content { max-width:1000px; box-sizing:border-box; }
#observing-editor { padding:10px; margin:10px 0; border:1px solid #53647b; border-radius:8px; }
#observing-editor summary, #planner-chart summary { cursor:pointer; padding:6px; }
.observing-fields { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:10px; margin:10px 0; }
.observing-fields label, #observing-editor>label, .observing-actions label, #diary-list>label { display:flex; flex-direction:column; gap:5px; min-width:0; }
.observing-fields label[hidden] { display:none; }
#planner-dialog input, #planner-dialog textarea, #planner-dialog select, #diary-dialog input, #diary-dialog textarea, #diary-dialog select { box-sizing:border-box; max-width:100%; width:100%; min-width:0; padding:8px; background:#152235; color:#edf5ff; border:1px solid #7186a5; border-radius:5px; font:inherit; }
#planner-dialog textarea, #diary-dialog textarea { resize:vertical; }
.observing-actions { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin:10px 0; }
.observing-actions button, #observing-editor button, #diary-dialog button, #planner-chart select { padding:8px 10px; color:#edf5ff; border:1px solid #7186a5; border-radius:5px; background:#223959; font:inherit; cursor:pointer; }
.observing-actions button:disabled, #diary-dialog button:disabled { opacity:.55; cursor:default; }
.observing-note { font-size:13px; line-height:1.5; color:#c4d3e6; }
#observing-feedback, #diary-feedback { color:#ffd27a; overflow-wrap:anywhere; }
#planner-chart { margin:14px 0; padding:10px; border:1px solid #53647b; border-radius:8px; }
#planner-chart svg { display:block; width:100%; height:auto; background:#101a29; }
.chart-legend { display:flex; flex-wrap:wrap; gap:12px; font-size:13px; }
.chart-data { width:100%; border-collapse:collapse; font-size:12px; }
.chart-data th, .chart-data td { text-align:left; padding:6px; border-bottom:1px solid #53647b; }
.diary-target { padding:12px; margin:14px 0; border:1px solid #53647b; border-radius:8px; overflow-wrap:anywhere; }
.diary-target h4 { margin:0 0 8px; }
#diary-create { align-items:end; }
#diary-list>label { margin:12px 0; }
#planner-session-label { font-size:13px; overflow-wrap:anywhere; }
@media(max-width:600px) { .observing-fields { grid-template-columns:1fr; } #planner-dialog .location-dialog-content, #diary-dialog .location-dialog-content { padding:12px; width:98%; max-height:94dvh; } .planner-table { font-size:12px; } .planner-table .observing-actions { flex-direction:column; align-items:stretch; } .chart-data th, .chart-data td { padding:3px; } }

/* ── Solo cielo (planetarium-skyonly.js) ─────────────────────────────────────── */
body.sky-only #top-bar, body.sky-only #status-strip, body.sky-only #controls, body.sky-only #info-panel, body.sky-only #chatbot-widget,
body.sky-only #place-hint, body.sky-only #selected-object, body.sky-only #keyboard-help, body.sky-only #console-log { display: none !important; }
/* Gli avvisi del motore e Riprova restano accessibili sopra il pulsante Comandi. */
body.sky-only #sky-status { position: fixed; top: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 54px);
    left: 10px; right: auto; width: fit-content; max-width: min(520px, calc(100vw - 20px)); z-index: 10001; border: 1px solid #ff9800; }
#sky-only-hud { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; z-index: 30; max-width: calc(100vw - 20px); padding: 5px 12px; border-radius: 999px;
    background: rgba(10,17,28,.75); border: 1px solid rgba(83,103,127,.7); color: #e6eefc; font-size: 12.5px; font-variant-numeric: tabular-nums; pointer-events: none; }
#sky-only-hud[hidden], #sky-only-exit[hidden] { display: none; }
#sky-only-exit { position: fixed; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 10002; min-width: 44px; min-height: 44px; padding: 0 16px; border-radius: 22px;
    background: rgba(10,17,28,.82); border: 1px solid #72b6ed; color: #fff; font: inherit; font-size: 14px; cursor: pointer; align-items: center; gap: 8px; }
#sky-only-exit:not([hidden]) { display: inline-flex; }
body.gyro-active #sky-only-hud, body.gyro-active #sky-only-exit { display: none !important; }
#toggle-night[aria-pressed="true"] ~ #sky-only-btn { background: rgba(255,40,0,.25); }
#sky-only-btn[aria-pressed="true"] { background: #ff9800; }

/* ── Touch: bersagli da almeno 44 px, comandi con il loro nome, tastiera che non copre la chat ───────────────── */
:root { --keyboard: 0px; }
@media (pointer: coarse) {
    #help-btn, #account-btn, #lang-btn { min-height: 44px; min-width: 44px; }
    #info-panel-header { min-height: 44px; }
    #info-panel button, #info-panel select, #info-panel input:not([type="checkbox"]):not([type="range"]), #info-panel summary { min-height: 44px; }
    #info-panel .time-steps button { min-height: 44px; }
    #info-panel .info-row { min-height: 44px; }
    #info-panel label { min-height: 44px; }
    #info-panel input[type="checkbox"] { width: 22px !important; height: 22px !important; }
    #info-panel input[type="range"] { min-height: 44px; }
    /* dock: icona e nome, tre bersagli larghi uguali; la scorciatoia da tastiera non serve senza tastiera */
    #controls button { min-height: 48px; flex: 1 1 0; justify-content: center; flex-wrap: wrap; gap: 0 6px; padding: 4px 8px; font-size: 13px; line-height: 1.25; }
    #controls .dock-text { display: inline; }
    #controls .label-state { font-size: 10px; padding: 0 6px; }
    #controls { gap: 6px; }
    #controls #toggle-help { display: none; }
    #chatbot-input { min-height: 44px; font-size: 16px; }   /* 16 px: iOS non ingrandisce la pagina al focus */
    #chatbot-toggle-btn, #chatbot-send-btn, #chatbot-mic-btn { width: 44px; height: 44px; }
    #chatbot-widget { bottom: calc(10px + var(--keyboard, 0px)); }
    #chatbot-popup { max-height: min(50vh, calc(100dvh - var(--keyboard, 0px) - 100px)); }
    #time-toggle, #speed-control button { min-height: 44px; }
    #sky-retry { min-width: 44px; min-height: 44px; }
    /* Anche le finestre create dopo l'avvio (account e diario) e le schede degli oggetti. */
    :is([role="dialog"], #dialog-popup) :is(button, select, textarea, summary, a[href], [role="button"],
        input:not([type="checkbox"], [type="radio"], [type="hidden"])) { min-width: 44px; min-height: 44px; }
    :is([role="dialog"], #dialog-popup) a[href] { display: inline-flex; align-items: center; }
    :is([role="dialog"], #dialog-popup) label:has(input:is([type="checkbox"], [type="radio"])) {
        display: inline-flex; align-items: center; gap: 8px; min-width: 44px; min-height: 44px; }
}

/* Mobile navigation is activated by planetarium-mobile.js; desktop keeps its original controls. */
#mobile-panel-header, #mobile-explore-tools, #mobile-nav[hidden], #mobile-more-panel[hidden] { display: none; }
body.mobile-layout { --mobile-nav-height: 66px; --mobile-sheet-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); --mobile-reserved-height: 82px; }
body.mobile-layout #status-strip { position: fixed; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); width: auto; max-width: none; }
#mobile-mode-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
body.mobile-layout #connection-status { position: static; flex: 0 0 8px; width: 8px; height: 8px; padding: 0; border-radius: 50%; }
#mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10020; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 4px max(6px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: rgba(10,17,28,.97); border-top: 1px solid #456587; }
#mobile-nav button { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; min-width: 0; min-height: 56px;
    padding: 3px; margin: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #dce8fa; font: inherit; font-size: 12px; line-height: 1.25; }
#mobile-nav button[aria-expanded="true"] { background: #20527d; border-color: #72b6ed; color: #fff; }
#mobile-nav .mobile-nav-icon, #mobile-more > span:first-child { font-size: 22px; line-height: 24px; }
#mobile-nav #toggle-info-icon { display: none; }
#mobile-nav .mobile-unread::after { content: ''; position: absolute; width: 8px; height: 8px; right: 18px; top: 6px; border-radius: 50%; background: #ffb84d; }
body.mobile-layout #info-panel:not(.mobile-panel-open), body.mobile-layout #chatbot-widget:not(.mobile-panel-open) { display: none; }
body.mobile-layout #info-panel, #mobile-more-panel { position: fixed; top: auto; left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: var(--mobile-sheet-bottom);
    width: auto; max-width: none; max-height: calc(var(--mobile-visible-height, 100dvh) - var(--mobile-reserved-height)); z-index: 10010;
    padding: 0 12px 12px; border: 1px solid #456587; border-radius: 16px 16px 0 0; background: #101a29; overflow-y: auto; overscroll-behavior: contain; }
body.mobile-layout #info-panel { height: 48dvh; }
body.mobile-layout #info-panel.mobile-expanded { height: 80dvh; }
body.mobile-layout #info-panel .start-heading, body.mobile-layout #info-panel .start-hint { display: none; }
body.mobile-layout #mobile-panel-header, .mobile-sheet-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; min-height: 52px; background: #101a29; border-bottom: 1px solid #344150; margin-bottom: 10px; }
body.mobile-layout #mobile-panel-header { touch-action: none; user-select: none; -webkit-user-select: none; }
body.mobile-layout #mobile-panel-header h2, .mobile-sheet-header h2 { flex: 1; margin: 0; font-size: 17px; color: #dce8fa; }
:is(#mobile-panel-header, .mobile-sheet-header) button { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 1px solid #53677f; border-radius: 8px; background: #172a40; color: #fff; font-size: 23px; cursor: pointer; }
body.mobile-layout #primary-actions { grid-template-columns: 1fr; }
body.mobile-layout #info-panel[data-mobile-panel="explore"] #mobile-explore-tools { display: block; }
body.mobile-layout #info-panel-content { padding: 0; }
body.mobile-layout #info-panel[data-mobile-panel="search"] #primary-actions,
body.mobile-layout #info-panel[data-mobile-panel="search"] #info-panel-content > :not(#object-search-form):not(#search-hint),
body.mobile-layout #info-panel[data-mobile-panel="explore"] #object-search-form,
body.mobile-layout #info-panel[data-mobile-panel="explore"] #search-hint { display: none; }
body.mobile-layout #info-panel[data-mobile-panel="search"] .search-row { display: flex; gap: 6px; }
body.mobile-layout #object-search { min-width: 0; font-size: 16px; }
body.mobile-layout #object-search-form { margin-top: 6px; }
#mobile-more-panel { min-height: 200px; }
body.mobile-layout #mobile-more-panel #top-bar, body.mobile-layout #mobile-more-panel #controls { position: static; transform: none; width: auto; max-width: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; justify-content: flex-start; }
body.mobile-layout #mobile-more-panel #top-bar { margin-bottom: 8px; }
body.mobile-layout #mobile-more-panel #lang-btn { flex: 1; min-width: 100px; max-width: 100%; }
body.mobile-layout #mobile-more-panel #controls .dock-text { display: inline; }
body.mobile-layout #mobile-more-panel #controls button { min-height: 48px; }
body.mobile-layout #advanced-settings { margin-top: 12px; }
body.mobile-layout #mobile-more-panel :is(button, input:not([type="checkbox"]), select, summary) { min-height: 44px; }
body.mobile-layout #mobile-more-panel label { min-height: 44px; }
body.mobile-layout #mobile-more-panel input[type="range"] { max-width: 55%; }
body.mobile-layout #chatbot-widget { left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: var(--mobile-sheet-bottom); width: auto; max-width: none; transform: none;
    height: min(58dvh, calc(var(--mobile-visible-height, 100dvh) - var(--mobile-reserved-height))); }
body.mobile-layout #chatbot-popup { flex: 1; min-height: 0; max-height: none; }
body.mobile-layout #chatbot-toggle-btn { display: none; }
body.mobile-layout #chatbot-input { min-width: 0; font-size: 16px; }
body.mobile-layout #chatbot-bar { width: 100%; }
body.mobile-layout #sky-status, body.mobile-layout #place-hint { position: fixed; top: auto; bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 12px); left: 10px; right: 10px; max-width: none; transform: none; }
/* Stato del cielo e suggerimento del luogo stanno nello stesso punto: se c'e' lo stato (errore, ripresa), il suggerimento sale sopra e non copre "Riprova". */
body.mobile-layout:has(#sky-status:not([data-state="ready"])) #place-hint { bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 132px); }
body.mobile-layout #tour-card { bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 12px); }
body.mobile-layout.mobile-keyboard-open { --mobile-sheet-bottom: calc(var(--keyboard, 0px) + 8px); --mobile-reserved-height: 16px; }
body.mobile-keyboard-open #mobile-nav { visibility: hidden; }
body.sky-only #mobile-nav, body.sky-only #mobile-more-panel, body.gyro-active #mobile-nav, body.gyro-active #mobile-more-panel { display: none !important; }
body.mobile-layout.sky-only #sky-status { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 54px); }
/* In orizzontale la navigazione passa sul lato per non sottrarre due righe al cielo. */
@media (max-height: 500px) and (orientation: landscape) {
    body.mobile-layout { --mobile-nav-height: 0px; --mobile-sheet-bottom: max(8px, env(safe-area-inset-bottom)); --mobile-reserved-height: 24px; }
    body.mobile-layout #mobile-nav { top: 0; left: auto; width: calc(68px + env(safe-area-inset-right)); grid-template-columns: 1fr; grid-template-rows: repeat(4, minmax(0, 1fr));
        border-top: 0; border-left: 1px solid #456587; padding: max(4px, env(safe-area-inset-top)) env(safe-area-inset-right) max(4px, env(safe-area-inset-bottom)) 0; }
    body.mobile-layout #status-strip { right: calc(78px + env(safe-area-inset-right)); grid-template-columns: minmax(0, 1fr) auto auto; }
    body.mobile-layout .context-time { grid-column: 1; grid-row: 1; }
    body.mobile-layout #context-place { grid-column: 2; grid-row: 1; min-height: 44px; }
    body.mobile-layout #context-place::after { display: none; }
    body.mobile-layout #time-controls { grid-column: 3; grid-row: 1; flex-direction: row; align-items: center; }
    body.mobile-layout #time-toggle, body.mobile-layout #speed-control button { min-height: 44px; }
    body.mobile-layout #info-panel, body.mobile-layout #mobile-more-panel, body.mobile-layout #chatbot-widget { right: calc(76px + env(safe-area-inset-right)); }
    body.mobile-layout:not(.sky-only) #sky-status, body.mobile-layout #place-hint { right: calc(78px + env(safe-area-inset-right)); }
    body.mobile-layout #tour-card { left: calc((100vw - 68px) / 2); width: calc(100vw - 88px); }
}
@media (max-height: 500px) and (orientation: landscape) and (max-width: 700px) {
    body.mobile-layout #speed-slower, body.mobile-layout #speed-faster { display: none; }
    body.mobile-layout #time-toggle { font-size: 0; min-width: 44px; padding: 0; }
    body.mobile-layout #time-toggle::before { content: '⏸'; font-size: 18px; }
    body.mobile-layout #time-toggle[data-paused="true"]::before { content: '▶'; }
    body.mobile-layout #strip-datetime { font-size: 11px; }
}
/* barra di stato sul telefono: velocita' e pausa su un'unica riga da 44 px, a destra; il luogo ha una zona di tocco piu' grande di quanto si veda */
@media (pointer: coarse) and (max-width: 768px), (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
    #time-controls { grid-column: 2; grid-row: 1 / span 2; flex-direction: row; align-items: center; gap: 6px; }
    #time-toggle { min-height: 44px; padding: 0 12px; font-size: 14px; }
    #speed-control button { min-height: 44px; min-width: 44px; padding: 0 4px; }
    #speed-value { min-width: 56px; font-size: 13px; }
    #context-place { position: relative; min-height: 28px; overflow: visible; }   /* visibile: la zona di tocco esce dal riquadro */
    #context-place #strip-place { display: inline-block; max-width: calc(100% - 22px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
    #context-place::after { content: ''; position: absolute; inset: -14px -8px -2px -8px; }
    #strip-datetime { white-space: normal; }
}
/* la barra si adatta alla propria larghezza (non a quella dello schermo, che in orizzontale la divide con la chat): con meno di 374 px la
   pausa e' la sola icona (il nome resta nell'etichetta di accessibilita'), con meno di 342 spariscono anche le frecce, che restano nel pannello */
#status-strip { container-type: inline-size; container-name: strip; }
@media (pointer: coarse) and (max-width: 768px), (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
    @container strip (max-width: 373px) {
        #time-toggle { font-size: 0; min-width: 44px; padding: 0; }
        #time-toggle::before { content: '⏸'; font-size: 18px; }
        #time-toggle[data-paused="true"]::before { content: '▶'; }
    }
    @container strip (max-width: 341px) {
        #speed-control #speed-slower, #speed-control #speed-faster { display: none; }
        #speed-control { border-radius: 8px; }
        #speed-value { min-width: 52px; }
        #strip-datetime { font-size: 11px; }
    }
}
