/* Semaia Voice: stesso stile Moleskine di Semaia Write (carta avorio, copertina nera, velluti),
   con in fondo le parti proprie di Voice. */
@font-face { font-family: 'Playfair'; src: url('../app/fonts/playfair_display.ttf') format('truetype'); font-weight: 400 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Playfair'; src: url('../app/fonts/playfair_display_italic.ttf') format('truetype'); font-weight: 400 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'Garamond'; src: url('../app/fonts/eb_garamond.ttf') format('truetype'); font-weight: 400 800; font-display: swap; }

:root {
  --bg: #F3EDE0; --sheet: #FAF6EC; --ink: #23201C; --muted: #6F675B; --hair: #E2D8C6;
  --cover: #1B1A18; --gold: #9E7330; --gold-light: #E2B866; --porpora: #6E1A3B; --verde: #0F3D27;
  --error: #9B2C2C; --radius: 14px;
  --ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 16px; line-height: 1.45; }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: 'Playfair', Georgia, serif; font-weight: 700; margin: .2em 0 .4em; line-height: 1.2; }
h1 { font-size: 1.75rem; }
h3 { font-size: 1.2rem; }
input, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=url], input[type=search], textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--hair); border-radius: 10px; background: var(--sheet); outline: none;
}
input:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(158, 115, 48, .15); }

/* ---------- impaginazione: barra in basso sul telefono, colonna a sinistra sugli schermi larghi */
#app { min-height: 100vh; }
.main { padding: calc(env(safe-area-inset-top) + 8px) 12px calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); max-width: 860px; margin: 0 auto; }
main:focus { outline: none; }
.nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: center;
  background: var(--cover); color: #E9E2D2; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 12px rgba(0,0,0,.25); }
.nav-logo, .nav-sign { display: none; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; font-size: .72rem; letter-spacing: .02em; color: #CFC6B4; min-width: 64px; }
.nav-item .velvet { display: grid; place-items: center; width: 40px; height: 32px; border-radius: 10px; color: var(--gold-light);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), inset 0 -2px 6px rgba(0,0,0,.35); background-image: radial-gradient(circle at 30% 20%, rgba(255,255,255,.12), transparent 60%); }
.nav-item.active { color: var(--gold-light); font-weight: 600; }
.nav-item.active .velvet { outline: 2px solid var(--gold-light); outline-offset: 1px; }
@media (min-width: 900px) {
  #app { display: flex; }
  #navwrap { width: 108px; flex: none; }
  .nav { position: fixed; top: 0; bottom: 0; left: 0; right: auto; width: 108px; flex-direction: column; justify-content: flex-start; gap: 22px; padding: 28px 0; }
  .nav-logo { display: block; margin-bottom: 12px; }
  .nav-sign { display: block; margin-top: auto; text-align: center; font-size: .75rem; color: var(--gold-light); opacity: .7; text-decoration: none; }
  .nav-item { font-size: .78rem; }
  .nav-item .velvet { width: 52px; height: 52px; border-radius: 14px; }
  .main { flex: 1; padding: 24px 32px; }
}

