/* =================================================================
   365 Erinnerungen – Stylesheet
   - Dark only, ruhig und zurückhaltend
   - Kartenbasiert, große lesbare Serif-Typografie für die Inhalte
   ================================================================= */

/* ---------- Design-Tokens ---------- */
:root {
  /* Typografie */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  --font-read: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;

  /* Farben – dunkel, neutral, eine warme Akzentnote */
  --bg: #101013;
  --bg-2: #15151a;
  --surface: #18181d;
  --surface-2: #212128;
  --border: #28282f;
  --border-soft: #202026;
  --text: #ecebe8;
  --text-soft: #aeacb4;
  --muted: #74727c;
  --accent: #c8a87c;          /* warmes Sand, sparsam eingesetzt */
  --accent-soft: rgba(200,168,124,0.12);
  --accent-line: rgba(200,168,124,0.35);
  --accent-text: #16140f;
  --fav: #e2b65a;
  --danger: #d97070;

  /* Form */
  --radius: 14px;
  --radius-sm: 9px;
  --gap: 16px;
  --maxw: 1120px;

  /* Übergänge */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --speed: 0.22s;
}

/* ---------- Reset / Grundlagen ---------- */
* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

h1, h2, h3 { margin: 0; font-weight: 600; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); font-size: 0.88rem; }

kbd {
  font-family: var(--font-ui);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 0.78rem;
  color: var(--text-soft);
}

/* ---------- Layout-Container ---------- */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 22px 120px;
}

/* ---------- Kopfzeile ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-family: var(--font-read);
  font-size: 1.5rem;
  line-height: 1;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-weight: 600;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  padding: 7px 11px;
}
.brand-text h1 { font-size: 1.05rem; letter-spacing: 0.2px; font-weight: 600; }
.brand-sub { margin: 2px 0 0; font-size: 0.78rem; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background var(--speed) var(--ease),
              border-color var(--speed) var(--ease),
              color var(--speed) var(--ease),
              opacity var(--speed) var(--ease);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-soft);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: var(--border); }

.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 7px 12px; font-size: 0.82rem; }

/* ---------- Karten-Oberfläche (gemeinsam) ---------- */
.card-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---------- Erfassung ---------- */
.capture {
  margin-top: 24px;
  padding: 18px;
}
.quick-row { display: flex; gap: 10px; }
.quick-input {
  flex: 1;
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 14px 16px;
  font-size: 1.05rem;
  font-family: var(--font-read);
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.quick-input:focus, .search-input:focus, .field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.capture-hint { margin: 12px 2px 0; font-size: 0.82rem; color: var(--muted); }

/* ---------- Werkzeugleiste ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 26px 0 8px;
}
.search-wrap { position: relative; flex: 1; min-width: 220px; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted);
}
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 11px 16px 11px 42px;
  font-size: 0.96rem;
}

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease),
              border-color var(--speed) var(--ease);
}
.chip:hover { color: var(--text); }
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.select {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 32px 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2374727c' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

.range { display: flex; align-items: center; gap: 6px; }
.range-input {
  width: 70px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.range-sep { color: var(--muted); }

/* ---------- Statuszeile ---------- */
.stats-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin: 10px 2px 20px; min-height: 20px; gap: 12px;
}
.stats-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.storage-mode {
  font-size: 0.72rem;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.storage-mode.is-warn {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.saved-hint { font-size: 0.78rem; color: var(--accent); opacity: 0; transition: opacity var(--speed) var(--ease); }
.saved-hint.show { opacity: 1; }

/* ---------- Kartenraster ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
}

.note-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-height: 150px;
  transition: transform var(--speed) var(--ease), border-color var(--speed) var(--ease),
              background var(--speed) var(--ease);
  animation: cardIn 0.35s var(--ease) both;
}
.note-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-line);
  background: var(--surface-2);
}

.note-num {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.85;
}
.note-text {
  font-family: var(--font-read);
  font-size: 1.16rem;
  line-height: 1.5;
  color: var(--text);
  margin: 10px 0 16px;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px;
  border-radius: 8px;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.icon-btn svg { display: block; }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn.fav.is-fav { color: var(--fav); }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Leere Zustände ---------- */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-soft);
  animation: cardIn 0.35s var(--ease) both;
}
.empty-title { font-size: 1.35rem; margin-bottom: 10px; font-weight: 600; }
.empty-text { max-width: 420px; margin: 0 auto 18px; color: var(--muted); }

