/* Titelschrift, selbst gehostet. */
@font-face {
  font-family: "Tesla";
  src: url("assets/fonts/TESLA.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Selbst gehostet, kein externer Request. SIL Open Font License. */
@font-face {
  font-family: "JetBrains Mono";
  src: url("assets/fonts/JetBrainsMono-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1b1d21;
  --muted: #6b7280;
  --line: #e3e5ea;
  --accent: #2f6fed;
  --accent-soft: #e8efff;
  --field: #f7f8fa;
  --shadow: 0 1px 2px rgba(16, 20, 30, .06), 0 12px 32px rgba(16, 20, 30, .08);
  --weak: #d94b4b;
  --ok: #d98b25;
  --good: #2f9e57;
}

/* Systemvorgabe: greift, solange nicht ausdruecklich "hell" gewaehlt wurde. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #14161a;
  --card: #1c1f25;
  --text: #eceef2;
  --muted: #9aa1ad;
  --line: #2c3038;
  --accent: #6b9bff;
  --accent-soft: #23304a;
  --field: #23272e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
  --weak: #f07070;
  --ok: #e0a44a;
  --good: #5fc98a;
  }
}

/* Ausdrueckliche Wahl im Umschalter oben rechts. */
:root[data-theme="dark"] {
  --bg: #14161a;
  --card: #1c1f25;
  --text: #eceef2;
  --muted: #9aa1ad;
  --line: #2c3038;
  --accent: #6b9bff;
  --accent-soft: #23304a;
  --field: #23272e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
  --weak: #f07070;
  --ok: #e0a44a;
  --good: #5fc98a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 32px 16px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.card {
  width: 100%;
  max-width: 540px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
}

h1 {
  margin: 0 0 6px;
  font-family: "Tesla", system-ui, sans-serif;
  font-size: 34px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: .01em;
}
.sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }

/* --- Ausgabe --- */
.output { margin-bottom: 26px; }

.password {
  display: block;
  width: 100%;
  padding: 18px 16px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  font: 600 21px/1.35 "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  word-break: break-all;
  text-align: center;
  user-select: all;
}

.output-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  flex: 1;
  min-height: 44px;
  touch-action: manipulation;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); }

.meta {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
}
.dot { opacity: .5; }

.strength {
  margin-top: 8px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
.strength-bar {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--weak);
  transition: width .25s ease, background .25s ease;
}

.hint {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
}

/* --- Bedienelemente --- */
.controls { display: grid; gap: 16px; }

.row {
  display: grid;
  grid-template-columns: 130px 1fr 34px;
  align-items: center;
  gap: 12px;
}
.row label { font-size: 14px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 40px;              /* Trefferflaeche fuer den Finger, optisch unsichtbar */
  background: transparent;
  outline-offset: 4px;
  touch-action: manipulation;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: var(--line);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  margin-top: -7px;          /* zentriert den Griff auf dem 4px-Strich */
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--card);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--card);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
}

.num {
  font: 600 14px/1 "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  text-align: right;
  color: var(--muted);
}

.chips {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 4px 0 0;
}
.chips legend { padding: 0 6px; font-size: 13px; color: var(--muted); }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  position: relative;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  font: 600 15px/1 "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  cursor: pointer;
  user-select: none;
  transition: background .12s, border-color .12s, color .12s;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:hover { border-color: var(--accent); }
.chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.custom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}
.custom input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  color: var(--text);
  font: 600 15px/1 "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
.custom input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.check { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.foot {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}
.foot code {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
}

@media (max-width: 460px) {
  body { padding: 16px 12px; }
  .card { padding: 18px; }
  .head { padding: 0 44px; }
  h1 { font-size: 28px; }
  .row { grid-template-columns: 104px 1fr 26px; gap: 8px; }
  .password { font-size: 17px; padding: 16px 12px; }
  .formula { font-size: 11px; }
  .chips { padding: 12px; }
  .chip { min-width: 44px; height: 44px; }
  .custom { flex-direction: column; align-items: stretch; gap: 6px; }
  .output-actions { gap: 8px; }
}

.formula {
  margin: 10px 0 0;
  text-align: center;
  font: 600 12px/1.4 "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color: var(--muted);
  opacity: .85;
  word-break: break-word;
}

.meta span[title] { border-bottom: 1px dotted var(--muted); cursor: help; }

/* --- Kopfzeile mit Design-Umschalter --- */
.head {
  position: relative;
  text-align: center;
  padding: 0 48px;
  margin-bottom: 24px;
}
.head .sub { margin-bottom: 0; }

.theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.theme-toggle .icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
}
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }

/* Angezeigt wird das Ziel des Klicks: Mond im hellen, Sonne im dunklen Design. */
.icon-sun { display: none; }
.icon-moon { display: block; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* Fallback ohne JavaScript: Systemvorgabe. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

.foot { text-align: center; }
