:root {
  --espresso: #2b1d14;
  --coffee: #6b3e26;
  --crema: #d9a066;
  --milk: #f4ece1;
  --card: #fffaf3;
  --sea: #1f6f8b;
  --sea-dark: #17566c;
  --terracotta: #c8553d;
  --muted: #8a7262;
  --line: #eadfce;
  --ok: #2f7d4f;
  --radius: 22px;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--espresso);
  background: #1b2b33;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--sea); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ----------------------------- Sfondo ----------------------------- */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.bg .slide {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 1.6s ease;
  background-size: cover; background-position: center;
}
.bg .slide.on { opacity: 1; }
.bg .slide.on.ken { animation: ken 18s ease-out forwards; }
.bg video.slide { width: 100%; height: 100%; object-fit: cover; }
@keyframes ken { from { transform: scale(1.06); } to { transform: scale(1); } }
.bg .fallback {
  background:
    radial-gradient(ellipse at 75% 18%, rgba(255, 214, 150, .85) 0, rgba(255, 190, 120, 0) 38%),
    linear-gradient(180deg, #f6b26b 0%, #e98c6b 26%, #a46a87 48%, #3d6d8c 66%, #1f4f68 82%, #163a4d 100%);
}
.bg .fallback::after {
  content: ''; position: absolute; left: 0; right: 0; top: 64%; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 230, 190, .55), transparent);
}
.bg::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.35) 0, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 55%, rgba(0,0,0,.55) 100%);
}

