/* remind Mini App — mobile-first, под Telegram WebApp.
   Дизайн-система синхронизирована с qveep.ru/miniapp:
   aurora-фон, cyan/purple акценты, Space Grotesk заголовки, glassmorphism. */
:root {
  /* Базовые поверхности */
  --bg: #0e0f12;
  --bg-elev: #181a1f;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.1);
  --text: #f4f5f7;
  --text-dim: rgba(244, 245, 247, 0.6);
  --text-mute: rgba(244, 245, 247, 0.4);
  /* Акценты по ролям */
  --accent: #00bfff;
  --accent-2: #a855f7;
  --accent-3: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;
  /* Радиусы */
  --radius: 14px;
  --radius-sm: 10px;
  /* Шрифты */
  --font-sans: "Inter", -apple-system, system-ui, sans-serif;
  --font-display: "Space Grotesk", "Inter", sans-serif;
  /* Telegram */
  --tg-section: var(--tg-theme-section-bg-color, var(--surface));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }

svg { width: 1em; height: 1em; display: inline-block; vertical-align: middle; }
.bottom-nav svg { width: 22px; height: 22px; }
.share-detail-btn svg { width: 18px; height: 18px; }
.card-meta svg { width: 13px; height: 13px; }
.empty-state svg { width: 48px; height: 48px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(64px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
  padding-top: var(--safe-top, 0px);
  overflow-x: hidden;
}

/* Aurora-фон (как на основном сайте) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 40% at 20% 0%, rgba(168, 85, 247, 0.10), transparent 60%),
    radial-gradient(ellipse 60% 35% at 85% 5%, rgba(0, 191, 255, 0.08), transparent 60%);
}

/* ---------- Шапка ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(14, 15, 18, 0.8);
  backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}
.app-logo span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-subtitle {
  color: var(--text-mute);
  font-size: 0.78rem;
  margin-left: auto;
}
.share-detail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.share-detail-btn:active { transform: scale(0.92); }
.share-detail-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Фильтры (облако) ---------- */
.topic-cloud { padding: 12px 16px 0; }
.topics-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.topic-chip:active { transform: scale(0.96); }
.topic-chip:hover { border-color: var(--accent-2); background: rgba(168,85,247,0.12); }
.topic-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #001824;
  font-weight: 600;
}

/* ---------- Лента ---------- */
.feed { padding: 8px 16px; display: flex; flex-direction: column; gap: 14px; }
.loader, .empty {
  color: var(--text-mute);
  text-align: center;
  padding: 50px 20px;
  font-size: 0.92rem;
}

/* Section title */
.section-title {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 8px 0 4px;
}

/* ---------- Карточка напоминания ---------- */
.card {
  background: var(--tg-section);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.card:active {
  transform: scale(0.985);
  border-color: var(--accent);
}
.card-body { padding: 14px 16px; }
.card-title {
  margin: 0 0 7px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  word-break: break-word;
}
.card-excerpt {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0 0 9px;
  line-height: 1.4;
}
.card-meta {
  color: var(--text-mute);
  font-size: 0.74rem;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.card-meta .meta-date { color: var(--accent); font-weight: 500; }
.card-meta .meta-pri-high { color: var(--danger); font-weight: 500; }
.card-meta .meta-pri-mid { color: var(--accent-3); font-weight: 500; }
.card-meta .meta-pri-low { color: var(--success); font-weight: 500; }
.card-meta .meta-pri-rec { color: var(--accent-2); font-weight: 500; }
.card-meta .meta-in { color: var(--accent-2); }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.card-tag {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
}
.card-actions { display: flex; gap: 8px; margin-top: 12px; }
.card-actions button {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.card-actions button:active { transform: scale(0.96); }
.card-actions .act-snooze:hover { border-color: var(--accent); color: var(--accent); }
.card-actions .act-edit:hover { border-color: var(--accent-2); color: var(--accent-2); }
.card-actions .act-del:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(14, 15, 18, 0.85);
  backdrop-filter: blur(16px) saturate(160%);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}
.nav-item {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text-mute);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-item.is-active { color: var(--accent); }
.nav-item.is-active svg { transform: translateY(-1px); }
.nav-item:active svg { transform: scale(0.9); }

/* ---------- Модалы ---------- */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}
.auth-modal.is-open { display: flex; }
.auth-modal-card {
  width: min(360px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.auth-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.auth-subtitle { color: var(--text-dim); font-size: 0.86rem; margin-bottom: 18px; }
.auth-modal-card input,
.auth-modal-card select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.92rem;
  margin-bottom: 10px;
}
.auth-modal-card select { appearance: none; }
.auth-modal-card input:focus,
.auth-modal-card select:focus { outline: none; border-color: var(--accent); }
.auth-modal-card select option { background: var(--bg-elev); }
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
}
.auth-submit {
  width: 100%;
  background: var(--accent);
  color: #001824;
  border: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  margin-top: 6px;
}
.auth-submit:active { transform: scale(0.98); }
.auth-cancel {
  width: 100%;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
}
.auth-error {
  color: var(--danger);
  font-size: 0.82rem;
  margin-top: 10px;
  min-height: 1em;
  text-align: center;
}

/* ---------- Экспорт ---------- */
.export-body { font-size: 0.9rem; line-height: 1.6; }
.export-body .hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.export-body code {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  word-break: break-all;
  font-size: 0.8rem;
  margin: 6px 0 12px;
  color: var(--accent);
}
.export-body b { color: var(--text); }

/* ---------- Пустое состояние ---------- */
.empty-state {
  text-align: center;
  padding: 60px 30px;
  color: var(--text-mute);
}
.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}
.empty-state p { font-size: 0.9rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.85rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 2000;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- Скроллбар ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }

/* ---------- Tablet / Desktop ---------- */
@media (min-width: 600px) {
  .feed { max-width: 640px; margin-left: auto; margin-right: auto; }
  .app-header .header-inner { max-width: 640px; margin: 0 auto; }
  .topic-cloud { max-width: 640px; margin: 0 auto; }
}

/* ---------- Skeleton-загрузка ---------- */
.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg,
      rgba(255,255,255,0.04) 0%,
      rgba(255,255,255,0.10) 50%,
      rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin-bottom: 10px;
}
.skeleton-line.short { width: 55%; }
.skeleton-line.mid { width: 80%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Футер / privacy ---------- */
.app-footer {
  text-align: center;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.app-footer a {
  color: var(--text-mute);
  font-size: 0.78rem;
  text-decoration: none;
  border-bottom: 1px dotted var(--text-mute);
}
.app-footer a:hover { color: var(--accent); }

.privacy-page { padding-bottom: 32px; }
.privacy section { margin-bottom: 20px; }
.privacy h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.privacy p, .privacy li {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.6;
}
.privacy ul { padding-left: 18px; }
.privacy li { margin-bottom: 6px; }
.privacy b { color: var(--text); }
.privacy code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.82rem;
}
.privacy a { color: var(--accent-2); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .card:active, .nav-item:active, .topic-chip:active,
  .share-detail-btn:active, .auth-submit:active { transform: none !important; }
}
