/* Block Notes — colori e caratteri dal design system "Man" */
@font-face { font-family: "Fontel"; src: url(fonts/Fontel.otf) format("opentype"); font-display: swap; }
@font-face { font-family: "Montserrat"; font-weight: 400; src: url(fonts/montserrat-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 500; src: url(fonts/montserrat-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 600; src: url(fonts/montserrat-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 700; src: url(fonts/montserrat-latin-700-normal.woff2) format("woff2"); }

:root {
  --antracite: #242424;
  --antracite-2: #2f2f2f;
  --antracite-3: #3a3a3a;
  --viola: #8a2cff;          /* Viola.Web */
  --viola-hover: #7a1ff0;
  --viola-soft: rgba(138,44,255,.16);
  --bianco: #ffffff;
  --bianco-70: rgba(255,255,255,.7);
  --bianco-50: rgba(255,255,255,.5);
  --bianco-30: rgba(255,255,255,.3);
  --verde: #90ff00;          /* solo piccoli accenti */
  --gap: 10px;               /* Spazio-fra-elementi */
  --r: 5px;                  /* Elementi-grafici */
  --r-card: 14px;
  --font-title: "Fontel", "Montserrat", sans-serif;
  --font-text: "Montserrat", system-ui, sans-serif;
  --pad: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--antracite);
  color: var(--bianco);
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; padding: 0; }
input, textarea { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
[hidden] { display: none !important; }

.view { min-height: 100%; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--bianco-50); }
.title { font-family: var(--font-title); font-weight: 400; font-size: 40px; line-height: 1.05; margin: 2px 0 0; letter-spacing: .01em; }

/* ---------- Elenco ---------- */
.list-head { padding: calc(20px + env(safe-area-inset-top)) var(--pad) 14px; display: flex; align-items: flex-end; justify-content: space-between; }

.search {
  margin: 0 var(--pad); display: flex; align-items: center; gap: var(--gap);
  background: var(--antracite-2); border-radius: var(--r); padding: 0 12px;
  border: 1px solid transparent; transition: border-color .15s;
}
.search:focus-within { border-color: var(--viola); }
.search svg { width: 20px; height: 20px; color: var(--bianco-50); }
.search input { flex: 1; min-width: 0; height: 44px; border: 0; outline: 0; background: none; font-size: 14px; }
.search input::placeholder { color: var(--bianco-50); }
.search input::-webkit-search-cancel-button { filter: invert(1); opacity: .5; }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 12px var(--pad) 4px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 14px; border-radius: 16px;
  border: 1px solid var(--antracite-3); font-size: 13px; font-weight: 500; color: var(--bianco-70);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip .n { font-size: 11px; opacity: .6; }
.chip.on { background: var(--viola); border-color: var(--viola); color: var(--bianco); }

.list { padding: 10px var(--pad) 110px; display: flex; flex-direction: column; gap: var(--gap); }

.card {
  background: var(--antracite-2); border-radius: var(--r-card); padding: 14px 16px 12px;
  border: 1px solid transparent; transition: transform .12s ease, border-color .15s;
  position: relative; overflow: hidden;
}
.card:active { transform: scale(.985); border-color: var(--antracite-3); }
.card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--stato, var(--bianco-30)); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--gap); }
.card-title { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 24px; line-height: 1.15; word-break: break-word; }
.card-title.untitled { color: var(--bianco-50); }
.card-base {
  margin-top: 10px; display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--bianco-70); min-height: 32px;
}
.card-base > svg { width: 17px; height: 17px; color: var(--viola); }
.card-base .bname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-base .bname.none { color: var(--bianco-30); font-style: italic; }
.card-meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--bianco-50); }
.card-meta span { display: inline-flex; align-items: center; gap: 4px; }
.card-meta svg { width: 14px; height: 14px; }

/* Stato */
.stato {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 12px; margin-top: 2px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
  background: var(--antracite-3); color: var(--bianco-70);
}
.stato::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--stato, var(--bianco-50)); }
[data-stato="idea"]       { --stato: rgba(255,255,255,.55); }
[data-stato="scrittura"]  { --stato: var(--viola); }
[data-stato="registrare"] { --stato: #c08bff; }
[data-stato="completa"]   { --stato: var(--verde); }
.stato[data-stato="scrittura"] { background: var(--viola-soft); color: var(--bianco); }

.mini-btn {
  flex: none; height: 32px; padding: 0 10px 0 12px; border-radius: 16px;
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--viola); color: var(--bianco); font-size: 12.5px; font-weight: 600;
  transition: background-color .15s, transform .12s;
}
.mini-btn svg { width: 14px; height: 14px; }
.mini-btn:active { background: var(--viola); transform: scale(.96); }