/* ----------------------------- Barra in alto ---------------------- */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; color: #fff;
}
.brand { display: flex; align-items: baseline; gap: 12px; color: #fff; text-decoration: none; }
.brand b { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: .2px; }
.brand span { font-size: 13px; opacity: .85; }
.top nav { display: flex; align-items: center; gap: 6px; }
.top nav a, .top nav button {
  color: #fff; text-decoration: none; background: rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.25);
  padding: 7px 14px; border-radius: 999px; font-size: 14px; cursor: pointer; backdrop-filter: blur(6px);
}
.top nav a:hover, .top nav button:hover { background: rgba(0,0,0,.32); }

/* ----------------------------- Pannello --------------------------- */
.panel {
  position: fixed; z-index: 4; left: 44px; top: 50%; transform: translateY(-50%);
  width: 410px; max-height: calc(100vh - 150px); overflow: auto;
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0,0,0,.35), 0 2px 0 rgba(255,255,255,.6) inset;
  padding: 28px;
}
.panel h1 { font-family: var(--serif); font-weight: 600; font-size: 27px; margin: 0 0 6px; line-height: 1.15; }
.panel h2 { font-size: 15px; margin: 18px 0 8px; }
.panel p.lead { margin: 0 0 18px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.input, textarea.input, select.input {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--sea); box-shadow: 0 0 0 3px rgba(31,111,139,.15); }
textarea.input { resize: vertical; min-height: 70px; }
.code-input { font-size: 28px; letter-spacing: 10px; text-align: center; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 13px 22px; cursor: pointer;
  background: var(--sea); color: #fff; font-weight: 600; font-size: 15px; text-decoration: none;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--sea-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--espresso); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--milk); }
.btn.danger { background: var(--terracotta); }
.linkbtn { background: none; border: 0; color: var(--sea); cursor: pointer; padding: 0; font-size: 14px; text-decoration: underline; }

.tabs { display: flex; background: var(--milk); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--espresso); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.drop {
  border: 2px dashed #d9c9b3; border-radius: 18px; padding: 20px; text-align: center;
  transition: background .15s, border-color .15s; margin-bottom: 14px;
}
.drop.over { background: #f6efe4; border-color: var(--sea); }
.drop .big { font-family: var(--serif); font-size: 19px; margin-bottom: 4px; }
.drop .actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.drop .actions .btn { padding: 9px 16px; font-size: 14px; }

.files { list-style: none; padding: 0; margin: 0 0 12px; max-height: 190px; overflow: auto; }
.files li { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.files li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files li .s { color: var(--muted); font-size: 13px; white-space: nowrap; }
.files li button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }
.files li a { text-decoration: none; color: var(--sea); font-weight: 600; font-size: 13px; }
.total { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.total.over { color: var(--terracotta); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 7px; }
.chips span { background: var(--milk); border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.chips span button { border: 0; background: none; cursor: pointer; color: var(--muted); }
.chips input { border: 0; outline: none; flex: 1; min-width: 140px; padding: 4px; }

details.opts { margin: 6px 0 16px; }
details.opts summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--sea); list-style: none; }
details.opts summary::-webkit-details-marker { display: none; }
details.opts[open] summary { margin-bottom: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.msg { border-radius: 12px; padding: 11px 14px; font-size: 14px; margin-bottom: 12px; }
.msg.err { background: #fbe9e4; color: #8f2f1d; }
.msg.ok { background: #e6f3ea; color: var(--ok); }
.msg.info { background: #e8f1f5; color: var(--sea-dark); }

.note { background: var(--milk); border-radius: 14px; padding: 13px 15px; font-size: 14px; white-space: pre-wrap; margin-bottom: 14px; }
.meta { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

.copy { display: flex; gap: 8px; margin: 14px 0; }
.copy input { flex: 1; }

/* ----------------------------- Tazzina ---------------------------- */
.cup { display: block; margin: 6px auto 8px; width: 170px; height: 150px; }
.cup .liquid { transition: y .4s ease, height .4s ease; }
.cup .steam path { opacity: 0; }
.cup.ready .steam path { animation: steam 2.6s ease-in-out infinite; }
.cup.ready .steam path:nth-child(2) { animation-delay: .5s; }
.cup.ready .steam path:nth-child(3) { animation-delay: 1s; }
@keyframes steam {
  0% { opacity: 0; transform: translateY(8px); }
  40% { opacity: .75; }
  100% { opacity: 0; transform: translateY(-14px); }
}
.pct { text-align: center; font-family: var(--serif); font-size: 34px; margin: 0; }
.status { text-align: center; color: var(--muted); font-size: 14px; min-height: 20px; margin: 4px 0 16px; }

/* ----------------------------- Didascalia ------------------------- */
.caption {
  position: fixed; z-index: 3; right: 44px; bottom: 64px; max-width: 460px; text-align: right; color: #fff;
  text-shadow: 0 2px 18px rgba(0,0,0,.45); transition: opacity .8s;
}
.caption .place { text-transform: uppercase; letter-spacing: 2px; font-size: 12px; opacity: .9; }
.caption .title { font-family: var(--serif); font-size: 34px; line-height: 1.12; margin: 6px 0 12px; }
.caption a.go {
  display: inline-block; color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.7);
  padding: 8px 16px; border-radius: 999px; font-size: 14px; backdrop-filter: blur(4px); background: rgba(0,0,0,.12);
}
.caption a.go:hover { background: rgba(255,255,255,.18); }
.caption .by { font-size: 12px; opacity: .85; margin-top: 10px; }

/* ----------------------------- Eventi ----------------------------- */
.events {
  position: fixed; z-index: 3; right: 44px; top: 82px; width: 300px;
  background: rgba(255,250,243,.92); backdrop-filter: blur(10px); border-radius: 18px; padding: 16px 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2); font-size: 14px;
}
.events h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 18px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.events h3 button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 18px; }
.events ul { list-style: none; margin: 0; padding: 0; }
.events li { padding: 8px 0; border-top: 1px solid var(--line); }
.events li:first-child { border-top: 0; }
.events li .d { font-size: 12px; color: var(--terracotta); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.events li a, .events li span.t { color: var(--espresso); text-decoration: none; font-weight: 600; }
.events li a:hover { text-decoration: underline; }
.events li .p { color: var(--muted); font-size: 13px; }
.events.closed ul { display: none; }
.events.closed h3 { margin: 0; }

/* ----------------------------- Piede ------------------------------ */
.foot { position: fixed; z-index: 3; left: 44px; bottom: 18px; font-size: 12px; color: rgba(255,255,255,.85); display: flex; gap: 14px; }
.foot a, .foot button { color: rgba(255,255,255,.85); text-decoration: none; background: none; border: 0; cursor: pointer; padding: 0; font-size: 12px; }
.foot a:hover, .foot button:hover { color: #fff; text-decoration: underline; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { border-bottom: 1px solid var(--line); padding: 12px 0; }
.list li .t { font-weight: 600; }
.list li .m { font-size: 13px; color: var(--muted); margin-top: 3px; }
.list li .a { margin-top: 8px; display: flex; gap: 12px; }
.badge { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--milk); color: var(--muted); }
.badge.ready { background: #e6f3ea; color: var(--ok); }
.badge.blocked { background: #fbe9e4; color: #8f2f1d; }

.hidden { display: none !important; }

@media (max-width: 860px) {
  body { overflow: auto; }
  .bg { position: fixed; }
  .top { position: absolute; padding: 14px 16px; }
  .brand span { display: none; }
  .brand b { font-size: 20px; white-space: nowrap; }
  .top nav { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  .top nav a, .top nav button { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
  .panel { position: relative; left: auto; top: auto; transform: none; width: auto; max-height: none; margin: 38vh 12px 20px; }
  .caption { position: absolute; top: 22vh; bottom: auto; left: 18px; right: 18px; text-align: left; max-width: none; }
  .caption .title { font-size: 26px; }
  .events { position: relative; top: auto; right: auto; width: auto; margin: 0 12px 20px; }
  .foot { position: relative; left: auto; bottom: auto; justify-content: center; padding: 0 0 26px; flex-wrap: wrap; }
}
