/*
 * Helles und dunkles Erscheinungsbild sind gleichwertig gepflegt: Die
 * Farbwerte sind so gewählt, dass Fließtext in beiden Fällen deutlich
 * über dem WCAG-AA-Kontrast liegt und auch die gedämpften Hinweistexte
 * noch bequem lesbar bleiben.
 */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-sunken: #f0f2f5;
  --surface-hover: #e6e9ef;
  --fg: #14161a;
  --fg-muted: #565e6e;
  --border: #dde1e8;
  --border-strong: #c3cad6;
  --accent: #1f5fd0;
  --accent-hover: #1a4fb0;
  --accent-active: #163f8c;
  --accent-fg: #ffffff;
  --accent-subtle: #eef3fd;
  /* --danger trägt Text auf hellem Grund, --danger-solid füllt Flächen.
     Beides muss getrennt bleiben: Was als Schriftfarbe gut lesbar ist,
     taugt selten als Hintergrund und umgekehrt. */
  --danger: #b42318;
  --danger-solid: #d92d20;
  --danger-solid-hover: #a91d14;
  --danger-solid-active: #8a1610;
  --danger-solid-fg: #ffffff;
  --danger-subtle: #fdf0ef;
  --success: #10653f;
  --success-subtle: #eef8f2;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 4%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-sunken: #1e222a;
    --surface-hover: #2b323e;
    --fg: #e9ecf2;
    --fg-muted: #a4acbb;
    --border: #2a2f39;
    --border-strong: #3a4150;
    --accent: #6f9bff;
    --accent-hover: #93b6ff;
    --accent-active: #b3ccff;
    --accent-fg: #0f1115;
    --accent-subtle: #1a2334;
    /* Auf dunklem Grund werden gefüllte Flächen heller statt dunkler:
       Abdunkeln würde sie im Hintergrund verschwinden lassen, statt eine
       Rückmeldung zu geben. Die Schrift darauf ist entsprechend dunkel. */
    --danger: #ff9b93;
    --danger-solid: #ff8a80;
    --danger-solid-hover: #ffb3ac;
    --danger-solid-active: #ffd0cb;
    --danger-solid-fg: #2b0f0c;
    --danger-subtle: #2e1a18;
    --success: #7ce0a6;
    --success-subtle: #16271e;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 1px 3px rgb(0 0 0 / 30%);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.page {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  flex: 1;
}

/* --- Kopfbereich --- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}

.brand svg {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--accent);
  flex: none;
}

.lang {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.lang button {
  border: none;
  background: none;
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
}

.lang button:hover {
  color: var(--fg);
}

.lang button.active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow);
}

/* --- Typografie --- */

h1 {
  font-size: 1.5rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.4;
  margin: 0 0 0.75rem;
}

p {
  margin: 0 0 1rem;
}

p:last-child {
  margin-bottom: 0;
}

.tagline {
  color: var(--fg-muted);
  margin-bottom: 1.75rem;
}

.lead {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

/* --- Karten --- */

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

.card + .card {
  margin-top: 1.25rem;
}

/* --- Formularelemente --- */

.field + .field {
  margin-top: 1.25rem;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.hint {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

textarea,
input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  resize: vertical;
  min-height: 9rem;
}

textarea::placeholder {
  color: var(--fg-muted);
  opacity: 0.85;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentcolor 50%),
    linear-gradient(135deg, currentcolor 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.25rem;
}

:where(textarea, input, select, button, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  outline-offset: 1px;
}

/* --- Schaltflächen --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.15rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.94rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.13s, border-color 0.13s, color 0.13s, transform 0.06s;
}

/* Beim Drücken sinkt die Fläche sichtbar ein - eine Rückmeldung, die
   unabhängig von der Farbwahrnehmung funktioniert. */
.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
}

.btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--border-strong);
}

/* Rahmen und Schrift wechseln mit: Eine reine Flächenänderung ist auf
   dunklem Grund kaum wahrnehmbar. */
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-secondary:active:not(:disabled) {
  background: var(--accent-subtle);
  border-color: var(--accent);
}

