/* JARVIS_HUD_V2 - schermata essenziale, il resto nel Menu */
:root {
  --bg: #03070d;
  --text: #e6f4ff;
  --muted: #7d93ab;
  --line: rgb(94 231 255 / .14);
  --accent: 94 231 255;
  --ok: 60 240 197;
  --warn: 255 181 71;
  --bad: 255 107 107;
  --size: min(64vw, 34dvh, 300px);
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }

.bg { position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 90% 45% at 50% 34%, rgb(30 120 180 / .26), transparent 70%),
    radial-gradient(ellipse 80% 35% at 50% 105%, rgb(60 240 197 / .07), transparent 70%),
    var(--bg); }
.bg::before { content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgb(94 231 255 / .04) 1px, transparent 1px),
                    linear-gradient(90deg, rgb(94 231 255 / .04) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 38%, #000 10%, transparent 65%);
          mask-image: radial-gradient(ellipse at 50% 38%, #000 10%, transparent 65%); }

.app { --c: var(--accent); --lvl: 0; position: relative; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; max-width: 560px; margin: 0 auto;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.app[data-phase="listening"] { --c: var(--ok); }
.app[data-phase="transcribing"] { --c: 155 140 255; }
.app[data-phase="thinking"], .app[data-phase="starting"] { --c: var(--warn); }
.app[data-phase="error"] { --c: var(--bad); }
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Testata */
.top { display: flex; align-items: center; justify-content: space-between; height: 52px; flex: 0 0 auto; }
.brand-sm { font-weight: 700; font-size: 15px; letter-spacing: .45em;
  background: linear-gradient(90deg, #fff, rgb(var(--accent))); -webkit-background-clip: text; background-clip: text; color: transparent; }
.clock { display: flex; align-items: baseline; gap: 8px; }
.clock b { font: 600 18px/1 var(--mono); letter-spacing: .04em; }
.clock span { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Due informazioni a colpo d'occhio */
.glance { flex: 0 0 auto; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 2px; }
.chip-btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 99px;
  font-size: 14px; color: #cfe6f7; border: 1px solid var(--line); background: rgb(8 20 32 / .6); }
.chip-btn svg { color: rgb(var(--accent)); }
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.led.ok { background: rgb(var(--ok)); box-shadow: 0 0 8px rgb(var(--ok)); }
.led.warn { background: rgb(var(--warn)); box-shadow: 0 0 8px rgb(var(--warn)); }
.led.bad { background: rgb(var(--bad)); box-shadow: 0 0 8px rgb(var(--bad)); }

/* Nucleo */
.stage { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; padding-top: 18px; }
.core { position: relative; width: var(--size); height: var(--size); border-radius: 50%; outline: none; }
.ring { position: absolute; border-radius: 50%; pointer-events: none; }
.r0 { inset: -5%; background: repeating-conic-gradient(rgb(var(--c) / .5) 0 .8deg, transparent .8deg 6deg);
  -webkit-mask: radial-gradient(circle, transparent 66%, #000 67%, #000 70%, transparent 71%);
          mask: radial-gradient(circle, transparent 66%, #000 67%, #000 70%, transparent 71%);
  animation: spin 90s linear infinite; }
.r1 { inset: 3%; border: 1px dashed rgb(var(--c) / .3); animation: spin 50s linear infinite reverse; }
.r2 { inset: 10%; border: 2px solid transparent; border-top-color: rgb(var(--c) / .95);
  border-left-color: rgb(var(--c) / .3); animation: spin 12s linear infinite; }
.r3 { inset: 22%; border: 1.5px solid rgb(var(--c) / .75);
  box-shadow: 0 0 22px rgb(var(--c) / .35), inset 0 0 22px rgb(var(--c) / .2);
  scale: calc(1 + var(--lvl) * .1); transition: scale .08s linear; }
.glow { position: absolute; inset: 8%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgb(var(--c) / .32), transparent 66%); filter: blur(8px);
  scale: calc(.9 + var(--lvl) * .45); opacity: calc(.6 + var(--lvl) * .4); }
.nucleus { position: absolute; inset: 33%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 34% 28%, #fff 0, rgb(var(--c)) 34%, rgb(var(--c) / .55) 62%, #061827 100%);
  box-shadow: 0 0 36px rgb(var(--c) / .55), 0 0 80px rgb(var(--c) / .22);
  scale: calc(1 + var(--lvl) * .18); transition: scale .08s linear; animation: breathe 4.5s ease-in-out infinite; }
.app[data-phase="listening"] .r2 { animation-duration: 5s; }
.app[data-phase="thinking"] .r2, .app[data-phase="starting"] .r2, .app[data-phase="transcribing"] .r2 { animation-duration: 1s; }
.app[data-phase="thinking"] .nucleus, .app[data-phase="transcribing"] .nucleus { animation-duration: 1s; }
.state { margin: 14px 0 0; font-size: 21px; font-weight: 650; text-align: center; }
.hint { margin: 2px 0 0; min-height: 18px; font-size: 14px; color: var(--muted); text-align: center; padding: 0 12px; }

/* Conversazione */
.feed { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 12px; padding: 14px 2px 8px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 24px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 24px); }
.feed > :first-child { margin-top: auto; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.suggest button { padding: 9px 14px; border-radius: 99px; font-size: 14px; color: #cfe6f7;
  background: rgb(94 231 255 / .06); border: 1px solid var(--line); }
.msg { max-width: 92%; word-wrap: break-word; overflow-wrap: anywhere; animation: rise .25s ease both; }
.msg p { margin: 0 0 .5em; } .msg p:last-child { margin-bottom: 0; }
.msg.user { align-self: flex-end; max-width: 82%; font-size: 15px; color: #cfe9ff;
  background: rgb(var(--accent) / .1); border: 1px solid rgb(var(--accent) / .2); padding: 8px 12px; border-radius: 16px 16px 5px 16px; }
.msg.jarvis { align-self: flex-start; font-size: 17px; line-height: 1.5; padding-left: 12px; border-left: 2px solid rgb(var(--accent) / .5); }
.msg.jarvis strong { color: #fff; }
.msg a { color: rgb(var(--accent)); text-decoration: none; }
.msg.err { align-self: center; font-size: 13px; color: #ff9b9b; text-align: center; }
.chip { display: inline-block; margin-top: 6px; font-size: 12px; padding: 3px 10px; border-radius: 99px; background: rgb(var(--ok) / .12); color: #7ff5d6; }
.sources { margin-top: 8px; font-size: 13px; color: var(--muted); }
.sources a { display: block; padding: 3px 0; }
.dots { display: inline-flex; gap: 5px; padding: 6px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgb(var(--accent)); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }

/* Barra inferiore */
.dock { flex: 0 0 auto; padding: 6px 0 max(12px, env(safe-area-inset-bottom)); }
.compose { display: flex; gap: 8px; margin-bottom: 8px; }
.compose input { flex: 1; height: 46px; border-radius: 14px; padding: 0 16px; font-size: 16px;
  background: rgb(94 231 255 / .06); border: 1px solid var(--line); outline: none; }
.compose input:focus { border-color: rgb(var(--accent) / .6); }
.send { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: rgb(var(--accent)); color: #031520; }
.dock-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.dock-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); padding: 6px 14px; justify-self: start; }
.dock-btn:last-child { justify-self: end; }
.app[data-kb="1"] #toggle-kb { color: rgb(var(--accent)); }
.mic { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; color: #031520;
  background: radial-gradient(circle at 35% 30%, #a8f5ff, #2bb8e0 55%, #0b5f86);
  box-shadow: 0 0 0 4px rgb(var(--accent) / .12), 0 8px 26px rgb(43 184 224 / .45), inset 0 1px 0 rgb(255 255 255 / .4);
  transition: transform .15s; }
.mic:active { transform: scale(.94); }
.mic .ic-stop { display: none; }
.app[data-active="1"] .mic { color: #fff; background: radial-gradient(circle at 35% 30%, #ff9e9e, #d9434f 60%, #8a1f29);
  box-shadow: 0 0 0 4px rgb(var(--bad) / .15), 0 8px 26px rgb(217 67 79 / .45); }
.app[data-active="1"] .mic .ic-mic { display: none; }
.app[data-active="1"] .mic .ic-stop { display: block; }

/* Login */
.login { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.mini-core { width: 110px; height: 110px; border-radius: 50%; margin-bottom: 10px;
  background: radial-gradient(circle at 34% 28%, #fff 0, rgb(var(--accent)) 34%, rgb(var(--accent) / .5) 62%, #061827 100%);
  box-shadow: 0 0 50px rgb(var(--accent) / .5), 0 0 0 14px rgb(var(--accent) / .06), 0 0 0 15px rgb(var(--accent) / .25);
  animation: breathe 4.5s ease-in-out infinite; }
.brand { margin: 0; font-size: 24px; letter-spacing: .35em; font-weight: 700; }
.login-form { display: flex; flex-direction: column; gap: 10px; width: min(320px, 100%); margin-top: 14px; }
.login-form input { height: 50px; border-radius: 12px; padding: 0 16px; font-size: 16px;
  background: rgb(94 231 255 / .06); border: 1px solid var(--line); outline: none; }
.login-msg { color: #ff9b9b; min-height: 20px; font-size: 14px; }
.muted { color: var(--muted); } .small { font-size: 13px; }

/* Pannelli */
.btn { display: block; width: 100%; height: 46px; border-radius: 12px; font-weight: 600;
  background: rgb(94 231 255 / .07); border: 1px solid var(--line); margin-top: 12px; }
.btn.primary { background: rgb(var(--accent)); color: #031520; border: 0; }
.btn.danger { color: #ff9b9b; }
.link { color: rgb(var(--accent)); font-weight: 600; padding: 4px 6px; }
dialog.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 86dvh;
  border-radius: 22px 22px 0 0; background: #07111c; color: var(--text);
  border-top: 1px solid rgb(var(--accent) / .3); box-shadow: 0 -10px 40px rgb(0 0 0 / .6); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: up .25s ease; }
dialog.sheet::backdrop { background: rgb(2 5 10 / .6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-body { overflow-y: auto; padding: 4px 20px max(24px, env(safe-area-inset-bottom)); }
.sub { margin: 18px 0 8px; font: 600 11px var(--mono); letter-spacing: .14em; color: rgb(var(--accent)); text-transform: uppercase; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; border-radius: 16px; text-align: left;
  background: rgb(94 231 255 / .05); border: 1px solid var(--line); }
.tile svg { color: rgb(var(--accent)); margin-bottom: 4px; }
.tile b { font-size: 16px; } .tile small { font-size: 12px; color: var(--muted); }
.tile:active { background: rgb(94 231 255 / .12); }

.wx-hero { display: flex; align-items: flex-start; flex-wrap: wrap; margin: 4px 0 14px; }
.wx-hero b { font: 300 56px/1 var(--mono); text-shadow: 0 0 18px rgb(var(--accent) / .45); }
.wx-hero span { font-size: 18px; color: var(--muted); margin: 6px 0 0 2px; }
.wx-hero p { width: 100%; margin: 6px 0 0; color: #b8d6ea; font-size: 15px; text-transform: capitalize; }

.news-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.news-list button { width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px; font-size: 15px; line-height: 1.35;
  background: rgb(94 231 255 / .04); border: 1px solid var(--line); }
.news-list small { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }

.mem-form textarea { width: 100%; border-radius: 12px; padding: 12px 14px; font-size: 16px; resize: vertical;
  background: rgb(94 231 255 / .05); border: 1px solid var(--line); outline: none; }
.mem-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mem-list li { background: rgb(94 231 255 / .04); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; }
.mem-list p { margin: 0 0 8px; font-size: 15px; }
.mem-row { display: flex; align-items: center; gap: 6px; }
.mem-row .tag { margin-right: auto; font: 10px var(--mono); text-transform: uppercase; letter-spacing: .08em;
  color: rgb(var(--accent)); background: rgb(var(--accent) / .1); padding: 3px 8px; border-radius: 99px; }
.mem-row button { font-size: 13px; color: var(--muted); padding: 4px 8px; }
.mem-row button.danger { color: #ff9b9b; }
.sys-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sys-grid > div { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: rgb(94 231 255 / .03); }
.sys-grid small { display: block; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sys-grid b { font: 600 20px/1.3 var(--mono); }
.sys-grid span { font-size: 12px; color: var(--muted); }
.bar { height: 4px; border-radius: 4px; background: rgb(255 255 255 / .08); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: rgb(var(--ok)); }
.bar.mid i { background: rgb(var(--warn)); } .bar.high i { background: rgb(var(--bad)); }
.sys-svc { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sys-svc li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.sys-svc li b { width: 9px; height: 9px; border-radius: 50%; background: rgb(var(--bad)); box-shadow: 0 0 6px rgb(var(--bad)); }
.sys-svc li b.on { background: rgb(var(--ok)); box-shadow: 0 0 6px rgb(var(--ok)); }
.sys-svc li span { margin-left: auto; font: 12px var(--mono); color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 14px; font-size: 14px; color: var(--muted); }
.field.row { flex-direction: row; align-items: center; justify-content: space-between; color: var(--text); font-size: 16px; }
.field select { height: 44px; border-radius: 10px; padding: 0 12px; font-size: 16px; color: var(--text);
  background: rgb(94 231 255 / .06); border: 1px solid var(--line); }
.switch { -webkit-appearance: none; appearance: none; width: 50px; height: 30px; border-radius: 99px; position: relative;
  background: rgb(255 255 255 / .15); transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }

@keyframes spin { to { rotate: 360deg; } }
@keyframes breathe { 50% { filter: brightness(1.25) saturate(1.15); } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes rise { from { opacity: 0; translate: 0 6px; } }
@keyframes up { from { translate: 0 40px; opacity: .4; } }

@media (max-height: 700px) { :root { --size: min(56vw, 29dvh, 240px); } .stage { padding-top: 10px; } .state { font-size: 19px; margin-top: 10px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }

/* Pulsante per pulire lo schermo */
.clear-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; height: 30px; padding: 0 12px; border-radius: 99px; font-size: 13px; color: var(--muted); border: 1px solid var(--line); background: rgb(8 20 32 / .6); }
.clear-btn:active { color: var(--text); background: rgb(94 231 255 / .12); }

/* Diario */
.filters { display: flex; gap: 6px; overflow-x: auto; margin: 14px 0 6px; padding-bottom: 2px; }
.filters button { flex: 0 0 auto; padding: 6px 12px; border-radius: 99px; font-size: 13px; color: var(--muted); border: 1px solid var(--line); }
.filters button.on { color: #031520; background: rgb(var(--accent)); border-color: transparent; font-weight: 600; }
.diary-day { margin: 14px 0 6px; font: 600 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: rgb(var(--accent)); }
.diary-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: start; padding: 10px 12px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 12px; background: rgb(94 231 255 / .04); }
.diary-item time { font: 12px/1.6 var(--mono); color: var(--muted); }
.diary-item p { margin: 0; font-size: 15px; }
.diary-item small { display: block; margin-top: 3px; font-size: 11px; color: rgb(var(--accent)); }
.diary-item button { font-size: 18px; line-height: 1; color: var(--muted); padding: 2px 4px; }

/* Stazioni */
.chip-btn.warn { color: #ffd59a; border-color: rgb(var(--warn) / .55); }
.chip-btn.warn svg { color: rgb(var(--warn)); }
.st-list { display: flex; flex-direction: column; gap: 10px; }
.st-card { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; background: rgb(94 231 255 / .04); }
.st-card.stale { border-color: rgb(var(--bad) / .55); background: rgb(var(--bad) / .06); }
.st-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.st-head b { font-size: 16px; }
.st-head span { font: 12px var(--mono); color: var(--muted); }
.st-card.stale .st-head span { color: #ff9b9b; }
.st-main { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 8px; }
.st-temp { font: 300 34px/1 var(--mono); text-shadow: 0 0 14px rgb(var(--accent) / .4); }
.st-cond { font-size: 14px; color: #b8d6ea; }
.st-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; }
.st-grid div { font-size: 12px; color: var(--muted); }
.st-grid small { display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.st-grid b { font: 600 16px/1.3 var(--mono); color: var(--text); }

/* Promemoria e notifiche */
.tiles .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
.rem-form { display: flex; flex-direction: column; }
.rem-form input { height: 46px; border-radius: 12px; padding: 0 14px; font-size: 16px; background: rgb(94 231 255 / .05); border: 1px solid var(--line); outline: none; }
.rem-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 11px 13px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 12px; background: rgb(94 231 255 / .04); }
.rem-item p { margin: 0; font-size: 15px; }
.rem-item small { display: block; margin-top: 2px; font: 12px var(--mono); color: rgb(var(--accent)); }
.rem-item.done { opacity: .5; }
.rem-item.done small { color: var(--muted); }
.rem-item button { font-size: 18px; color: var(--muted); padding: 2px 6px; }
