/* ═══════════════════════════════════════════════════════════
   Generatore di password — tema monocromatico (nero / bianco / grigio)
   ═══════════════════════════════════════════════════════════ */

:root {
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --t: 140ms cubic-bezier(.4, 0, .2, 1);
}

/* ── Chiaro ── */
[data-theme="light"] {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #f2f2f3;
  --surface-3: #e8e8ea;
  --border: #d9d9dc;
  --border-strong: #b4b4b8;
  --text: #0d0d0f;
  --text-dim: #4a4a50;
  --text-mute: #77777e;
  --inverse: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(0, 0, 0, .05);
  --focus: #0d0d0f;
  --lvl-1: #c9c9cc;
  --lvl-2: #a1a1a6;
  --lvl-3: #6d6d73;
  --lvl-4: #333338;
  --lvl-5: #0d0d0f;
}

/* ── Scuro ── */
[data-theme="dark"] {
  --bg: #0b0b0c;
  --surface: #141416;
  --surface-2: #1c1c1f;
  --surface-3: #26262a;
  --border: #2c2c31;
  --border-strong: #4a4a51;
  --text: #f4f4f5;
  --text-dim: #b6b6bc;
  --text-mute: #85858d;
  --inverse: #0b0b0c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .45);
  --focus: #f4f4f5;
  --lvl-1: #34343a;
  --lvl-2: #55555c;
  --lvl-3: #83838b;
  --lvl-4: #c2c2c8;
  --lvl-5: #ffffff;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 clamp(16px, 4vw, 32px) 64px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t), color var(--t);
}

.mono { font-family: var(--mono); font-variant-ligatures: none; }
.muted { color: var(--text-mute); font-style: normal; }

code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--surface-3);
  border-radius: 5px;
  padding: .1em .38em;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  background: var(--text); color: var(--inverse);
  padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0; text-decoration: none;
}
.skip-link:focus { left: 0; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Intestazione ── */
.site-header {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 34px) 0 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; gap: 13px; align-items: center; }

.brand-mark {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: none;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
}

.site-header h1 { margin: 0; font-size: clamp(19px, 3.4vw, 23px); letter-spacing: -.02em; font-weight: 650; }
.brand-sub { margin: 1px 0 0; font-size: 13px; color: var(--text-mute); }

main { max-width: 860px; margin: 0 auto; display: grid; gap: 18px; }

/* ── Banner ── */
.banner {
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  font-size: 14px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 24px);
  box-shadow: var(--shadow);
  transition: background-color var(--t), border-color var(--t);
}

.card h2 { margin: 0 0 4px; font-size: 15px; font-weight: 650; letter-spacing: .01em; }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 16px;
}
.card-head h2 { margin: 0; }

.card-output { padding: clamp(16px, 3vw, 22px); }

/* ── Output ── */
.output-row { display: flex; gap: 12px; align-items: stretch; }

.password {
  flex: 1 1 auto;
  min-width: 0;
  display: flex; align-items: center;
  min-height: 72px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: clamp(17px, 3.2vw, 25px);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: .01em;
  word-break: break-all;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: copy;
  transition: background-color var(--t), border-color var(--t);
  user-select: all;
}
.password:hover { border-color: var(--border-strong); }
.password:empty::before { content: "—"; color: var(--text-mute); font-weight: 400; }

.output-actions { display: flex; gap: 8px; flex: none; }

/* ── Bottoni ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 550;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--t), border-color var(--t), color var(--t), opacity var(--t);
}
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-solid { background: var(--text); color: var(--inverse); }
.btn-solid:hover:not(:disabled) { background: var(--text-dim); }

.btn-outline { border-color: var(--border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--surface-3); }

.btn-ghost { color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px 12px; }
.btn-icon-only { padding: 10px; }
.btn-icon-only svg { flex: none; }
.btn-icon svg { flex: none; }
.btn-text { display: inline-block; min-width: 3.6em; text-align: left; }

[data-theme="light"] .icon-moon,
[data-theme="dark"] .icon-sun { display: none; }

/* ── Misuratore di forza ── */
.meter-block { margin-top: 16px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; }

.strength-label { font-size: 13.5px; font-weight: 600; }
.strength-bits { font-size: 12.5px; color: var(--text-mute); }

.meter {
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.meter::after {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg, var(--surface) 0 1px, transparent 1px 33.4%);
  opacity: .55;
}
.meter-fill {
  height: 100%; width: 0;
  border-radius: 999px;
  background: var(--lvl-1);
  transition: width 220ms ease, background-color 220ms ease;
}
.meter-fill.lvl-1 { background: var(--lvl-1); }
.meter-fill.lvl-2 { background: var(--lvl-2); }
.meter-fill.lvl-3 { background: var(--lvl-3); }
.meter-fill.lvl-4 { background: var(--lvl-4); }
.meter-fill.lvl-5 { background: var(--lvl-5); }
.meter-fill.lvl-0 { background: repeating-linear-gradient(45deg, var(--lvl-1) 0 4px, var(--surface-3) 4px 8px); }

