:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-accent: #4f46e5;
  --color-accent-hover: #4338ca;
  --strength-weak: #ef4444;
  --strength-medium: #f97316;
  --strength-strong: #eab308;
  --strength-very-strong: #22c55e;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.25rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-accent);
  text-decoration: none;
}

.nav-link {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-decoration: none;
}

.nav-link:hover { color: var(--color-text); }

header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 2.5rem 1rem 2rem;
  text-align: center;
}

header h1 {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.tagline {
  color: var(--color-text-muted);
  margin-top: 0.4rem;
  font-size: 1rem;
}

main, footer, article {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

main { padding-top: 2rem; padding-bottom: 2rem; }

footer {
  text-align: center;
  margin-top: 1rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

/* Card */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* Tool layout */

.tool {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .tool { grid-template-columns: 1fr 1fr; }
}

/* Controls */

.control-group { margin-bottom: 1.25rem; }
.control-group:last-child { margin-bottom: 0; }

.control-group label,
.control-group legend {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.control-group fieldset { border: none; padding: 0; }

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

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
}

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 0.4rem;
  font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--color-accent);
}

select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.btn-generate {
  width: 100%;
  min-height: 46px;
  margin-top: 1rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.1s ease;
}

.btn-generate:hover { background: var(--color-accent-hover); }
.btn-generate:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* Output */

.output { min-height: 120px; }

.output-placeholder {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1.5rem 0;
}

.error-msg {
  color: var(--strength-weak);
  font-size: 0.9rem;
  font-weight: 600;
}

.password-entry { margin-bottom: 1rem; }
.password-entry:last-child { margin-bottom: 0; }

.password-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.password-text {
  flex: 1;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9rem;
  word-break: break-all;
  user-select: all;
}

.btn-copy {
  flex-shrink: 0;
  padding: 0.3rem 0.65rem;
  min-height: 34px;
  background: var(--color-surface);
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.1s ease, color 0.1s ease;
  white-space: nowrap;
}

.btn-copy:hover {
  background: var(--color-accent);
  color: #fff;
}

.btn-copy:disabled {
  background: var(--strength-very-strong);
  color: #fff;
  border-color: var(--strength-very-strong);
  cursor: default;
}

/* Strength meter */

.strength-meter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.strength-bar-track {
  flex: 1;
  height: 5px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}

.strength-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.strength-bar--weak        { width: 25%; background: var(--strength-weak); }
.strength-bar--medium      { width: 50%; background: var(--strength-medium); }
.strength-bar--strong      { width: 75%; background: var(--strength-strong); }
.strength-bar--very-strong { width: 100%; background: var(--strength-very-strong); }

.strength-label {
  font-size: 0.78rem;
  font-weight: 600;
  min-width: 72px;
}

.strength-label--weak        { color: var(--strength-weak); }
.strength-label--medium      { color: var(--strength-medium); }
.strength-label--strong      { color: #a16207; }
.strength-label--very-strong { color: var(--strength-very-strong); }

/* Ad units */

.ad-unit { width: 100%; min-height: 90px; background: transparent; margin: 1.5rem 0; }
.ad-unit--content { min-height: 250px; }

/* Content section */

.content-section { margin-top: 2rem; }

.content-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.content-section h2:first-child { margin-top: 0; }

.content-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.content-section p {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--color-text-muted);
}

code {
  background: #f1f5f9;
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.875em;
}

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

@media (prefers-reduced-motion: reduce) {
  .btn-generate, .btn-copy, .strength-bar { transition: none; }
}
