/* EveryIdea base: токены, 3 темы, reset, типографика, базовые компоненты.
   4px-сетка, радиусы 16/12 (карточки/контролы), двухслойные тени — конвенции Сороки. */

:root {
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --r-card: 16px;
  --r-control: 12px;
  --r-sm: 10px;
  --font-ui: 'Inter', -apple-system, 'SF Pro Text', 'Segoe UI', Roboto, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

/* --- Тема «Бумага» (светлая) --- */
:root, :root[data-theme='paper'] {
  color-scheme: light;
  --bg: #fafaf7;
  --bg-secondary: #f3f3ee;
  --surface: #ffffff;
  --surface-2: #f7f7f2;
  --text: #1a1a1a;
  --hint: #6b7280;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --destructive: #ff3b30;
  --success: #34c759;
  --warning: #b45309;
  --separator: rgba(60, 60, 67, 0.12);
  --fill: rgba(120, 120, 128, 0.14);
  --border: #e5e5de;
  --shadow: 0 1px 3px rgba(26, 26, 26, 0.05), 0 8px 24px rgba(26, 26, 26, 0.05);
  --shadow-lift: 0 2px 6px rgba(26, 26, 26, 0.07), 0 16px 40px rgba(26, 26, 26, 0.09);
  --board-grid: rgba(60, 60, 67, 0.14);
  --glass: none;
  --bg-image: none;
  --accent-gradient: linear-gradient(135deg, #4f46e5, #6366f1);
}

/* --- Тема «Оникс» (true black) --- */
:root[data-theme='onyx'] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --bg-secondary: #131316;
  --surface: #131316;
  --surface-2: #1b1b1f;
  --text: #e4e4e7;
  --hint: #a1a1aa;
  --accent: #6366f1;
  --accent-strong: #818cf8;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --destructive: #ff453a;
  --success: #30d158;
  --warning: #f59e0b;
  --separator: rgba(84, 84, 88, 0.5);
  --fill: rgba(120, 120, 128, 0.22);
  --border: #27272a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.55), 0 16px 40px rgba(0, 0, 0, 0.5);
  --board-grid: rgba(132, 132, 140, 0.2);
  --glass: none;
  --bg-image: none;
  --accent-gradient: linear-gradient(135deg, #6366f1, #818cf8);
}

/* --- Тема «Аврора» (тёмная, градиент, стекло) --- */
:root[data-theme='aurora'] {
  color-scheme: dark;
  --bg: #141226;
  --bg-secondary: rgba(255, 255, 255, 0.04);
  --surface: rgba(255, 255, 255, 0.07);
  --surface-2: rgba(255, 255, 255, 0.1);
  --text: #ede9fe;
  --hint: #a5a3c2;
  --accent: #a78bfa;
  --accent-strong: #c4b5fd;
  --accent-contrast: #1e1b4b;
  --accent-soft: rgba(167, 139, 250, 0.18);
  --destructive: #ff453a;
  --success: #30d158;
  --warning: #fbbf24;
  --separator: rgba(255, 255, 255, 0.12);
  --fill: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.14);
  --shadow: 0 1px 3px rgba(10, 8, 30, 0.4), 0 8px 24px rgba(10, 8, 30, 0.35);
  --shadow-lift: 0 2px 8px rgba(10, 8, 30, 0.5), 0 16px 48px rgba(10, 8, 30, 0.5);
  --board-grid: rgba(255, 255, 255, 0.1);
  --glass: blur(18px) saturate(1.4);
  --bg-image: linear-gradient(140deg, #1e1b4b 0%, #312e81 45%, #155e75 100%);
  --accent-gradient: linear-gradient(135deg, #a78bfa, #22d3ee);
}

/* --- reset --- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-image);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
html.theme-anim body,
html.theme-anim .card,
html.theme-anim .sidebar,
html.theme-anim .bottom-nav,
html.theme-anim .input,
html.theme-anim .pane {
  transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
button:disabled { opacity: 0.5; cursor: default; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

#app { height: 100dvh; }

/* --- карточки и кнопки --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  min-height: 40px;
  border-radius: var(--r-control);
  font-weight: 500;
  font-size: 14px;
  border: 1px solid transparent;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, border-color 120ms ease;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { color: var(--hint); }
.btn-ghost:hover { color: var(--accent); background: var(--accent-soft); }
.btn-danger {
  background: color-mix(in srgb, var(--destructive) 12%, transparent);
  color: var(--destructive);
  border-color: color-mix(in srgb, var(--destructive) 30%, transparent);
}
.btn-danger:hover { background: var(--destructive); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 32px; padding: var(--s1) var(--s3); font-size: 13px; border-radius: var(--r-sm); }
.btn-icon { min-width: 40px; padding: var(--s2); }
.btn-icon.btn-sm { min-width: 32px; }
.btn .icon { width: 18px; height: 18px; }
.btn-ghost.danger { color: var(--destructive); }
.btn-ghost.danger:hover { background: color-mix(in srgb, var(--destructive) 12%, transparent); }

.icon { width: 20px; height: 20px; flex: none; }

/* --- поля ввода --- */
.input {
  min-height: 40px;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-control);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 120ms ease, background-color 120ms ease;
}
.input:focus { border-color: var(--accent); background: var(--surface); outline: none; }
.input::placeholder { color: var(--hint); }

/* --- chips (метки дат / типов — паттерн Сороки) --- */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--s2);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--fill);
  color: var(--hint);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-date { background: var(--accent-soft); color: var(--accent); }