.meter-note { margin: 9px 0 0; font-size: 13px; color: var(--text-dim); }

/* ── Campi ── */
.pane { display: grid; gap: 18px; }
.pane[hidden] { display: none; }

.fieldset { border: 0; margin: 0; padding: 0; }
.fieldset legend {
  padding: 0; margin-bottom: 10px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-mute);
}

.field-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-grow { flex: 1 1 220px; min-width: 0; }
.field-sm { flex: 0 0 auto; min-width: 150px; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
label, .field > label, .field-head label { font-size: 13.5px; font-weight: 550; }

.text-input, .num-input, select.text-input {
  font: inherit; font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
  transition: border-color var(--t), background-color var(--t);
}
.text-input::placeholder { color: var(--text-mute); }
.text-input:hover, .num-input:hover { border-color: var(--border-strong); }
.text-input:focus, .num-input:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }

select.text-input { appearance: none; cursor: pointer; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.num-input { width: 68px; text-align: center; padding: 6px 4px; font-size: 13.5px; }

.help { margin: 0; font-size: 12.5px; color: var(--text-mute); }
.help.warn { color: var(--text-dim); font-weight: 550; }

/* ── Slider ── */
input[type="range"] {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 22px; background: none; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px;
  border-radius: 50%; background: var(--text); border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  transition: transform var(--t);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text); border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--focus); outline-offset: 2px; }

.ticks { position: relative; height: 15px; font-size: 11px; color: var(--text-mute); font-family: var(--mono); }
.ticks span { position: absolute; top: 0; white-space: nowrap; }

/* ── Checkbox ── */
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 20px; }

.check, .switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.check input, .switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.box {
  flex: none; width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-2);
  display: grid; place-items: center;
  transition: background-color var(--t), border-color var(--t);
}
.check input:checked + .box { background: var(--text); border-color: var(--text); }
.check input:checked + .box::after {
  content: ""; width: 9px; height: 5px;
  border: 2px solid var(--inverse); border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}
.check input:focus-visible + .box, .switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.check:hover .box { border-color: var(--text-mute); }

.check-text { color: var(--text-dim); }
.check input:checked ~ .check-text { color: var(--text); }

.switch { gap: 9px; font-size: 13.5px; color: var(--text-dim); }
.switch-track {
  position: relative; flex: none; width: 38px; height: 21px;
  border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--border); transition: background-color var(--t), border-color var(--t);
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: transform var(--t);
}
.switch input:checked + .switch-track { background: var(--text); border-color: var(--text); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(17px); }
.switch-sm .switch-track { width: 34px; height: 19px; }
.switch-sm .switch-thumb { width: 13px; height: 13px; }
.switch-sm input:checked + .switch-track .switch-thumb { transform: translateX(15px); }

/* ── Tab ── */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border-radius: 10px;
}
.tab {
  font: inherit; font-size: 13.5px; font-weight: 550;
  padding: 7px 15px; border: 0; border-radius: 7px;
  background: none; color: var(--text-dim); cursor: pointer;
  transition: background-color var(--t), color var(--t);
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ── Lote ── */
.inline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-field { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-mute); }

.bulk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bulk-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  word-break: break-all;
}
.bulk-list .bulk-index { color: var(--text-mute); font-size: 11.5px; min-width: 2.2em; text-align: right; flex: none; }
.bulk-list .bulk-pw { flex: 1 1 auto; min-width: 0; }
.bulk-list .bulk-bits { color: var(--text-mute); font-size: 11.5px; flex: none; }
.bulk-empty { padding: 14px; color: var(--text-mute); font-size: 13.5px; text-align: center; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); }

/* ── Verificatore ── */
.input-action { display: flex; gap: 8px; align-items: center; }
.input-action .text-input { flex: 1 1 auto; }
.check-result { margin-top: 16px; }
.notes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.notes li { display: flex; gap: 8px; color: var(--text-dim); }
.notes li::before { content: "–"; color: var(--text-mute); flex: none; }
.notes li.ok::before { content: "✓"; }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 30;
  display: flex; align-items: center; gap: 9px;
  padding: 11px 18px;
  background: var(--text); color: var(--inverse);
  border-radius: 999px; font-size: 14px; font-weight: 550;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
  animation: toast-in 180ms ease;
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ── Piè di pagina ── */
.site-footer { color: var(--text-dim); font-size: 13px; max-width: 70ch; }
.site-footer p { margin: 0 0 10px; }
.site-footer p:last-child { margin-bottom: 0; }

/* ── Responsive ── */
@media (max-width: 620px) {
  .output-row { flex-direction: column; }
  .output-actions { justify-content: stretch; }
  .output-actions .btn-solid { flex: 1 1 auto; }
  .brand-sub { display: none; }
  .check-grid { grid-template-columns: 1fr; }
  .card-head { align-items: flex-start; }
  .input-action { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  .site-header, .card-output, .btn, .tabs, .site-footer { display: none; }
  .bulk-list li { background: none; }
}
