/* Lumia – aspetto del sito: toni del blu notte con la lanterna ambrata. Tutti i colori sono variabili qui sotto. */
:root {
  --bg: #0a1428;
  --card: #11203d;
  --ink: #e9f0ff;
  --muted: #9db0d0;
  --line: #25396a;
  --brand: #5aa9ff;
  --brand-ink: #04122b;
  --brand-soft: #16305a;
  --lantern: #ffc15a;
  --lantern-soft: #33381f;
  --ok: #5cd19a;
  --bad: #ff8f86;
  --bubble-me: #1a3d7a;
  --bubble-igy: #1b2c52;
  --sky1: #16306b; --sky2: #0a1428;
  --far: #15264a; --near: #1d3866; --tower: #3b82c6; --roof: #2a4f8f; --win: #ffc15a; --lamp: #ffc15a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(2, 8, 24, .45);
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .4em; letter-spacing: .005em; }
a { color: var(--brand); }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--lantern); outline-offset: 2px; border-radius: 6px; }

.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px 48px; }

/* barra in alto */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand b { font: 700 1.45rem var(--serif); letter-spacing: .02em; }
.brand small { display: block; color: var(--muted); font-size: .72rem; margin-top: -3px; }
.who { display: flex; align-items: center; gap: 8px; font-size: .9rem; min-width: 0; }
.who .nick { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28vw; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; background: var(--line); color: var(--muted); }
.badge.citizen { background: var(--brand-soft); color: var(--brand); }
.badge.founder { background: var(--lantern-soft); color: var(--lantern); }
.badge.adottata { background: var(--lantern-soft); color: var(--lantern); }

/* piazza illustrata */
.hero { position: relative; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); background: var(--sky2); min-height: 190px; border: 1px solid var(--line); }
.hero .art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero .txt { position: relative; padding: 22px 22px 70px; max-width: 42%; }
.hero h1 { font-size: 1.9rem; margin: 0; }
.hero p { margin: 4px 0 0; color: var(--ink); opacity: .85; font-size: .95rem; }
.chips { position: absolute; left: 16px; right: 16px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: color-mix(in srgb, var(--card) 88%, transparent); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font-size: .8rem; font-weight: 600; backdrop-filter: blur(4px); }
.chip b { color: var(--lantern); }
@media (max-width: 640px) {
  .hero { min-height: 290px; background: var(--sky1); }
  .hero .txt { max-width: 100%; padding: 20px 18px 0; }
  .hero .art { top: auto; bottom: 0; height: 66%; }
  .hero h1 { font-size: 1.6rem; }
  .brand small { display: none; }
  .who .nick { max-width: 38vw; }
}

/* schede */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 14px 2px 6px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 999px; font: 600 .9rem var(--sans); cursor: pointer; }
.tab:hover { border-color: var(--brand); }
.tab[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); margin-top: 12px; }
.card h2 { font-size: 1.25rem; }
.muted { color: var(--muted); font-size: .9rem; }

.callout { border-radius: 12px; padding: 10px 14px; font-size: .9rem; line-height: 1.45; background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent); }
.callout.warm { background: var(--lantern-soft); border-color: color-mix(in srgb, var(--lantern) 40%, transparent); white-space: pre-wrap; }

/* chat */
.chat { height: 380px; overflow-y: auto; padding: 6px 4px; display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.msg { display: flex; gap: 8px; max-width: 88%; align-items: flex-end; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .av { width: 30px; height: 30px; flex: none; }
.msg .bub { padding: 8px 12px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.msg.assistant .bub { background: var(--bubble-igy); border-bottom-left-radius: 4px; }
.msg.user .bub { background: var(--bubble-me); border-bottom-right-radius: 4px; }
.msg .who-line { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); margin-bottom: 1px; }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }

.composer { display: flex; gap: 8px; }
input[type=text], input[type=email], input[type=password], input[type=url], textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit;
}
textarea { resize: vertical; min-height: 84px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
.btn { border: 0; border-radius: 12px; padding: 11px 18px; background: var(--brand); color: var(--brand-ink); font: 700 .95rem var(--sans); cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.small { padding: 6px 12px; font-size: .85rem; border-radius: 999px; }

/* idee */
.idea { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.idea:first-child { border-top: 0; }
.vote { flex: none; width: 54px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; padding: 6px 0; text-align: center; font: 700 1rem var(--sans); cursor: pointer; line-height: 1.2; }
.vote small { display: block; font-size: .65rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.vote[aria-pressed="true"] { background: var(--lantern); border-color: var(--lantern); color: #2b1a00; }
.vote[aria-pressed="true"] small { color: #2b1a00; }
.vote:disabled { opacity: .6; cursor: not-allowed; }
.idea .body { min-width: 0; overflow-wrap: anywhere; }
.idea .meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }

/* diario */
.progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0 4px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--lantern), var(--brand)); border-radius: 999px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 12px; }
.tile { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.tile b { display: block; font: 700 1.6rem var(--serif); color: var(--brand); line-height: 1.1; }
.tile span { font-size: .8rem; color: var(--muted); }
.entry { position: relative; padding: 0 0 18px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.entry::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--lantern); border: 2px solid var(--card); }
.entry h3 { font-size: 1rem; margin-bottom: 2px; }
.entry p { margin: 0; white-space: pre-wrap; }
.ord { padding: 10px 14px; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 10px 10px 0; margin: 8px 0; }

/* biblioteca */
.corso { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-top: 10px; cursor: pointer; background: var(--bg); }
.corso:hover { border-color: var(--brand); }
.corso strong { font-family: var(--serif); font-size: 1.05rem; }
.testo { line-height: 1.7; }
.testo h2 { font-size: 1.2rem; margin-top: 1.3em; }
.testo h3 { font-size: 1.02rem; }
.fonti { font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); margin-top: 18px; padding-top: 10px; }

/* vetrine */
.shops { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 10px; }
.shop { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg); border-top: 5px solid var(--lantern); }
.shop strong { font-family: var(--serif); font-size: 1.05rem; display: block; }

