:root {
  --bg: #f6f6f9;
  --panel: #ffffff;
  --panel-2: #f0f0f5;
  --line: #e4e4ec;
  --text: #17171f;
  --muted: #6b6b7b;
  --accent: #7c6cff;
  --accent-ink: #ffffff;
  --user: #17171f;
  --user-ink: #ffffff;
  --danger: #e5484d;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .04), 0 4px 16px rgba(20, 20, 40, .06);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e13;
    --panel: #17171f;
    --panel-2: #20202a;
    --line: #2a2a36;
    --text: #ececf2;
    --muted: #9a9aab;
    --user: #ececf2;
    --user-ink: #0e0e13;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 15.5px/1.55 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
#app { display: flex; height: 100dvh; }
#sidebar {
  width: 290px; flex: none; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: calc(14px + var(--sat)) 12px 12px;
}
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.wrap { max-width: 820px; margin: 0 auto; padding: 0 20px; width: 100%; }

#tabbar { display: none; }

@media (max-width: 860px) {
  #sidebar { display: none; }
  #tabbar {
    display: flex; flex: none; justify-content: space-around;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + var(--sab));
  }
  #tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 11px; color: var(--muted); padding: 4px 0;
  }
  #tabbar button svg { width: 24px; height: 24px; }
  #tabbar button.on { color: var(--accent); }
  body.in-chat #tabbar { display: none; }
  .wrap { padding: 0 16px; }
}

/* ---------- sidebar ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 650; font-size: 16px; }
.brand-logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #8b7bff, #5b4ff0); color: #fff; font-size: 16px;
}
.btn-new {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--accent); color: var(--accent-ink); border-radius: 12px;
  padding: 10px 12px; font-weight: 600; margin-bottom: 14px;
}
.btn-new:hover { filter: brightness(1.06); }
.side-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 6px; }
.side-list { overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.side-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 7px 10px; border-radius: 10px; color: var(--text); font-size: 14px;
}
.side-item:hover { background: var(--panel-2); }
.side-item.on { background: var(--panel-2); font-weight: 600; }
.side-item .ttl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-nav { display: flex; gap: 4px; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
.side-nav button { flex: 1; min-width: 0; padding: 6px 2px; border-radius: 10px; color: var(--muted); font-size: 12px; display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center; }
.side-nav button:hover, .side-nav button.on { background: var(--panel-2); color: var(--text); }
.side-nav svg { width: 17px; height: 17px; }

/* ---------- avatar ---------- */
.av {
  --c: var(--accent);
  width: 28px; height: 28px; flex: none; border-radius: 9px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); font-size: 15px; line-height: 1;
}
.av.lg { width: 44px; height: 44px; border-radius: 13px; font-size: 22px; }
.av.sm { width: 22px; height: 22px; border-radius: 7px; font-size: 12px; }
.dot-run { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; flex: none; }

