/* ---------- Tokens ---------- */
:root {
  --brand-1: #8c52ff;
  --brand-2: #ff914d;
  --brand-grad: linear-gradient(120deg, var(--brand-1), var(--brand-2));

  --bg: #f5f3fb;
  --surface: #ffffff;
  --surface-2: #f7f6fb;
  --border: #e6e3f0;
  --text: #1c1830;
  --muted: #6b6785;
  --focus: rgba(140, 82, 255, 0.35);

  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(28, 24, 48, 0.06), 0 12px 40px rgba(28, 24, 48, 0.12);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #110e1c;
    --surface: #1b1729;
    --surface-2: #231e35;
    --border: #322b4a;
    --text: #f1eefb;
    --muted: #a29cbd;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 40px rgba(0, 0, 0, 0.45);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* Brand gradient band behind the card */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 340px;
  background: var(--brand-grad);
  z-index: -1;
}

.shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.brand { margin-bottom: 24px; }

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.brand-link img {
  border-radius: 10px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

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

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 28px;
  color: var(--muted);
}

.lede code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  color: var(--text);
}

.foot {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Form ---------- */
.form { display: grid; gap: 26px; }

.field { display: grid; gap: 12px; }

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

label {
  font-weight: 600;
  font-size: 15px;
}

input[type="number"] {
  font: inherit;
  color: var(--text);
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Amount stepper */
.stepper {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.stepper input {
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  padding: 12px 0;
  min-width: 0;
}

.stepper input:focus { outline: none; }
.stepper:focus-within { box-shadow: 0 0 0 4px var(--focus); border-color: var(--brand-1); }

.step {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.step:hover { background: var(--border); color: var(--text); }

/* Value pill next to slider labels */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.pill input {
  width: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  text-align: center;
  font-weight: 700;
  padding: 3px 0;
}
.pill input:focus { outline: 2px solid var(--brand-1); }

/* Range slider */
input[type="range"] {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  margin: 0;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--brand-1), var(--brand-2)) 0 / var(--fill) 100% no-repeat,
    var(--border);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand-1);
  box-shadow: 0 2px 6px rgba(28, 24, 48, 0.25);
  transition: transform 0.15s;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand-1);
  box-shadow: 0 2px 6px rgba(28, 24, 48, 0.25);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s, filter 0.15s;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }
.btn:active { transform: translateY(1px); }

.btn svg, .icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-primary {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 6px 18px rgba(140, 82, 255, 0.3);
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 8px 24px rgba(140, 82, 255, 0.38); }

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  padding: 8px 14px;
  font-size: 14px;
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-block { width: 100%; padding: 15px 20px; font-size: 16px; margin-top: 4px; }

/* ---------- Results ---------- */
.results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.results-head .lede { margin-bottom: 20px; }

.toolbar { display: flex; gap: 8px; margin-bottom: 16px; }

.pw-list {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.pw-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 10px 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.pw-item:hover { border-color: var(--brand-1); }

.pw-index {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.pw-text {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 16px;
  overflow-wrap: anywhere;
  user-select: all;
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface); color: var(--brand-1); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.icon-btn.copied { color: #16a34a; }

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

/* ---------- Notices ---------- */
.notice {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #f5c2a8;
  background: #fff4ed;
  color: #8a3b12;
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  .notice { background: #2c1b14; border-color: #6b3a22; color: #ffc9a8; }
}
.notice[hidden] { display: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 999px;
  background: #1c1830;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .shell { padding-top: 20px; }
  .card { padding: 22px 18px; }
  h1 { font-size: 24px; }
  .pw-text { font-size: 14px; letter-spacing: -0.02em; }
  .pw-item { gap: 10px; padding-left: 10px; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; color: #000; }
  body::before, .brand, .foot, .no-print, .toast { display: none !important; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .pw-item { background: none; border: 1px solid #ccc; break-inside: avoid; }
  .pw-index { border-color: #ccc; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
