:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-contrast: #ffffff;
  --surface: #f8fafc;
  --border: #e2e8f0;
  --shadow: 0 12px 36px rgba(2, 6, 23, 0.12);
  --accent-start: #60a5fa;
  --accent-end: #34d399;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --fg: #e5e7eb;
    --muted: #9aa4b2;
    --primary: #60a5fa;
    --primary-contrast: #0b1220;
    --surface: #111827;
    --border: #253046;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
    --accent-start: #60a5fa;
    --accent-end: #34d399;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  color: var(--fg);
  background: radial-gradient(1200px 600px at 20% -10%, #93c5fd22, transparent 60%),
              radial-gradient(1000px 600px at 120% 10%, #a7f3d022, transparent 60%),
              var(--bg);
  line-height: 1.6;
}

.app-header {
  padding: 48px 16px 8px;
  text-align: center;
}

.app-title {
  margin: 0;
  font-size: 36px;
  letter-spacing: 0.6px;
}

.brand { display: inline-flex; align-items: center; gap: 12px; }
.logo { filter: drop-shadow(0 6px 16px rgba(96,165,250,.35)); }
.gradient-text {
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.app-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.app-main {
  display: grid;
  place-items: start center;
  padding: 24px 16px 40px;
}

.generator {
  width: min(920px, 100%);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), transparent 60%), var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 24px;
  backdrop-filter: blur(12px) saturate(120%);
}

.section-title {
  margin: 6px 0 16px;
  font-size: 18px;
}

.output-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.output {
  width: 100%;
  padding: 16px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 18px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.output:focus-visible {
  border-color: color-mix(in oklab, var(--primary) 65%, white 35%);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--primary) 35%, transparent 65%);
}

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

.strength {
  margin-top: 12px;
}

label[for="strength-meter"] {
  display: inline-block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

meter {
  width: 100%;
  height: 16px;
}

.strength-text {
  margin-top: 6px;
  font-size: 14px;
}

.strength-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.strength-bar {
  position: relative;
  width: 100%;
  height: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(0,0,0,0.06));
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.strength-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #ef4444, #f59e0b 20%, #10b981 60%, #22c55e 80%, #16a34a);
  border-radius: inherit;
  transition: width .3s ease;
}

.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;
}

.controls {
  margin-top: 18px;
  display: grid;
  gap: 16px;
}

fieldset {
  margin: 0;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
}

.length-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 12px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
}

input[type="number"],
input[type="text"],
input[type="password"],
input[type="search"],
textarea, select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.inline {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: center;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .06s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: var(--primary-contrast);
  border-color: transparent;
  box-shadow: 0 10px 30px rgba(96,165,250,0.35), 0 6px 18px rgba(52,211,153,0.25);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn.secondary {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-color: var(--border);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--primary) 35%, transparent 65%);
}

/* Button enhancements */
.btn.primary:hover {
  filter: brightness(1.02);
  transform: translateY(-1px);
}

.btn.secondary:hover {
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  transform: translateY(-1px);
}

/* Inputs focus-visible */
input[type="number"]:focus-visible,
input[type="text"]:focus-visible,
input[type="password"]:focus-visible,
input[type="search"]:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: color-mix(in oklab, var(--primary) 65%, white 35%);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--primary) 35%, transparent 65%);
}

.btn-icon { display: inline-flex; }
.btn-label { display: inline-block; }

.hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.app-footer {
  padding: 28px 16px 40px;
  text-align: center;
  color: var(--muted);
}

/* Larger screens typography tuning */
@media (min-width: 960px) {
  .app-title { font-size: 44px; }
  .section-title { font-size: 20px; }
  .generator { padding: 28px; }
}

@media (max-width: 520px) {
  .output-row {
    grid-template-columns: 1fr;
  }

  .length-row {
    grid-template-columns: 1fr 72px;
  }

  .inline {
    grid-template-columns: 1fr;
  }
}