/* ---------- home ---------- */
.home { padding-top: calc(28px + var(--sat)); padding-bottom: 40px; }
.hello { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px; }
.hello-sub { color: var(--muted); margin: 0 0 22px; }
.ask {
  display: flex; align-items: flex-end; gap: 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow);
}
.ask textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; padding: 8px 0; max-height: 200px; min-height: 24px; }
.section { margin-top: 30px; }
.section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.section h2 button { text-transform: none; letter-spacing: 0; color: var(--accent); font-size: 13px; font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
@media (max-width: 500px) { .grid { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 8px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.card:active { transform: scale(.98); }
.card b { font-size: 15px; }
.card span { color: var(--muted); font-size: 12.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.row:last-child { border-bottom: 0; }
button.row:hover { background: var(--panel-2); }
.row .txt { flex: 1; min-width: 0; }
.row .t1 { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .when { color: var(--muted); font-size: 12px; flex: none; }
.date-pill { flex: none; width: 46px; text-align: center; border-radius: 10px; background: var(--panel-2); padding: 4px 0; line-height: 1.15; }
.date-pill b { display: block; font-size: 17px; }
.date-pill small { font-size: 10.5px; text-transform: uppercase; color: var(--muted); }
.date-pill.soon { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.date-pill.soon small { color: var(--danger); }
.empty { color: var(--muted); padding: 18px; text-align: center; font-size: 14px; }

/* ---------- chat ---------- */
.chat-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--sat)) 14px 10px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.chat-head .txt { flex: 1; min-width: 0; }
.chat-head .t1 { font-weight: 650; }
.chat-head .t2 { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 21px; height: 21px; }
.back { display: none; }
@media (max-width: 860px) { .back { display: grid; } }

.msgs { padding-top: 20px; padding-bottom: 10px; }
.msg { margin: 0 0 22px; display: flex; gap: 12px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user); color: var(--user-ink); border-radius: 20px 20px 6px 20px;
  padding: 10px 15px; max-width: 82%; white-space: pre-wrap; word-wrap: break-word;
}
.msg.ai .body { flex: 1; min-width: 0; }
.files { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.file-chip { font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; display: inline-flex; gap: 5px; align-items: center; }
.file-chip button { color: var(--muted); font-size: 14px; line-height: 1; }

.steps { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.step { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.step .av.sm { width: 18px; height: 18px; font-size: 10px; border-radius: 5px; }
.step.agent { color: var(--text); font-weight: 550; }
.steps-toggle { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: inline-flex; gap: 4px; align-items: center; }
.steps-toggle:hover { color: var(--text); }

.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.msg-tools { display: flex; gap: 2px; margin-top: 6px; opacity: .7; }
.msg-tools button { font-size: 12px; color: var(--muted); padding: 3px 7px; border-radius: 7px; }
.msg-tools button:hover { background: var(--panel-2); color: var(--text); }

.composer-wrap { flex: none; padding: 8px 0 calc(12px + var(--sab)); background: linear-gradient(transparent, var(--bg) 30%); }
.composer {
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
  padding: 6px 6px 6px 6px;
}
.composer .files { justify-content: flex-start; padding: 6px 8px 0; margin: 0; }
.composer-row { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; padding: 9px 6px; max-height: 40vh; min-height: 24px; line-height: 1.45; }
.send {
  width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; flex: none;
}
.send:disabled { opacity: .35; cursor: default; }
.send svg { width: 19px; height: 19px; }
.send.stop { background: var(--text); color: var(--bg); }
.mic.on { color: var(--danger); animation: pulse 1s infinite; }
.hint { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* ---------- testo formattato ---------- */
.md { word-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md table, .md pre, .md blockquote { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 8px; line-height: 1.3; letter-spacing: -.01em; }
.md h1 { font-size: 21px; } .md h2 { font-size: 18.5px; } .md h3 { font-size: 16.5px; } .md h4 { font-size: 15.5px; }
.md ul, .md ol { padding-left: 22px; }
.md li { margin: 3px 0; }
.md code { font: 13.5px ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--panel-2); padding: 12px 14px; border-radius: 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.md .tbl { overflow-x: auto; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 12px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 0; }
.md th, .md td { padding: 7px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { background: var(--panel-2); font-weight: 600; white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }
.md td.num, .md th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- pagine semplici ---------- */
.page-head { padding-top: calc(22px + var(--sat)); padding-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.page-head h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; flex: 1; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13.5px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.search { width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); outline: 0; margin-bottom: 12px; }
.mem-doc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 40px; }

/* ---------- login ---------- */
.login { margin: auto; width: 100%; max-width: 360px; padding: 24px; text-align: center; }
.login .brand-logo { width: 56px; height: 56px; border-radius: 16px; font-size: 28px; margin: 0 auto 16px; }
.login h1 { font-size: 22px; margin: 0 0 6px; }
.login p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.login input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); outline: 0; margin-bottom: 10px; text-align: center; }
.login button { width: 100%; padding: 12px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }
.err { color: var(--danger); font-size: 13.5px; min-height: 20px; margin-top: 8px; }

/* ---------- toast e menu ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--sab)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 50; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 861px) { .sheet-bg { align-items: center; } }
.sheet {
  background: var(--panel); width: 100%; max-width: 440px; border-radius: 22px 22px 0 0;
  padding: 10px 10px calc(14px + var(--sab)); max-height: 80dvh; overflow-y: auto; animation: up .2s ease;
}
@media (min-width: 861px) { .sheet { border-radius: 20px; } }
.sheet h3 { margin: 8px 12px 10px; font-size: 15px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

/* ---------- tastierino PIN ---------- */
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 6px 0 4px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); transition: all .12s; }
.pin-dots i.on { background: var(--accent); border-color: var(--accent); transform: scale(1.1); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 300px; margin: 10px auto 0; }
.login .pin-pad button {
  width: auto; aspect-ratio: 1; max-height: 84px; border-radius: 50%; padding: 0;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font-size: 30px; font-weight: 500; justify-self: center; height: 84px; width: 84px;
  transition: background .1s, transform .1s;
}
.login .pin-pad button:active { background: var(--panel-2); transform: scale(.94); }
.login .pin-pad button[data-k="⌫"] { border: 0; background: none; font-size: 26px; color: var(--muted); }

/* ---------- impostazioni ---------- */
.row.set { cursor: pointer; }
.wrap-t { white-space: normal !important; }
.row input[type=time] { border: 1px solid var(--line); background: var(--panel-2); border-radius: 9px; padding: 5px 8px; flex: none; }
.row input[type=time]:disabled { opacity: .4; }
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
a.row { color: inherit; text-decoration: none; }

/* ---------- blocco impronta (app Android) ---------- */
#bio-lock { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
#bio-lock .brand-logo { width: 64px; height: 64px; border-radius: 18px; font-size: 32px; }
#bio-lock .bio-t { font-size: 19px; font-weight: 650; }
#bio-lock .bio-b { background: var(--accent); color: #fff; border-radius: 14px; padding: 14px 26px; font-weight: 600; font-size: 16px; }

/* ---------- conoscenza ---------- */
.ring-w { position: relative; width: 64px; height: 64px; flex: none; }
.ring { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--panel-2); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.ring-w b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; letter-spacing: -.02em; }
.know { margin-top: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.know.big { margin-top: 0; }
.know-top { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; }
.know-top .txt { display: flex; flex-direction: column; gap: 2px; }
.know-top b { font-size: 17px; }
.know-top span { color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.know-ask { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.know-ask > span { color: var(--muted); font-size: 13px; margin-right: 2px; }
.row.area .t1 { margin-bottom: 6px; }
.bar { height: 6px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; transition: width .6s ease; }
.hero {
  margin-top: 22px; width: 100%; display: flex; gap: 14px; align-items: center; text-align: left; padding: 18px;
  border-radius: 20px; color: #fff; background: linear-gradient(135deg, #7c6cff, #a855f7 60%, #ec4899);
  box-shadow: 0 10px 30px rgba(124, 108, 255, .35);
}
.hero-ic { width: 48px; height: 48px; flex: none; border-radius: 14px; background: rgba(255,255,255,.2); display: grid; place-items: center; font-size: 24px; }
.hero-t { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.hero-t b { font-size: 18px; }
.hero-t span { font-size: 13.5px; opacity: .92; line-height: 1.4; }
.hero-go { background: #fff; color: #6d28d9; font-weight: 650; padding: 8px 14px; border-radius: 99px; font-size: 14px; flex: none; }

/* ---------- domande iniziali ---------- */
body.onb-mode #sidebar, body.onb-mode #tabbar { display: none !important; }
.onb { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.onb-top { display: flex; align-items: center; gap: 12px; padding-top: calc(14px + var(--sat)); padding-bottom: 6px; max-width: 620px; }
.onb-bar { flex: 1; height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.onb-bar i { display: block; height: 100%; background: linear-gradient(90deg, #7c6cff, #ec4899); border-radius: 99px; transition: width .4s ease; }
.onb-skip { color: var(--muted); font-size: 14px; padding: 8px 4px; min-width: 38px; }
.onb-body { max-width: 620px; padding-top: 18px; padding-bottom: 24px; animation: onbIn .3s ease; }
@keyframes onbIn { from { opacity: 0; transform: translateX(18px); } }
.onb-t { font-size: 28px; letter-spacing: -.02em; margin: 8px 0 6px; line-height: 1.2; }
.onb-sub { color: var(--muted); margin: 0 0 22px; }
.onb-l { display: block; font-weight: 600; font-size: 14px; margin: 18px 0 8px; }
.onb-i { width: 100%; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--panel); outline: 0; font-size: 16px; resize: vertical; }
.onb-i:focus { border-color: var(--accent); }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick .chip { padding: 10px 15px; font-size: 15px; transition: all .12s; }
.pick .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.onb-foot { max-width: 620px; padding-top: 10px; padding-bottom: calc(16px + var(--sab)); }
.btn-primary { width: 100%; padding: 16px; border-radius: 16px; background: var(--accent); color: #fff; font-weight: 650; font-size: 16.5px; box-shadow: 0 8px 22px rgba(124, 108, 255, .35); }
.btn-primary:disabled { opacity: .6; }
.btn-primary:active { transform: scale(.98); }
.onb-hero { text-align: center; padding-top: 4vh; }
.onb-hero .brand-logo { width: 72px; height: 72px; border-radius: 22px; font-size: 36px; margin: 0 auto 18px; box-shadow: 0 12px 30px rgba(124, 108, 255, .4); }
.onb-hero h1 { font-size: 28px; letter-spacing: -.02em; margin: 0 0 10px; line-height: 1.2; }
.onb-hero p { color: var(--muted); margin: 0 auto 24px; max-width: 460px; }
.onb-feat { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.onb-feat div { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 3px; }
.onb-feat span { font-size: 22px; }
.onb-feat b { font-size: 14.5px; }
.onb-feat small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }

/* ---------- foto, vocali, risposte rapide ---------- */
.msg.user .u { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 85%; }
.msg.user .u .bubble { max-width: 100%; }
.media { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.att-img { max-width: 220px; max-height: 260px; border-radius: 14px; object-fit: cover; cursor: zoom-in; background: var(--panel-2); min-width: 80px; min-height: 80px; }
.att-img.broken { display: none; }
.voice { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 4px 6px 4px 12px; }
.voice audio { height: 36px; max-width: 240px; }
.transcript { font-size: 13.5px; color: var(--muted); font-style: italic; max-width: 100%; text-align: right; line-height: 1.45; }
.transcript.pending { animation: pulse 1.2s infinite; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick .chip { padding: 9px 15px; font-size: 14.5px; border-color: var(--accent); color: var(--accent); background: transparent; animation: up .25s ease both; }
.quick .chip:active { background: var(--accent); color: #fff; }
.thumb { position: relative; display: inline-block; }
.thumb img { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; display: block; }
.thumb button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); color: var(--bg); font-size: 13px; line-height: 20px; }
.mic-big { background: var(--accent); }
.mic-big svg { width: 20px; height: 20px; }
.rec-row { display: flex; align-items: center; gap: 10px; padding: 0 0 0 2px; min-height: 38px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; flex: none; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 38px; }
.rec-wave { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 2px; height: 32px; overflow: hidden; }
.rec-wave i { width: 3px; border-radius: 2px; background: var(--accent); flex: none; }
.att-ic { font-size: 22px; width: 32px; text-align: center; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; animation: up .15s ease; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.ask .icon-btn { align-self: flex-end; }
.send[hidden], .icon-btn[hidden] { display: none; }
.ask { padding-left: 6px; }
.chat-head .txt { min-width: 0; }
.chat-head .t1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.onb-i + .pick { margin-top: 14px; }

/* ---------- oggi: azioni, salute, sonno ---------- */
.row.az { align-items: flex-start; gap: 10px; }
.row.az.done .t1 { text-decoration: line-through; opacity: .55; }
.row.az.done .t2 { opacity: .5; }
.az-ora { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 42px; padding-top: 2px; }
.az-b { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 16px; flex: none; cursor: pointer; }
.az-b.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line, rgba(127,127,127,.3)); }
.az-ok { color: var(--accent); font-weight: 700; padding: 6px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.tile { background: var(--panel); box-shadow: var(--shadow); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; min-width: 0; }
.tile small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile b { font-size: 20px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile span { color: var(--muted); font-size: 11px; }
.sleep { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; border: 0; cursor: pointer; color: #eef; padding: 14px 16px; border-radius: 18px;
  background: linear-gradient(135deg, #1d2350, #3a2f6b); box-shadow: 0 6px 20px rgba(40, 30, 100, .25); }
.sleep > span { font-size: 28px; }
.sleep b { display: block; font-size: 16px; }
.sleep small { display: block; opacity: .8; font-size: 12.5px; margin-top: 2px; }
.sleep.on { background: linear-gradient(135deg, #0f1430, #24204a); animation: sleep-glow 3s ease-in-out infinite; }
@keyframes sleep-glow { 50% { box-shadow: 0 6px 26px rgba(120, 100, 255, .45); } }

.step.agent { flex-wrap: wrap; }
.step.agent .sub { flex-basis: 100%; font-size: 12px; color: var(--muted); padding-left: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.codice-acc { font-size: 44px; font-weight: 800; letter-spacing: 10px; margin: 18px 0 8px; font-variant-numeric: tabular-nums; color: var(--accent); }
.login .muted { color: var(--muted); font-size: 14px; }
.row.req { background: color-mix(in srgb, var(--accent) 10%, transparent); flex-wrap: wrap; gap: 8px; }

/* ---------- indicatore di lavoro e aggiunte ---------- */
.work { font-size: 13px; color: var(--muted); margin-top: 6px; }
.work-what { color: var(--text); font-weight: 600; animation: work-pulse 1.6s ease-in-out infinite; }
.work-hint { display: none; font-size: 12px; margin-top: 4px; }
.work.long .work-hint { display: block; }
@keyframes work-pulse { 50% { opacity: .55; } }
.msg.user.aggiunta .bubble { border: 1px dashed var(--accent); }
.agg-st { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: 3px; }
.agg-st.ok { color: var(--accent); }

/* ---------- cassaforte ---------- */
.vault-chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 999px; padding: 1px 10px; font: inherit; font-size: .95em; cursor: pointer; vertical-align: baseline; }
.vault-sheet h3 { margin: 0 0 10px; }
.vault-sheet input, .vault-sheet textarea, .vault-sheet select { width: 100%; box-sizing: border-box; margin: 6px 0; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.vs-l { display: block; font-size: 13px; font-weight: 600; margin-top: 6px; }
.vs-l small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.vs-p { color: var(--muted); font-size: 14px; line-height: 1.45; }
.vs-p.small { font-size: 12px; }
.vs-err { color: var(--danger); font-size: 13px; min-height: 18px; }
.vs-go { width: 100%; margin-top: 8px; padding: 13px; border-radius: 14px; border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.vs-go.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.vs-go.danger { background: var(--danger); }
.vs-val { font-family: ui-monospace, Consolas, monospace; font-size: 18px; padding: 14px; border-radius: 12px; background: var(--bg); word-break: break-all; user-select: all; }
.vs-intro { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 4px 0 14px; }
.vs-big { width: 100%; padding: 16px; border-radius: 16px; border: 0; font: inherit; font-weight: 650; font-size: 16px; color: #fff; cursor: pointer; background: linear-gradient(135deg, #2a2f55, #4b3f8f); }
.vs-row code { font-size: 11px; opacity: .7; }
.vault-link { margin: 4px 0 14px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; }

.upd { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; border: 0; cursor: pointer; padding: 13px 16px; border-radius: 16px; margin: 0 0 14px;
  background: color-mix(in srgb, var(--accent) 14%, var(--panel)); color: var(--text); box-shadow: var(--shadow); font: inherit; }
.upd > span { font-size: 24px; }
.upd b { display: block; }
.upd small { color: var(--muted); }

/* ---------- conversazione a voce ---------- */
.talk { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; border: 0; cursor: pointer; padding: 14px 16px; border-radius: 18px; margin: 0 0 16px;
  background: linear-gradient(135deg, #6c5cff, #a35cff); color: #fff; font: inherit; box-shadow: 0 6px 20px rgba(108, 92, 255, .3); }
.talk > span { font-size: 26px; }
.talk b { display: block; font-size: 16px; }
.talk small { opacity: .85; }
.voce { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 30px;
  background: radial-gradient(circle at 50% 40%, #2b2466, #0d0b1f 70%); color: #fff; --lv: 0; }
.voce-x { position: absolute; top: calc(18px + var(--sat)); right: 18px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 18px; cursor: pointer; }
.voce-orb { position: relative; width: 190px; height: 190px; cursor: pointer; }
.voce-orb i { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #b9a8ff, #6c5cff 55%, #3b2bb8); transition: transform .08s linear; }
.voce-orb i:nth-child(2) { inset: -14px; opacity: .25; transform: scale(calc(1 + var(--lv) * .35)); }
.voce-orb i:nth-child(3) { inset: -30px; opacity: .12; transform: scale(calc(1 + var(--lv) * .6)); }
.voce[data-st="ascolto"] .voce-orb i:first-child { transform: scale(calc(1 + var(--lv) * .15)); }
.voce[data-st="penso"] .voce-orb i { animation: voce-penso 1.4s ease-in-out infinite; }
.voce[data-st="parlo"] .voce-orb i:nth-child(2), .voce[data-st="parlo"] .voce-orb i:nth-child(3) { animation: voce-parlo 1.1s ease-in-out infinite; }
.voce[data-st="pausa"] .voce-orb { filter: grayscale(.7) brightness(.7); }
@keyframes voce-penso { 50% { transform: scale(.92); opacity: .7; } }
@keyframes voce-parlo { 50% { transform: scale(1.12); } }
.voce-st { font-size: 20px; font-weight: 650; }
.voce-cap { max-width: 560px; min-height: 3.2em; text-align: center; font-size: 17px; line-height: 1.45; opacity: .9; }
.voce-hint { position: absolute; bottom: calc(24px + var(--sab)); font-size: 13px; opacity: .6; text-align: center; padding: 0 24px; }

.upd-bar { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 12px 0 6px; }
.upd-bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }

.ha-how { margin: 8px 0 12px; font-size: 14px; color: var(--muted); }
.ha-how summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.ha-how ol { padding-left: 20px; line-height: 1.5; }
.ha-r { font-size: 12.5px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.ha-r.no { color: var(--danger); }
.vault-sheet input.switch { width: auto; margin: 0; padding: 0; }

/* ---------- domotica ---------- */
.ha-sec { margin-top: 22px; }
.ha-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; align-items: start; }
.ha-c { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 12px 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ha-c.off { opacity: .55; }
.ha-top { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.ha-top .txt { flex: 1; min-width: 0; }
.ha-top .t1 { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ha-top .t2 { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ha-ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--panel-2); font-size: 20px; flex: none; transition: background .15s; }
.ha-c.on .ha-ic { background: color-mix(in srgb, #f5b83d 30%, var(--panel)); }
.ha-c.lock .ha-ic { background: color-mix(in srgb, var(--danger) 14%, var(--panel)); }
.ha-star { width: 36px; height: 36px; border-radius: 10px; color: var(--muted); font-size: 18px; flex: none; line-height: 1; }
.ha-star.on { color: #f5b83d; }
.ha-star:hover { background: var(--panel-2); }
.ha-sl { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.ha-sl > span { width: 20px; text-align: center; flex: none; }
.ha-sl input[type=range] { flex: 1; min-width: 0; height: 32px; accent-color: var(--accent); cursor: pointer; }
.ha-sl output { min-width: 50px; text-align: right; font-variant-numeric: tabular-nums; }
.ha-btns { display: flex; gap: 8px; }
.ha-btns button { flex: 1; min-height: 46px; border-radius: 12px; background: var(--panel-2); font-weight: 600; font-size: 15px; }
.ha-btns button:hover { background: color-mix(in srgb, var(--accent) 12%, var(--panel-2)); }
.ha-btns button:active, .ha-set button:active, .ha-scene:active { background: color-mix(in srgb, var(--accent) 28%, var(--panel-2)); }
.ha-clima { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ha-temp small { display: block; color: var(--muted); font-size: 12px; }
.ha-temp b { font-size: 26px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ha-set { display: flex; align-items: center; gap: 6px; }
.ha-set button { width: 50px; height: 50px; border-radius: 50%; background: var(--panel-2); font-size: 24px; font-weight: 600; line-height: 1; }
.ha-set b { min-width: 64px; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; color: var(--accent); }
.ha-modi { display: flex; gap: 6px; flex-wrap: wrap; }
.ha-modi .chip { padding: 8px 13px; }
.ha-modi .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ha-c select { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.ha-blocco { font-size: 13px; line-height: 1.45; color: var(--muted); background: color-mix(in srgb, var(--danger) 8%, transparent); border-radius: 12px; padding: 9px 11px; }
.ha-blocco button { color: var(--accent); font-size: 13px; font-weight: 600; text-decoration: underline; }
.ha-scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.ha-scn { position: relative; }
.ha-scene { width: 100%; min-height: 54px; padding: 8px 38px 8px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); text-align: left; font-weight: 550; font-size: 14px; line-height: 1.3; display: flex; align-items: center; gap: 8px; }
.ha-scene span { font-size: 18px; flex: none; }
.ha-scn .ha-star { position: absolute; top: 50%; right: 2px; transform: translateY(-50%); }
.ha-tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.ha-tile { position: relative; }
.ha-tile small { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; padding-right: 26px; line-height: 1.35; }
.ha-tile.on b { color: var(--accent); }
.ha-tile b { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ha-tile .ha-star { position: absolute; top: 4px; right: 2px; width: 30px; height: 30px; font-size: 15px; }
.ha-vuoto { text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 20px 20px; margin-top: 6px; }
.ha-vuoto-ic { font-size: 40px; }
.ha-vuoto p { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 6px auto 16px; max-width: 420px; }
.ha-avviso { font-size: 13px; color: var(--danger); margin-bottom: 10px; }
.ha-nota { color: var(--muted); font-size: 12.5px; text-align: center; margin: 18px 0 0; }

/* ---------- app Android: comportamento da app nativa ---------- */
html.native, html.native body { overscroll-behavior: none; }
html.native body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
html.native .md, html.native .bubble, html.native .transcript, html.native .mem-doc, html.native .vs-val,
html.native input, html.native textarea, html.native select { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
html.native img { -webkit-user-drag: none; }
html.native .scroll { overscroll-behavior: contain; }
@keyframes v-avanti { from { transform: translateX(32px); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes v-indietro { from { transform: translateX(-32px); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes v-cambio { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.view.v-avanti { animation: v-avanti .24s cubic-bezier(.2, .8, .2, 1); }
.view.v-indietro { animation: v-indietro .24s cubic-bezier(.2, .8, .2, 1); }
.view.v-cambio { animation: v-cambio .18s ease-out; }
@media (prefers-reduced-motion: reduce) { .view.v-avanti, .view.v-indietro, .view.v-cambio { animation: none; } }

/* collegamento al PC assente: striscia in alto, il resto della pagina scende */
body.offline { --sat: calc(env(safe-area-inset-top, 0px) + 36px); }
#rete-bar { position: fixed; z-index: 95; left: 0; right: 0; top: env(safe-area-inset-top, 0px); height: 36px;
  display: flex; align-items: center; justify-content: center; gap: 9px; padding: 0 12px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--text); }
#rete-bar i { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; flex: none; animation: rete-p 1.6s ease-in-out infinite; }
#rete-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rete-bar button { flex: none; padding: 4px 11px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 600; }
@keyframes rete-p { 50% { opacity: .35; } }
.agg-st.coda { color: #d97706; }
.pc-addr, .login .pc-addr { width: auto; background: none; padding: 6px; font-weight: 500; border-radius: 0; margin-top: 18px; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.upd.coda-b { background: var(--panel); color: var(--text); border: 1px solid var(--line); cursor: default; }
.upd.coda-b small { color: var(--muted); }
.via-b { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; vertical-align: 1px; }
.via-b.casa { background: color-mix(in srgb, #10b981 18%, transparent); color: #10b981; }
.via-b.remoto { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
