/* ============================================================
   Dankbarkeits-Glas — eigenes Design
   Palette: cremiges Beige + sanftes Rosé/Gold, warm & ruhig
   ============================================================ */

:root {
  /* Helle Variante */
  --bg: #f7efe4;
  --bg-grad-a: #faf3e9;
  --bg-grad-b: #f1e3d2;
  --surface: #fffaf3;
  --surface-2: #fbeede;
  --ink: #4a3b2f;
  --ink-soft: #7a6754;
  --ink-faint: #a08c78;
  --rose: #d99a93;
  --rose-deep: #c47c75;
  --gold: #cba24c;
  --gold-soft: #e3c787;
  --accent: var(--rose-deep);
  --accent-ink: #fffaf3;
  --line: #e6d4be;
  --line-soft: #efe0cd;
  --danger: #b5645b;
  --shadow: 24px 40px 80px -40px rgba(120, 80, 50, 0.45);
  --shadow-soft: 0 8px 24px -12px rgba(120, 80, 50, 0.35);

  /* Glas */
  --glass-fill-a: #e9c6a3;
  --glass-fill-b: #e7b1a8;
  --glass-inner: rgba(255, 250, 243, 0.5);
  --glass-outline: #b89a78;
  --glass-lid: #cba24c;
  --glass-lid-2: #b88e3a;
  --glass-shine-a: rgba(255, 255, 255, 0.75);
  --glass-shine-b: rgba(255, 255, 255, 0.12);
  --note-a: #fff6e9;
  --note-b: #fbe6cf;
  --note-c: #f7d9c6;
  --note-d: #f3e2c2;
  --note-ink: #8a6f53;

  --radius: 20px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

[data-theme="dark"] {
  --bg: #2a221c;
  --bg-grad-a: #2f261f;
  --bg-grad-b: #241d18;
  --surface: #362b23;
  --surface-2: #40342a;
  --ink: #f3e6d6;
  --ink-soft: #d3bfa9;
  --ink-faint: #a48f78;
  --rose: #d99a93;
  --rose-deep: #e0a59e;
  --gold: #e0bf72;
  --gold-soft: #cba24c;
  --accent: #e0a59e;
  --accent-ink: #2a221c;
  --line: #4d3f33;
  --line-soft: #443629;
  --danger: #e08a82;
  --shadow: 24px 40px 80px -40px rgba(0, 0, 0, 0.7);
  --shadow-soft: 0 8px 24px -12px rgba(0, 0, 0, 0.55);

  --glass-fill-a: #b98a63;
  --glass-fill-b: #bf7f78;
  --glass-inner: rgba(255, 250, 243, 0.06);
  --glass-outline: #8a7257;
  --glass-lid: #cba24c;
  --glass-lid-2: #9c7a31;
  --glass-shine-a: rgba(255, 255, 255, 0.28);
  --glass-shine-b: rgba(255, 255, 255, 0.04);
  --note-a: #f3e2c8;
  --note-b: #e9cba8;
  --note-c: #e7c0ad;
  --note-d: #e3d0a6;
  --note-ink: #5a4631;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% -10%, var(--bg-grad-a), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-a), var(--bg-grad-b));
  background-attachment: fixed;
  min-height: 100vh;
  padding:
    env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 100;
  transition: top .2s ease;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 0; }

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 18px 8px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 14px;
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--gold-soft), var(--rose));
  box-shadow: var(--shadow-soft);
}
.brand-text h1 {
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.1;
  margin: 0;
  letter-spacing: .2px;
}
.tagline {
  margin: 2px 0 0;
  font-size: .82rem;
  color: var(--ink-soft);
}

.icon-btn {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 14px;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }
[data-theme="dark"] .ico-moon { display: block; }

/* ---------- Main ---------- */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 18px 48px;
  display: grid;
  gap: 22px;
}

/* ---------- Glas ---------- */
.glas-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.glas-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.glas-svg {
  width: min(62vw, 230px);
  height: auto;
  filter: drop-shadow(0 24px 30px rgba(120, 80, 50, .22));
}
[data-theme="dark"] .glas-svg {
  filter: drop-shadow(0 24px 30px rgba(0, 0, 0, .5));
}

