/* ═══════════════════════════════════════════════════════════════════
   J.A.R.V.I.S. — Command Center UI
   Design futuristico ispirato a FRIDAY/JARVIS — Iron Man
═══════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --cyan:        #00d4ff;
    --cyan-dim:    #0099bb;
    --blue:        #0066ff;
    --blue-dim:    #003388;
    --green:       #00ff9d;
    --orange:      #ff8c00;
    --red:         #ff3355;
    --bg:          #0a0a0f;
    --bg2:         #0d0d18;
    --bg3:         #111122;
    --panel:       rgba(0, 20, 40, 0.75);
    --panel-border: rgba(0, 212, 255, 0.18);
    --panel-glow:   rgba(0, 212, 255, 0.06);
    --text:        #c8e8ff;
    --text-dim:    #6688aa;
    --text-bright: #ffffff;
    --font-mono:   'Share Tech Mono', 'Courier New', monospace;
    --font-ui:     'Rajdhani', sans-serif;
    --font-logo:   'Orbitron', sans-serif;
    --radius:      4px;
    --header-h:    52px;
    --footer-h:    62px;
    --sidebar-w:   220px;
    --info-w:      240px;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.4;
}

/* ── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cyan-dim); border-radius: 2px; }

/* ── Canvas di sfondo (griglia + particelle) ─────────────────── */
#bgCanvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT PRINCIPALE — CSS Grid
═══════════════════════════════════════════════════════════════ */
.hud-layout {
    position: relative;
    z-index: 1;
    height: 100vh;
    display: grid;
    grid-template-rows: var(--header-h) 1fr var(--footer-h);
    grid-template-areas:
        "header"
        "body"
        "footer";
}

/* ═══════════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════════ */
.hud-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(0, 8, 20, 0.92);
    border-bottom: 1px solid var(--panel-border);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    gap: 12px;
}

.header-logo {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.logo-text {
    font-family: var(--font-logo);
    font-size: 18px;
    font-weight: 700;
    color: var(--cyan);
    text-shadow: 0 0 12px rgba(0, 212, 255, 0.7), 0 0 30px rgba(0, 212, 255, 0.3);
    letter-spacing: 3px;
}

.logo-sub {
    font-family: var(--font-mono);
    font-size: 8px;
    color: var(--text-dim);
    letter-spacing: 2px;
    margin-top: 2px;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.clock-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.clock-time {
    font-family: var(--font-mono);
    font-size: 22px;
    color: var(--cyan);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    letter-spacing: 3px;
    line-height: 1;
}

.clock-date {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1px;
    padding: 3px 8px;
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    background: var(--panel);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    transition: background 0.4s, box-shadow 0.4s;
}
.status-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse-dot 2s infinite; }
.status-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-dot.unknown { background: var(--orange); }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

.header-model {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--cyan-dim);
    letter-spacing: 1px;
}

.header-sysinfo {
    display: flex;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-dim);
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.icon-btn:hover {
    color: var(--cyan);
    border-color: var(--cyan);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
}

/* ═══════════════════════════════════════════════════════════════
   BODY (tre colonne)
═══════════════════════════════════════════════════════════════ */
.hud-body {
    grid-area: body;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr var(--info-w);
    grid-template-areas: "sidebar main info";
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR SINISTRA
═══════════════════════════════════════════════════════════════ */
.hud-sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-right: 1px solid var(--panel-border);
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.sidebar-section {
    padding: 10px 12px;
    flex-shrink: 0;
}
.sidebar-section:not(:last-child) {
    border-bottom: 1px solid var(--panel-border);
}
.sidebar-section:first-child {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.section-label {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--cyan-dim);
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

.chat-msg {
    font-size: 12px;
    line-height: 1.4;
    padding: 5px 8px;
    border-radius: var(--radius);
    word-break: break-word;
    animation: fadeInMsg 0.3s ease;
}

@keyframes fadeInMsg {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
    background: rgba(0, 102, 255, 0.15);
    border-left: 2px solid var(--blue);
    color: var(--cyan);
}
.chat-msg.jarvis {
    background: rgba(0, 212, 255, 0.07);
    border-left: 2px solid var(--cyan-dim);
    color: var(--text);
}
.chat-msg.system {
    background: transparent;
    border-left: 2px solid var(--text-dim);
    color: var(--text-dim);
    font-size: 11px;
}
.msg-prefix {
    font-family: var(--font-mono);
    font-size: 9px;
    margin-right: 4px;
    opacity: 0.7;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.qa-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 7px 4px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    color: var(--text-dim);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}
.qa-btn i { font-size: 13px; }
.qa-btn:hover {
    background: rgba(0, 212, 255, 0.15);
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}
.qa-btn:active { transform: scale(0.96); }

/* Model Select */
.model-select {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--panel-border);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 5px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    outline: none;
}
.model-select:focus { border-color: var(--cyan); }

/* ═══════════════════════════════════════════════════════════════
   AREA PRINCIPALE — ORB
═══════════════════════════════════════════════════════════════ */
.hud-main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    gap: 12px;
    padding: 12px;
}

