/* Content Engine: un solo foglio di stile, niente font o script esterni. */
/* Stessa famiglia grafica di Trend Scout (scout.ohjucky.com): scuro, accento lime, Inter + JetBrains Mono. */
:root {
  --bg: #0a0c10; --bg-2: #0f1218; --surface: #13171f; --surface-2: #181d27; --line: #222836; --line-2: #2c3446;
  --text: #e8ecf3; --muted: #8a93a6; --dim: #5d6679;
  --accent: #b6f24a; --accent-text: #0d1400; --accent-soft: rgba(182, 242, 74, 0.12);
  --ok: #3ddc97; --ok-bg: rgba(61, 220, 151, 0.13); --warn: #ffb347; --warn-bg: rgba(255, 179, 71, 0.13);
  --bad: #ff5470; --bad-bg: rgba(255, 84, 112, 0.14); --info: #6aa8ff; --info-bg: rgba(106, 168, 255, 0.14);
  --idle: #8a93a6; --idle-bg: rgba(138, 147, 166, 0.13); --violet: #b79cff; --violet-bg: rgba(183, 156, 255, 0.14);
  --radius: 12px; --ident: var(--accent);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1 { font-size: 30px; margin: 0 0 .4rem; line-height: 1.1; letter-spacing: -0.025em; font-weight: 800; }
h2 { font-size: 1.2rem; margin: 0 0 .4rem; line-height: 1.3; }
h3 { font: 500 10.5px var(--mono); margin: 1.1rem 0 .5rem; text-transform: uppercase; letter-spacing: .14em; color: var(--dim); }
p { margin: .4rem 0; }
code { font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; overflow-wrap: anywhere; }
pre { background: var(--surface-2); padding: .8rem; border-radius: var(--radius); overflow-x: auto; }
pre code { background: none; padding: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--bad); }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain > li + li { margin-top: .5rem; }

/* guscio: barra laterale come Trend Scout */
.app { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  padding: 18px 12px; background: var(--bg-2); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 20px; color: var(--text); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); flex: none; }
.brand-mark svg { width: 20px; height: 20px; }
.brand b { display: block; white-space: nowrap; font-size: 15px; letter-spacing: -0.01em; }
.brand small { display: block; font: 10px var(--mono); color: var(--dim); letter-spacing: .14em; text-transform: uppercase; }
.nav-label { font: 10px var(--mono); letter-spacing: .16em; color: var(--dim); text-transform: uppercase; padding: 14px 10px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--muted); font-weight: 500; text-decoration: none; transition: background .12s, color .12s;
}
.nav a svg { width: 16px; height: 16px; flex: none; }
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav .badge { margin-left: auto; }
.nav a.ext { font-size: 13px; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; font-size: 11px; color: var(--dim); }
.sidebar-foot form { margin-top: 8px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font: inherit; text-decoration: underline; }
.badge { display: inline-block; min-width: 1.5em; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font: 700 11px var(--mono); text-align: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  border-bottom: 1px solid var(--line); background: rgba(10, 12, 16, 0.86); backdrop-filter: blur(10px);
}
.topbar .spacer { flex: 1; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); font: 11.5px var(--mono); color: var(--muted); }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status-pill.wait .dot { background: var(--accent); }
main { width: 100%; max-width: 1280px; padding: 28px; }
.page-head { margin-bottom: 22px; }
.page-head p { color: var(--muted); max-width: 760px; }
.foot { padding: 0 28px 28px; color: var(--dim); font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; margin-bottom: 1rem; }
.block { margin-top: .9rem; }
.block h3 { margin-top: 0; }
.note { background: var(--warn-bg); color: var(--text); border-left: 4px solid var(--warn); padding: .6rem .8rem; border-radius: 6px; }

/* messaggi */
.flashes { margin-bottom: 1rem; }
.flash { padding: .7rem .9rem; border-radius: 8px; border: 1px solid transparent; margin: 0 0 .5rem; }
.flash-ok { background: var(--ok-bg); border-color: var(--ok); }
.flash-warn { background: var(--warn-bg); border-color: var(--warn); }
.flash-error { background: var(--bad-bg); border-color: var(--bad); }

/* etichette */
.chips, .filters, .legend { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.filters, .legend { margin-bottom: .8rem; }
.chip {
  display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; line-height: 1.5;
  background: var(--surface-2); color: var(--text); text-decoration: none; white-space: nowrap;
}
.chip-on { background: var(--accent); color: var(--accent-text); }
.st-pending { background: var(--warn-bg); color: var(--warn); }
.st-approved, .st-queued, .st-testing { background: var(--info-bg); color: var(--info); }
.st-sent_to_phone, .st-manual { background: var(--violet-bg); color: var(--violet); }
.st-published, .st-connected, .st-active { background: var(--ok-bg); color: var(--ok); }
.st-rejected, .st-missing, .st-retired, .st-unknown { background: var(--idle-bg); color: var(--idle); }
.st-failed { background: var(--bad-bg); color: var(--bad); }

/* bottoni e campi */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: .45rem 1rem;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 13.5px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, summary:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-small { min-height: 30px; padding: .15rem .6rem; font-size: .8rem; font-weight: 500; }
.field { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); margin: .6rem 0; }
input[type="text"], input[type="url"], input[type="password"] {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: .55rem .7rem; min-height: 44px; width: 100%;
}
.form-error { color: var(--bad); font-weight: 600; }
details > summary { cursor: pointer; }
details > summary:not(.btn) { color: var(--accent); padding: .4rem 0; }