.glas-inner { fill: var(--glass-inner); }
.glas-outline {
  fill: none;
  stroke: var(--glass-outline);
  stroke-width: 3.5;
  stroke-linejoin: round;
}
.glas-lid { fill: var(--glass-lid); }
.glas-lid-band { fill: var(--glass-lid-2); }
.glas-glanz {
  fill: none;
  stroke: url(#glasGlanz);
  stroke-width: 8;
  stroke-linecap: round;
  opacity: .85;
}
.fill-rect { fill: var(--glass-fill-b); opacity: .55; }
.fill-wave { fill: var(--glass-fill-a); opacity: .6; }

.zettel-layer .zettel {
  transform-box: fill-box;
  transform-origin: center;
}
.zettel-paper { stroke: rgba(140, 110, 80, .18); stroke-width: .6; }

/* sanftes Schaukeln der Zettel */
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); }
  50% { transform: translateY(-2px) rotate(calc(var(--rot, 0deg) + 1.5deg)); }
}
.zettel-layer .zettel {
  animation: bob 5.5s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes dropIn {
  0% { transform: translateY(-160px) rotate(0deg); opacity: 0; }
  70% { opacity: 1; }
  100% { transform: translateY(0) rotate(var(--rot, 0deg)); opacity: 1; }
}
.zettel.is-new { animation: dropIn .9s cubic-bezier(.3, .8, .4, 1) both; }

.glas-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.count-pill, .streak-pill {
  font-size: .8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.streak-pill {
  background: linear-gradient(135deg, var(--gold-soft), var(--rose));
  color: var(--accent-ink);
  border-color: transparent;
}

.glas-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  padding: 11px 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease, border-color .2s ease;
  line-height: 1;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  background: linear-gradient(135deg, var(--rose-deep), var(--gold));
  color: var(--accent-ink);
  box-shadow: var(--shadow-soft);
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.05); }

/* ---------- Eingabe ---------- */
.entry-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px 16px;
  box-shadow: var(--shadow-soft);
}
.entry-section h2 {
  font-family: var(--serif);
  font-size: 1.18rem;
  margin: 0 0 14px;
  color: var(--ink);
}
.entry-form { display: grid; gap: 10px; }
.entry-input {
  width: 100%;
  resize: vertical;
  min-height: 64px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  line-height: 1.5;
}
.entry-input::placeholder { color: var(--ink-faint); }
.entry-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196, 124, 117, .25); }

.entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.char-count { font-size: .78rem; color: var(--ink-faint); }
.hint {
  margin: 12px 0 0;
  font-size: .8rem;
  color: var(--ink-faint);
  text-align: center;
}

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(60, 40, 25, .42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade .25s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px 18px;
  width: 100%;
  max-width: 440px;
  max-height: 86vh;
  overflow: auto;
  animation: pop .28s cubic-bezier(.3, .8, .4, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-x {
  position: absolute;
  top: 10px; right: 12px;
  width: 34px; height: 34px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 10px;
}
.modal-x:hover { background: var(--surface-2); }
.modal-title {
  font-family: var(--serif);
  font-size: 1.25rem;
  margin: 0 0 14px;
  padding-right: 28px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* Gezogener Zettel */
.paper-card {
  background:
    linear-gradient(180deg, var(--note-a), var(--note-b));
  border-color: var(--note-c);
}
[data-theme="dark"] .paper-card { color: var(--note-ink); }
.draw-text {
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.5;
  margin: 6px 0 10px;
  color: var(--note-ink);
  border-left: 3px solid var(--rose-deep);
  padding-left: 14px;
}
.draw-date {
  font-size: .82rem;
  color: var(--note-ink);
  opacity: .75;
  margin: 0;
}

/* Liste */
.list-tools { margin-bottom: 12px; }
.search-input {
  width: 100%;
  font: inherit;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196, 124, 117, .25); }
.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.entry-item {
  background: linear-gradient(180deg, var(--note-a), var(--note-b));
  border: 1px solid var(--note-c);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  position: relative;
}
.entry-item-text {
  margin: 0 0 6px;
  color: var(--note-ink);
  line-height: 1.5;
  word-break: break-word;
}
.entry-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.entry-item-date {
  font-size: .76rem;
  color: var(--note-ink);
  opacity: .72;
}
.del-btn {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
}
.del-btn:hover { background: rgba(181, 100, 91, .14); }
.list-empty {
  text-align: center;
  color: var(--ink-faint);
  padding: 20px 0;
}
.confirm-msg { color: var(--ink-soft); line-height: 1.5; margin: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--surface);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
  z-index: 90;
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Fokus-States ---------- */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Responsiv ---------- */
@media (min-width: 560px) {
  .glas-svg { width: 230px; }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .zettel.is-new { animation: none; }
  .zettel-layer .zettel { animation: none; }
}