/* Orb wrapper */
.orb-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Anelli HUD esterni rotanti */
.orb-hud-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(0, 212, 255, 0.25);
    pointer-events: none;
}
.ring-outer {
    width: 260px;
    height: 260px;
    border-style: dashed;
    border-color: rgba(0, 212, 255, 0.12);
    animation: ring-rotate 30s linear infinite;
}
.ring-mid {
    width: 220px;
    height: 220px;
    border-color: rgba(0, 102, 255, 0.2);
    animation: ring-rotate 15s linear infinite reverse;
}

@keyframes ring-rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Container Orb */
.orb-container {
    position: relative;
    width: 180px;
    height: 180px;
    flex-shrink: 0;
}

.orb-glow {
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 102, 255, 0.25) 0%, transparent 70%);
    animation: orb-pulse 3s ease-in-out infinite;
    pointer-events: none;
}

.orb {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%,
        #1a3a6e 0%,
        #0a1a40 50%,
        #030810 100%
    );
    border: 1px solid rgba(0, 212, 255, 0.4);
    box-shadow:
        0 0 20px rgba(0, 102, 255, 0.5),
        0 0 50px rgba(0, 102, 255, 0.2),
        inset 0 0 20px rgba(0, 40, 80, 0.5);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.3s;
}
.orb:hover {
    box-shadow:
        0 0 30px rgba(0, 212, 255, 0.7),
        0 0 70px rgba(0, 212, 255, 0.3),
        inset 0 0 20px rgba(0, 40, 80, 0.5);
}

#waveform {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* Stati dell'orb */
.orb-container.idle  .orb-glow { animation: orb-pulse 3s ease-in-out infinite; }
.orb-container.listening .orb-glow {
    background: radial-gradient(circle, rgba(0, 212, 255, 0.4) 0%, transparent 70%);
    animation: orb-pulse 0.8s ease-in-out infinite;
}
.orb-container.listening .orb {
    border-color: var(--cyan);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.8), 0 0 80px rgba(0, 212, 255, 0.3), inset 0 0 20px rgba(0, 40, 80, 0.5);
}
.orb-container.speaking .orb-glow {
    background: radial-gradient(circle, rgba(0, 255, 157, 0.35) 0%, transparent 70%);
    animation: orb-pulse 0.5s ease-in-out infinite;
}
.orb-container.speaking .orb {
    border-color: var(--green);
    box-shadow: 0 0 30px rgba(0, 255, 157, 0.6), 0 0 80px rgba(0, 255, 157, 0.2), inset 0 0 20px rgba(0, 40, 80, 0.5);
}

@keyframes orb-pulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50%       { opacity: 1; transform: scale(1.05); }
}

/* Particelle fluttuanti */
.orb-particles {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 4px var(--cyan);
    animation: float-particle var(--dur, 6s) linear infinite;
    opacity: 0;
    top: var(--y, 50%);
    left: var(--x, 50%);
}
@keyframes float-particle {
    0%   { opacity: 0; transform: translate(0, 0) scale(0); }
    20%  { opacity: 0.8; transform: translate(var(--tx, 20px), var(--ty, -30px)) scale(1); }
    80%  { opacity: 0.4; }
    100% { opacity: 0; transform: translate(var(--tx2, 40px), var(--ty2, -60px)) scale(0); }
}

/* Label Orb */
.orb-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 4px;
    color: var(--cyan-dim);
    text-align: center;
    margin-top: 4px;
}