/* accesso */
.auth { max-width: 420px; margin: 16px auto 0; }
.field { display: flex; flex-direction: column; gap: 10px; }
.err { color: var(--bad); font-weight: 600; font-size: .9rem; min-height: 1.2em; }
.okmsg { color: var(--ok); font-weight: 600; font-size: .9rem; }
.link { color: var(--brand); cursor: pointer; text-align: center; margin-top: 12px; background: none; border: 0; font: inherit; text-decoration: underline; width: 100%; }
label.chk { display: flex; gap: 8px; align-items: flex-start; font-size: .85rem; color: var(--muted); }
label.chk input { margin-top: 4px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 28px; }
@media (prefers-reduced-motion: no-preference) { .tab, .btn, .vote, .corso { transition: background .15s, border-color .15s, filter .15s; } }

/* notifiche sulle schede: puntino = novità, giallo con numero = qualcosa aspetta te */
.tab { position: relative; }
.tab.news { background: var(--lantern-soft); border-color: var(--lantern); }
.tab.news::after { content: ""; position: absolute; top: 5px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--lantern); }
.tab.todo { background: var(--lantern); border-color: var(--lantern); color: #2b1a00; }
.tab .pill, .cmdrow .pill { display: inline-block; margin-left: 7px; min-width: 1.5em; text-align: center; background: #2b1a00; color: #fff; border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 700; line-height: 1.55; }
.tab[aria-selected="true"].news, .tab[aria-selected="true"].todo { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.tab[aria-selected="true"] .pill { background: var(--lantern); color: #2b1a00; }
.tab[aria-selected="true"].news::after { background: var(--brand-ink); }
.cmdrow { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 8px; border-top: 1px solid var(--line); }
.cmdrow:first-of-type { border-top: 0; }
.cmdrow code { font: 700 .92rem ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--brand); }
.cmdrow .muted { font-size: .85rem; }
.cmdrow.hot { background: var(--lantern-soft); border-left: 4px solid var(--lantern); border-radius: 0 10px 10px 0; }
.cmdrow.hot .btn { background: var(--lantern); color: #2b1a00; }
.cmdrow .hotpill { background: var(--lantern); color: #2b1a00; }
@media (prefers-reduced-motion: no-preference) { .tab.news::after { animation: batti 2.4s ease-in-out 3; } }
@keyframes batti { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.5); } }
@media (min-width: 641px) { .tabs { flex-wrap: wrap; overflow: visible; } }

/* gestione a pulsanti */
.voce { display: grid; gap: 8px; padding: 12px 10px; border-top: 1px solid var(--line); }
.voce:first-of-type { border-top: 0; }
.voce p { margin: 2px 0; }
.voce.hot { background: var(--lantern-soft); border-left: 4px solid var(--lantern); border-radius: 0 10px 10px 0; margin: 6px 0; border-top: 0; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card h3 { font: 700 .95rem var(--sans); margin: 18px 0 4px; color: var(--muted); }
.card h2 .pill { display: inline-block; margin-left: 9px; min-width: 1.6em; text-align: center; border-radius: 999px; padding: 0 8px; font: 700 .78rem var(--sans); line-height: 1.7; vertical-align: middle; }
select { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: var(--card, transparent); color: var(--ink); font: inherit; }
.esito { margin-top: 10px; position: sticky; top: 8px; z-index: 5; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.hidden { display: none !important; }

/* il volto di IGY */
.igyvolto { display: block; width: 100%; height: auto; overflow: visible; }
.igyvolto .bocca > * { display: none; }
.igyvolto[data-bocca="neutro"] .m-neutro, .igyvolto[data-bocca="sorriso"] .m-sorriso, .igyvolto[data-bocca="aperta"] .m-aperta,
.igyvolto[data-bocca="media"] .m-media, .igyvolto[data-bocca="pensa"] .m-pensa, .igyvolto[data-bocca="o"] .m-o { display: inline; }
.igyvolto .occhi { transform-origin: 60px 53px; animation: igy-batti 5s infinite; }
.igyvolto .fiamma { transform-origin: 60px 18px; animation: igy-fiamma 2.4s ease-in-out infinite; }
.igyvolto .alone { animation: igy-alone 3.2s ease-in-out infinite; }
.igyvolto .sopracciglia path { transition: transform .25s; }
.igyvolto[data-stato="pensa"] .dx { transform: translateY(-4px) rotate(-6deg); transform-origin: 71px 43px; }
.igyvolto[data-stato="pensa"] .occhi { transform: translate(2px, -1.500px); animation: none; }
.igyvolto[data-stato="felice"] .guance circle, .igyvolto[data-umore="festoso"] .guance circle { opacity: .7; }
.igyvolto[data-umore="energico"] .sopracciglia { transform: translateY(-2px); }
.igyvolto[data-umore="riflessivo"] .sx { transform: rotate(5deg); transform-origin: 49px 43px; }
.igyvolto[data-umore="riflessivo"] .dx { transform: rotate(-5deg); transform-origin: 71px 43px; }
.igyvolto[data-umore="curioso"] .dx { transform: translateY(-3px); }
.igyvolto[data-umore="assonnato"] .occhi { transform: scaleY(.45); animation: none; }
.igyvolto[data-umore="assonnato"] .fiamma { transform: scale(.7); animation: none; }
.igyvolto[data-umore="festoso"] .fiamma { animation-duration: 1.2s; }
.igyvolto.piccolo .occhi, .igyvolto.piccolo .fiamma, .igyvolto.piccolo .alone { animation: none; }
@keyframes igy-batti { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.08); } }
@keyframes igy-fiamma { 0%, 100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.08, .94) rotate(2deg); } }
@keyframes igy-alone { 0%, 100% { opacity: .18; } 50% { opacity: .34; } }
@media (prefers-reduced-motion: reduce) { .igyvolto .occhi, .igyvolto .fiamma, .igyvolto .alone { animation: none; } }

/* scheda di IGY sopra la chat */
.igycard { display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: center; margin-bottom: 10px; }
.igycard .faccia { width: 92px; cursor: pointer; }
.igycard .parola { background: var(--bubble-igy); border-radius: 16px 16px 16px 4px; padding: 10px 14px; font-size: .95rem; position: relative; }
.igycard .parola b { font-family: var(--serif); }
.vocebox { margin-top: 8px; font-size: .88rem; }
.vocebox summary { cursor: pointer; color: var(--brand); font-weight: 700; }
.vocebox .riga { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
.vocebox label { display: flex; align-items: center; gap: 6px; }
.vocebox input[type=range] { width: 120px; accent-color: var(--brand); }
.vocebox select { max-width: 100%; }
.presenti { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.presenti b { color: var(--ink); }
.msg.altro .bub { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .az { display: inline-flex; gap: 10px; margin-left: 8px; font-size: .7rem; font-weight: 600; }
.msg .az button { all: unset; cursor: pointer; color: var(--muted); text-decoration: underline; }
.msg .az button:hover, .msg .az button:focus-visible { color: var(--brand); }
.msg.nascosto .bub { opacity: .5; text-decoration: line-through; }
.msg .ruolo { font-weight: 600; color: var(--brand); margin-left: 4px; }
.msg .ora { font-weight: 400; margin-left: 6px; opacity: .8; }
.msg .av .igyvolto { width: 30px; height: 30px; }
.btn.mic { padding: 11px 13px; }
.btn.mic.ascolta { background: var(--lantern); color: #2b1a00; }
@media (max-width: 520px) { .igycard { grid-template-columns: 70px 1fr; } .igycard .faccia { width: 70px; } }
.msg.user.altro { align-self: flex-start; flex-direction: row; }

/* crescita di IGY */
.crescita { grid-column: 1 / -1; font-size: .85rem; }
.crescita .titolo { font-weight: 700; }
.crescita .barra { height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 4px; }
.crescita .barra i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--lantern)); border-radius: 999px; }