.empty { text-align: center; padding: 60px 40px; color: var(--bianco-70); }
.empty svg { width: 48px; height: 48px; color: var(--viola); }
.empty h2 { font-family: var(--font-title); font-weight: 400; font-size: 26px; margin: 10px 0 4px; color: var(--bianco); }
.empty p { margin: 0; font-size: 14px; }

.fab {
  position: fixed; right: 20px; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 20;
  width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
  background: var(--viola); box-shadow: 0 8px 24px rgba(138,44,255,.35), 0 2px 6px rgba(0,0,0,.4);
  transition: transform .12s ease, background-color .15s;
}
.fab svg { width: 30px; height: 30px; }
.fab:active { transform: scale(.94); background: var(--viola-hover); }

/* ---------- Nota ---------- */
#noteView { display: flex; flex-direction: column; height: 100%; }
.note-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 8px;
}
.note-head .saved { flex: 1; text-align: center; font-size: 12px; color: var(--bianco-50); opacity: 0; transition: opacity .3s; }
.note-head .saved.show { opacity: 1; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  transition: background-color .15s, transform .12s;
}
.icon-btn:active { background: var(--antracite-2); transform: scale(.94); }

.note-scroll { flex: 1; overflow-y: auto; padding: 4px var(--pad) calc(40px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }

.title-input {
  width: 100%; border: 0; outline: 0; background: none; padding: 4px 0 6px;
  font-family: var(--font-title); font-size: 34px; line-height: 1.15; border-bottom: 1.5px solid var(--antracite-3);
  transition: border-color .15s;
}
.title-input:focus { border-bottom-color: var(--viola); }
.title-input::placeholder { color: var(--bianco-30); }

.label { margin: 22px 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--bianco-50); display: flex; justify-content: space-between; }
.label-meta { letter-spacing: .02em; text-transform: none; font-weight: 500; }

.stati { display: flex; flex-wrap: wrap; gap: 8px; }
.stati .chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--stato); }
.stati .chip.on { background: var(--antracite-3); border-color: var(--stato); color: var(--bianco); }
.stati .chip[data-stato="scrittura"].on { background: var(--viola); border-color: var(--viola); }
.stati .chip[data-stato="scrittura"].on::before { background: var(--bianco); }

.box { background: var(--antracite-2); border-radius: var(--r-card); overflow: hidden; }
.field { display: flex; align-items: center; gap: var(--gap); padding: 0 8px 0 14px; min-height: 50px; border: 1px solid transparent; border-radius: var(--r-card); transition: border-color .15s; }
.field + .field { border-top-color: var(--antracite-3); border-radius: 0 0 var(--r-card) var(--r-card); }
.field:focus-within { border-color: var(--viola); }
.field > svg { width: 19px; height: 19px; color: var(--bianco-50); }
.field input { flex: 1; min-width: 0; height: 48px; border: 0; outline: 0; background: none; font-size: 14.5px; }
.field input::placeholder { color: var(--bianco-50); }
#fBaseUrl { color: #c9a6ff; font-size: 13.5px; }

.takes { display: flex; flex-direction: column; gap: 8px; }
.takes:not(:empty) { margin-bottom: 10px; }
.take {
  display: flex; align-items: center; gap: 12px;
  background: var(--antracite-2); border-radius: var(--r-card); padding: 10px 6px 10px 10px;
  border: 1px solid transparent;
}
.take.active { border-color: var(--viola); }
.play {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--viola); transition: transform .12s, background-color .15s;
}
.play:active { transform: scale(.93); }
.play svg { width: 22px; height: 22px; }
.take-body { flex: 1; min-width: 0; }
.take-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.take-sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.bar { flex: 1; height: 18px; position: relative; display: flex; align-items: center; }
.bar::before { content: ""; position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--antracite-3); }
.bar .fill { position: absolute; left: 0; height: 4px; border-radius: 2px; background: var(--viola); width: 0; }
.bar .knob { position: absolute; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--bianco); left: 0; opacity: 0; transition: opacity .15s; }
.take.active .bar .knob { opacity: 1; }
.take-time { font-size: 11.5px; color: var(--bianco-50); font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
.take-src { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--bianco-50); }
.more { width: 36px; height: 42px; display: grid; place-items: center; color: var(--bianco-50); flex: none; }
.more svg { width: 20px; height: 20px; }