/* ── Risposta / Typewriter ──────────────────────────────────── */
.response-area {
    width: 100%;
    max-width: 480px;
    min-height: 40px;
    text-align: center;
    padding: 0 8px;
}

.response-text {
    font-family: var(--font-ui);
    font-size: 15px;
    color: var(--text);
    line-height: 1.6;
}

.response-text::after {
    content: '\2588';
    color: var(--cyan);
    animation: blink-cursor 0.9s step-end infinite;
    margin-left: 2px;
    font-size: 12px;
}
.response-text.done::after { display: none; }

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ── Visualizzatore Audio ──────────────────────────────────── */
.audio-viz {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 30px;
    opacity: 0;
    transition: opacity 0.3s;
}
.audio-viz.active { opacity: 1; }

.viz-bar {
    width: 5px;
    background: var(--green);
    border-radius: 3px 3px 0 0;
    box-shadow: 0 0 6px var(--green);
    height: 4px;
    transition: height 0.1s;
    animation: bar-idle 2s ease-in-out infinite;
}
.viz-bar:nth-child(1) { animation-delay: 0.0s; }
.viz-bar:nth-child(2) { animation-delay: 0.1s; }
.viz-bar:nth-child(3) { animation-delay: 0.2s; }
.viz-bar:nth-child(4) { animation-delay: 0.3s; }
.viz-bar:nth-child(5) { animation-delay: 0.2s; }
.viz-bar:nth-child(6) { animation-delay: 0.1s; }
.viz-bar:nth-child(7) { animation-delay: 0.05s; }
.viz-bar:nth-child(8) { animation-delay: 0.15s; }

@keyframes bar-idle {
    0%, 100% { height: 4px; }
    50%       { height: 22px; }
}

/* ═══════════════════════════════════════════════════════════════
   INFO PANEL DESTRO — WIDGET
═══════════════════════════════════════════════════════════════ */
.hud-info {
    grid-area: info;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--panel);
    border-left: 1px solid var(--panel-border);
    overflow-y: auto;
    backdrop-filter: blur(8px);
}

.widget {
    border-bottom: 1px solid var(--panel-border);
    flex-shrink: 0;
}

.widget-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px 5px;
    background: rgba(0, 212, 255, 0.04);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--cyan-dim);
    border-bottom: 1px solid rgba(0, 212, 255, 0.08);
    text-transform: uppercase;
}
.widget-header i { font-size: 11px; }
.widget-update {
    margin-left: auto;
    font-size: 8px;
    color: var(--text-dim);
}

.widget-body {
    padding: 8px 12px;
}

/* Meteo */
.meteo-main {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 4px;
}
.meteo-icon { font-size: 22px; }
.meteo-temp {
    font-family: var(--font-mono);
    font-size: 24px;
    color: var(--cyan);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.4);
}
.meteo-desc {
    font-size: 12px;
    color: var(--text);
    text-transform: capitalize;
    margin-bottom: 2px;
}
.meteo-extra {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
}

/* News */
.news-list { display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow-y: auto; }
.news-item {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    transition: color 0.2s;
}
.news-item:hover { color: var(--cyan); }
.news-item:last-child { border-bottom: none; }
.news-title {
    font-size: 11px;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 2px;
}
.news-meta {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-dim);
}
.news-item-loading { font-size: 11px; color: var(--text-dim); animation: pulse-text 1.5s infinite; }
@keyframes pulse-text { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* Calendario */
.cal-event {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.cal-event:last-child { border-bottom: none; }
.cal-title { font-size: 11px; color: var(--text); margin-bottom: 2px; }
.cal-time  { font-family: var(--font-mono); font-size: 10px; color: var(--cyan-dim); }
.cal-empty { font-size: 11px; color: var(--text-dim); font-style: italic; }

/* Sistema */
.sys-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.sys-label {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-dim);
    width: 32px;
    letter-spacing: 1px;
    flex-shrink: 0;
}
.sys-bar-wrap {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.07);
    border-radius: 3px;
    overflow: hidden;
}
.sys-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--cyan));
    border-radius: 3px;
    width: 0%;
    transition: width 0.6s ease;
    box-shadow: 0 0 4px var(--cyan);
}
.sys-val {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--cyan);
    width: 36px;
    text-align: right;
    flex-shrink: 0;
}
.sys-uptime {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 2px;
    animation: live-pulse 3s ease infinite;
}
@keyframes live-pulse {
    0%, 100% { opacity: 0.7; }
    50%       { opacity: 1; }
}

