@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Lora:ital,wght@0,500;0,600;0,700;1,500;1,600&display=swap");

:root {
  --bg: #f8f4ee; --paper: #fffdfa; --ink: #1d1b19; --ink2: #4a4540; --muted: #7a726a; --line: #e7dfd3; --line2: #d8cebf;
  --accent: #8e2b1e; --accent2: #b4462f; --accent-soft: #f6e7e1; --ok: #2e7d4f; --warn: #b7791f; --err: #c0392b;
  --shadow: 0 1px 2px rgba(60,40,20,.06), 0 8px 24px rgba(60,40,20,.07);
  --r: 16px; --head: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
/* Il sito non deve mai scorrere di lato sul telefono */
html, body { max-width: 100%; overflow-x: clip; overscroll-behavior-x: none; }
body { font: 15.5px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
.hide { display: none !important; }
.serif { font-family: Lora, Georgia, serif; }

/* ---------- bottoni ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 600; font-size: 15px; background: var(--ink); color: #fff; text-decoration: none; transition: transform .08s, background .15s, opacity .15s; white-space: nowrap; }
.btn:hover { background: #000; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.accent { background: var(--accent); } .btn.accent:hover { background: #7a2418; }
.btn.ghost { background: transparent; color: var(--ink2); border: 1px solid var(--line2); }
.btn.ghost:hover { background: #fff; color: var(--ink); }
.btn.sm { padding: 7px 12px; font-size: 13.5px; border-radius: 10px; }
.btn.danger { background: transparent; color: var(--err); border: 1px solid #efc9c2; } .btn.danger:hover { background: #fdf0ed; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 20; height: var(--head); display: flex; align-items: center; gap: 18px; padding: 0 22px; background: rgba(248,244,238,.86); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 16.5px; letter-spacing: -.01em; }
.mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-family: Lora, serif; font-weight: 700; font-size: 19px; font-style: italic; }
.nav { display: flex; gap: 4px; margin-left: 10px; }
.nav a { text-decoration: none; padding: 8px 13px; border-radius: 10px; color: var(--ink2); font-weight: 500; font-size: 14.5px; }
.nav a:hover { background: rgba(0,0,0,.04); color: var(--ink); }
.nav a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13.5px; flex: none; }
.me button { background: none; border: 0; color: var(--muted); font-size: 13.5px; padding: 6px 8px; border-radius: 8px; }
.me button:hover { background: rgba(0,0,0,.05); color: var(--ink); }

main { max-width: 1160px; margin: 0 auto; padding: 0 22px 80px; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1fr 1.05fr; gap: 56px; align-items: center; padding: 64px 0 56px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 6px 12px; border-radius: 99px; }
.hero h1 { font-family: Lora, Georgia, serif; font-weight: 600; font-size: clamp(40px, 5.4vw, 66px); line-height: 1.02; letter-spacing: -.025em; margin: 20px 0 18px; }
.hero h1 em { color: var(--accent); font-style: italic; }
.hero p.lead { font-size: 18px; color: var(--ink2); max-width: 30em; margin: 0 0 26px; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; color: var(--ink2); font-size: 15px; }
.checks li { display: flex; gap: 10px; align-items: flex-start; }
.checks li::before { content: ""; flex: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%; background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3 3 7-7' fill='none' stroke='%238e2b1e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.composer { padding: 22px; }
.composer h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.01em; }
.composer .hint { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.uso { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 12.5px; color: var(--muted); margin: -6px 0 14px; }
.uso .bar { flex: 0 0 90px; height: 5px; border-radius: 9px; background: #efe7dc; overflow: hidden; }
.uso .bar i { display: block; height: 100%; background: var(--ok); }
.uso.full { color: var(--warn); background: #fdf6e7; padding: 8px 10px; border-radius: 10px; display: block; }
.drop { position: relative; border: 2px dashed var(--line2); border-radius: 16px; padding: 30px 18px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; background: #fffaf4; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .big { font-family: Lora, serif; font-size: 21px; font-weight: 600; margin: 8px 0 4px; color: var(--ink); }
.drop .small { font-size: 13.5px; color: var(--muted); }
.drop svg { width: 38px; height: 38px; color: var(--accent); }
.chosen { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; max-height: 190px; overflow: auto; }
.chosen li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #f6f1ea; font-size: 13.5px; }
.chosen li .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chosen li .s { color: var(--muted); font-size: 12.5px; }
.chosen li button { border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 4px; }
.ext { font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 3px 6px; border-radius: 6px; background: #fff; border: 1px solid var(--line2); color: var(--ink2); min-width: 38px; text-align: center; }
.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--ink2); margin: 16px 0 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { border: 1px solid var(--line2); background: #fff; color: var(--ink2); border-radius: 99px; padding: 6px 12px; font-size: 13.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; }
.chip:hover { border-color: var(--ink2); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip .c { opacity: .6; font-size: 12px; }
input.in, textarea.in { width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1px solid var(--line2); border-radius: 12px; padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s; }
input.in:focus, textarea.in:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(142,43,30,.1); }
textarea.in { resize: vertical; min-height: 84px; }
.row2 { display: grid; grid-template-columns: 1fr; gap: 0; }
.send { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.send .btn { flex: none; padding: 13px 22px; font-size: 15.5px; }
.prog { flex: 1; height: 6px; background: #efe7dc; border-radius: 9px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.err { color: var(--err); font-size: 14px; min-height: 1.2em; margin: 10px 0 0; }

.section { padding: 34px 0 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { font-family: Lora, serif; font-weight: 600; font-size: 28px; letter-spacing: -.015em; margin: 0; }
.section-head a { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 14.5px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.step { padding: 22px; }
.step .num { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; margin-bottom: 12px; }
.step h3 { margin: 0 0 6px; font-size: 16.5px; }
.step p { margin: 0; color: var(--ink2); font-size: 14.5px; }

/* ---------- griglia dispense ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 16px; }
.dcard { position: relative; display: flex; flex-direction: column; text-decoration: none; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; transition: transform .15s, box-shadow .15s, border-color .15s; min-height: 178px; }
.dcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line2); }
.dcard .band { height: 74px; padding: 14px 16px; color: #fff; display: flex; align-items: flex-start; justify-content: space-between; position: relative; overflow: hidden; }
.dcard .band::after { content: ""; position: absolute; right: -24px; bottom: -40px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.1); }
.dcard .mat { font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .92; }
.dcard .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.dcard h3 { font-family: Lora, serif; font-weight: 600; font-size: 17.5px; line-height: 1.25; margin: 0; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dcard .meta { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: rgba(255,255,255,.22); color: #fff; position: relative; z-index: 1; }
.badge.lt { background: #f1ebe2; color: var(--ink2); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .25; } }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line2); border-radius: 18px; }

.libhead { padding: 40px 0 20px; }
.libhead h1 { font-family: Lora, serif; font-weight: 600; font-size: 42px; letter-spacing: -.02em; margin: 0 0 6px; }
.libhead p { margin: 0 0 22px; color: var(--ink2); }
.search { position: relative; max-width: 440px; margin-bottom: 14px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search input { padding-left: 40px; }

/* ---------- pagina dispensa ---------- */
.dview { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: calc(100vh - var(--head)); height: calc(100dvh - var(--head)); }
.viewer { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); background: #efe9df; }
.vbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.vbar .ttl { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.vbar .ttl b { font-family: Lora, serif; font-size: 18px; font-weight: 600; line-height: 1.2; cursor: text; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbar .ttl small { color: var(--muted); font-size: 12.5px; }
select.in { font: inherit; font-size: 13.5px; padding: 7px 30px 7px 10px; border: 1px solid var(--line2); border-radius: 10px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 8l4 4 4-4' fill='none' stroke='%237a726a' stroke-width='2'/%3E%3C/svg%3E") right 8px center/16px no-repeat; appearance: none; max-width: 260px; color: var(--ink); }
.seg { display: inline-flex; background: #f1ebe2; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.frame { flex: 1; position: relative; }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #efe9df; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 30px; color: var(--ink2); }
.placeholder .big { font-family: Lora, serif; font-size: 24px; font-weight: 600; margin: 18px 0 8px; color: var(--ink); }
.book { width: 84px; height: 84px; }
.book .pg { animation: flip 1.6s infinite ease-in-out; transform-origin: 50% 50%; }
@keyframes flip { 0%,100% { transform: scaleX(1); } 50% { transform: scaleX(-1); } }

.chat { display: flex; flex-direction: column; min-height: 0; background: var(--paper); }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-head b { font-size: 15px; }
.chat-head small { color: var(--muted); font-size: 12.5px; display: block; }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; }
.msg .avatar { width: 28px; height: 28px; font-size: 12px; }
.bubble { padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 86%; }
.msg.me { flex-direction: row-reverse; }
.msg.me .bubble { background: var(--ink); color: #fff; border-bottom-right-radius: 5px; }
.msg.other .bubble { background: #f1ebe2; border-bottom-left-radius: 5px; }
.msg.ai .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.sys { justify-content: center; } .msg.sys .bubble { background: #fdf0ed; color: var(--err); font-size: 13px; max-width: 100%; }
.who { font-size: 11.5px; color: var(--muted); margin: 0 0 3px 2px; }
.msg.me .who { text-align: right; margin-right: 2px; }
.att { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.att a { font-size: 12px; text-decoration: none; padding: 3px 8px; border-radius: 7px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); }
.msg.other .att a { background: #fff; border-color: var(--line2); }
.vlink { display: inline-flex; align-items: center; gap: 6px; margin-top: 9px; font-size: 12.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 8px; padding: 5px 10px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 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% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
.sugg { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 10px; scrollbar-width: none; }
.sugg button { flex: none; border: 1px solid var(--line2); background: #fff; border-radius: 99px; padding: 6px 11px; font-size: 12.5px; color: var(--ink2); }
.sugg button:hover { border-color: var(--accent); color: var(--accent); }
.compose { border-top: 1px solid var(--line); padding: 12px 14px 14px; }
.compose .box { display: flex; align-items: flex-end; gap: 8px; background: #fff; border: 1px solid var(--line2); border-radius: 16px; padding: 6px 6px 6px 8px; transition: border-color .15s, box-shadow .15s; }
.compose .box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(142,43,30,.08); }
.compose textarea { flex: 1; border: 0; outline: none; resize: none; font: inherit; font-size: 14.5px; padding: 7px 4px; max-height: 160px; background: transparent; }
.ib { width: 36px; height: 36px; border-radius: 11px; border: 0; display: grid; place-items: center; background: transparent; color: var(--muted); flex: none; }
.ib:hover { background: #f1ebe2; color: var(--ink); }
.ib.go { background: var(--accent); color: #fff; } .ib.go:hover { background: #7a2418; } .ib.go:disabled { opacity: .35; }
.pending { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pending span { font-size: 12px; background: #f1ebe2; border-radius: 7px; padding: 3px 8px; display: inline-flex; gap: 6px; }
.pending b { cursor: pointer; font-weight: 400; color: var(--muted); }
.note-lock { font-size: 12.5px; color: var(--muted); text-align: center; padding: 4px 0 0; }
.tabs { display: none; }

/* ---------- menu e finestre ---------- */
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; z-index: 30; }
.menu-pop a, .menu-pop button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 11px; border: 0; background: none; border-radius: 9px; text-decoration: none; color: var(--ink); font-size: 14px; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: #f6f1ea; }
.menu-pop .danger { color: var(--err); }
.modal-bg { position: fixed; inset: 0; background: rgba(29,27,25,.35); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: min(520px, 100%); max-height: 80vh; overflow: auto; padding: 22px; }
.modal h3 { margin: 0 0 12px; font-family: Lora, serif; font-size: 22px; }
.flist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.flist a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; background: #f8f4ee; text-decoration: none; font-size: 14px; }
.flist a:hover { background: #f1ebe2; }
.flist .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flist small { color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); animation: fade .2s; max-width: calc(100% - 32px); }

/* ---------- login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .side { background: var(--accent); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .side::before { content: ""; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px; border-radius: 50%; background: rgba(255,255,255,.07); }
.login .side::after { content: ""; position: absolute; left: -80px; bottom: -160px; width: 360px; height: 360px; border-radius: 50%; background: rgba(0,0,0,.08); }
.login .side h1 { font-family: Lora, serif; font-weight: 600; font-size: clamp(38px, 4.4vw, 58px); line-height: 1.04; letter-spacing: -.02em; margin: 0; position: relative; z-index: 1; }
.login .side h1 em { font-style: italic; opacity: .85; }
.login .side .brand { color: #fff; position: relative; z-index: 1; } .login .side .mark { background: #fff; color: var(--accent); }
.login .side p { opacity: .85; max-width: 26em; position: relative; z-index: 1; margin: 0; }
.login .form { display: grid; place-items: center; padding: 32px 20px; }
.login form { width: min(360px, 100%); }
.login form h2 { font-family: Lora, serif; font-size: 30px; margin: 0 0 6px; font-weight: 600; }
.login form .hint { color: var(--muted); margin: 0 0 22px; font-size: 14.5px; }
.login .show { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); margin: 10px 0 18px; cursor: pointer; }
.login .btn { width: 100%; padding: 13px; }

/* ---------- telefono e tablet ---------- */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding: 32px 0 30px; }
  .steps { grid-template-columns: 1fr; }
  .dview { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .chat, .viewer, .msgs, .sugg { min-width: 0; max-width: 100%; }
  .tabs { display: flex; gap: 4px; padding: 8px 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
  .tabs button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); }
  .tabs button.on { background: #f1ebe2; color: var(--ink); }
  .dview .viewer, .dview .chat { grid-row: 2; grid-column: 1; min-height: 0; }
  .dview[data-tab="chat"] .viewer, .dview[data-tab="doc"] .chat { display: none; }
  .viewer { border-right: 0; }
  .login { grid-template-columns: 1fr; }
  .login .side { padding: 28px 22px 34px; gap: 40px; }
}
@media (max-width: 640px) {
  .top { padding: 0 14px; gap: 10px; }
  .brand span.t { display: none; }
  .nav { margin-left: 0; } .nav a { padding: 8px 10px; }
  .me .nm { display: none; }
  main { padding: 0 16px 60px; }
  .composer { padding: 16px; }
  .send { flex-wrap: wrap; } .send .btn { width: 100%; }
  .libhead h1 { font-size: 34px; }
  .vbar { padding: 8px 10px; gap: 8px; }
  .vbar .ttl { min-width: 0; flex: 1 1 calc(100% - 60px); }
  select.in { max-width: 150px; }
}