/* coda */
.video { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: 1.4rem; align-items: start; }
.video > * { min-width: 0; }
.player video, .no-video { width: 100%; aspect-ratio: 9 / 16; border-radius: var(--radius); background: #000; display: block; }
.player { position: sticky; top: 76px; }
.no-video { display: flex; align-items: center; justify-content: center; padding: 1rem; text-align: center; color: var(--muted); background: var(--bg-2); border: 1px solid var(--line); }
.video-head .chips { margin: .3rem 0; }
.score { display: flex; gap: .8rem; align-items: flex-start; }
.score-num { font: 700 1.5rem var(--mono); font-weight: 700; min-width: 3.2rem; text-align: center; padding: .2rem .4rem; border-radius: 8px; background: var(--surface-2); }
.score-good .score-num { background: var(--ok-bg); color: var(--ok); }
.score-mid .score-num { background: var(--warn-bg); color: var(--warn); }
.score-bad .score-num { background: var(--bad-bg); color: var(--bad); }
.hooks { margin: 0; padding-left: 1.4rem; }
.hooks li { padding: .2rem .3rem; border-radius: 6px; }
.hooks li.chosen { background: var(--info-bg); font-weight: 600; }
.captions { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .6rem; }
.caption { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; min-width: 0; }
.caption-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.cap-text, .cap-title, .post-hook { overflow-wrap: anywhere; white-space: pre-line; }
.tags { color: var(--accent); overflow-wrap: anywhere; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-start; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.reject { flex: 1 1 100%; }
.reject > summary { list-style: none; display: inline-flex; }
.reject > summary::-webkit-details-marker { display: none; }
.reject[open] > summary { display: none; }
.reject-form { border: 1px solid var(--line); border-radius: 8px; padding: .8rem; }
.chip-choices { display: flex; flex-wrap: wrap; gap: .4rem; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: inline-flex; align-items: center; min-height: 40px; padding: .3rem .8rem; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.choice input:checked + span { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); font-weight: 600; }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* calendario */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; min-height: 7rem; min-width: 0; }
.day h2 { font-size: .9rem; }
.day-past { opacity: .8; }
.day-today { border-color: var(--accent); border-width: 2px; }
.ident { border-left: 3px solid var(--ident); padding-left: .5rem; margin-top: .5rem; }
.ident h3 { margin: 0 0 .25rem; font-size: .7rem; }
.cal-item { display: block; font-size: .8rem; padding: .3rem .4rem; border-radius: 6px; line-height: 1.3; }
.cal-time { font-variant-numeric: tabular-nums; font-weight: 600; margin-right: .3rem; }
.cal-what { overflow-wrap: break-word; color: var(--text); }
.cal-status { display: block; font-size: .72rem; opacity: .9; }

/* formati */
.timeline { display: flex; gap: 2px; border-radius: 8px; overflow: hidden; margin: .4rem 0; }
.seg { flex-basis: 0; min-width: 3.2rem; padding: .35rem .4rem; display: flex; flex-direction: column; font-size: .75rem; line-height: 1.25; overflow: hidden; }
.seg-role { font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.seg-hook { background: var(--bad-bg); color: var(--bad); }
.seg-build { background: var(--warn-bg); color: var(--warn); }
.seg-payoff { background: var(--ok-bg); color: var(--ok); }
.seg-cta { background: var(--info-bg); color: var(--info); }
.seg-other { background: var(--idle-bg); color: var(--idle); }

/* account */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .6rem; }
.acc { border: 1px solid var(--line); border-radius: 8px; padding: .7rem; min-width: 0; }
.acc-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.cmd { display: flex; align-items: center; gap: .5rem; justify-content: space-between; margin-top: .5rem; }

/* statistiche */
.table-wrap { overflow-x: auto; margin: .4rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font: 500 10px var(--mono); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; }
td.al-right, th.al-right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.al-center, th.al-center { text-align: center; }
.chart { width: 100%; max-width: 720px; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .line, .spark .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .12; }
.chart .dot { fill: var(--accent); }
.spark { display: block; }
.post-head > div { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: .5rem; margin: .7rem 0 .3rem; }
.stat-row > div { background: var(--surface-2); border-radius: 8px; padding: .45rem .6rem; }
.stat-row dt { font-size: .72rem; color: var(--muted); }
.stat-row dd { margin: 0; font: 700 1.1rem var(--mono); font-variant-numeric: tabular-nums; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 .7rem; }
.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 260px; }
.inline-form .btn { margin-bottom: .6rem; }