/* ---------- Modale ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s var(--ease);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,0.8);
  animation: modalIn 0.28s var(--ease);
  max-height: 86vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  border: none; background: transparent; color: var(--muted);
  font-size: 1.05rem; padding: 6px 9px; border-radius: 8px;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-title { font-size: 1.2rem; margin-bottom: 18px; font-weight: 600; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Fokus-Karte (großer Einzelzettel) */
.focus-card { max-width: 600px; text-align: center; padding: 44px 38px; }
.focus-number {
  font-size: 0.76rem; font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 20px;
}
.focus-text {
  font-family: var(--font-read);
  font-size: 1.65rem;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 22px;
}
.focus-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#focusFav.is-active { color: var(--fav); border-color: color-mix(in srgb, var(--fav) 45%, var(--border)); }

/* Formularfelder */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { font-size: 0.82rem; color: var(--text-soft); }
.field-input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 13px;
  font-size: 0.96rem;
  font-family: var(--font-ui);
}
textarea.field-input { font-family: var(--font-read); line-height: 1.55; resize: vertical; }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }
.checkbox-field { flex-direction: row; align-items: center; gap: 8px; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--accent); }

.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.modal-actions .spacer { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 18px 40px -20px rgba(0,0,0,0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease);
  z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Hilfe-Button ---------- */
.help-fab {
  position: fixed; bottom: 22px; right: 22px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 1.05rem; font-weight: 600;
  z-index: 40;
  transition: color var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.help-fab:hover { color: var(--accent); border-color: var(--accent-line); }

.shortcuts { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.shortcuts li { display: flex; align-items: center; gap: 14px; }
.shortcuts li span { color: var(--text-soft); font-size: 0.92rem; }
.shortcuts kbd { min-width: 52px; text-align: center; }

/* =================================================================
   Responsive – Anpassungen für Tablets und Smartphones
   ================================================================= */

/* Tablet und kleiner */
@media (max-width: 720px) {
  .container { padding: 22px 16px 110px; }
  .app-header { padding: 14px 16px; }
  .toolbar { gap: 10px; }
  /* Bereichsfilter und Sortierung dürfen die volle Breite nutzen */
  .filters { width: 100%; }
}

@media (max-width: 640px) {
  .brand-sub { display: none; }
  /* Suchfeld und Filter untereinander stapeln, jeweils volle Breite */
  .search-wrap { flex: 1 1 100%; min-width: 0; }
}

/* Smartphone */
@media (max-width: 480px) {
  .container { padding: 18px 13px 100px; }

  /* Erfassung: Eingabefeld und Button untereinander, beide volle Breite */
  .quick-row { flex-wrap: wrap; }
  .quick-input { flex: 1 1 100%; }
  .quick-row .btn-primary { width: 100%; justify-content: center; }

  /* Nummern-Bereich auf volle Breite ziehen, Eingaben teilen sich den Platz */
  .range { flex: 1 1 100%; }
  .range-input { flex: 1; width: auto; }
  .sortSelect, .select { flex: 1; }

  /* Modal-Aktionen NICHT mehr nebeneinander quetschen, sondern stapeln.
     column-reverse: Hauptaktion (Speichern) oben, Löschen unten. */
  .modal-card { padding: 22px 18px; }
  .modal-actions { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
  .modal-actions .spacer { display: none; }
  .modal-actions .btn { width: 100%; justify-content: center; }

  /* Fokus-Ansicht etwas kompakter, damit der Text nicht eingequetscht wirkt */
  .focus-card { padding: 32px 22px; }
  .focus-text { font-size: 1.4rem; }
  .focus-actions .btn { flex: 1 1 calc(50% - 8px); justify-content: center; }
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
