@font-face { font-family: "Dodger"; src: url("/brand/fonts/the-dodger-inky.woff") format("woff"); }
@font-face { font-family: "Cormorant"; font-weight: 600; src: url("/brand/fonts/cormorant-latin-600-normal.woff") format("woff"); }
@font-face { font-family: "Cormorant"; font-weight: 500; font-style: italic; src: url("/brand/fonts/cormorant-latin-500-italic.woff") format("woff"); }

:root {
  --bg: #160f0d;
  --panel: #221714;
  --panel-2: #2c1f1b;
  --line: #3d2c26;
  --espresso: #3c2424;
  --crema: #f0e6af;
  --text: #f6efe3;
  --muted: #b9aa98;
  --ok: #9fcf8a;
  --warn: #f2b45c;
  --bad: #ef7d6a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

/* ---------- Testata ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.top .logo { height: 38px; }
.top h1 {
  font: 400 26px/1 "Dodger", sans-serif;
  letter-spacing: 2px;
  color: var(--crema);
  margin: 4px 0 0;
  text-transform: uppercase;
  white-space: nowrap;
}
.pills { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  font-size: 13px;
  padding: 5px 10px 5px 8px;
  border-radius: 99px;
  background: var(--panel-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.on::before { background: var(--ok); }
.pill.test::before { background: var(--warn); }

/* ---------- Bottoni ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--crema); color: #2a1a16; border-color: var(--crema); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; font-size: 14px; padding: 0 14px; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.link { appearance: none; background: none; border: 0; color: var(--crema); font: inherit; font-size: 14px; cursor: pointer; padding: 6px 0; }
.link.small { color: var(--muted); align-self: flex-start; }

/* ---------- Area principale ---------- */
main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 20px;
  padding: 12px 20px;
  min-height: 0;
}
.stage { display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 0; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg button {
  appearance: none; border: 0; background: none; color: var(--muted);
  font-family: inherit; font-size: 15px; font-weight: 600;
  min-height: 40px; min-width: 110px; border-radius: 9px; cursor: pointer;
}
.seg button.on { background: var(--espresso); color: var(--crema); }

.frame {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#preview {
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.frame.post #preview { aspect-ratio: 4 / 5; }
/* Foto spostata nel browser durante trascinamento e zoom, sopra l'anteprima. */
.live-crop { position: absolute; overflow: hidden; border-radius: 10px; background: var(--panel); pointer-events: none; }
.live-crop img { position: absolute; left: 0; top: 0; max-width: none; user-select: none; }
.live-crop img.base { transform-origin: 0 0; will-change: transform; }
.live-crop img.overlay { width: 100%; height: 100%; }
.loading {
  position: absolute; top: 12px; right: 12px; width: 18px; height: 18px;
  border: 2px solid rgba(240, 230, 175, 0.25); border-top-color: var(--crema);
  border-radius: 50%; animation: spin 0.8s linear infinite; display: none;
}
.frame.busy .loading { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.zoom { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; justify-content: center; white-space: nowrap; }
.zoom input { width: 180px; height: 28px; }

/* ---------- Pannello ---------- */
.panel { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; min-height: 0; padding-bottom: 12px; }
.status {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.status .label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.status .main { font: 600 30px/1.1 "Cormorant", Georgia, serif; color: var(--crema); margin-top: 4px; }
.status .sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
.status .bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 12px; overflow: hidden; }
.status .bar i { display: block; height: 100%; background: var(--crema); width: 0; transition: width 1s linear; }
.status.done .main { color: var(--ok); }
.status.err .main { color: var(--bad); }

.warn {
  background: rgba(242, 180, 92, 0.12);
  border: 1px solid rgba(242, 180, 92, 0.45);
  color: #ffd9a3;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 15px;
}

.block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.block h2 { font: 400 20px/1 "Dodger", sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: var(--crema); margin: 0; }
.ai-hint { font-size: 13px; color: var(--muted); text-align: right; }
.ai-hint.alta { color: var(--ok); }
.ai-hint.media, .ai-hint.bassa { color: var(--warn); }

.field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  font-family: inherit;
  font-size: 17px;
  line-height: 1.35;
  padding: 12px 14px;
  min-height: 50px;
  resize: vertical;
}
.field:focus { outline: 2px solid rgba(240, 230, 175, 0.5); outline-offset: 1px; }
.dish { display: flex; gap: 8px; }
.dish .field { font: 600 21px/1.2 "Cormorant", Georgia, serif; }
.dish button { flex: none; width: 50px; }
#dishes { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.tip { margin: 0; font-size: 13px; color: var(--muted); }
.suggest {
  appearance: none; text-align: left; cursor: pointer;
  background: rgba(240, 230, 175, 0.08); border: 1px dashed rgba(240, 230, 175, 0.4);
  color: var(--muted); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 14px; line-height: 1.3;
}
.suggest em { font: italic 500 19px/1.2 "Cormorant", Georgia, serif; color: var(--crema); }
.suggest b { color: var(--crema); margin-left: 6px; white-space: nowrap; }

.slider { display: grid; grid-template-columns: 70px 1fr 44px; align-items: center; gap: 10px; font-size: 15px; }
.slider output { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 32px; background: transparent; width: 100%; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--crema); margin-top: -11px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--crema); border: 0; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .primary { grid-column: 1 / -1; min-height: 56px; font-size: 18px; }
.actions [hidden] { display: none; }

/* ---------- Striscia scatti ---------- */
.strip {
  display: flex;
  gap: 10px;
  padding: 8px 20px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.strip button {
  appearance: none; border: 2px solid transparent; background: var(--panel); padding: 0;
  border-radius: 10px; overflow: hidden; flex: none; width: 64px; cursor: pointer; position: relative;
}
.strip button.on { border-color: var(--crema); }
.strip img { width: 100%; height: 56px; object-fit: cover; display: block; }
.strip span { display: block; font-size: 11px; color: var(--muted); padding: 3px 0 4px; }
.strip button.pubblicata span { color: var(--ok); }
.strip button.sostituita { opacity: 0.5; }

/* ---------- Stato vuoto, toast ---------- */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 40px; color: var(--muted); }
.empty img { width: 200px; opacity: 0.9; margin-bottom: 12px; }
.empty .big { font: 600 34px/1.1 "Cormorant", Georgia, serif; color: var(--crema); margin: 0; }
.empty p { margin: 0 0 12px; }
.toast {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%);
  background: var(--crema); color: #2a1a16; padding: 12px 18px; border-radius: 12px;
  font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); z-index: 10; max-width: 90vw;
}
.toast.err { background: var(--bad); color: #fff; }
/* Impostazioni: conferma piccola in basso a destra, non copre la pagina. */
.toast.corner {
  left: auto; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); transform: none;
  max-width: min(360px, calc(100vw - 32px)); padding: 7px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500; background: var(--panel-2); color: var(--crema);
  border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.toast.corner.err { background: var(--bad); color: #fff; border-color: transparent; }

/* ---------- iPad in verticale / schermi stretti ---------- */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; overflow-y: auto; align-content: start; }
  .stage, .panel { min-height: auto; }
  .frame { flex: none; height: 60dvh; }
  .panel { overflow: visible; }
  .top h1 { font-size: 20px; }
}
@media (max-width: 560px) {
  .top { flex-wrap: wrap; padding: 10px 16px; }
  .pills { order: 3; width: 100%; justify-content: flex-start; margin: 0; }
  main { padding: 12px 16px; }
  .actions { grid-template-columns: 1fr; }
}