/* Budget */
.budget-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}
.budget-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1px;
}
.budget-val {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
}
.budget-val.positive  { color: var(--green); }
.budget-val.negative  { color: var(--red); }
.budget-val.saldo     { color: var(--cyan); text-shadow: 0 0 8px rgba(0, 212, 255, 0.4); }
.budget-divider {
    height: 1px;
    background: var(--panel-border);
    margin: 4px 0;
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER — Bottom Bar
═══════════════════════════════════════════════════════════════ */
.hud-footer {
    grid-area: footer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    background: rgba(0, 8, 20, 0.92);
    border-top: 1px solid var(--panel-border);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.06);
    backdrop-filter: blur(12px);
}

.footer-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 120px;
}

.status-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    transition: all 0.3s;
}
.status-indicator-dot.thinking  { background: var(--orange); box-shadow: 0 0 6px var(--orange); animation: pulse-dot 0.6s infinite; }
.status-indicator-dot.speaking  { background: var(--green);  box-shadow: 0 0 6px var(--green);  animation: pulse-dot 0.4s infinite; }
.status-indicator-dot.listening { background: var(--cyan);   box-shadow: 0 0 6px var(--cyan);   animation: pulse-dot 0.8s infinite; }
.status-indicator-dot.ready     { background: var(--green);  box-shadow: 0 0 5px var(--green); }

.footer-input {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 20, 40, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 0 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.footer-input:focus-within {
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

.footer-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-bright);
    font-family: var(--font-ui);
    font-size: 14px;
    padding: 8px 4px;
    caret-color: var(--cyan);
}
.footer-chat-input::placeholder { color: var(--text-dim); }

.footer-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.footer-btn:hover { color: var(--cyan); background: rgba(0, 212, 255, 0.1); }

.voice-btn.active { color: var(--cyan); background: rgba(0, 212, 255, 0.15); animation: pulse-dot 1s infinite; }
.mic-btn.recording { color: var(--red); background: rgba(255, 51, 85, 0.15); animation: pulse-dot 0.5s infinite; }
.send-btn:hover { color: var(--blue); background: rgba(0, 102, 255, 0.15); }

.footer-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 80px;
}
.ws-status {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 1px;
}
.ws-status.connected { color: var(--green); }
.ws-status.error     { color: var(--red); }
.model-badge {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--cyan-dim);
    letter-spacing: 0.5px;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   MODALE APPROVAZIONE
