/* Countdown-Wand – eigenes Design
   Palette: Tiefes Nachtblau #0b1220 + Neon-Cyan #22d3ee, festlich. */

:root {
  --bg: #0b1220;
  --bg-2: #0f1830;
  --surface: #141f3a;
  --surface-2: #1b294a;
  --border: #243353;
  --text: #e8eefc;
  --text-dim: #93a4c8;
  --accent: #22d3ee;
  --accent-2: #38bdf8;
  --accent-soft: rgba(34, 211, 238, 0.16);
  --danger: #f87171;
  --success: #34d399;
  --warn: #fbbf24;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --radius-sm: 12px;
  --ring: 0 0 0 3px rgba(34, 211, 238, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="light"] {
  --bg: #eef3fb;
  --bg-2: #e3ebf8;
  --surface: #ffffff;
  --surface-2: #f3f7ff;
  --border: #cdd9ee;
  --text: #0d1830;
  --text-dim: #5b6b8c;
  --accent: #0891b2;
  --accent-2: #0284c7;
  --accent-soft: rgba(8, 145, 178, 0.12);
  --danger: #dc2626;
  --success: #059669;
  --warn: #b45309;
  --shadow: 0 8px 24px rgba(40, 60, 110, 0.16);
  --ring: 0 0 0 3px rgba(8, 145, 178, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 80% -10%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(56, 189, 248, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  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-text-size-adjust: 100%;
  overflow-x: hidden;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #04111c;
  padding: 10px 16px;
  border-radius: 0 0 10px 0;
  z-index: 200;
  font-weight: 700;
}
.skip-link:focus { left: 0; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(14px, 4vw, 28px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-glyph {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: #041018;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 20px var(--accent-soft);
  flex: none;
}

.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: clamp(1.05rem, 4vw, 1.35rem);
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0.2px;
}
.tagline {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* Buttons */
.primary-btn,
.ghost-btn,
.danger-btn {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.18s ease, background 0.18s ease;
  white-space: nowrap;
}
.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111c;
  box-shadow: 0 6px 18px rgba(34, 211, 238, 0.28);
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active { transform: translateY(1px); }

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

.danger-btn {
  background: var(--danger);
  color: #fff;
}
.danger-btn:hover { filter: brightness(1.05); }

.icon-btn {
  font-family: inherit;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.18s ease, transform 0.12s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.96); }

.theme-icon::before { content: "🌙"; font-size: 1.1rem; }
[data-theme="light"] .theme-icon::before { content: "☀️"; }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 10px;
}

/* Main */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(14px, 4vw, 28px);
}

/* Stats */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.stat-num {
  display: block;
  font-size: clamp(1.3rem, 5vw, 1.7rem);
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* Wall */
.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
  gap: 16px;
}

.card {
  position: relative;
  background:
    linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: pop 0.32s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* Akzent-Glanz oben, abhängig von Karten-Farbe */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--card-color, var(--accent)), transparent 85%);
}
.card::after {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--card-color, var(--accent)), transparent 70%);
  opacity: 0.16;
  pointer-events: none;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}
.card-emoji {
  font-size: 1.7rem;
  line-height: 1;
  flex: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}
.card-titlewrap { min-width: 0; flex: 1; }
.card-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.card-date {
  font-size: 0.74rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.card-menu { display: flex; gap: 4px; flex: none; }
.mini-btn {
  font-family: inherit;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 40%, transparent);
  color: var(--text-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  transition: color 0.15s ease, background 0.15s ease;
}
.mini-btn:hover { color: var(--text); background: var(--surface-2); }

/* Timer */
.timer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.unit {
  text-align: center;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 4px 8px;
}
.unit-num {
  display: block;
  font-size: clamp(1.25rem, 6vw, 1.6rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--card-color, var(--accent));
  letter-spacing: 0.5px;
}
.unit-label {
  display: block;
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Erreicht-Status */
.card.reached {
  border-color: color-mix(in srgb, var(--success) 50%, var(--border));
}
.card.reached::before {
  background: linear-gradient(90deg, var(--success), transparent 85%);
}
.reached-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  padding: 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--success) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 45%, transparent);
  color: var(--success);
  font-weight: 800;
  font-size: 1.05rem;
}
.card.reached .timer { display: none; }
.card.reached .reached-banner { display: flex; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 18px;
  max-width: 460px;
  margin: 12px auto;
}
.empty-glyph { font-size: 3.4rem; margin-bottom: 8px; }
.empty-state h2 { margin: 6px 0; font-size: 1.3rem; }
.empty-state p { color: var(--text-dim); margin: 0 0 20px; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 9, 20, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  padding: 20px clamp(16px, 5vw, 24px) calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }

.modal-sm { max-width: 380px; border-radius: 22px; align-self: center; }
.modal-backdrop:has(.modal-sm) { align-items: center; padding: 16px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h2 { margin: 0; font-size: 1.2rem; }

.field { display: block; margin-bottom: 16px; border: 0; padding: 0; min-width: 0; }
.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

input[type="text"],
input[type="date"],
input[type="time"] {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: var(--text-dim); }
input:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* Color picker */
.color-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.color-swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease;
}
.color-swatch:hover { transform: scale(1.08); }
.color-swatch[aria-checked="true"] {
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px currentColor;
}
.color-swatch[aria-checked="true"]::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #04111c;
  font-weight: 900;
  font-size: 0.9rem;
}

/* Emoji picker */
.emoji-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
}
.emoji-opt {
  font-family: inherit;
  font-size: 1.4rem;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}
.emoji-opt:hover { background: var(--surface); transform: translateY(-1px); }
.emoji-opt[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--ring);
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: -6px 0 12px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.modal-actions .primary-btn,
.modal-actions .ghost-btn,
.modal-actions .danger-btn { flex: 1; }

.confirm-text { color: var(--text-dim); margin: 0 0 18px; line-height: 1.5; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-success { border-left-color: var(--success); }

/* Desktop modal centered */
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
