/* Configuratore Fustelle — iKUTX
   Brand iKUTX: Inchiostro #141518 · Carta #F1EEE7 · Arancio Lama #FF5B1F · Kraft #C49A6C · Pietra #8E8A82.
   Tema Giorno (bianco) predefinito e tema Notte, arancio solo per l'azione primaria, Geist / Geist Mono. */

@font-face { font-family: 'Geist'; font-weight: 100 900; font-display: swap; src: url(../fonts/Geist-Variable.woff2) format('woff2'); }
@font-face { font-family: 'Geist Mono'; font-weight: 100 900; font-display: swap; src: url(../fonts/GeistMono-Variable.woff2) format('woff2'); }
/* DM Sans resta disponibile per i testi dei progetti già salvati nel designer */
@font-face { font-family: 'DM Sans'; font-weight: 400; font-display: swap; src: url(../fonts/dm-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 700; font-display: swap; src: url(../fonts/dm-sans-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Serif Display'; font-weight: 400; font-display: swap; src: url(../fonts/dm-serif-display-latin-400-normal.woff2) format('woff2'); }

/* Tema Giorno (predefinito): fondo bianco */
:root {
  color-scheme: light;
  --inchiostro: #141518;
  --carta: #F1EEE7;
  --arancio: #FF5B1F;
  --kraft: #C49A6C;
  --pietra: #8E8A82;

  --accent: #FF5B1F;
  --accent-hover: #FF7A47;
  --accent-ink: #D94A14;
  --accent-soft: rgba(255,91,31,.1);
  --on-accent: #141518;
  --ink: #141518;
  --ink-2: #45433E;
  --on-ink: #F1EEE7;
  --muted: #7A766F;
  --ghost: #DDD9D1;
  --bg: #FFFFFF;
  --dot: #EEEBE5;
  --card: #FFFFFF;
  --surface: #F7F5F1;
  --surface-2: #EFECE6;
  --field: #FFFFFF;
  --line: #EAE7E1;
  --line-2: #D9D5CD;
  --cut: #141518;
  --crease: #FF5B1F;
  --zone: #C49A6C;
  --hover: rgba(20,21,24,.05);
  --head-bg: rgba(255,255,255,.86);
  --nav-bg: rgba(255,255,255,.92);
  --overlay: rgba(20,21,24,.32);
  --modal-bg: rgba(20,21,24,.42);
  --badge-bg: rgba(255,255,255,.9);
  --seg-on: #FFFFFF;
  --warn-bg: #FFF4DA; --warn: #8A6100;
  --err-bg: #FFE9E6; --err: #C23A2B;
  --ok-bg: #E4F5EC; --ok: #17804F;
  --mono: 'Geist Mono', ui-monospace, Menlo, Consolas, monospace;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20,21,24,.04), 0 8px 26px rgba(20,21,24,.06);
  --shadow-lg: 0 22px 60px rgba(20,21,24,.16);
  --ease: cubic-bezier(.2,.8,.2,1);
  --spring: cubic-bezier(.34,1.56,.64,1);
  --nav-h: 64px;
  --head-h: 60px;
}

/* Tema Notte: Inchiostro */
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent-ink: #FF7A47;
  --accent-soft: rgba(255,91,31,.14);
  --ink: #F1EEE7;
  --ink-2: #C9C4BA;
  --on-ink: #141518;
  --muted: #8E8A82;
  --ghost: #3A3A3F;
  --bg: #141518;
  --dot: #202126;
  --card: #1C1D21;
  --surface: #17181B;
  --surface-2: #26272C;
  --field: #141518;
  --line: #2A2B30;
  --line-2: #3A3B41;
  --cut: #F1EEE7;
  --hover: rgba(241,238,231,.06);
  --head-bg: rgba(20,21,24,.84);
  --nav-bg: rgba(28,29,33,.9);
  --overlay: rgba(0,0,0,.55);
  --modal-bg: rgba(0,0,0,.6);
  --badge-bg: rgba(20,21,24,.78);
  --seg-on: #2E2F35;
  --warn-bg: rgba(245,165,36,.13); --warn: #F5B94A;
  --err-bg: rgba(255,90,90,.13); --err: #FF7272;
  --ok-bg: rgba(76,195,138,.14); --ok: #5BD097;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.28);
  --shadow-lg: 0 24px 70px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink); background: var(--bg);
  background-image: radial-gradient(var(--dot) 1.1px, transparent 1.2px);
  background-size: 18px 18px;
  -webkit-font-smoothing: antialiased;
  font-size: 15px; line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- Tipografia del video ---------- */
.eyebrow { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.eyebrow b { color: var(--ink); font-weight: 500; }
.title { font-size: clamp(30px, 5.2vw, 54px); font-weight: 900; letter-spacing: -.045em; line-height: 1; margin: 0 0 6px; }
.subtitle { color: var(--muted); margin: 6px 0 0; font-size: 15px; }
.reveal .w { display: inline-block; color: var(--ghost); animation: ink .55s var(--ease) forwards; animation-delay: calc(var(--i) * 85ms + 120ms); transform: translateY(.12em); }
@keyframes ink { 0% { color: var(--ghost); transform: translateY(.12em); } 100% { color: var(--ink); transform: none; } }
.reveal .w:last-child { animation-name: inkCut; }
@keyframes inkCut { 0% { color: var(--ghost); transform: translateY(.12em); } 100% { color: var(--arancio); transform: none; } }
.counter { font-size: clamp(64px, 12vw, 120px); font-weight: 900; letter-spacing: -.045em; line-height: .9; color: var(--ink); font-variant-numeric: tabular-nums; display: block; }

/* ---------- Pulsanti e campi ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--card); border-radius: 999px; padding: 10px 18px; font-weight: 600; font-size: 14px; transition: transform .15s var(--ease), background .2s, box-shadow .2s, border-color .2s; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 6px 22px rgba(255,91,31,.3); }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-dark { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }
.btn-danger { color: var(--err); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }
.btn svg, .ico { width: 18px; height: 18px; flex: none; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span, .lbl { font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
input[type=text], input[type=number], input[type=password], input[type=search], input[type=date], input:not([type]), select, textarea {
  width: 100%; border: 1.5px solid var(--line-2); background: var(--field); border-radius: 12px; padding: 10px 12px; outline: none; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,91,31,.16); }
textarea { min-height: 80px; resize: vertical; }
input[type=color] { width: 40px; height: 40px; padding: 0; border: 1.5px solid var(--line-2); border-radius: 12px; background: none; cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--accent-ink); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent-ink); }
.sub { margin-left: 28px; animation: fadeIn .25s ease; }

.seg { display: inline-flex; background: var(--surface);  border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; position: relative; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 13px; color: var(--ink-2); transition: background .25s var(--ease), color .2s, box-shadow .25s; }
.seg button.on { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 4px rgba(20,21,24,.12); }
.seg.accent button.on { background: var(--ink); color: var(--on-ink); }
.seg.full { display: flex; } .seg.full button { flex: 1; }

.pills { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { border: 1.5px solid var(--line-2); background: transparent; color: var(--ink-2); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 13px; white-space: nowrap; transition: all .25s var(--ease); }
.pill.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.pill .n { opacity: .55; font-weight: 500; margin-left: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .06em; background: var(--accent-soft); color: var(--accent-ink); }
.badge.grey { background: var(--surface-2); color: var(--ink-2); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.dark { background: var(--ink); color: var(--on-ink); }

/* ---------- Login / install ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login { width: 100%; max-width: 420px; }
.login.install { max-width: 520px; }
.login-card { padding: 22px; margin-top: 22px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.login-card h3 { font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 8px 0 12px; }
.login-mark { width: 210px; margin-bottom: 26px; }
.login-mark img { display: block; width: 100%; height: auto; }
.login-foot { color: var(--muted); font-size: 12px; text-align: center; margin-top: 16px; }
.form-error { background: var(--err-bg); color: var(--err); padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.form-ok { background: var(--ok-bg); color: var(--ok); padding: 10px 12px; border-radius: 12px; }
.code { background: var(--surface); font-family: var(--mono); border: 1px solid var(--line); padding: 12px; border-radius: 12px; overflow: auto; font-size: 12px; }

.cube-logo .f1 { fill: var(--accent); animation: drop .7s var(--spring) both; }
.cube-logo .f2 { fill: var(--carta); animation: drop .7s .12s var(--spring) both; }
.cube-logo .f3 { fill: var(--kraft); animation: drop .7s .24s var(--spring) both; }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Splash ---------- */
.splash { position: fixed; inset: 0; z-index: 100; background: var(--bg); background-image: inherit; background-size: 18px 18px; display: grid; place-items: center; text-align: center; transition: opacity .6s var(--ease), visibility .6s; }
.splash.out { opacity: 0; visibility: hidden; }
.splash .cube-logo { width: 96px; height: 96px; margin: 0 auto 18px; display: block; }
.splash .brand-logo { width: min(260px, 64vw); height: auto; display: block; margin: 0 auto 26px; animation: drop .8s var(--spring) both; }
.splash .brand { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .24em; color: var(--muted); margin-bottom: 10px; animation: fadeUp .6s .35s both; }
.splash h1 { font-size: clamp(28px, 6vw, 44px); margin: 0 auto 18px; max-width: 12ch; line-height: 1; letter-spacing: -.045em; font-weight: 900; }
.splash .chip { display: inline-block; border: 1px solid var(--line-2); color: var(--ink-2); font-family: var(--mono); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; font-weight: 500; padding: 8px 16px; border-radius: 999px; animation: fadeUp .6s .8s both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Header ---------- */
.app-head { position: sticky; top: 0; z-index: 30; height: var(--head-h); display: flex; align-items: center; gap: 10px; padding: 0 clamp(12px, 3vw, 28px); background: var(--head-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.app-head .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.app-head .logo svg { width: 28px; height: 28px; }
.app-head .logo img { display: block; height: 26px; width: auto; }
.app-head .logo .simbolo { height: 30px; }
.app-head .logo small { display: block; font-size: 10px; letter-spacing: .14em; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.proj-chip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; justify-content: center; }
.proj-chip button { display: flex; align-items: center; gap: 8px; max-width: 100%; border: 1px solid var(--line-2); background: var(--card); border-radius: 999px; padding: 6px 14px 6px 8px; }
.proj-chip .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; transition: background .3s; }
.save-dot.dirty { background: #F5A524; }
.head-actions { display: flex; gap: 6px; align-items: center; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); transform-origin: top right; animation: pop .22s var(--ease); z-index: 40; }
.menu-pop button, .menu-pop a { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 10px; font-weight: 500; color: var(--ink); text-decoration: none; font-size: 14px; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); }
.menu-pop .who { padding: 10px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Account di prova ---------- */
.trial { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 7px 14px; background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 13px; white-space: nowrap; animation: pop .4s var(--spring); }
.trial b { color: var(--accent); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.trial.urgente { background: var(--err); }
.trial.urgente { color: var(--on-ink); }
.trial.urgente b { color: var(--on-ink); }
@media (max-width: 720px) { .trial .lunga { display: none; } }
.cred { background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 16px; padding: 14px 16px; font-size: 14px; line-height: 1.6; margin: 0 0 12px; white-space: pre-wrap; font-family: var(--mono); }
.req { background: var(--warn-bg); border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
.req-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid rgba(245,185,74,.18); font-size: 14px; }
.req-item:first-of-type { border-top: 0; }
.req-item .t { flex: 1; min-width: 0; }

/* ---------- Sezioni ---------- */
main.app { padding: 22px clamp(12px, 3vw, 28px) calc(var(--nav-h) + 40px); max-width: 1320px; margin: 0 auto; }
.section { display: none; }
.section.on { display: block; animation: sectionIn .55s var(--ease); }
@keyframes sectionIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.sec-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---------- Libreria ---------- */
.lib-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.lib-tools .search { flex: 1 1 260px; position: relative; }
.lib-tools .search input { padding-left: 38px; border-radius: 999px; }
.lib-tools .search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.lib-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .lib-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 960px) { .lib-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .lib-grid { grid-template-columns: repeat(5, 1fr); } }
.tpl { position: relative; text-align: left; border: 1.5px solid var(--line); background: var(--card); border-radius: 18px; padding: 10px; transition: transform .3s var(--ease), border-color .25s, box-shadow .3s; animation: cardIn .5s var(--ease) both; animation-delay: calc(var(--k, 0) * 28ms); }
.tpl:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); }
.tpl.sel { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,91,31,.2), var(--shadow); transform: translateY(-3px); }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.tpl .thumb { aspect-ratio: 4 / 3; background: var(--surface); border-radius: 12px; display: grid; place-items: center; overflow: hidden; }
.tpl .thumb svg { width: 88%; height: 88%; }
.tpl .thumb svg path { fill: none; stroke: var(--cut); stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.tpl .thumb svg .cr { stroke: var(--crease); stroke-dasharray: 3 3; stroke-width: 1; }
.tpl .nm { font-weight: 600; font-size: 13px; line-height: 1.25; margin: 9px 2px 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.tpl .cd { font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; color: var(--muted); margin: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl .badge { position: absolute; top: 16px; right: 16px; font-size: 10px; }
.tpl .go { position: absolute; left: 50%; bottom: -16px; transform: translate(-50%, 6px) scale(.8); opacity: 0; pointer-events: none; transition: all .35s var(--spring); z-index: 2; box-shadow: 0 8px 22px rgba(255,91,31,.38); }
.tpl.sel .go { opacity: 1; transform: translate(-50%, 0) scale(1); pointer-events: auto; }
.lib-more { display: flex; justify-content: center; margin: 26px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }

/* ---------- Designer ---------- */
.des-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1024px) { .des-grid { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; } .des-side { position: sticky; top: calc(var(--head-h) + 14px); max-height: calc(100vh - var(--head-h) - var(--nav-h) - 40px); overflow: auto; } }
.stage { position: relative; overflow: hidden; height: min(68vh, 720px); min-height: 360px; background: var(--carta); color: var(--inchiostro); --cut: #141518; --line-2: #D9D4CA; border-color: var(--line); }
.stage svg.dl { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.stage svg.dl.panning { cursor: grabbing; }
.stage .zoom { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
.stage .zoom .btn { background: rgba(255,255,255,.92); color: var(--inchiostro); border-color: #D9D4CA; }
.stage .legend { position: absolute; left: 14px; bottom: 12px; display: flex; gap: 12px; font-size: 11px; color: #4A4842; background: rgba(255,255,255,.9); padding: 6px 10px; border-radius: 999px; font-family: var(--mono); letter-spacing: .06em; }
.stage .legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--cut); vertical-align: middle; margin-right: 5px; }
.stage .legend i.c { border-top: 2px dashed var(--crease); }
.stage .legend i.z { border-top: 2px dashed var(--zone); }
.stage .toolbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); }
.dl .cut { fill: none; stroke: var(--cut); stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.dl .perf { fill: none; stroke: #D6249F; stroke-width: 1.2; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
.tpl .thumb svg .pf { stroke: #D6249F; stroke-dasharray: 2 2; stroke-width: 1; }
.dl .crease { fill: none; stroke: var(--crease); stroke-width: 1.2; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.dl .zone { fill: rgba(196,154,108,.05); stroke: var(--zone); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.dl .zone.np { fill: rgba(20,21,24,.035); stroke: none; }
.dl .bleed { fill: none; stroke: rgba(196,154,108,.2); stroke-linejoin: round; }
.dl .plabel { fill: #8E8A82; paint-order: stroke; stroke: rgba(255,255,255,.75); stroke-width: .5px; stroke-linejoin: round; font-weight: 600; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.dl .uparrow { fill: none; stroke: #B9B2A7; stroke-width: 1.2; vector-effect: non-scaling-stroke; pointer-events: none; }
.dl .el { cursor: move; }
.dl .selbox { fill: none; stroke: var(--accent); stroke-width: 1.2; vector-effect: non-scaling-stroke; pointer-events: none; }
.dl .h { fill: #fff; stroke: var(--accent); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.dl .h.rot { fill: var(--accent); }
.dl.drawing .cut, .dl.drawing .crease-draw { stroke-dasharray: var(--len) var(--len); stroke-dashoffset: var(--len); animation: draw 1.5s var(--ease) forwards; }
.dl.drawing .crease, .dl.drawing .perf, .dl.drawing .zone, .dl.drawing .plabel, .dl.drawing .uparrow { opacity: 0; animation: fadeIn .6s 1.1s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadeIn { to { opacity: 1; } }

.tabs { margin-bottom: 14px; }
.panel { padding: 16px; }
.panel + .panel { margin-top: 14px; }
.panel h4 { margin: 0 0 12px; font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1.5px var(--line-2); transition: transform .2s var(--spring), box-shadow .2s; }
.swatch.on { box-shadow: 0 0 0 2.5px var(--ink); transform: scale(1.08); }
.sym-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sym-grid button { aspect-ratio: 1; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; display: grid; place-items: center; transition: all .2s var(--ease); padding: 6px; }
.sym-grid button:hover { border-color: var(--accent); transform: translateY(-2px); }
.sym-grid svg { width: 60%; height: 60%; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sym-grid small { font-size: 10px; color: var(--muted); }
.el-list { list-style: none; margin: 0; padding: 0; }
.el-list li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 12px; cursor: pointer; }
.el-list li.on { background: var(--accent-soft); }
.el-list li .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.el-list .k { font-family: var(--mono); font-size: 10px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; width: 52px; }
.uploader { border: 2px dashed var(--line-2); border-radius: 16px; padding: 18px; text-align: center; color: var(--muted); transition: all .2s; cursor: pointer; display: block; }
.uploader:hover, .uploader.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.img-strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; }
.img-strip button { width: 56px; height: 56px; flex: none; border-radius: 10px; border: 1.5px solid var(--line); background: var(--carta) center/contain no-repeat; }

details.acc { border-top: 1px solid var(--line); }
details.acc:first-of-type { border-top: 0; }
details.acc summary { list-style: none; cursor: pointer; padding: 13px 2px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: ''; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .3s var(--ease); margin-right: 4px; }
details.acc[open] summary::after { transform: rotate(-135deg); }
details.acc .body { padding: 2px 2px 14px; animation: fadeUp .35s var(--ease); }
.alerts { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.alert { padding: 10px 12px; border-radius: 12px; font-size: 13px; background: var(--warn-bg); color: var(--warn); animation: fadeUp .3s var(--ease); }
.alert.err { background: var(--err-bg); color: var(--err); }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.stat b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.stat span { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* ---------- 3D, scena, export ---------- */
.view3d { position: relative; height: min(60vh, 620px); min-height: 360px; border-radius: 24px; overflow: hidden; border: 1px solid var(--line); }
.view3d .gl { display: block; width: 100%; height: 100%; cursor: grab; }
.view3d .gl:active { cursor: grabbing; }
.view3d .hint { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); font-size: 12px; color: #6F6B64; background: rgba(255,255,255,.75); padding: 5px 12px; border-radius: 999px; pointer-events: none; transition: opacity .6s; }
.bg-inchiostro { background: #1C1D21; } .bg-crema { background: #F1EEE7; } .bg-ghiaccio { background: #E8F4F8; } .bg-bianco { background: #fff; } .bg-grafite { background: #2B2D31; }
.bg-grafite .hint, .bg-inchiostro .hint { background: rgba(255,255,255,.08); color: var(--muted); }
.float-card { position: relative; margin: -70px auto 0; max-width: 760px; padding: 16px 18px; z-index: 2; animation: fadeUp .6s .15s var(--ease) both; }
@media (max-width: 640px) { .float-card { margin-top: -40px; } }
.dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dim label { display: block; font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.dim .in { position: relative; }
.dim input { font-size: 22px; font-weight: 800; letter-spacing: -.02em; padding: 10px 40px 10px 12px; font-variant-numeric: tabular-nums; }
.dim .u { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 11px; color: var(--muted); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.card-head b { font-size: 15px; }
.tool-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tool-row + .tool-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; flex: none; transition: transform .2s var(--spring); }
.play:active { transform: scale(.9); }
.play svg { width: 18px; height: 18px; }
.slider-wrap { flex: 1; display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; min-width: 200px; }
.bgsw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1.5px var(--line-2); }
.bgsw.on { box-shadow: 0 0 0 2.5px var(--ink); }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.exp-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.exp-actions .btn { justify-content: flex-start; padding: 14px 16px; border-radius: 16px; }

/* ---------- Navigazione a pillola ---------- */
.nav { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 35; display: flex; gap: 2px; padding: 6px; background: var(--nav-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-lg); }
.nav .ind { position: absolute; top: 6px; bottom: 6px; left: 6px; border-radius: 999px; background: var(--ink); transition: transform .45s var(--spring), width .45s var(--spring); z-index: 0; }
.nav button { position: relative; z-index: 1; border: 0; background: none; display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--ink-2); transition: color .3s; }
.nav button.on { color: var(--on-ink); }
.nav button svg { width: 18px; height: 18px; }
@media (max-width: 720px) { .nav button { padding: 10px 12px; } .nav button span { display: none; } .nav button.on span { display: inline; } }

/* ---------- Overlay (archivio, admin, progetto) ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: var(--overlay); backdrop-filter: blur(4px); display: flex; justify-content: flex-end; animation: fadeIn .25s forwards; opacity: 0; }
.sheet { width: min(1100px, 100%); height: 100%; background: var(--bg); background-image: radial-gradient(var(--dot) 1.1px, transparent 1.2px); background-size: 18px 18px; overflow: auto; padding: 22px clamp(14px, 3vw, 32px) 40px; animation: slideIn .45s var(--ease); box-shadow: var(--shadow-lg); }
.sheet.narrow { width: min(520px, 100%); }
@keyframes slideIn { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.arch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.proj { padding: 10px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); animation: cardIn .45s var(--ease) both; animation-delay: calc(var(--k, 0) * 30ms); display: flex; flex-direction: column; }
.proj .ph { aspect-ratio: 1; border-radius: 12px; background: var(--surface) center/cover no-repeat; margin-bottom: 10px; cursor: pointer; }
.proj .meta { font-size: 12px; color: var(--muted); }
.proj .ttl { font-weight: 700; margin: 2px 0; }
.proj .acts { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; align-items: center; }
.proj .acts select { flex: 1; min-width: 0; }
.st-bozza { background: var(--surface-2); color: var(--ink-2); } .st-approvato { background: var(--accent-soft); color: var(--accent-ink); }
.st-in_produzione { background: var(--warn-bg); color: var(--warn); } .st-prodotto { background: var(--ok-bg); color: var(--ok); } .st-archiviato { background: var(--surface); color: var(--muted); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-family: var(--mono); font-weight: 500; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: var(--card); }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl-wrap { max-height: 60vh; overflow: auto; border-radius: 16px; border: 1px solid var(--line); background: var(--card); }
.log { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.log time { color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; }

/* ---------- Toast e modali ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 30px); transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--on-ink); padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toastIn .45s var(--spring); display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--err); color: var(--on-ink); }
.toast.ok::before { content: ''; width: 16px; height: 16px; border-radius: 50%; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%23141518' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center/contain; }
.toast.out { animation: toastOut .3s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }
.modal-bg { position: fixed; inset: 0; z-index: 95; background: var(--modal-bg); display: grid; place-items: center; padding: 20px; animation: fadeIn .2s forwards; opacity: 0; }
.modal { width: min(440px, 100%); padding: 22px; animation: pop .3s var(--spring); }
.modal h3 { margin: 0 0 8px; font-size: 22px; font-weight: 800; letter-spacing: -.03em; }
.modal p { color: var(--ink-2); margin: 0 0 16px; }
.modal .row { justify-content: flex-end; }
.modal .row > * { flex: none; }

/* ---------- Utilità ---------- */
.muted { color: var(--muted); }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.spacer { flex: 1; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 5px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; } }
@media print { .nav, .app-head, .toasts { display: none; } }
@media (max-width: 560px) {
  .app-head { gap: 6px; }
  #undoBtn, #redoBtn { display: none; }
  .proj-chip button { padding: 6px 10px; }
  .proj-chip .ttl { max-width: 110px; }
  #saveBtn span { display: none; }
  #saveBtn { width: 40px; height: 40px; padding: 0; }
}
.exp-actions .btn { white-space: normal; text-align: left; line-height: 1.25; }

.hint { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.3; margin-top: 1px; }
.hint.bad { color: var(--err); font-weight: 600; animation: fadeUp .25s var(--ease); }
.field.bad input, .dim.bad input { border-color: var(--err); box-shadow: 0 0 0 4px rgba(255,90,90,.14); }
.dim .hint { margin-top: 5px; }

.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-top: 8px; max-height: 220px; overflow: auto; }
.img-cell { position: relative; }
.img-add { width: 100%; aspect-ratio: 1; border-radius: 12px; border: 1.5px solid var(--line); background: var(--carta) center/contain no-repeat; transition: border-color .2s, transform .2s var(--ease); }
.img-add:hover { border-color: var(--accent); transform: translateY(-2px); }
.img-del { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: var(--on-ink); font-size: 14px; line-height: 1; opacity: 0; transition: opacity .2s; }
.img-cell:hover .img-del, .img-del:focus { opacity: 1; }
@media (hover: none) { .img-del { opacity: .85; } }

/* ---------- iKUTX: dettagli di brand ---------- */
::selection { background: var(--arancio); color: var(--inchiostro); }
.splash { background-color: var(--bg); }
.app-head .logo { gap: 12px; }
.app-head .logo .tag { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line-2); }
@media (max-width: 900px) { .app-head .logo .tag { display: none; } }
.card .stage { border-radius: inherit; }
.stage .toolbar .btn { background: var(--inchiostro); color: var(--carta); border-color: var(--inchiostro); }
.stage .toolbar .btn.btn-accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
.tpl .badge { background: var(--badge-bg); color: var(--ink-2); border: 1px solid var(--line-2); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* ---------- Loghi per tema ---------- */
.logo-notte { display: none !important; }
:root[data-theme="dark"] .logo-giorno { display: none !important; }
:root[data-theme="dark"] .logo-notte { display: block !important; }
.app-head .logo .simbolo { display: none !important; }
@media (max-width: 560px) {
  .app-head .logo .full { display: none !important; }
  .app-head .logo .simbolo.logo-giorno { display: block !important; }
  :root[data-theme="dark"] .app-head .logo .simbolo.logo-giorno { display: none !important; }
  :root[data-theme="dark"] .app-head .logo .simbolo.logo-notte { display: block !important; }
}
.menu-pop .tema { padding: 8px 12px 10px; border-top: 1px solid var(--line); margin-top: 4px; }
.menu-pop .tema .lbl { display: block; margin-bottom: 6px; }
.menu-pop .tema .seg button { display: inline-flex; justify-content: center; gap: 6px; padding: 7px 10px; width: auto; }
@media (min-width: 720px) { #libCats.pills { flex-wrap: wrap; overflow: visible; } }