/* ---------- Riquadri (accesso, telefono) ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { font: 400 22px/1 "Dodger", sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: var(--crema); margin: 4px 0 0; }
.help { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-size: 13px; color: var(--crema); }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.field:disabled { opacity: 0.6; }
.result { margin: 0; font-size: 14px; min-height: 1em; }
.result.good { color: var(--ok); }
.result.bad { color: var(--bad); }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--crema); }
.top .gear { color: var(--muted); text-decoration: none; font-size: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; white-space: nowrap; }
.back { color: var(--crema); text-decoration: none; font-size: 26px; padding: 0 6px; }

/* ---------- Impostazioni ---------- */
/* Elenchi a righe come le impostazioni dell'iPad: etichetta a sinistra, valore a destra. */
main.prefs { display: flex; flex-direction: column; gap: 36px; padding: 28px 20px 64px; max-width: 720px; width: 100%; margin: 0 auto; }
.prefs section { display: flex; flex-direction: column; gap: 8px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px; }
.group-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.state { font-size: 13px; color: var(--muted); white-space: nowrap; }
.state::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 7px; vertical-align: 1px; }
.state:empty { display: none; }
.state.on { color: var(--ok); }
.state.test { color: var(--warn); }
.group { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; padding: 8px 16px; border-top: 1px solid var(--line); }
.group > :first-child { border-top: 0; }
.item .label { display: flex; flex-direction: column; gap: 2px; font-size: 16px; }
.item .label small { color: var(--muted); font-size: 13px; }
.item .value { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--crema); font-weight: 600; text-align: right; }
.item.end { justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.item.stack { flex-direction: column; align-items: stretch; gap: 10px; padding-block: 14px; }
.item .seg { padding: 3px; border-radius: 10px; background: var(--bg); }
.item .seg button { min-width: 64px; min-height: 36px; font-size: 14px; border-radius: 8px; }
.pick { width: min(60%, 340px); min-height: 40px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font: inherit; font-size: 15px; }
.pick:focus { outline: 2px solid rgba(240, 230, 175, 0.5); outline-offset: 1px; }
.pick:disabled { opacity: 0.6; }
.pick::placeholder { color: var(--muted); }
select.pick { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.mono { font: 13px/1.3 ui-monospace, Menlo, monospace; color: var(--muted); background: none; border: 0; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.item .range { display: flex; align-items: center; gap: 12px; width: min(60%, 340px); }
.item .range output { flex: none; min-width: 58px; text-align: right; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.item .range input:disabled { opacity: 0.4; }
.switch { appearance: none; flex: none; width: 51px; height: 31px; margin: 0; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: var(--text); transition: transform 0.2s; }
.switch:checked { background: var(--crema); }
.switch:checked::after { transform: translateX(20px); background: var(--espresso); }
.note { margin: 0; padding: 0 4px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.note.alert { color: var(--warn); }
.note a, .how a { color: var(--crema); }
.prefs .result { padding: 0 4px; }
.prefs .result:empty { display: none; }
.how { padding: 0 4px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.how summary { cursor: pointer; color: var(--crema); width: fit-content; }
.how p, .how ol { margin: 8px 0 0; }
.how ol { padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.how b { color: var(--text); }
.folder-browser { border-top: 1px solid var(--line); }
.fb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--panel-2); }
.fb-list { display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; }
.fb-item { appearance: none; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); color: var(--text); font: inherit; padding: 12px 16px; cursor: pointer; }
.fb-item:first-child { border-top: 0; }
.fb-item:hover { background: rgba(240, 230, 175, 0.06); }
.fb-item.folder::after { content: "›"; float: right; color: var(--muted); }
.fb-item span { color: var(--muted); }
.pages { display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; }
.pages:not(:empty) { border: 1px solid var(--line); background: var(--panel); }
@media (max-width: 600px) {
  .item:not(.end):not(.stack) { flex-wrap: wrap; }
  .pick, .item .range { width: 100%; }
  .mono { max-width: 180px; }
}

/* ---------- Accesso ---------- */
.login-page { align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 380px; align-items: stretch; text-align: center; }
.login .logo { height: 56px; align-self: center; }
.login .field { text-align: center; font-size: 18px; }
