:root {
  /* Brand Sviluppatore Migliore: arancione + nero/bianco. Mai blu/azzurro. */
  --bg: #0a0a0b;
  --bg2: #0d0c0d;
  --panel: #1a1512;
  --panel2: #141110;
  --line: #2c2218;
  --text: #f6efe7;
  --muted: #b6a596;
  --orange: #ff6a00;
  --orange-l: #ff9442;
  --orange-d: #c44e00;
  --ink: #1a0d00;        /* dark text on orange */
  --danger: #ff5a4d;
  --ok: #ff8a1e;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
button { font-family: inherit; cursor: pointer; }
body {
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 800px at 70% -10%, #2a1407 0%, var(--bg) 55%);
  color: var(--text);
  overflow: hidden;
}
.hidden { display: none !important; }
input {
  font-family: inherit; width: 100%; padding: 13px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  font-size: 16px; outline: none;
}
input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,106,0,.18); }

.primary {
  width: 100%; padding: 13px; border: none; border-radius: 11px; margin-top: 12px;
  background: linear-gradient(135deg, var(--orange-l), var(--orange) 55%, var(--orange-d));
  color: #fff; font-weight: 800; font-size: 15px;
  transition: transform .08s, filter .15s; box-shadow: 0 6px 20px rgba(255,106,0,.3);
}
.primary:hover { filter: brightness(1.07); }
.primary:active { transform: translateY(1px); }
.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 12px; margin-top: 10px; width: 100%; font-weight: 600;
}
.ghost:hover { color: var(--text); border-color: var(--orange); }
.ghost.sm { width: auto; padding: 5px 10px; margin: 0; font-size: 12px; }

/* ---------- LOGIN ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; }
.login-card {
  position: relative; z-index: 2; width: min(92vw, 400px);
  background: rgba(20,16,14,.82); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 20px; padding: 34px 30px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 30px; letter-spacing: -.5px; }
.brand-orb, .logo-orb {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffd2a3, var(--orange) 45%, var(--orange-d) 100%);
  box-shadow: 0 0 22px rgba(255,106,0,.7);
}
.sub { color: var(--muted); margin: 8px 0 24px; font-size: 14px; }
.step label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.hint { color: #8c7a6b; font-size: 12px; margin-top: 12px; }
.msg { margin-top: 14px; font-size: 13px; min-height: 18px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }
.code-input { letter-spacing: 12px; text-align: center; font-size: 26px; font-weight: 800; }
.login-stars {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 80% 70%, #ffd2a3, transparent),
    radial-gradient(2px 2px at 50% 20%, #fff, transparent),
    radial-gradient(1px 1px at 65% 45%, #ffb878, transparent),
    radial-gradient(1px 1px at 35% 80%, #fff, transparent);
  opacity: .5;
}

/* ---------- APP ---------- */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: rgba(13,12,13,.72); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); z-index: 10;
}
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; }
.logo-orb { width: 18px; height: 18px; }
.views { display: flex; gap: 6px; }
.views button {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  border-radius: 9px; padding: 7px 13px; font-weight: 700; font-size: 14px;
}
.views button:hover { color: var(--text); }
.views button.active { color: var(--orange); background: rgba(255,106,0,.12); border-color: rgba(255,106,0,.4); }
.spacer { flex: 1; }
.admin-btn { background: rgba(255,106,0,.14); color: var(--orange-l); border: 1px solid rgba(255,106,0,.45); border-radius: 9px; padding: 7px 13px; font-weight: 700; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }

#viewport { flex: 1; position: relative; }
#viewport canvas { display: block; }

.hint-overlay {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(13,12,13,.82); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 18px; font-size: 13px; color: var(--muted); z-index: 5; pointer-events: none;
  white-space: nowrap;
}

/* info panel */
.info-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: min(92vw, 380px);
  background: rgba(18,14,12,.95); backdrop-filter: blur(14px);
  border-left: 1px solid var(--line); padding: 26px 26px 30px; overflow-y: auto; z-index: 8;
  box-shadow: -20px 0 60px rgba(0,0,0,.6); animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.info-close { position: absolute; top: 16px; right: 16px; background: transparent; border: none; color: var(--muted); font-size: 20px; }
.info-close:hover { color: #fff; }
.info-panel h2 { margin: 8px 0 10px; font-size: 26px; }
.info-panel p { color: var(--muted); line-height: 1.55; }
.info-panel ul { padding-left: 18px; line-height: 1.7; }
.info-panel li::marker { color: var(--orange); }
.badge { display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 4px 10px; border-radius: 999px; }
.badge.live { background: rgba(255,106,0,.18); color: var(--orange-l); }
.badge.wip { background: rgba(255,170,80,.16); color: #ffb061; }
.badge.planned { background: rgba(182,165,150,.16); color: var(--muted); }
.info-link { display: inline-block; margin-top: 18px; background: linear-gradient(135deg, var(--orange-l), var(--orange-d)); color: #fff; text-decoration: none; padding: 10px 18px; border-radius: 10px; font-weight: 800; }

/* ---------- ADMIN ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.72); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 100; }
.modal-card { width: min(96vw, 980px); max-height: 92vh; background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 20px; }
.tabs { display: flex; gap: 6px; }
.tabs button { background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 8px; padding: 6px 14px; font-weight: 700; }
.tabs button.active { color: var(--orange); background: rgba(255,106,0,.12); border-color: rgba(255,106,0,.4); }
.modal-head .ghost { width: auto; margin: 0; margin-left: auto; }
.tab { padding: 18px 20px; overflow-y: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.row-actions { display: flex; gap: 6px; }
.btn-sm { padding: 5px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-weight: 600; font-size: 12px; }
.btn-sm:hover { border-color: var(--orange); }
.btn-sm.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-add { background: linear-gradient(135deg, var(--orange-l), var(--orange-d)); color: #fff; border: none; padding: 8px 16px; border-radius: 9px; font-weight: 800; margin-bottom: 14px; }

.editor { display: grid; gap: 12px; }
.editor .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.editor label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 5px; }
.editor textarea { width: 100%; min-height: 90px; padding: 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-family: inherit; font-size: 14px; resize: vertical; }
.editor select { width: 100%; padding: 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 14px; }
.editor-actions { display: flex; gap: 10px; margin-top: 6px; }
.editor-actions .primary, .editor-actions .ghost { width: auto; margin: 0; }
.swatch { width: 18px; height: 18px; border-radius: 5px; display: inline-block; vertical-align: middle; margin-right: 7px; border: 1px solid rgba(255,255,255,.2); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 18px; font-size: 14px; z-index: 200; box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
.toast.ok { border-color: rgba(255,138,30,.55); }
.toast.err { border-color: rgba(255,90,77,.55); }

@media (max-width: 640px) {
  .editor .grid2, .editor .grid3 { grid-template-columns: 1fr; }
  .who #who-email { display: none; }
  .hint-overlay { white-space: normal; width: 90%; text-align: center; }
}
