:root {
  --bg-primary: #0f0f11;
  --bg-secondary: #1a1a1f;
  --bg-tertiary: #242429;
  --bg-input: #1e1e24;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.16);
  --text-primary: #f0f0f2;
  --text-secondary: #9898a6;
  --text-muted: #5a5a68;
  --accent: #7c5cfc;
  --accent-hover: #9b7ffe;
  --accent-soft: rgba(124,92,252,0.12);
  --accent-soft-hover: rgba(124,92,252,0.22);
  --green: #22c55e;
  --green-soft: rgba(34,197,94,0.12);
  --yellow: #eab308;
  --red: #ef4444;
  --red-soft: rgba(239,68,68,0.12);
  --radius-sm: 4px;
  --radius-md: 4px;
  --radius-lg: 4px;
  --radius-xl: 4px;
  --shadow: 0 1px 2px rgba(0,0,0,0.4);
  --transition: 0.18s ease;
}

[data-theme="light"] {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #ebebed;
  --bg-input: #f9f9fb;
  --border: rgba(0,0,0,0.08);
  --border-hover: rgba(0,0,0,0.16);
  --text-primary: #111113;
  --text-secondary: #6b6b78;
  --text-muted: #a0a0ad;
  --accent: #6d48f0;
  --accent-hover: #5535d4;
  --accent-soft: rgba(109,72,240,0.08);
  --accent-soft-hover: rgba(109,72,240,0.14);
  --green: #16a34a;
  --green-soft: rgba(22,163,74,0.1);
  --yellow: #ca8a04;
  --red: #dc2626;
  --red-soft: rgba(220,38,38,0.1);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 1px rgba(0,0,0,0.04);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4rem 1rem 4rem;
  transition: background var(--transition), color var(--transition);
}

/* Icons */
.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
  margin-bottom: 2rem;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 18px;
}

h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Theme switcher */
.theme-switcher {
  display: flex;
  background: var(--bg-tertiary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.theme-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 16px;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

.theme-btn:hover:not(.active) { color: var(--text-secondary); }

/* Card */
.card {
  background: var(--bg-secondary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
}

/* Password display */
.password-display {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  margin-bottom: 1rem;
  position: relative;
  transition: border-color var(--transition);
}

.password-display:hover { border-color: var(--border-hover); }

.password-text {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  word-break: break-all;
  line-height: 1.5;
  min-height: 2rem;
  padding-right: 3rem;
}

.password-actions {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.icon-btn {
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn.copied {
  color: var(--green);
}

/* Strength bar */
.strength-bar-container { margin-bottom: 1.25rem; }

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

.strength-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.strength-value {
  font-size: 12px;
  font-weight: 600;
  transition: color var(--transition);
}

.strength-track {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1), background 0.3s ease;
}

/* Length */
.length-section { margin-bottom: 1.25rem; }

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

.section-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.length-value-pill {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

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

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 0 0 1px var(--accent);
  transition: transform var(--transition), box-shadow var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 0 0 1px var(--accent);
}

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

.option-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.option-toggle:hover { border-color: var(--border-hover); }

.option-toggle.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.toggle-icon {
  font-size: 18px;
  color: var(--text-muted);
  transition: color var(--transition);
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.option-toggle.active .toggle-icon { color: var(--accent); }

.toggle-text { flex: 1; }

.toggle-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.option-toggle.active .toggle-name { color: var(--text-primary); }

.toggle-example {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
}

.toggle-check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  transition: all var(--transition);
  flex-shrink: 0;
}

.option-toggle.active .toggle-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Divider */
.divider {
  height: 0.5px;
  background: var(--border);
  margin-bottom: 1.25rem;
}

/* Exclude */
.exclude-section { margin-bottom: 1.25rem; }

.exclude-label { margin-bottom: 8px; }

.exclude-input-wrap { position: relative; }

.exclude-input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px 9px 36px;
  font-size: 14px;
  font-family: 'SF Mono', monospace;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}

.exclude-input::placeholder { color: var(--text-muted); }

.exclude-input:focus {
  border-color: var(--accent);
  background: var(--bg-input);
}

.exclude-input-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
  display: flex;
}

/* Generate button */
.generate-btn {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition);
  letter-spacing: -0.01em;
}

.generate-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.generate-btn:active { transform: scale(0.99) translateY(0); }

.generate-btn .icon { font-size: 18px; }

/* History */
.history-section {
  margin-top: 1rem;
  background: var(--bg-secondary);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.5rem;
  width: 100%;
  max-width: 520px;
}

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

.history-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 6px;
  transition: all var(--transition);
}

.clear-btn:hover { color: var(--red); background: var(--red-soft); }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.history-item:hover { background: var(--bg-tertiary); }

.history-pw {
  font-family: 'SF Mono', monospace;
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}

.history-copy {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 3px;
  border-radius: 5px;
  transition: all var(--transition);
  opacity: 0;
  display: flex;
}

.history-item:hover .history-copy { opacity: 1; }
.history-copy:hover { color: var(--accent); }

.empty-history {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 12px 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
  .options-grid { grid-template-columns: 1fr; }
  .password-text { font-size: 16px; }
}