/* report e documenti */
.report-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 1rem; align-items: start; }
.report-list { display: flex; flex-direction: column; gap: .2rem; }
.report-list a { padding: .45rem .6rem; border-radius: 8px; text-decoration: none; color: var(--text); overflow-wrap: anywhere; }
.report-list a[aria-current="page"] { background: var(--info-bg); color: var(--info); font-weight: 600; }
.prose { max-width: 820px; overflow-wrap: anywhere; }
.prose h1 { margin-top: 0; }
.prose h2 { margin-top: 1.4rem; font-size: 1.25rem; }
.prose h3 { text-transform: none; letter-spacing: 0; font-size: 1.05rem; color: var(--text); }
.prose h4, .prose h5, .prose h6 { margin: 1rem 0 .3rem; }
.prose li { margin: .2rem 0; }
.prose blockquote { margin: .6rem 0; padding: .1rem .9rem; border-left: 4px solid var(--line); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

@media (max-width: 1100px) {
  .video { grid-template-columns: 1fr; }
  .player { position: static; max-width: 300px; }
}
@media (max-width: 1000px) {
  .cal { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .brand > span:last-child, .nav-label, .sidebar-foot, .topbar { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav a { padding: 7px 9px; white-space: nowrap; }
  .nav a svg { display: none; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
  main { padding: 16px; }
  .video { grid-template-columns: 1fr; }
  .player { position: static; max-width: 300px; margin: 0 auto; width: 100%; }
  .cal { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .report-layout { grid-template-columns: 1fr; }
  .report-list { flex-direction: row; overflow-x: auto; }
  .report-list a { white-space: nowrap; }
  .actions form, .actions .btn { flex: 1 1 100%; width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: border-color .12s; }
}

/* login */
.login { max-width: 380px; margin: 8vh auto 0; padding: 24px; }
.login form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.login label { font: 500 10px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.login button, .login #pk-login, .login #pk-register { min-height: 40px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-weight: 700; cursor: pointer; }

/* ---------- editor a timeline ---------- */
.crumbs { font: 12px var(--mono); color: var(--dim); margin: 0 0 8px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.mono { font-family: var(--mono); }
.ed-top { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.ed-player video { width: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: var(--radius); display: block; }
.ed-time { font-size: 12px; color: var(--muted); margin-top: 6px; }
.ed-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ed-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ed-status { font-size: 12px; color: var(--muted); }
.ed-status.run { color: var(--accent); }
.ed-status.err { color: var(--bad); }
.ed-insp .row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; align-items: center; margin: 6px 0; font-size: 13px; }
.ed-insp label { font: 10px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.ed-insp input, .ed-insp select, .ed-agent textarea {
  width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 9px; font: 13px var(--font);
}
.ed-insp h3, .ed-agent h3 { margin-top: 0; }
.ed-tl { padding: 10px; }
.ed-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.ed-scroll { overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); }
.ed-canvas { position: relative; user-select: none; -webkit-user-select: none; }
.ed-ruler { position: relative; height: 24px; margin-left: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.ed-tick { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--line-2); font: 10px var(--mono); color: var(--dim); padding-left: 3px; }
.ed-track { position: relative; height: 34px; border-bottom: 1px solid var(--line); }
.ed-track .lab { position: sticky; left: 0; z-index: 3; display: inline-block; width: 74px; height: 100%; padding: 0 8px; font: 10px/34px var(--mono); letter-spacing: .1em; color: var(--dim); background: var(--bg-2); border-right: 1px solid var(--line); }
.ed-item { position: absolute; top: 4px; height: 26px; border-radius: 6px; padding: 0 8px; font: 11px/26px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: grab; border: 1px solid transparent; color: #0d1400; }
.ed-item.sel { outline: 2px solid #fff; outline-offset: 1px; }
.ed-item .h { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.ed-item .h.l { left: 0; } .ed-item .h.r { right: 0; }
.ed-item.video { background: #6aa8ff; }
.ed-item.title { background: #ffffff; }
.ed-item.music { background: #b79cff; }
.ed-item.dip { background: rgba(255, 84, 112, .55); color: #fff; }
.ed-item.sfx { background: var(--accent); }
.ed-item.game { background: #3ddc97; cursor: pointer; }
.ed-item .peak { position: absolute; top: 2px; bottom: 2px; width: 2px; background: rgba(0,0,0,.45); }
.ed-ev { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--warn); pointer-events: none; z-index: 2; }
.ed-ev span { position: absolute; top: 2px; left: 3px; font: 10px var(--mono); color: var(--warn); background: var(--bg-2); padding: 0 3px; }
.ed-head { position: absolute; top: 0; bottom: 0; width: 2px; background: #ff5470; pointer-events: none; z-index: 4; }
.ed-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-top: 10px; }
.ed-lib .it { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; min-width: 0; }
.ed-lib .it span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-lib .it small { color: var(--dim); font-family: var(--mono); }
.ed.proposal .ed-scroll { outline: 2px dashed var(--accent); }
@media (max-width: 900px) { .ed-top { grid-template-columns: 1fr; } .ed-player { max-width: 260px; } }
.login #pk-login, .login #pk-register { width: 100%; margin: 6px 0; }
