/* Pepito Studio — identità di pepitoproduzioni.eu (Space Grotesk, Azeret Mono, Mansalva; #DC3918, #121212, #EBEAE9)
   su template chiaro. Font self-hosted (OFL), nessuna chiamata esterna. */
@font-face { font-family: "Space Grotesk"; src: url("fonts/SpaceGrotesk-latin.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Azeret Mono"; src: url("fonts/AzeretMono-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Mansalva"; src: url("fonts/Mansalva-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --red: #dc3918;
  --ink: #121212;
  --stone: #ebeae9;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f4f3;
  --border: #ebeae9;
  --border-strong: #d6d4d2;
  --text: #121212;
  --muted: #707070;
  --accent: #dc3918;
  --accent-ink: #ffffff;
  --accent-soft: #fbebe7;
  --ok: #2e7d4f;
  --ok-soft: #e7f3ec;
  --warn: #a86400;
  --warn-soft: #fbf1e1;
  --bad: #c0281a;
  --bad-soft: #fbe7e4;
  --info: #474646;
  --info-soft: #f0efee;
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: "Azeret Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --hand: "Mansalva", "Space Grotesk", cursive;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 30px; line-height: 1.1; margin: 0; font-weight: 700; text-transform: uppercase; letter-spacing: -.01em; }
h1 .muted { text-transform: none; font-weight: 500; letter-spacing: 0; }
h2 { font-size: 14px; margin: 0 0 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
h3 { font: 400 12px var(--mono); margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code, .mono { font-family: var(--mono); font-size: 12px; font-weight: 400; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }
::selection { background: var(--red); color: #fff; }

/* buttons & fields */
.btn { font: 500 14px var(--font); border: 1px solid var(--ink); background: var(--surface); color: var(--ink); border-radius: 0;
  padding: 8px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, color .15s, border-color .15s; }
.btn:hover { background: var(--ink); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-icon { padding: 6px 10px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font: 400 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
input, select, textarea { font: 400 14px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 0; padding: 8px 10px; min-width: 0; }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 -2px 0 var(--red); }
.btn:focus-visible, .chip:focus-visible, .nav a:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.error { color: var(--bad); margin: 0; }

/* brand */
.brand { display: flex; align-items: flex-end; gap: 6px; padding: 0 8px; line-height: 1; }
.brand-logo { height: 44px; width: auto; display: block; }
.brand-hand { white-space: nowrap; font-family: var(--hand); font-size: 19px; color: var(--red); transform: rotate(-6deg); display: inline-block; margin-bottom: 2px; }
.brand-lg { justify-content: center; padding: 4px 0 8px; }
.brand-lg .brand-logo { height: 84px; }
.brand-lg .brand-hand { font-size: 30px; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background:
  linear-gradient(90deg, var(--stone) 1px, transparent 1px) 0 0 / 48px 48px, var(--bg); }
.login-card { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--ink); padding: 32px;
  display: flex; flex-direction: column; gap: 16px; box-shadow: 8px 8px 0 var(--red); }
.login-card .btn-primary { justify-content: center; padding: 11px 16px; }
.code { background: var(--surface-2); border-left: 3px solid var(--red); padding: 10px 12px; font: 400 12px var(--mono); margin: 0; overflow-x: auto; }

/* shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 22px 12px; display: flex; flex-direction: column;
  gap: 22px; position: sticky; top: 0; height: 100vh; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a { color: var(--ink); padding: 8px 10px 8px 12px; display: flex; gap: 10px; align-items: center; font-weight: 500;
  border-left: 3px solid transparent; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { border-left-color: var(--red); background: var(--accent-soft); color: var(--ink); font-weight: 700; }
.nav .ico { width: 18px; text-align: center; color: var(--muted); }
.nav a.active .ico { color: var(--red); }
.nav-section { font: 400 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 16px 12px 6px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.identity { font: 300 11px var(--mono); color: var(--muted); word-break: break-all; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 28px; border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.topbar select { max-width: 280px; font-weight: 600; }
.series-pick { display: flex; align-items: center; gap: 6px; }
.series-pick span { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.inline-input { width: 100%; min-width: 200px; font-weight: 600; }
.menu-btn { display: none; }
.view { padding: 28px; max-width: 1320px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--ink); }
.page-head .sub { font: 300 13px var(--mono); color: var(--muted); margin-top: 8px; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); padding: 20px; min-width: 0; }
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row h2 { margin-bottom: 14px; }
.kpi { border-top: 3px solid var(--ink); }
.kpi:first-child { border-top-color: var(--red); }
.kpi .label { font: 400 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .hint { font: 300 12px var(--mono); color: var(--muted); margin-top: 6px; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 400 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px;
  border-bottom: 1px solid var(--ink); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.click:hover td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; font: 500 11px var(--mono); text-transform: uppercase;
  letter-spacing: .03em; white-space: nowrap; background: var(--surface-2); color: var(--info); border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.b-accent { background: var(--red); color: #fff; }
.pill { font: 500 11px var(--mono); padding: 4px 10px; background: var(--ink); color: #fff; text-transform: uppercase; letter-spacing: .04em; }
.pill-env { background: var(--surface); color: var(--red); border: 1px solid var(--red); }
.tag-sim { font: 500 10px var(--mono); color: var(--ink); background: var(--stone); padding: 2px 6px; text-transform: uppercase; letter-spacing: .05em; }

/* progress & steps */
.bar { height: 10px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }
.bar .settled { background: var(--red); }
.bar .reserved { background: var(--ink); opacity: .35; }
.legend { display: flex; gap: 16px; font: 300 12px var(--mono); color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; }
.steps { display: flex; margin-top: 6px; }
.step { flex: 1; text-align: center; font: 400 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  position: relative; padding-top: 22px; }
.step::before { content: ""; position: absolute; top: 4px; left: 50%; width: 12px; height: 12px; margin-left: -6px; background: var(--surface);
  border: 2px solid var(--border-strong); z-index: 1; }
.step::after { content: ""; position: absolute; top: 9px; left: -50%; width: 100%; height: 2px; background: var(--border); }
.step:first-child::after { display: none; }
.step.done { color: var(--ink); }
.step.done::before { background: var(--ink); border-color: var(--ink); }
.step.done::after { background: var(--ink); }
.step.current { color: var(--red); font-weight: 500; }
.step.current::before { background: var(--red); border-color: var(--red); box-shadow: 0 0 0 4px var(--accent-soft); }

/* media */
.player { width: 100%; background: var(--ink); aspect-ratio: 16 / 9; display: block; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; align-items: start; }
.media-card { border: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; transition: border-color .15s; }
.media-card:hover { border-color: var(--ink); }
a.ep-card { color: inherit; text-decoration: none; }
a.ep-card:hover { text-decoration: none; }
.media-card .thumb { aspect-ratio: 16 / 9; background: var(--surface-2); display: grid; place-items: center; color: var(--muted);
  font: 300 12px var(--mono); position: relative; overflow: hidden; }
.media-card .thumb img, .media-card .thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card .thumb video { background: var(--ink); object-fit: contain; }
.media-card .thumb .audio-thumb { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; padding: 12px; background: var(--ink); }
.media-card .thumb .audio-ico { font-size: 34px; color: var(--red); line-height: 1; }
.media-card .thumb audio { width: 100%; }
.media-card .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.media-card .title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card .small.muted { font: 300 12px var(--mono); }
.run-thumb { width: 76px; aspect-ratio: 16/9; object-fit: cover; background: var(--surface-2); display: block; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 14px; margin: 0; }
.kv dt { font: 400 11px/1.9 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list { display: flex; flex-direction: column; gap: 12px; }
.fb { border-left: 3px solid var(--red); padding: 2px 0 2px 12px; }
.fb .meta { font: 300 12px var(--mono); color: var(--muted); margin-top: 4px; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; font: 300 13px var(--mono); }
.empty h2 { font-family: var(--font); color: var(--ink); }
.alert { padding: 12px 16px; font-size: 14px; border-left: 3px solid currentColor; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert-bad { background: var(--bad-soft); color: var(--bad); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-info { background: var(--surface-2); color: var(--ink); border-left-color: var(--red); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); padding: 5px 12px; font: 400 12px var(--mono); cursor: pointer;
  color: var(--ink); text-transform: uppercase; letter-spacing: .03em; }
.chip:hover { border-color: var(--ink); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
details summary { cursor: pointer; font: 400 12px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
pre.json { background: var(--surface-2); padding: 14px; overflow: auto; max-height: 420px; font: 300 12px/1.5 var(--mono); margin: 10px 0 0; }
.rules-file { white-space: pre-wrap; font: 300 13px/1.6 var(--mono); margin: 0; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px;
  font: 400 13px var(--mono); border-left: 4px solid var(--red); z-index: 50; max-width: calc(100% - 32px); }
.skeleton { font: 300 13px var(--mono); color: var(--muted); padding: 48px 0; text-align: center; }

@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 20; transform: translateX(-100%); transition: transform .2s;
    box-shadow: 0 0 0 100vmax rgba(18, 18, 18, 0); }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(18, 18, 18, .35); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .view { padding: 18px 16px; }
  h1 { font-size: 24px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .topbar select { max-width: 60vw; }
  .topbar { flex-wrap: wrap; }
  .series-pick span { display: none; }
}
@media (max-width: 480px) { .grid-4 { grid-template-columns: 1fr 1fr; } .kpi .value { font-size: 26px; } .login-card { padding: 22px; box-shadow: 5px 5px 0 var(--red); } }

#diff-panel { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.diff-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.diff-head h3 { margin: 0; }
.rules-file.diff div { white-space: pre-wrap; padding: 0 6px; }
.d-add { color: #1d6b34; background: #e6f4ea; }
.d-del { color: #9b1c1c; background: #fbe9e9; }
.d-hunk { color: var(--muted); background: #f3f3f3; }
.d-file { color: var(--muted); font-weight: 600; }

.check { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.check input { width: auto; }
details summary { cursor: pointer; }
