@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #f3f1ec;
  --surface: #eae7e0;
  --text: #2b2a27;
  --muted: #8a877e;
  --divider: #ddd9d0;
  --accent: #6b7d78;
  --accent-hover: #566661;
  --crisis-bg: #f6efe6;
  --crisis-border: #d8c9ad;
  --danger: #a3453a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1b18;
    --surface: #242320;
    --text: #e9e6de;
    --muted: #8f8b80;
    --divider: #38362f;
    --accent: #92aaa3;
    --accent-hover: #a9bdb7;
    --crisis-bg: #2c2620;
    --crisis-border: #4a3f2d;
    --danger: #c17067;
  }
}

:root[data-theme="dark"] {
  --bg: #1c1b18;
  --surface: #242320;
  --text: #e9e6de;
  --muted: #8f8b80;
  --divider: #38362f;
  --accent: #92aaa3;
  --accent-hover: #a9bdb7;
  --crisis-bg: #2c2620;
  --crisis-border: #4a3f2d;
  --danger: #c17067;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.column {
  max-width: 640px;
  margin: 0 auto;
  padding: 4.5rem 1.5rem 6rem;
}

/* Ecken-UI: Meine-Gedanken-Button oben links, Theme-Toggle unten rechts */
.my-thoughts-btn {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  z-index: 10;
}
.my-thoughts-btn:hover { color: var(--accent); }
.my-thoughts-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.theme-toggle {
  position: fixed;
  bottom: 1.6rem;
  right: 1.6rem;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  background: var(--text);
  cursor: pointer;
  padding: 0;
  z-index: 10;
  transition: transform 0.15s ease;
}
.theme-toggle:hover { transform: scale(1.2); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.gentle-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
  letter-spacing: 0.01em;
  margin: 0 0 2.5rem;
}

/* Composer */
.composer {
  margin-bottom: 3rem;
}

.composer textarea {
  width: 100%;
  min-height: 4.5rem;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: inherit;
  padding: 0;
  outline: none;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.composer-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
  min-height: 1.6rem;
}

.char-count {
  font-size: 0.75rem;
  color: var(--muted);
  visibility: hidden;
}
.char-count.visible { visibility: visible; }

.btn-finish {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--accent);
  background: none;
  border: 1px solid var(--divider);
  border-radius: 3px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.btn-finish.visible {
  opacity: 1;
  pointer-events: auto;
}
.btn-finish:hover { color: var(--accent-hover); border-color: var(--accent-hover); }

.already-posted {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
  margin-bottom: 3rem;
}

.crisis-banner {
  background: var(--crisis-bg);
  border: 1px solid var(--crisis-border);
  border-radius: 4px;
  padding: 0.9rem 1.1rem;
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.75rem;
  line-height: 1.6;
}
.crisis-banner a { color: var(--accent); }

/* Feed */
.feed { }

.thought {
  padding: 1.6rem 0;
  border-top: 1px solid var(--divider);
}
.thought:first-child { border-top: 1px solid var(--divider); }

.thought-text {
  position: relative;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 1.75em;
}

.thought.writing .thought-text::after {
  content: '';
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  background: var(--text);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s step-start infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.writing-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}

.thought-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.9rem;
  font-size: 0.78rem;
}

.reaction-btn {
  font-family: inherit;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.15s ease;
}
.reaction-btn:hover { color: var(--accent); }
.reaction-btn .count { color: var(--muted); font-size: 0.72rem; }
.reaction-btn.reacted { color: var(--accent); cursor: default; }
.reaction-btn:disabled { cursor: default; }
.reaction-btn:disabled:not(.reacted) { opacity: 0.6; }

.report-btn {
  margin-left: auto;
  font-family: inherit;
  background: none;
  border: none;
  color: var(--divider);
  cursor: pointer;
  font-size: 0.72rem;
}
.report-btn:hover { color: var(--muted); }

.empty-feed {
  color: var(--muted);
  font-style: italic;
  padding-top: 1.6rem;
  border-top: 1px solid var(--divider);
}

/* Live-Tipp-Effekt: einzelne Buchstaben blenden mit Staubpartikeln ein.
   Nur fuer fremde "schreibt gerade"-Eintraege, nie fuer den eigenen
   Composer (siehe assets/app.js). */
.letter-in {
  display: inline-block;
  opacity: 0;
  animation: letterIn 420ms cubic-bezier(.2,.75,.25,1) forwards;
}

@keyframes letterIn {
  from { opacity: 0; transform: translateY(3px) scale(0.92); filter: blur(2.5px); }
  to   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.particle {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  will-change: transform, opacity;
}

@media (prefers-reduced-motion: reduce) {
  .letter-in { animation: none; opacity: 1; }
  .thought.writing .thought-text::after { animation: none; }
}

/* "Meine Gedanken"-Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
}
.modal-overlay.hidden { display: none; }

.modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 1.75rem;
  max-width: 440px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0;
}

.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem;
}
.modal-close:hover { color: var(--text); }

.modal-tabs {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--divider);
}
.modal-tab {
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.1rem 0 0.6rem;
  cursor: pointer;
}
.modal-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.modal-field { display: block; margin-bottom: 0.9rem; }
.modal-field label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.modal-field input {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--divider);
  border-radius: 4px;
  padding: 0.55rem 0.65rem;
}
.modal-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.password-field { position: relative; }
.password-field input { padding-right: 2.4rem; }
.toggle-visibility {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toggle-visibility:hover { color: var(--accent); }
.toggle-visibility:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.toggle-visibility svg { width: 16px; height: 16px; }

.modal-link {
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-right: 1rem;
}
.modal-link:hover { color: var(--accent); }

.modal-success {
  color: var(--accent);
  font-size: 0.85rem;
  line-height: 1.6;
}

.modal-submit {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 4px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
}
.modal-submit:hover { background: var(--accent-hover); }
.modal-submit:disabled { opacity: 0.6; cursor: default; }

.modal-error {
  color: var(--danger);
  font-size: 0.78rem;
  margin: -0.4rem 0 0.9rem;
}

.modal-logged-in-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
  padding-right: 1rem;
}

.modal-logout {
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.modal-logout:hover { color: var(--accent); }

.my-thought-item {
  padding: 0.9rem 0;
  border-top: 1px solid var(--divider);
  font-size: 0.9rem;
}
.my-thought-item:first-child { border-top: none; padding-top: 0; }
.my-thought-date {
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

/* Admin-Uebersicht */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--divider);
}
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 500; }
.stat-label { font-size: 0.7rem; color: var(--muted); margin-top: 0.2rem; }
