:root {
  --bg: #0f1117;
  --bg-soft: #171a23;
  --bg-card: #1b1f2b;
  --border: #2a2f3d;
  --text: #e6e8ee;
  --text-dim: #9aa3b5;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.12);
  --accent-hover: #6aa0ff;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 12px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}
.brand span { color: var(--accent); }
.nav-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.nav-links a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
}
.nav-links a:hover { color: var(--text); background: var(--bg-card); }
.nav-links a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Layout ---------- */
.main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}
.page-head { margin-bottom: 28px; }
.page-head h1 { font-size: 28px; letter-spacing: -0.4px; }
.page-head p { color: var(--text-dim); margin-top: 6px; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- Cards (homepage) ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: transform 0.15s ease, border-color 0.15s ease;
  display: block;
  color: var(--text);
}
.tool-card:hover { transform: translateY(-3px); border-color: var(--accent); color: var(--text); }
.tool-card .icon { font-size: 26px; }
.tool-card h3 { margin: 12px 0 6px; font-size: 18px; }
.tool-card p { color: var(--text-dim); font-size: 14px; }

/* ---------- Forms ---------- */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
}

label { font-size: 14px; color: var(--text-dim); }

textarea, input[type="text"], select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 12px;
  resize: vertical;
}
textarea:focus, input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 180px; line-height: 1.5; }

.input-row { margin-bottom: 16px; }
.input-row > label { display: block; margin-bottom: 6px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
  color: var(--text);
}
.check-row input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--bg-card); border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Output ---------- */
.output-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
  min-height: 80px;
}
.output-box:empty::before { content: "Output will appear here…"; color: var(--text-dim); }
.output-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

/* ---------- Alerts ---------- */
.alert {
  display: none;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid;
}
.alert.show { display: block; }
.alert-error { background: rgba(248, 113, 113, 0.1); border-color: var(--red); color: var(--red); }
.alert-success { background: rgba(52, 211, 153, 0.1); border-color: var(--green); color: var(--green); }

/* ---------- Range slider ---------- */
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row output {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 16px;
  min-width: 42px;
  text-align: right;
}

/* ---------- Strength meter ---------- */
.strength-wrap { margin-top: 12px; }
.strength-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 6px;
}
.strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: width 0.25s ease, background 0.25s ease;
}
.strength-label { font-size: 13px; color: var(--text-dim); }

/* ---------- Match highlighting ---------- */
.matches-list { margin-top: 12px; }
.match-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 13px;
}
.match-item:nth-child(odd) { background: var(--bg); }
.match-idx { color: var(--text-dim); min-width: 34px; font-size: 12px; }
.match-text { color: var(--green); word-break: break-all; }

.highlight-target {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  max-height: 260px;
  overflow: auto;
}
mark { background: var(--amber); color: #1a1500; border-radius: 3px; padding: 0 1px; }

/* ---------- Generated password list ---------- */
.pw-list { margin-top: 14px; }
.pw-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.pw-item code { font-family: var(--mono); font-size: 14px; word-break: break-all; }
.pw-item .btn { padding: 5px 10px; font-size: 12px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  background: var(--bg-soft);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .main { padding: 20px 14px 48px; }
  .page-head h1 { font-size: 22px; }
  .nav { height: auto; padding: 10px 14px; flex-direction: column; gap: 8px; }
  .nav-links { justify-content: center; }
}