═══════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 4, 12, 0.85);
    backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: var(--bg2);
    border: 1px solid var(--cyan);
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.3);
    border-radius: 8px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
    animation: modal-in 0.2s ease;
}
@keyframes modal-in {
    from { opacity: 0; transform: scale(0.9) translateY(-20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 2px;
    color: var(--orange);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-body {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 20px;
    line-height: 1.6;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.modal-btn {
    padding: 8px 20px;
    border-radius: var(--radius);
    border: 1px solid;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.modal-btn.deny {
    background: transparent;
    border-color: var(--red);
    color: var(--red);
}
.modal-btn.deny:hover { background: rgba(255, 51, 85, 0.15); }
.modal-btn.approve {
    background: rgba(0, 212, 255, 0.1);
    border-color: var(--cyan);
    color: var(--cyan);
}
.modal-btn.approve:hover { background: rgba(0, 212, 255, 0.25); box-shadow: 0 0 12px rgba(0, 212, 255, 0.3); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile / Tablet
═══════════════════════════════════════════════════════════════ */

/* ── Telegram Web App — safe area insets ────────────────────── */
body {
    padding-top:    env(safe-area-inset-top,    0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left:   env(safe-area-inset-left,   0px);
    padding-right:  env(safe-area-inset-right,  0px);
}

/* ── ≤ 900px: layout a colonna singola ──────────────────────── */
@media (max-width: 900px) {
    :root {
        --sidebar-w: 0px;
        --info-w:    0px;
        --header-h:  44px;
        --footer-h:  58px;
    }

    /* hud-body diventa flex colonna: main in alto, widget in basso */
    .hud-body {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Main area: occupa lo spazio disponibile */
    .hud-main {
        flex: 1;
        min-height: 0;
        padding: 8px;
        gap: 8px;
    }

    /* ── Sidebar: drawer fisso fuori schermo a sinistra ── */
    .hud-sidebar {
        position: fixed;
        left: -280px;
        top: var(--header-h);
        height: calc(100vh - var(--header-h) - var(--footer-h));
        width: 260px;
        z-index: 600;
        transition: left 0.25s ease;
        display: flex;         /* sempre flex, solo fuori schermo */
        flex-direction: column;
        overflow-y: auto;
        border-right: 1px solid var(--panel-border);
        background: rgba(0, 12, 28, 0.97);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }
    .hud-sidebar.mobile-open {
        left: 0;
        box-shadow: 6px 0 40px rgba(0, 0, 0, 0.85);
        border-right-color: var(--cyan);
    }

    /* ── Backdrop semi-trasparente quando sidebar è aperta ── */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 599;
        background: rgba(0, 0, 0, 0.55);
    }
    .sidebar-backdrop.visible { display: block; }

    /* ── Info panel: strip orizzontale scrollabile ── */
    .hud-info {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        border-left: none;
        border-top: 1px solid var(--panel-border);
        padding: 8px;
        gap: 8px;
        flex-shrink: 0;
        background: rgba(0, 10, 24, 0.85);
    }
    .hud-info::-webkit-scrollbar { display: none; }

    /* Widget come card orizzontali */
    .widget {
        min-width: 200px;
        max-width: 240px;
        flex-shrink: 0;
        border-bottom: none;
        border: 1px solid var(--panel-border);
        border-radius: 6px;
        background: rgba(0, 20, 40, 0.8);
    }
    .news-list { max-height: 110px; }

    /* ── Header ── */
    #hamburgerBtn { display: flex !important; }
    .header-sysinfo { display: none; }
    .logo-text { font-size: 15px; letter-spacing: 2px; }
    .clock-time { font-size: 19px; }

    /* ── Orb ridotto ── */
    .orb-container { width: 140px; height: 140px; }
    .ring-outer { width: 200px; height: 200px; }
    .ring-mid   { width: 168px; height: 168px; }
    .orb-hud-ring { pointer-events: none; }
    #waveform { width: 140px !important; height: 140px !important; }

    /* ── Touch target minimi 44px ── */
    .footer-btn  { width: 44px; height: 44px; font-size: 16px; }
    .qa-btn      { min-height: 44px; padding: 6px 8px; }
    .icon-btn    { width: 36px; height: 36px; }
    .model-select { font-size: 13px; padding: 6px 8px; }

    /* Previeni zoom automatico iOS sull'input */
    .footer-chat-input { font-size: 16px; }

    /* ── Quick actions: riga scroll orizzontale nella sidebar ── */
    .quick-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 5px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .quick-actions::-webkit-scrollbar { display: none; }
    .qa-btn { flex-shrink: 0; min-width: 64px; flex-direction: row; gap: 5px; font-size: 11px; }
    .qa-btn i { font-size: 14px; }

    /* ── Footer ── */
    .footer-status { display: none; }
    .footer-meta   { display: none; }
    .hud-footer    { padding: 0 8px; gap: 6px; }
}

/* ── ≤ 480px: schermo molto piccolo ─────────────────────────── */
@media (max-width: 480px) {
    :root { --header-h: 40px; --footer-h: 56px; }
    .logo-sub     { display: none; }
    .header-model { display: none; }
    .clock-date   { display: none; }
    .clock-time   { font-size: 17px; letter-spacing: 2px; }

    .orb-container { width: 120px; height: 120px; }
    .ring-outer { width: 175px; height: 175px; }
    .ring-mid   { width: 148px; height: 148px; }

    .widget { min-width: 185px; }

    .response-text { font-size: 13px; }
}

/* ── Stato typing / loading ─────────────────────────────────── */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--cyan);
    animation: dot-bounce 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%           { transform: scale(1.1); opacity: 1; }
}

/* ── HUD grid overlay sfondo ────────────────────────────────── */
.hud-main::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 212, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 255, 0.025) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}
.hud-main > * { position: relative; z-index: 1; }

/* ── Scan line effect ───────────────────────────────────────── */
.hud-main::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(transparent 50%, rgba(0, 0, 0, 0.03) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}
