:root {
  --accent: #7d6bd0;
  --accent-ink: #ffffff;
  --bg-1: #1c2350;
  --blob-1: #202c60;
  --blob-2: #4a2170;
  --glass-bg: rgba(255, 255, 255, 0.16);
  --glass-border: rgba(255, 255, 255, 0.32);
  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.72);
  font-family: "Georgia", "Iowan Old Style", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: linear-gradient(165deg, #161a3a 0%, #3d1f63 100%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, .greeting { font-family: "Georgia", "Iowan Old Style", serif; }

.hidden { display: none !important; }

.bg-blobs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

#loginScreen, #app { position: relative; z-index: 1; }

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px) saturate(150%);
  opacity: 0.55;
  animation: drift 26s ease-in-out infinite;
}

.blob-1 { width: 60vmax; height: 60vmax; background: var(--blob-1); top: -20%; left: -15%; }
.blob-2 { width: 55vmax; height: 55vmax; background: var(--blob-2); bottom: -25%; right: -15%; animation-delay: -12s; }

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 56px 56px;
}

.bg-sketch {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 145vmax;
  height: 145vmax;
  opacity: 0.22;
  transform: translate(-50%, -50%) rotate(18deg);
  mask-image: linear-gradient(115deg, black 30%, transparent 80%);
  -webkit-mask-image: linear-gradient(115deg, black 30%, transparent 80%);
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(5%, 7%) scale(1.12); }
}

.glass {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.24), var(--glass-bg) 60%);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-radius: 26px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 8px 34px rgba(0, 0, 0, 0.28);
}

#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  padding: 40px 32px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.login-box h1 { margin: 0 0 24px; font-size: 1.6rem; }

.login-box input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 14px;
}

.login-box input::placeholder { color: var(--text-soft); }

.login-box button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.login-error { color: #ff8b8b; margin-top: 10px; font-size: 0.9rem; min-height: 1.2em; }

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 96px;
}

.app-header {
  align-self: center;
  width: auto;
  max-width: 90%;
  margin: 20px 0 8px;
  padding: 14px 26px;
  text-align: center;
}

.greeting {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.4;
}

main {
  flex: 1;
  padding: 8px 16px 24px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.view-title { font-size: 1.3rem; margin: 12px 4px 14px; }

.tile {
  padding: 20px 24px;
  margin-bottom: 16px;
}

.tile h3 { margin: 0 0 12px; font-size: 1rem; opacity: 0.9; }

.placeholder { color: var(--text-soft); font-size: 0.95rem; margin: 0; }

.view-enter { animation: viewIn 0.25s ease; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tab bar */
.tab-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 8px;
  z-index: 10;
}

.tab-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 14px;
  border-radius: 16px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.72rem;
  transition: background 0.2s, color 0.2s;
}

.tab-link svg { width: 22px; height: 22px; }
.tab-link.active { background: var(--accent); color: var(--accent-ink); }

/* Agenda / task / note lists */
.agenda-list, .task-list { display: flex; flex-direction: column; gap: 8px; }

.agenda-item, .task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}

.agenda-item .time { font-weight: 600; min-width: 48px; opacity: 0.85; }
.agenda-item .info { flex: 1; }
.agenda-item .note { display: block; font-size: 0.82rem; color: var(--text-soft); }

.task-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(6px);
  cursor: pointer;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}
.task-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.task-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.task-item .title { flex: 1; }
.task-item.done .title { text-decoration: line-through; opacity: 0.6; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 10px;
}

.delete-btn {
  background: none;
  border: none;
  color: rgba(255, 140, 140, 0.85);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
}

/* Forms */
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.inline-form input {
  flex: 1;
  min-width: 100px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
.inline-form input::placeholder { color: var(--text-soft); }
.inline-form button, .task-form button {
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
}

.quick-status {
  margin: 8px 0 0;
  font-size: 0.85rem;
  min-height: 1.2em;
  color: var(--text-soft);
}
.quick-status.success { color: #7be3b0; }
.quick-status.error { color: #ff8b8b; }

/* Calendar */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-label { font-weight: 600; }
.cal-weekdays, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}
.cal-weekdays span { font-size: 0.75rem; color: var(--text-soft); padding-bottom: 6px; }
.cal-grid { gap: 4px; }
.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 0.85rem;
  gap: 2px;
}
.cal-day.outside { opacity: 0.3; }
.cal-day.today { border: 1px solid var(--accent); }
.cal-day.selected { background: var(--accent); color: var(--accent-ink); }
.cal-day .dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: 0.85; }

/* Notes */
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.note-card {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  min-height: 100px;
  display: flex;
  flex-direction: column;
}
.note-card .note-card-title { font-weight: 600; margin-bottom: 6px; }
.note-card .note-card-preview { font-size: 0.82rem; color: var(--text-soft); overflow: hidden; }
.note-card.add-card { align-items: center; justify-content: center; font-size: 1.6rem; opacity: 0.8; }

.note-title-input {
  width: 100%;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid var(--glass-border);
  background: none;
  color: var(--text);
  margin-bottom: 10px;
}
.note-text-input {
  width: 100%;
  min-height: 220px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 1rem;
  resize: vertical;
  font-family: inherit;
}
.note-detail-actions { display: flex; gap: 8px; margin-top: 12px; }
.note-detail-actions button {
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.note-detail-actions button#noteSaveBtn { background: var(--accent); color: var(--accent-ink); }
.note-detail-actions button.danger { background: rgba(255, 90, 90, 0.25); }

/* Desktop: alle 4 Bereiche nebeneinander statt Tabs (Handy behaelt die Tab-Ansicht) */
@media (min-width: 900px) {
  #app { padding-bottom: 32px; }

  main {
    max-width: 2200px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 24px;
  }

  main section.view {
    flex: 1 1 280px;
    min-width: 280px;
    margin: 0;
  }

  main section.view.hidden { display: block !important; }
  main .view-enter { animation: none; }

  .tab-bar { display: none; }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-1: #f4eefb;
    --text: #2a2140;
    --text-soft: rgba(42, 33, 64, 0.62);
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.6);
  }
  .agenda-item, .task-item, .note-card { background: rgba(255, 255, 255, 0.4); }
}