.row { display: flex; gap: var(--gap); }
.btn {
  flex: 1; height: 50px; padding: 0 16px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 14.5px;
  transition: transform .12s ease, background-color .15s ease;
}
.btn svg { width: 20px; height: 20px; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--viola); }
.btn.primary:active { background: var(--viola-hover); }
.btn.ghost { border: 1.5px solid var(--antracite-3); color: var(--bianco); }
.btn.danger { background: #e5484d; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bianco); box-shadow: 0 0 0 3px rgba(255,255,255,.25); }

.lyrics {
  width: 100%; min-height: 50vh; resize: none; border: 0; outline: 0;
  background: transparent; padding: 4px 0 0; overflow: hidden;
  font-size: 16px; line-height: 1.75; color: var(--bianco);
}
.lyrics::placeholder { color: var(--bianco-30); }

/* ---------- Registrazione ---------- */
.rec {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end;
  background: rgba(10,10,10,.6); animation: fade .2s ease;
}
.rec-card {
  width: 100%; background: var(--antracite); border-radius: 22px 22px 0 0;
  padding: 26px var(--pad) calc(22px + env(safe-area-inset-bottom)); text-align: center;
  box-shadow: 0 -10px 30px rgba(0,0,0,.4); animation: up .25s cubic-bezier(.2,.8,.2,1);
}
.rec-card .eyebrow.live { color: var(--verde); }
.rec-time { font-family: var(--font-title); font-size: 64px; line-height: 1.1; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.meter { height: 56px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.meter i { width: 4px; border-radius: 2px; background: var(--viola); height: 4px; transition: height .09s linear; }
.rec-for { font-size: 13px; color: var(--bianco-50); margin: 12px 0 20px; min-height: 20px; }
.stop-sq { width: 12px; height: 12px; border-radius: 2px; background: var(--bianco); }

/* ---------- Finestra ---------- */
.dialog { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(10,10,10,.65); animation: fade .15s ease; }
.dialog-card { width: 100%; max-width: 380px; background: var(--antracite-2); border-radius: 18px; padding: 22px 18px 18px; }
.dialog-card h3 { margin: 0 0 6px; font-family: var(--font-title); font-weight: 400; font-size: 24px; }
.dialog-card p { margin: 0 0 16px; font-size: 14px; color: var(--bianco-70); }
.dialog-card p:empty { display: none; }
.dialog-card input {
  width: 100%; height: 46px; margin: 4px 0 16px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--viola); outline: 0; background: var(--antracite); font-size: 15px;
}

/* ---------- Avviso ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 70;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--bianco); color: var(--antracite); font-size: 13.5px; font-weight: 600;
  padding: 10px 16px; border-radius: 22px; max-width: 86vw; text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }

/* ---------- Sincronizzazione ---------- */
.sync {
  flex: none; height: 32px; padding: 0 12px; border-radius: 16px; margin-bottom: 6px;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 500; color: var(--bianco-70); background: var(--antracite-2);
  transition: transform .12s;
}
.sync:active { transform: scale(.96); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bianco-30); }
.sync[data-s="ok"] .sync-dot { background: var(--verde); }
.sync[data-s="busy"] .sync-dot { background: var(--viola); animation: pulse 1s ease-in-out infinite; }
.sync[data-s="local"], .sync[data-s="auth"] { background: none; border: 1px solid var(--viola); color: var(--bianco); }
.sync[data-s="local"] .sync-dot, .sync[data-s="auth"] .sync-dot { background: var(--viola); }
@keyframes pulse { 50% { opacity: .3; } }

.auth { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 24px; background: var(--antracite); overflow-y: auto; }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: var(--gap); }
.auth-title { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 44px; line-height: 1.05; }
.auth-text { margin: 0 0 8px; color: var(--bianco-70); font-size: 14px; }
.auth-card input {
  height: 50px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--antracite-3);
  background: var(--antracite-2); outline: 0; font-size: 16px;
}
.auth-card input:focus { border-color: var(--viola); }
.auth-card input::placeholder { color: var(--bianco-50); }
.auth-err { margin: 0; min-height: 20px; font-size: 13px; color: #ff8a8f; }
.auth-err.ok { color: var(--verde); }
.auth-card .btn { flex: none; }
.auth-card .btn[disabled] { opacity: .6; }
.link { align-self: center; padding: 10px; font-size: 13.5px; color: var(--bianco-70); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Versione web (schermi larghi) ---------- */
.web body { background: #1d1d1d; }
.web .view { max-width: 760px; margin: 0 auto; background: var(--antracite); min-height: 100vh; }
.web #noteView { height: 100vh; }
.web .fab { right: max(20px, calc(50vw - 360px)); }
@media (hover: hover) {
  .card:hover { border-color: var(--antracite-3); cursor: pointer; }
  .chip:hover, .btn.ghost:hover, .mini-btn:hover { border-color: var(--viola); }
  .icon-btn:hover { background: var(--antracite-2); }
}
