/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── CSS Variables ── */
:root {
  --brown:       #5B4A2F;
  --brown-dark:  #3e3220;
  --brown-light: #7a6248;
  --bg:          #f0ece4;
  --bg-dots:     #d8d2c6;
  --surface:     #ffffff;
  --surface-2:   #faf8f5;
  --border:      #e2ddd5;
  --text:        #2a2118;
  --text-muted:  #8a7d6e;
  --focus:       #5B4A2F;
  --radius:      12px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);
}

/* ── Basis ── */
html, body {
  height: 100%;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--bg-dots) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
}

/* ── Layout ── */
.wrapper {
  max-width: 110ch;
  margin: 0 auto;
  padding: 1.5rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ── */
header {
  text-align: center;
  margin-bottom: 1.5rem;
  margin-top: 3rem;
}
header img {
  max-width: 480px;
  width: 100%;
  height: auto;
  filter: invert(1);
  opacity: 0.85;
}

/* ── Editor Card ── */
.editor {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

/* ── Toolbar ── */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ── Icon-Buttons – größer und deutlicher ── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: #5a4e42;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: inherit;
  padding: 0;
}
.icon-btn:hover {
  background: rgba(91,74,47,0.12);
  color: var(--brown);
}
.icon-btn:active {
  background: rgba(91,74,47,0.20);
}
.icon-btn .material-symbols-outlined {
  font-size: 1.5rem;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  display: block;
  color: inherit;
}

/* ── Textbereich (dirty) ── */
#deformat {
  width: 100%;
  height: 32em;
  padding: 1.25rem;
  border: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  font-size: 1rem;
  line-height: 1.6;
  overflow-y: auto;
  resize: vertical;
  outline: none;
  text-align: left;
  word-break: break-word;
  font-family: inherit;
  color: var(--text);
  display: block;
}
#deformat:focus {
  box-shadow: inset 0 0 0 2px var(--focus);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Textbereich (clean) – Textarea ── */
#cleanArea {
  display: none;   /* wird per JS eingeblendet */
  width: 100%;
  height: 32em;
  padding: 1.25rem;
  border: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.7;
  overflow-y: auto;
  resize: vertical;
  outline: none;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
#cleanArea:focus {
  box-shadow: inset 0 0 0 2px var(--focus);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Wash-Animation ── */
@keyframes wash {
  0%   { filter: blur(0px);  opacity: 1;   }
  25%  { filter: blur(5px);  opacity: 0.4; }
  60%  { filter: blur(5px);  opacity: 0.4; }
  100% { filter: blur(0px);  opacity: 1;   }
}
.washing {
  animation: wash 0.65s ease forwards;
  pointer-events: none;
  user-select: none;
}

/* ── Badge ── */
.clean-badge {
  position: absolute;
  top: 3.6rem;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: var(--brown);
  color: #fff;
  font-family: 'Fira Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.9rem;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
  box-shadow: var(--shadow-sm);
}
.clean-badge.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Tooltip ── */
.tooltip { position: relative; display: inline-block; }
.tooltip .tooltiptext {
  visibility: hidden;
  opacity: 0;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.5;
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  white-space: normal;
  z-index: 20;
  width: 22rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}
/* Variante: Tooltip öffnet nach unten rechts (für links positionierte Buttons) */
.tooltip .tooltiptext--right {
  bottom: auto;
  top: calc(100% + 8px);
  right: auto;
  left: 0;
  transform: translateY(-4px);
}
.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}
.tooltip:hover .tooltiptext--right {
  transform: translateY(0);
}
.tooltip .tooltiptext ul { margin: 0.4rem 0 0; padding-left: 1.1em; }
.tooltip .tooltiptext li { margin: 0.25em 0; color: var(--text); }

/* ── Controls ── */
.controls {
  display: flex;
  align-items: center;
  margin-top: 1rem;
  gap: 1rem;
}

/* ── Bereinigen-Button ── */
.btn-clean {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.4rem 0.6rem 1.1rem;
  background: var(--brown);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Fira Sans', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}
.btn-clean .material-symbols-outlined {
  font-size: 1.3rem;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  color: inherit;
  display: block;
}
.btn-clean:hover  { background: var(--brown-dark); box-shadow: var(--shadow-lg); }
.btn-clean:active { transform: scale(0.97); box-shadow: var(--shadow-sm); }

/* ── Zeichenzähler ── */
.charcount {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Footer ── */
.footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 2.5rem;
  padding-bottom: 1rem;
}
.footer a { color: var(--brown-light); font-weight: 600; text-decoration: none; }
.footer a:hover { text-decoration: underline; }