.chip-note { background: var(--accent-soft); color: var(--accent); }
.chip-board { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.chip-more { background: var(--fill); }

/* --- banner (предупреждения — паттерн Сороки) --- */
.banner {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-control);
  font-size: 13px;
  line-height: 1.45;
}
.banner .icon { width: 18px; height: 18px; margin-top: 1px; }
.banner-warn {
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 25%, transparent);
}

/* --- segmented-контрол (паттерн Сороки) --- */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--fill);
  border-radius: 10px;
}
.segmented button {
  padding: 5px var(--s3);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--hint);
  transition: background 180ms ease, box-shadow 180ms ease, color 180ms ease;
}
.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* --- toggle-row (настройки — паттерн Сороки) --- */
.check-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.check-row input[type='checkbox'] {
  appearance: none;
  width: 44px;
  height: 26px;
  flex: none;
  border-radius: 999px;
  background: var(--fill);
  position: relative;
  cursor: pointer;
  transition: background 180ms ease;
  margin: 0;
}
.check-row input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 180ms ease;
}
.check-row input[type='checkbox']:checked { background: var(--success); }
.check-row input[type='checkbox']:checked::after { transform: translateX(18px); }

/* --- dropzone (импорт — паттерн Сороки) --- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s6);
  margin-top: var(--s3);
  border: 2px dashed var(--separator);
  border-radius: 20px;
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}
.dropzone:active { transform: scale(0.985); }
.dropzone.dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.dropzone .dz-icon {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}
.dropzone .dz-icon .icon { width: 24px; height: 24px; }
.dropzone .dz-title { font-size: 16px; font-weight: 600; }
.dropzone .dz-sub { font-size: 13px; color: var(--hint); max-width: 320px; }

/* --- sync track --- */
.sync-track {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: 14px;
}
.sync-track .btn { margin-left: auto; }
.sync-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--hint);
  flex: none;
}
.sync-dot.sync-ok { background: var(--success); }
.sync-dot.sync-syncing { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.sync-dot.sync-offline { background: var(--warning); }
.sync-dot.sync-error { background: var(--destructive); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* --- тосты --- */
#toasts {
  position: fixed;
  top: calc(var(--s4) + env(safe-area-inset-top));
  right: var(--s4);
  left: var(--s4);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--s2);
  z-index: 1000;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  max-width: 380px;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-control);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lift);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  font-size: 14px;
  animation: toast-in 180ms ease;
  cursor: pointer;
}
.toast-error { border-color: color-mix(in srgb, var(--destructive) 40%, transparent); color: var(--destructive); }
.toast-success { border-color: color-mix(in srgb, var(--success) 40%, transparent); color: var(--success); }
.toast-out { opacity: 0; transform: translateY(-6px); transition: opacity 200ms ease, transform 200ms ease; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- модалка --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: var(--s4);
  background: rgba(10, 10, 15, 0.45);
  animation: fade-in 150ms ease;
}
.modal {
  width: 100%;
  max-width: 400px;
  padding: var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  animation: card-in 180ms ease;
}
.modal-title { font-size: 17px; font-weight: 600; }
.modal-hint { font-size: 13px; color: var(--hint); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s2); }

/* --- анимации появления --- */
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in { from { opacity: 0; } }
.card-anim { animation: card-in 150ms ease both; }

/* --- skeleton --- */
.skeleton {
  border-radius: var(--r-control);
  background: linear-gradient(90deg, var(--fill) 25%, var(--surface-2) 50%, var(--fill) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* --- пустые состояния --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s8) var(--s4);
  text-align: center;
  color: var(--hint);
}
.empty-compact { padding: var(--s5) var(--s4); }
.empty-illustration { width: 88px; height: 88px; opacity: 0.55; margin-bottom: var(--s2); }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); }
.empty-sub { font-size: 13px; max-width: 280px; }
.empty-state .btn { margin-top: var(--s2); }

.fatal {
  height: 100dvh;
  display: grid;
  place-content: center;
  gap: var(--s2);
  text-align: center;
  color: var(--hint);
}

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