/* ---------- carta e copertina */
.card { background: var(--sheet); border: 1px solid var(--hair); border-radius: var(--radius); padding: 16px; margin: 0 0 12px; box-shadow: 0 1px 2px rgba(60, 40, 10, .05); }
.subcard { border-top: 1px solid var(--hair); margin-top: 12px; padding-top: 12px; }
.label { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.italic { font-style: italic; }
.center { text-align: center; }
.error { color: var(--error) !important; }
.link { color: var(--gold); text-decoration: none; font-weight: 600; background: none; border: 0; padding: 0; cursor: pointer; }
.back { display: inline-block; margin-bottom: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.wrap { flex-wrap: wrap; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

.brand { position: relative; background: var(--cover); color: #F1E9D8; border-radius: 18px; padding: 26px 16px 18px; text-align: center; margin-bottom: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); overflow: hidden; }
.brand-s { display: block; margin: 0 auto 2px; width: 56px; height: auto; }
.brand-write { font-family: 'Playfair', serif; font-style: italic; font-weight: 700; font-size: 2.6rem; line-height: 1; }
.brand-rule { width: 44px; height: 3px; background: var(--gold-light); margin: 10px auto; border-radius: 2px; }
.brand-sign { font-size: .72rem; letter-spacing: .3em; color: #BDB3A0; text-decoration: none; }
.band { position: absolute; top: 0; bottom: 0; right: 22px; width: 7px; background: linear-gradient(90deg, #0d0d0c, #2c2a27 50%, #0d0d0c); }
.date-line { font-family: 'Garamond', serif; font-style: italic; color: var(--muted); font-size: 1.05rem; margin: -2px 0 10px; }

/* ---------- bottoni */
.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 10px 18px; border: 1px solid var(--hair); background: var(--sheet);
  cursor: pointer; font-weight: 600; white-space: nowrap; min-height: 44px; transition: transform .05s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--cover); color: #F6EFE0; border-color: var(--cover); }
.btn.velvet { background: var(--porpora); color: #fff; border-color: var(--porpora); }
.btn.velvet.listening { background: var(--cover); border-color: var(--cover); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn.danger-outline { color: var(--error); border-color: #e2b9b9; background: transparent; }
.icon { flex: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.scan-btns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { border: 1px solid var(--hair); background: var(--sheet); border-radius: 10px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.chip.on { background: #EADFC8; border-color: var(--gold); font-weight: 600; }

/* ---------- elenchi */
.list { display: flex; flex-direction: column; }
.row-page { display: block; text-decoration: none; padding: 12px 6px; border-bottom: 1px solid var(--hair); border-left: 3px solid transparent; }
.row-page:hover, .row-page:focus { background: #F1EADB; border-left-color: var(--gold); outline: none; }
.row-page .title { font-family: 'Playfair', serif; font-weight: 700; font-size: 1.05rem; }
.row-page .meta { font-size: .82rem; color: var(--muted); }
.row-page .nb { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin-top: 2px; }
.status.gold { color: var(--gold); }
.status.error { color: var(--error); }
.search { margin-top: 8px; border-radius: 24px !important; }

/* ---------- pagina */
.md { font-family: 'Garamond', Georgia, serif; font-size: 1.15rem; line-height: 1.55; overflow-wrap: anywhere; }
.md h2, .md h3, .md h4 { font-family: 'Playfair', serif; }
.md h2 { font-size: 1.4rem; }
.md h3 { font-size: 1.2rem; }
.md blockquote { margin: .6em 0; padding: .2em .9em; border-left: 3px solid var(--gold); color: #4b443b; font-style: italic; }
.md ul.tasks { list-style: none; padding-left: .2em; }
.md li.task { display: flex; gap: 8px; align-items: baseline; }
.md .box { display: inline-grid; place-items: center; width: 1em; height: 1em; border: 1.5px solid var(--ink); border-radius: 3px; font-size: .8em; flex: none; transform: translateY(.1em); }
.md li.task.done { color: var(--muted); }
.md code { font-family: ui-monospace, Menlo, monospace; font-size: .85em; background: #EFE7D6; padding: 0 4px; border-radius: 4px; }
.md .unreadable { color: var(--gold); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--hair); margin: 1em 0; }
.table-wrap { overflow-x: auto; }
.md table { border-collapse: collapse; font-family: var(--ui); font-size: .85rem; margin: .5em 0; min-width: 100%; }
.md th, .md td { border-bottom: 1px solid var(--hair); padding: 6px 8px; text-align: left; white-space: nowrap; }
.md th { font-weight: 700; color: var(--muted); }
.sheet-date { text-align: right; font-family: 'Garamond', serif; font-style: italic; color: var(--muted); border-bottom: 1px solid var(--hair); padding-bottom: 4px; margin-bottom: 8px; }
.scan { width: 100%; border-radius: 8px; display: block; }
.audio audio { width: 100%; margin: 6px 0; }
details.ai summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.ai summary::-webkit-details-marker { display: none; }
details.ai summary::after { content: '▾'; color: var(--gold); font-size: 1.2rem; }
details.ai[open] summary::after { content: '▴'; }
.ai-title { font-family: 'Playfair', serif; font-weight: 700; font-size: 1.15rem; }
.status-line { min-height: 1.2em; margin-top: 4px; }
.event { padding: 10px 0; border-bottom: 1px solid var(--hair); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.event .title { font-weight: 700; }

/* ---------- editor */
.title-input { font-family: 'Playfair', serif; font-size: 1.2rem; margin: 6px 0; }
.note-body { min-height: 45vh; font-family: 'Garamond', serif; font-size: 1.2rem; line-height: 1.6; resize: vertical; }
.partial { font-family: 'Garamond', serif; font-style: italic; color: var(--porpora); font-size: 1.05rem; margin: 4px 0 8px; }
.result { max-height: 55vh; overflow: auto; border: 1px solid var(--hair); border-radius: 10px; padding: 10px; background: #fff; margin-bottom: 10px; }

/* ---------- registratore */
.rec-center { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 0 8px; }
.rec-buttons { justify-content: center; }
.rec-big { width: 120px; height: 120px; border-radius: 50%; border: 0; background: var(--porpora); color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 8px 22px rgba(110, 26, 59, .35); }
.rec-big.recording { background: var(--cover); box-shadow: 0 8px 22px rgba(0,0,0,.3); }
.stop-square { width: 38px; height: 38px; border-radius: 6px; background: var(--gold-light); }
.rec-time { font-family: 'Playfair', serif; font-size: 2rem; }
.meter { width: 220px; height: 6px; border-radius: 3px; background: var(--hair); overflow: hidden; }
.meter-fill { height: 100%; width: 2%; background: var(--porpora); transition: width .15s; }

/* ---------- taccuini */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; margin-bottom: 16px; }
.cover-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cover { position: relative; width: 100%; aspect-ratio: 3 / 4; border-radius: 6px 14px 14px 6px; border: 0; color: #F3EAD7; cursor: pointer; text-align: left;
  padding: 16px 14px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
  background-image: radial-gradient(circle at 30% 20%, rgba(255,255,255,.18), transparent 55%), radial-gradient(circle at 80% 90%, rgba(0,0,0,.3), transparent 60%);
  box-shadow: inset 6px 0 10px rgba(0,0,0,.35), 0 6px 14px rgba(0,0,0,.2); }
.cover.active { outline: 3px solid var(--gold-light); outline-offset: 3px; }
.cover-band { position: absolute; top: 0; bottom: 0; right: 16px; width: 6px; background: rgba(0,0,0,.45); }
.cover-name { font-family: 'Playfair', serif; font-weight: 700; font-size: 1.1rem; }
.cover-count { font-size: .8rem; opacity: .8; }
.cover-active { position: absolute; top: 10px; left: 12px; font-size: .65rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-light); }
.cover.new { background: transparent; border: 2px dashed var(--hair); color: var(--muted); box-shadow: none; align-items: center; justify-content: center; }
.plus { font-size: 2.4rem; line-height: 1; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--hair); cursor: pointer; }
.swatch.on { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- impostazioni */
.radios { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.radio { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.radio input { width: 20px; height: 20px; accent-color: var(--cover); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field > span:first-child { font-weight: 600; font-size: .9rem; }

/* ---------- finestre, avvisi, lavori */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(27, 26, 24, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--sheet); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
@media (min-width: 640px) { .modal-back { align-items: center; } .modal { border-radius: 18px; } }
.modal textarea, .modal input { margin: 8px 0; }
#toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); transform: translate(-50%, 20px);
  background: var(--cover); color: #F6EFE0; padding: 12px 18px; border-radius: 12px; max-width: min(92vw, 560px); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--error); }
#jobs { position: sticky; top: env(safe-area-inset-top); z-index: 15; background: #FFF8E8; border: 1px solid var(--gold-light); border-radius: 12px;
  padding: 8px 12px; margin-bottom: 10px; font-size: .9rem; }
.job { display: flex; align-items: center; gap: 10px; padding: 2px 0; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--gold-light); border-top-color: var(--porpora); animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .btn, #toast { transition: none; } }

/* ================================================================ Semaia Voice */
.lab-badge { display: block; width: fit-content; margin: 10px auto 0; padding: 3px 10px; border: 1px solid var(--gold-light); color: var(--gold-light);
  border-radius: 999px; font-size: .68rem; letter-spacing: .18em; }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 6px; }
.app-tile { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--hair); border-radius: var(--radius);
  background: var(--sheet); text-decoration: none; min-height: 150px; }
.app-tile:hover, .app-tile:focus { border-color: var(--gold); outline: none; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.app-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--gold-light);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), inset 0 -2px 6px rgba(0,0,0,.35); background-image: radial-gradient(circle at 30% 20%, rgba(255,255,255,.12), transparent 60%); }
.app-icon.small { width: 32px; height: 32px; border-radius: 9px; }
.app-name { font-family: 'Playfair', Georgia, serif; font-weight: 700; font-size: 1.05rem; }
.app-desc { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.setup .title-input { margin-top: 8px; }
.people { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.person input { margin-top: 6px; }
.consent { margin-top: 10px; }
.consent-person { margin-top: 8px; }
.sig-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.sig { width: 100%; max-width: 420px; aspect-ratio: 600 / 220; background: #fff; border: 1px dashed var(--muted); border-radius: 10px; touch-action: none; }
.rec-tools { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.note-row input { flex: 1; }
.marks { list-style: none; padding: 0; margin: 6px 0 0; font-size: .92rem; }
.marks li { padding: 4px 0; border-bottom: 1px solid var(--hair); }
.gold { color: var(--gold); font-weight: 600; }
.time { display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--hair); background: var(--sheet); border-radius: 999px;
  padding: 1px 8px; font-size: .78rem; color: var(--gold); cursor: pointer; }
.turns { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.turn-head { display: flex; align-items: center; gap: 8px; }
.turn-text { margin-top: 2px; }
.voice-note { display: inline-flex; align-items: center; margin-top: 4px; font-size: .78rem; color: var(--porpora); background: #F4E6EA; border-radius: 8px; padding: 2px 8px; }
.analysis h2 { font-size: 1.25rem; margin: 0; }
.session audio { width: 100%; margin: 6px 0; }
.card-actions { margin: 4px 0 10px; }
select { width: 100%; padding: 12px 14px; border: 1px solid var(--hair); border-radius: 10px; background: var(--sheet); font: inherit; }
.quick { align-items: center; }

/* correzioni dell'utente sotto un'analisi (profili che si affinano) */
.feedback { margin-top: 14px; padding: 10px 12px; border-left: 3px solid var(--gold, #B08D57); background: rgba(176, 141, 87, .08); border-radius: 6px; }
.feedback ul { margin: 6px 0 0; padding-left: 18px; }
.person .chips a.chip, .card .chips a.chip { text-decoration: none; }
.recovery-code { font-family: ui-monospace, Menlo, monospace; font-size: 1.15rem; letter-spacing: .06em; text-align: center; background: var(--sheet, #fff); border: 1px dashed var(--gold); border-radius: 10px; padding: 12px; user-select: all; word-break: break-all; }
a.btn { text-decoration: none; }