/*
 * Zwischenzustand der Löschen-Schaltfläche: fragt nach, bevor sie handelt.
 * Die Schriftfarbe steht in jeder Zustandsregel erneut - träfen doch
 * einmal beide Varianten zusammen, würde sie sonst von der sekundären
 * Schaltfläche überschrieben und stünde blau auf rotem Grund.
 */
.btn-danger {
  background: var(--danger-solid);
  border-color: var(--danger-solid);
  color: var(--danger-solid-fg);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-solid-hover);
  border-color: var(--danger-solid-hover);
  color: var(--danger-solid-fg);
}

.btn-danger:active:not(:disabled) {
  background: var(--danger-solid-active);
  border-color: var(--danger-solid-active);
  color: var(--danger-solid-fg);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-icon {
  transition: background-color 0.13s, color 0.13s, transform 0.06s;
}

.btn-icon:active {
  transform: translateY(1px);
}

.btn-block {
  width: 100%;
  margin-top: 1.5rem;
}

.btn-icon {
  border: none;
  background: none;
  color: var(--fg-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  cursor: pointer;
}

.btn-icon:hover {
  color: var(--danger);
  background: var(--danger-subtle);
}

/* --- Dateiauswahl --- */

.dropzone {
  display: block;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--fg-muted);
  background: var(--surface-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: grid;
  gap: 0.4rem;
}

.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.5rem 0.55rem 0.8rem;
  font-size: 0.9rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- Ergebnis: Links zum Kopieren --- */

/* Eingabefeld und Schaltflächen liegen in einem Raster, damit die
   Schaltflächen beider Zeilen exakt untereinander stehen. */
.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: stretch;
}

.copy-row input {
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--surface-sunken);
}

.copy-row input:disabled {
  color: var(--fg-muted);
  text-decoration: line-through;
}

/* Die feste Mindestbreite ist so bemessen, dass auch der längere
   Bestätigungstext hineinpasst - sonst würde das Layout in dem Moment
   springen, in dem die Schaltfläche nachfragt. */
.copy-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(9rem, 1fr));
  gap: 0.5rem;
}

.copy-actions .btn {
  padding-inline: 0.75rem;
}

/* --- Rückmeldungen --- */

.status {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--fg-muted);
}

progress {
  width: 100%;
  height: 6px;
  margin-top: 0.75rem;
  accent-color: var(--accent);
}

.notice,
.error,
.success {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid;
}

.notice {
  color: var(--fg-muted);
  background: var(--surface-sunken);
  border-color: var(--border);
}

.error {
  color: var(--danger);
  background: var(--danger-subtle);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  margin-bottom: 1.25rem;
}

/* Gelungene Aktionen bekommen einen eigenen Farbton. Rot bleibt
   Problemen vorbehalten - sonst wäre am Farbton nicht mehr abzulesen,
   ob etwas schiefging. */
.success {
  color: var(--success);
  background: var(--success-subtle);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

/*
 * Rot und Grün liegen in ihrer Helligkeit fast gleichauf. Bei einer
 * Rot-Grün-Sehschwäche - der häufigsten Form - wären beide Meldungen
 * allein am Farbton kaum auseinanderzuhalten. Das vorangestellte Zeichen
 * trägt die Unterscheidung unabhängig von der Farbwahrnehmung.
 */
.error::before,
.success::before {
  font-weight: 700;
  margin-right: 0.45rem;
}

.error::before {
  content: "✕";
}

.success::before {
  content: "✓";
}

.notice-spaced {
  margin-top: 1.25rem;
}

/* --- Angezeigte Nachricht --- */

.message-output {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0 0 1rem;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.55;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* --- Fußzeile --- */

footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem;
}

footer nav {
  max-width: 44rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 0.85rem;
}

footer a {
  color: var(--fg-muted);
  text-decoration: none;
}

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

/* --- Infoseite --- */

.prose h2 {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.prose section:first-of-type h2 {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.prose ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

.prose strong {
  font-weight: 650;
}

[data-lang-block] {
  display: none;
}

[data-lang-block].active {
  display: block;
}

/* Wird es schmal, rutschen die Schaltflächen unter das Eingabefeld -
   nebeneinander bliebe für den Link zu wenig Platz. */
@media (max-width: 40rem) {
  .copy-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 32rem) {
  .page {
    padding: 1.5rem 1rem;
  }

  .card {
    padding: 1.15rem;
  }
}
