/* Chat sul telefono: aspetto del pannello Claude Code in VS Code (Light Modern / Dark Modern, segue il telefono). */
:root {
  --bg: #FFFFFF; --side: #F8F8F8; --line: #E5E5E5; --line-2: #D4D4D4;
  --text: #3B3B3B; --forte: #1F1F1F; --muted: #6E6E6E; --faint: #8B8B8B;
  --accent: #005FB8; --sel: #E8E8E8; --hover: #F0F0F0;
  --bolla: #F3F3F3; --codice: #F3F3F3; --mark: #FFE58F; --mark-t: #1F1F1F;
  --verde: #2EA043; --aranc: #E8833A; --rosso: #C93C37; --claude: #D97757;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1F1F1F; --side: #181818; --line: #2B2B2B; --line-2: #3C3C3C;
    --text: #CCCCCC; --forte: #E7E7E7; --muted: #9D9D9D; --faint: #7A7A7A;
    --accent: #4DAAFC; --sel: #37373D; --hover: #2A2D2E;
    --bolla: #2A2D2E; --codice: #181818; --mark: #6B5A12; --mark-t: #FFF4C2;
    --verde: #3FB950; --aranc: #F0883E; --rosso: #F85149;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1F1F1F; --side: #181818; --line: #2B2B2B; --line-2: #3C3C3C;
  --text: #CCCCCC; --forte: #E7E7E7; --muted: #9D9D9D; --faint: #7A7A7A;
  --accent: #4DAAFC; --sel: #37373D; --hover: #2A2D2E;
  --bolla: #2A2D2E; --codice: #181818; --mark: #6B5A12; --mark-t: #FFF4C2;
  --verde: #3FB950; --aranc: #F0883E; --rosso: #F85149;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; touch-action: manipulation; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; min-height: 100%; overflow-x: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; font-size: 16px; color: var(--forte); }
.nascosto { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- testata ---------- */
.testa { position: sticky; top: 0; z-index: 10; background: var(--side); border-bottom: 1px solid var(--line); padding: calc(var(--st) + 8px) 16px 10px; }
.riga1 { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.riga1 h1 { font-size: 20px; font-weight: 600; color: var(--forte); display: flex; align-items: center; gap: 8px; }
.riga1 h1 .ast { color: var(--claude); font-size: 22px; line-height: 1; }
.mac { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; min-height: 44px; padding: 0 2px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.riga1 h1 { flex: none; }
.mac i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.mac.on i { background: var(--verde); }
.cercabox { position: relative; margin-top: 4px; }
.cercabox svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); pointer-events: none; }
.cercabox input { width: 100%; height: 44px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); padding: 0 44px 0 36px; outline: none; -webkit-appearance: none; appearance: none; }
.cercabox input:focus { border-color: var(--accent); }
.cercabox input::placeholder { color: var(--faint); }
.cercabox input::-webkit-search-cancel-button { display: none; }
.cercabox .x { position: absolute; right: 0; top: 0; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 20px; }

/* ---------- elenco (barra di VS Code) ---------- */
.lista { padding-bottom: calc(var(--sb) + 24px); }
.gruppo-t { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 44px; padding: 8px 16px 6px 10px; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.gruppo-t .chev { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; transition: transform .15s; }
.gruppo-t.chiuso .chev { transform: rotate(-90deg); }
.gruppo-t .nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gruppo-t .num { font-size: 11px; font-weight: 600; background: var(--sel); color: var(--muted); border-radius: 9px; padding: 1px 7px; letter-spacing: 0; }
.voce { display: grid; grid-template-columns: 16px 1fr auto; column-gap: 8px; align-items: center; width: 100%; min-height: 56px; padding: 8px 16px 8px 14px; text-align: left; border-radius: 0; }
.voce:active { background: var(--sel); }
.voce .pall { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); justify-self: center; }
.voce .pall.busy { background: var(--verde); animation: pulsa 1.4s infinite; }
.voce .pall.idle { background: var(--verde); opacity: .55; }
.voce .pall.attesa { background: var(--aranc); animation: pulsa 1.4s infinite; }
.voce .pall.nonletta { background: var(--aranc); }
.voce .tit { font-size: 16px; color: var(--forte); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voce .quando { font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }
.voce .ant { grid-column: 2 / 4; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.35; }
@keyframes pulsa { 50% { opacity: .35; } }
.vuoto { padding: 32px 20px; color: var(--muted); text-align: center; font-size: 15px; }
.avviso { margin: 12px 16px 0; padding: 10px 12px; border-radius: 8px; background: var(--bolla); border: 1px solid var(--line); font-size: 14px; color: var(--muted); }

/* ---------- risultati della ricerca ---------- */
.sez { padding: 14px 16px 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ris { display: block; width: 100%; text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 56px; }
.ris:active { background: var(--sel); }
.ris .su { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.ris .su b { font-weight: 600; color: var(--forte); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ris .pz { margin-top: 3px; font-size: 15px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.ris .chi { color: var(--faint); }
mark { background: var(--mark); color: var(--mark-t); border-radius: 3px; padding: 0 1px; }

/* ---------- una chat ---------- */
.testa.chat { padding: calc(var(--st) + 4px) 8px 6px 4px; }
.testa.chat .riga1 { justify-content: flex-start; gap: 4px; }
.indietro { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex: none; color: var(--accent); }
.indietro svg { width: 22px; height: 22px; }
.ctit { min-width: 0; flex: 1; }
.ctit b { display: block; font-size: 16px; font-weight: 600; color: var(--forte); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctit .mac { min-height: 0; font-size: 12px; display: block; max-width: 100%; }
.ctit .mac i { display: inline-block; margin-right: 6px; vertical-align: 1px; }
.flusso { padding: 8px 14px calc(var(--sb) + 28px); max-width: 860px; margin: 0 auto; }
.sentinella { text-align: center; font-size: 13px; color: var(--faint); padding: 12px 0; min-height: 44px; }
.giorno { text-align: center; font-size: 12px; color: var(--faint); margin: 18px 0 6px; }
.ora { text-align: right; font-size: 12px; color: var(--faint); margin: 12px 2px 2px; font-variant-numeric: tabular-nums; }
.m { margin: 6px 0; word-wrap: break-word; overflow-wrap: anywhere; }
.m.u { display: flex; justify-content: flex-end; }
.m.u .bolla { max-width: 86%; background: var(--bolla); border: 1px solid var(--line); border-radius: 12px 12px 4px 12px; padding: 8px 12px; white-space: pre-wrap; color: var(--forte); font-size: 16px; }
.m.a { position: relative; padding-left: 18px; color: var(--text); }
.m.a::before { content: ""; position: absolute; left: 3px; top: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.m.t { position: relative; padding-left: 18px; font-size: 14px; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.m.t::before { content: ""; position: absolute; left: 3px; top: 50%; margin-top: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--verde); }
.m.t button { text-align: left; min-height: 44px; width: 100%; color: inherit; font-size: 14px; }
.m.t .nomi { color: var(--faint); }
.m.s { text-align: center; font-size: 13px; color: var(--faint); margin: 12px 0; }
.m.s span { display: inline-block; padding: 2px 10px; border: 1px solid var(--line); border-radius: 10px; }
.m.lampo .bolla, .m.lampo.a { animation: lampo 2.4s; }
@keyframes lampo { 0%, 40% { background: var(--mark); } 100% { } }
/* markdown delle risposte */
.md > :first-child { margin-top: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote, .md table, .md h1, .md h2, .md h3, .md h4 { margin: 8px 0; }
.md h1, .md h2 { font-size: 18px; font-weight: 600; color: var(--forte); }
.md h3, .md h4 { font-size: 16px; font-weight: 600; color: var(--forte); }
.md strong { color: var(--forte); font-weight: 600; }
.md ul, .md ol { padding-left: 22px; }
.md li + li { margin-top: 2px; }
.md a { color: var(--accent); text-decoration: none; word-break: break-all; }
.md code { font-family: var(--mono); font-size: 14px; background: var(--codice); border-radius: 4px; padding: 1px 4px; }
.md pre { background: var(--codice); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md pre code { background: none; padding: 0; font-size: 13px; line-height: 1.45; white-space: pre; }
.md blockquote { border-left: 3px solid var(--line-2); padding-left: 10px; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.md .tab { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 8px 0; }
.md table { border-collapse: collapse; font-size: 14px; margin: 0; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--side); font-weight: 600; }
.md img { max-width: 100%; }
.giu { position: fixed; right: 16px; bottom: calc(var(--sb) + 16px); width: 44px; height: 44px; border-radius: 50%; background: var(--side); border: 1px solid var(--line-2); box-shadow: 0 2px 8px rgba(0,0,0,.15); display: flex; align-items: center; justify-content: center; color: var(--forte); z-index: 9; }
.giu svg { width: 20px; height: 20px; }

/* ---------- accesso ---------- */
.accesso { max-width: 420px; margin: 0 auto; padding: calc(var(--st) + 12vh) 20px 40px; }
.accesso .logo { width: 56px; height: 56px; border-radius: 14px; background: var(--side); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--claude); font-size: 34px; line-height: 1; }
.accesso h1 { font-size: 24px; font-weight: 600; color: var(--forte); margin-top: 20px; }
.accesso .sotto { color: var(--muted); font-size: 15px; margin-top: 8px; }
.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 500; margin-top: 24px; }
.btn:disabled { opacity: .45; }
.link { color: var(--accent); min-height: 44px; padding: 0 4px; }
.otp { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 24px; }
.otp input { width: 100%; height: 52px; text-align: center; font-size: 22px; font-weight: 500; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg); outline: none; font-variant-numeric: tabular-nums; padding: 0; }
.otp input:focus { border-color: var(--accent); }
.otp.err input { border-color: var(--rosso); animation: scuoti .3s; }
@keyframes scuoti { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.msg { margin-top: 14px; font-size: 15px; min-height: 22px; }
.msg.err { color: var(--rosso); } .msg.ok { color: var(--verde); } .msg.oro { color: var(--aranc); }
.rinvio { margin-top: 16px; font-size: 14px; color: var(--muted); text-align: center; }
.piede { margin-top: 32px; font-size: 13px; color: var(--faint); text-align: center; }
.esci { display: block; margin: 24px auto 0; color: var(--muted); font-size: 14px; min-height: 44px; }
