:root {
  --bg: #16141c;
  --bg2: #1f1b2a;
  --card: #26213a;
  --line: #3a3352;
  --text: #f1eefc;
  --muted: #a9a2c4;
  --accent: #6d4aff;
  --accent-h: #7d5cff;
  --digit: #4fb3ff;
  --symbol: #3ed9a8;
  --vulnerable: #ff5e6c;
  --weak: #ffb547;
  --strong: #2ecc8f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #3b2a7a 0%, var(--bg) 60%);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar { padding: 18px 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; color: var(--text); }
.brand svg { color: var(--accent-h); }
.brand b { color: var(--accent-h); }

main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 20px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; column-gap: 20px; align-items: stretch; }
.main-col { display: contents; }
.main-col .hero { grid-column: 1; grid-row: 1; text-align: left; margin: 0 0 22px; }
.main-col .hero p { margin: 0; }
.gen-card { grid-column: 1; grid-row: 2; }
.layout > .side { grid-column: 2; grid-row: 2; }
.side .rating { flex: 1; }
.side .rating .gauge { margin-top: auto; }
.side .rating .entropy { margin-bottom: auto; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; row-gap: 20px; }
  .layout > .side { grid-column: 1; grid-row: 3; }
}

/* ---------- Classificação de segurança ---------- */
.rating { display: flex; flex-direction: column; }
.side { display: flex; flex-direction: column; gap: 16px; }
.side .info { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.rating h2 { font-size: 20px; font-weight: 600; margin-bottom: 24px; }
.gauge { position: relative; width: 100%; max-width: 240px; margin: 10px auto 6px; }
.gauge svg { width: 100%; display: block; overflow: visible; }
.gauge-track, .gauge-fill { fill: none; stroke-width: 26; }
.gauge-track { stroke: var(--line); }
.gauge-fill { transition: stroke-dasharray .45s ease, stroke .3s; }
.gauge-fill.g-vulnerable { stroke: var(--vulnerable); }
.gauge-fill.g-weak { stroke: var(--weak); }
.gauge-fill.g-strong { stroke: var(--strong); }
.gauge-label {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  padding: 5px 14px; border-radius: 7px; font-weight: 700; font-size: 15px; white-space: nowrap;
  transition: background .3s;
}
.gauge-label.g-vulnerable { background: var(--vulnerable); color: #fff; }
.gauge-label.g-weak { background: var(--weak); color: #3a2600; }
.gauge-label.g-strong { background: var(--strong); color: #04281a; }
.rating hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0 20px; }
.crack { text-align: center; font-size: 17px; color: var(--muted); line-height: 1.4; }
.crack b { color: var(--text); }
.entropy { text-align: center; font-size: 13px; margin-top: 8px; }

/* ---------- Senha editável ---------- */
.password { outline: none; cursor: text; min-height: 1.4em; }
.output { transition: border-color .2s, box-shadow .2s; }
.output:focus-within { border-color: var(--accent-h); box-shadow: 0 0 0 3px rgba(109, 74, 255, .25); }
.edit-hint { color: var(--muted); flex-shrink: 0; opacity: .6; }
.output:focus-within .edit-hint { color: var(--accent-h); opacity: 1; }
.hint { font-size: 13px; margin: 8px 2px 18px; }

.hero { text-align: center; margin: 20px 0 32px; }
.hero h1 { font-size: clamp(30px, 5vw, 44px); margin-bottom: 12px; }
.hero p { color: var(--muted); line-height: 1.55; max-width: 560px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

.output {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px;
  min-height: 82px;
}
.password {
  flex: 1;
  font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 24px;
  word-break: break-all;
  line-height: 1.4;
}
.password.long { font-size: 18px; }
.c-digit { color: var(--digit); }
.c-symbol { color: var(--symbol); }

.icon-btn {
  background: transparent; border: 0; color: var(--muted);
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--line); color: var(--text); }
.icon-btn.spin svg { animation: spin .45s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

.strength { margin: 16px 2px 20px; }
.bar { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; transition: width .3s, background .3s; border-radius: 6px; }
.strength-info { display: flex; justify-content: space-between; margin-top: 8px; font-size: 14px; }
.muted { color: var(--muted); }
.s-vulnerable { color: var(--vulnerable); background-color: var(--vulnerable); }
.s-weak { color: var(--weak); background-color: var(--weak); }
.s-strong { color: var(--strong); background-color: var(--strong); }
#strength-label { background: none; font-weight: 600; }

.primary {
  width: 100%; padding: 15px; font-size: 16px; font-weight: 600;
  background: var(--accent); color: #fff; border: 0; border-radius: 12px; cursor: pointer;
  transition: background .2s, transform .1s;
}
.primary:hover { background: var(--accent-h); }
.primary:active { transform: scale(.99); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.secondary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 15px; font-size: 16px; font-weight: 600;
  background: transparent; color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; cursor: pointer; transition: background .2s, border-color .2s, transform .1s;
}
.secondary:hover { background: var(--line); border-color: var(--accent-h); }
.secondary:active { transform: scale(.99); }
.secondary.spin svg { animation: spin .45s ease; }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--bg2); padding: 5px; border-radius: 12px; margin: 26px 0 20px;
}
.tab {
  padding: 11px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-size: 15px; cursor: pointer; transition: all .2s;
}
.tab.active { background: var(--line); color: var(--text); font-weight: 600; }

.options { display: flex; flex-direction: column; gap: 4px; }
.hidden { display: none; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.value { font-weight: 700; color: var(--accent-h); font-variant-numeric: tabular-nums; }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  background: var(--line); border-radius: 6px; margin: 6px 0 16px; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-h); cursor: pointer; border: 3px solid #fff;
}
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent-h); border: 3px solid #fff; cursor: pointer;
}

select {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; cursor: pointer;
}
.select-row { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 6px; }

.toggle {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.toggle:last-child { border-bottom: 0; }
.toggle input { display: none; }
.toggle i {
  position: relative; width: 44px; height: 24px; background: var(--line);
  border-radius: 24px; transition: background .2s; flex-shrink: 0;
}
.toggle i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .2s;
}
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(20px); }

.info { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 36px 0; }
.info div { background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.info h3 { font-size: 16px; margin-bottom: 8px; }
.info p { color: var(--muted); font-size: 14px; line-height: 1.5; }
code { background: var(--bg2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; }
footer a { color: var(--accent-h); }

.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translate(-50%, 20px);
  background: var(--strong); color: #0b2a1e; font-weight: 600;
  padding: 12px 22px; border-radius: 10px; opacity: 0; pointer-events: none; transition: all .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .card { padding: 18px; }
  .password { font-size: 19px; }
}
