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

:root {
  --bg: #080c14;
  --surface: #0f1623;
  --surface-2: #161f30;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.14);
  --accent: #4ade80;
  --accent-dim: rgba(74,222,128,0.12);
  --accent-glow: rgba(74,222,128,0.25);
  --text: #e8edf5;
  --text-muted: #6b7a95;
  --text-dim: #3d4e68;
  --warn: #f59e0b;
  --warn-bg: rgba(245,158,11,0.08);
  --danger: #f87171;

  --font-display: 'Syne', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 10px;
  --radius-lg: 16px;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px 60px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(74,222,128,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74,222,128,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

/* Header */
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lock-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-dim);
  border: 1px solid rgba(74,222,128,0.2);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  flex: 1;
}

.counter-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* Result box */
.result-box {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.result-box:focus-within {
  border-color: var(--border-hover);
}

.result-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 13px 16px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.5px;
  min-width: 0;
}

.result-box input::placeholder {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0;
}

.result-actions {
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 2px;
}

.result-actions button {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.result-actions button:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text);
}

.result-actions button.copied {
  color: var(--accent);
}

/* Strength */
.strength-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.strength-bar-track {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
}

#bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.4s;
}

.strength-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

#feedback {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.3px;
}

#crack-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* Warning */
.warning-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--warn-bg);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--warn);
  line-height: 1.5;
}

.warning-box svg {
  flex-shrink: 0;
  margin-top: 1px;
  stroke: var(--warn);
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-row label {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 60px;
  font-family: var(--font-display);
}

.slider-wrap {
  flex: 1;
}

input[type=range] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--surface-2);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s;
  box-shadow: 0 0 0 4px var(--accent-dim);
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type=range]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.slider-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  min-width: 24px;
  text-align: right;
}

/* Options */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.opt-label {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.opt-label:hover {
  border-color: var(--border-hover);
}

.opt-label.full {
  grid-column: 1 / -1;
}

.opt-label input[type=checkbox] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

.opt-label input[type=checkbox]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.opt-label input[type=checkbox]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 1px;
  width: 8px;
  height: 5px;
  border-left: 2px solid #080c14;
  border-bottom: 2px solid #080c14;
  transform: rotate(-45deg);
}

.opt-text {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.3;
}

.opt-text em {
  display: block;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}

.opt-label:has(input:checked) .opt-text {
  color: var(--text);
}

.opt-label:has(input:checked) .opt-text em {
  color: var(--accent);
}

/* Generate button */
#generate {
  width: 100%;
  padding: 13px 20px;
  background: var(--accent);
  color: #080c14;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.2s, transform 0.15s;
}

#generate:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

#generate:active {
  transform: translateY(0);
}

#generate kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  background: rgba(0,0,0,0.15);
  border-radius: 4px;
  padding: 2px 6px;
  opacity: 0.7;
}

/* Scramble animation */
@keyframes scramble-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.result-box input.scrambling {
  animation: scramble-flash 0.06s ease-in-out;
}

/* History */
.history-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.history-header span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.history-header button {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
  padding: 0;
}

.history-header button:hover {
  color: var(--danger);
}

#history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  gap: 10px;
  animation: slide-in 0.2s ease;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hist-pass {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.hist-reuse {
  font-size: 10px;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 8px;
  cursor: pointer;
  font-family: var(--font-display);
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.hist-reuse:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Scrollbar */
#history-list::-webkit-scrollbar { width: 4px; }
#history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
