/* =============================================
   To Do — стили
   =============================================
   Содержимое:
   1. База (html/body/root)
   2. Светлая и тёмная темы
   3. Типографика
   4. Анимации
   5. Скроллбары
   6. Переключатель темы
   7. Тосты
   8. Safe-area (iPhone с чёлкой)
   9. Мобильная адаптация
  10. Long-press
  11. Спиннер загрузки
   ============================================= */

/* 1. База */
html, body, #root { height: 100%; }
html { height: -webkit-fill-available; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow: hidden;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  -webkit-tap-highlight-color: transparent;
}

/* 2. Темы */
:root {
  --app-bg: #faf9f8;
  --app-fg: #201f1e;
  --sidebar-bg-start: #faf9f8;
  --sidebar-bg-end: #f3f2f1;
  --text-muted: #a19f9d;
  --scroll-thumb: #d2d0ce;
  --surface-strong: #fff;
  --composer-bg: rgba(255, 255, 255, 0.98);
  --composer-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
  --shadow-toggle: 0 1px 4px rgba(0,0,0,.3);
  --theme-track-active: #4338ca;
  --theme-track-idle: #d1d5db;
  --theme-icon-moon: #4338ca;
  --theme-icon-sun: #f59e0b;
  --task-detail-bg: #1c1c1e;
  --context-menu-bg: #2b2b2b;
}

html.dark {
  --app-bg: #1a1a2e;
  --app-fg: #e2e8f0;
  --sidebar-bg-start: #16213e;
  --sidebar-bg-end: #0f3460;
  --text-muted: #64748b;
  --scroll-thumb: #334155;
  --surface-strong: #1f2937;
  --composer-bg: rgba(17, 24, 39, 0.98);
  --composer-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  --context-menu-bg: #111827;
}

body { background: var(--app-bg); color: var(--app-fg); }
.sidebar-bg { background: linear-gradient(180deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-end) 100%); }

/* 3. Типографика */
.strike { text-decoration: line-through; color: var(--text-muted); }
.dark input[type="datetime-local"] { color-scheme: dark; }

.reminder-datetime-field {
  position: relative;
  margin-bottom: 0.75rem;
}

.reminder-datetime-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  min-height: 44px;
  margin-bottom: 0 !important;
}

.reminder-calendar {
  padding: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.92);
}

.reminder-calendar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.5);
}

.reminder-calendar-modal {
  width: min(100%, 22rem);
  max-height: min(88vh, 38rem);
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.reminder-calendar-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.reminder-calendar-modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #111827;
}

.reminder-calendar-modal-subtitle {
  margin-top: 0.15rem;
  font-size: 0.82rem;
  color: #64748b;
}

.reminder-calendar-close {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
}

.reminder-calendar-close:hover {
  background: rgba(148, 163, 184, 0.16);
}

html.dark .reminder-calendar {
  background: rgba(31, 41, 55, 0.92);
  border-color: rgba(71, 85, 105, 0.8);
}

html.dark .reminder-calendar-modal-title {
  color: #f8fafc;
}

html.dark .reminder-calendar-modal-subtitle,
html.dark .reminder-calendar-close {
  color: #94a3b8;
}

.reminder-calendar-head,
.reminder-time-row {
  display: flex;
  align-items: center;
}

.reminder-calendar-head {
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.reminder-calendar-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1f2937;
}

html.dark .reminder-calendar-title {
  color: #e5e7eb;
}

.reminder-calendar-nav {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  color: #6b7280;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.reminder-calendar-nav:hover {
  background: rgba(148, 163, 184, 0.16);
}

.reminder-calendar-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

html.dark .reminder-calendar-nav {
  color: #cbd5e1;
}

.reminder-calendar-weekdays,
.reminder-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
}

.reminder-calendar-weekdays {
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  text-align: center;
}

html.dark .reminder-calendar-weekdays {
  color: #94a3b8;
}

.reminder-calendar-day {
  aspect-ratio: 1;
  border-radius: 0.5rem;
  font-size: 0.86rem;
  color: #374151;
}

.reminder-calendar-day:hover {
  background: rgba(37, 99, 235, 0.1);
}

.reminder-calendar-day.is-today {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.12);
}

.reminder-calendar-day.is-selected {
  color: #fff;
  background: #2563eb;
}

.reminder-calendar-day.is-disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}

.reminder-calendar-day.is-disabled:hover {
  background: transparent;
}

html.dark .reminder-calendar-day {
  color: #e5e7eb;
}

html.dark .reminder-calendar-day:hover {
  background: rgba(96, 165, 250, 0.16);
}

html.dark .reminder-calendar-day.is-today {
  color: #93c5fd;
  background: rgba(37, 99, 235, 0.24);
}

html.dark .reminder-calendar-day.is-selected {
  color: #fff;
  background: #2563eb;
}

html.dark .reminder-calendar-day.is-disabled {
  color: #475569;
}

.reminder-time-row {
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
  color: #64748b;
}

html.dark .reminder-time-row {
  border-color: rgba(71, 85, 105, 0.8);
  color: #94a3b8;
}

.reminder-time-input {
  width: 4rem;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  padding: 0.5rem 0.65rem;
  text-align: center;
}

html.dark .reminder-time-input {
  border-color: #4b5563;
  background: #374151;
  color: #f9fafb;
}

.reminder-calendar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.reminder-actions-end {
  justify-content: flex-end;
}

/* 4. Анимации */
.fade-in { animation: fade .2s ease-out; }
@keyframes fade { from { opacity:0; transform:translateY(-3px); } to { opacity:1; transform:none; } }

.pop-in { animation: pop .14s ease-out; }
@keyframes pop { from { opacity:0; transform:scale(.96); } to { opacity:1; transform:scale(1); } }

.no-select { user-select: none; -webkit-user-select: none; }

/* 5. Скроллбары */
.scroll-thin {
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, 0.58) transparent;
}
.scroll-thin::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
.scroll-thin::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.5);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}
.scroll-thin::-webkit-scrollbar-thumb:hover {
  background: rgba(209, 213, 219, 0.72);
  border: 2px solid transparent;
  background-clip: padding-box;
}
.scroll-thin::-webkit-scrollbar-track { background: transparent; }

/* 6. Переключатель темы */
.theme-track {
  width: 44px; height: 24px; border-radius: 12px;
  position: relative; cursor: pointer;
  transition: background .3s ease;
}
.theme-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface-strong); box-shadow: var(--shadow-toggle);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  display: flex; align-items: center; justify-content: center;
}
.theme-track.dark-mode  { background: var(--theme-track-active); }
.theme-track.light-mode { background: var(--theme-track-idle); }
.theme-track.light-mode .theme-thumb { transform: translateX(0); }
.theme-track.dark-mode .theme-thumb { transform: translateX(20px); }

.bg-task-detail { background: var(--task-detail-bg); }

.task-detail-panel {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.task-detail-panel .ui-c-60,
.task-detail-panel .ui-c-93 {
  flex: 0 0 auto;
}

.task-detail-panel .ui-c-63 {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.task-detail-panel .ui-c-91 {
  flex: 0 0 auto;
  min-height: 0;
}

.task-detail-panel .ui-c-92 {
  height: auto;
  min-height: 9rem;
  overflow: hidden;
}

.task-notes-wrap {
  position: relative;
}

.task-notes-textarea {
  padding-right: 3rem;
}

.task-notes-diary-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
  width: 2.4rem;
  height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #8b8f98;
  border-radius: 0.5rem;
  transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.task-notes-diary-btn:hover {
  color: #d7dbe4;
  background: rgba(148, 163, 184, 0.12);
  transform: translateY(-1px);
}

.diary-overlay {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 2rem);
  background: rgba(248, 250, 252, 0.72);
  backdrop-filter: blur(9px);
}

html.dark .diary-overlay {
  background: rgba(3, 7, 18, 0.72);
}

.diary-shell {
  width: min(100%, 58rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.diary-book {
  position: relative;
  display: grid;
  min-height: min(72vh, 35rem);
  padding: 1.1rem;
  border-radius: 0.9rem;
  background: #e6dfd0;
  border: 1px solid rgba(150, 139, 120, 0.45);
  box-shadow: 0 24px 70px rgba(54, 46, 34, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  perspective: 1600px;
  overflow: hidden;
  touch-action: pan-y;
}

html.dark .diary-book {
  background: #121826;
  border-color: rgba(75, 85, 99, 0.55);
  box-shadow: 0 24px 74px rgba(0, 0, 0, 0.54), inset 0 0 0 1px rgba(148, 163, 184, 0.1);
}

.diary-book-spread {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.diary-book-single {
  grid-template-columns: minmax(0, 1fr);
}

.diary-book::before {
  content: "";
  position: absolute;
  top: 0.55rem;
  bottom: 0.55rem;
  width: 2.2rem;
  pointer-events: none;
  opacity: 0.72;
}

.diary-book::before {
  left: 0.55rem;
  border-left: 1px solid rgba(126, 116, 96, 0.24);
  box-shadow: 5px 0 0 rgba(255, 255, 255, 0.35), 10px 0 0 rgba(0, 0, 0, 0.04);
}

html.dark .diary-book::before {
  border-left-color: rgba(148, 163, 184, 0.12);
  box-shadow: 5px 0 0 rgba(148, 163, 184, 0.08), 10px 0 0 rgba(0, 0, 0, 0.2);
}

.diary-page {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(1.45rem, 3vw, 2.45rem);
  background: linear-gradient(90deg, #f5f3ed 0%, #fffefa 9%, #ffffff 52%, #faf8f0 100%);
  color: #20242c;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(145, 132, 106, 0.08);
}

.diary-page-left {
  border-radius: 0.45rem 0.1rem 0.1rem 0.45rem;
  border-right: 1px solid rgba(151, 143, 128, 0.34);
}

.diary-page-right {
  border-radius: 0.1rem 0.45rem 0.45rem 0.1rem;
  border-left: 1px solid rgba(151, 143, 128, 0.24);
}

.diary-page-right::before,
.diary-page-left::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2.35rem;
  pointer-events: none;
}

.diary-page-right::before {
  left: 0;
  background: linear-gradient(90deg, rgba(39, 36, 31, 0.22), rgba(255, 255, 255, 0));
}

.diary-page-left::after {
  right: 0;
  background: linear-gradient(270deg, rgba(39, 36, 31, 0.16), rgba(255, 255, 255, 0));
}

html.dark .diary-page {
  background: linear-gradient(90deg, #202733 0%, #2a313d 9%, #29313e 55%, #242b36 100%);
  color: #f1f5f9;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.2);
}

html.dark .diary-page-left {
  border-right-color: rgba(15, 23, 42, 0.78);
}

html.dark .diary-page-right {
  border-left-color: rgba(148, 163, 184, 0.08);
}

html.dark .diary-page-right::before {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.42), rgba(42, 49, 61, 0));
}

html.dark .diary-page-left::after {
  background: linear-gradient(270deg, rgba(0, 0, 0, 0.34), rgba(42, 49, 61, 0));
}

.diary-page-number {
  margin-bottom: 0.75rem;
  text-align: center;
  font-size: clamp(0.9rem, 1.8vw, 1.1rem);
  font-weight: 500;
  color: rgba(32, 36, 44, 0.58);
}

html.dark .diary-page-number {
  color: rgba(226, 232, 240, 0.5);
}

.diary-title-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: clamp(1.1rem, 1.8vw, 1.35rem);
  line-height: 1.2;
  font-weight: 500;
  color: #151923;
}

.diary-title-input {
  min-width: 0;
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  line-height: inherit;
  font: inherit;
  overflow-wrap: anywhere;
  overflow: hidden;
}

html.dark .diary-title-row {
  color: #f8fafc;
}

.diary-page-input {
  width: 100%;
  flex: 1;
  min-height: 10rem;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font-size: clamp(0.9rem, 1.45vw, 1.08rem);
  line-height: 1.35;
  overflow-y: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}

.diary-page-input::placeholder {
  color: rgba(32, 36, 44, 0.35);
}

html.dark .diary-page-input::placeholder {
  color: rgba(226, 232, 240, 0.32);
}

.diary-page-curl {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 4.7rem;
  height: 4.7rem;
  pointer-events: none;
  background: linear-gradient(135deg, transparent 48%, rgba(0, 0, 0, 0.08) 49%, rgba(255, 255, 255, 0.92) 55%, #ddd7cc 78%);
  border-radius: 0 0 0.4rem 0;
  filter: drop-shadow(-5px -5px 6px rgba(0, 0, 0, 0.13));
}

html.dark .diary-page-curl {
  background: linear-gradient(135deg, transparent 48%, rgba(0, 0, 0, 0.36) 49%, #4b5563 55%, #1f2937 78%);
  filter: drop-shadow(-5px -5px 7px rgba(0, 0, 0, 0.34));
}

.diary-page-left .diary-page-curl,
.diary-page-blank .diary-page-curl {
  display: none;
}

.diary-page-blank {
  background: linear-gradient(90deg, #fffefa 0%, #ffffff 45%, #faf8f0 100%);
}

html.dark .diary-page-blank {
  background: linear-gradient(90deg, #2a313d 0%, #29313e 55%, #242b36 100%);
}

.diary-close {
  position: absolute;
  top: 1.35rem;
  right: 1.35rem;
  z-index: 4;
  width: 2.8rem;
  height: 2.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.55rem;
  color: rgba(32, 36, 44, 0.46);
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.diary-close:hover {
  color: #1f2937;
  background: rgba(255, 255, 255, 0.82);
}

html.dark .diary-close {
  color: rgba(226, 232, 240, 0.46);
  background: rgba(15, 23, 42, 0.28);
  border-color: rgba(148, 163, 184, 0.12);
}

html.dark .diary-close:hover {
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.52);
}

.diary-page-turn {
  position: absolute;
  top: 1.1rem;
  bottom: 1.1rem;
  width: calc(50% - 1.1rem);
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(214, 205, 186, 0.82));
  box-shadow: 0 14px 26px rgba(48, 40, 30, 0.18);
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

html.dark .diary-page-turn {
  background: linear-gradient(90deg, rgba(42, 49, 61, 0.96), rgba(17, 24, 39, 0.9));
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.34);
}

.diary-book.is-flipping-next .diary-page-turn {
  right: 1.1rem;
  transform-origin: left center;
  animation: diaryFlipNext 0.98s cubic-bezier(0.18, 0.74, 0.22, 1);
}

.diary-book.is-flipping-prev .diary-page-turn {
  left: 1.1rem;
  transform-origin: right center;
  animation: diaryFlipPrev 0.98s cubic-bezier(0.18, 0.74, 0.22, 1);
}

@keyframes diaryFlipNext {
  0% { opacity: 0; transform: rotateY(0deg); }
  10% { opacity: 1; }
  72% { opacity: 1; }
  100% { opacity: 0; transform: rotateY(-178deg); }
}

@keyframes diaryFlipPrev {
  0% { opacity: 0; transform: rotateY(0deg); }
  10% { opacity: 1; }
  72% { opacity: 1; }
  100% { opacity: 0; transform: rotateY(178deg); }
}

.diary-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.diary-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 8.5rem;
  color: #3f4652;
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 500;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.diary-nav-btn:last-child {
  justify-content: flex-end;
}

.diary-nav-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.diary-nav-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.diary-nav-count {
  color: #687180;
  font-size: 0.9rem;
  font-weight: 600;
}

html.dark .diary-nav-btn {
  color: #d7dce6;
}

html.dark .diary-nav-count {
  color: #7d8796;
}

/* 7. Тосты */
.toast-enter { animation: toast-in .3s ease-out; }
.toast-leave { animation: toast-out .3s ease-in forwards; }
@keyframes toast-in  { from { opacity:0; transform:translateX(100%); } to { opacity:1; transform:translateX(0); } }
@keyframes toast-out { from { opacity:1; transform:translateX(0); }   to { opacity:0; transform:translateX(100%); } }

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* 8. Safe-area для iPhone с чёлкой */
.safe-top    { padding-top:    env(safe-area-inset-top); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }
.safe-left   { padding-left:   env(safe-area-inset-left); }
.safe-right  { padding-right:  env(safe-area-inset-right); }

.app-header {
  padding-top: calc(env(safe-area-inset-top) + 1.25rem);
  padding-bottom: 1.25rem;
}

.ui-c-49 { padding-top: calc(env(safe-area-inset-top) + 0.75rem); }
.ui-c-60,
.ui-c-97 { padding-top: calc(env(safe-area-inset-top) + 0.5rem); }
.ui-c-135 { padding-top: calc(env(safe-area-inset-top) + 0.75rem); }

/* 9. Мобильная адаптация */
@media (hover: none) {
  .group:not(:hover) .group-hover\:opacity-100,
  .opacity-0.group-hover\:opacity-100 { opacity: 1 !important; }
  .group:not(:hover) .group-hover\:opacity-0 { opacity: 0 !important; }
  .fade-in { -webkit-touch-callout: none; }
}

@media (max-width: 767px) {
  button, [role="button"] { min-height: 36px; }
  input, textarea, select { font-size: 16px !important; }
  .scroll-thin::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  .task-detail-panel-mobile {
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }
  .task-detail-panel-mobile .ui-c-60 {
    flex: 0 0 auto;
    touch-action: none;
  }
  .task-detail-panel-mobile .ui-c-63 {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }
  .task-detail-panel-mobile .ui-c-91 {
    flex: 1 1 0;
    min-height: 0;
  }
  .task-detail-panel-mobile .ui-c-92 {
    min-height: 0;
    padding-right: 0.35rem;
    -webkit-overflow-scrolling: touch;
  }
  /* Исключаем иконки-кнопки фиксированного размера из min-height */
  .task-detail-panel-mobile .task-notes-textarea {
    padding-right: 3rem;
  }
  .diary-overlay {
    padding: 0.7rem;
    align-items: stretch;
  }
  .diary-shell {
    width: 100%;
    justify-content: center;
  }
  .diary-book {
    min-height: min(76vh, 42rem);
    padding: 0.85rem;
  }
  .diary-book::before {
    opacity: 0.46;
  }
  .diary-page {
    border-radius: 0.45rem;
    border: 0;
    padding: 1.35rem 1.15rem 1.45rem;
  }
  .diary-page-left::after,
  .diary-page-right::before {
    display: none;
  }
  .diary-title-row {
    margin-bottom: 1.1rem;
    font-size: 1.08rem;
  }
  .diary-page-input {
    min-height: 14rem;
    font-size: 0.96rem !important;
  }
  .diary-page-curl {
    display: none;
  }
  .diary-page-turn {
    top: 0.85rem;
    bottom: 0.85rem;
    width: calc(100% - 1.7rem);
    animation-duration: 1.05s;
  }
  .diary-book.is-flipping-next .diary-page-turn,
  .diary-book.is-flipping-prev .diary-page-turn {
    left: 0.85rem;
    right: auto;
  }
  .diary-nav {
    gap: 0.5rem;
  }
  .diary-nav-btn {
    min-width: 0;
    font-size: 1rem;
  }
  .diary-nav-count {
    font-size: 0.78rem;
  }
  .theme-track { min-height: 0 !important; height: 24px !important; }
  .task-check-btn { min-height: 0 !important; min-width: 0 !important; width: 24px !important; height: 24px !important; }
}

button, .no-select { -webkit-user-select: none; user-select: none; }

/* 10. Long-press */
.long-press-active {
  transform: scale(0.98);
  transition: transform 0.15s ease;
}
.task-row {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Звезда: в светлой теме — полная заливка, в тёмной — обводка */
.star-active svg { fill: currentColor !important; stroke-width: 0 !important; }
html.dark .star-active svg { fill: none !important; stroke-width: 2px !important; }

/* 11. Спиннер загрузки */
@keyframes _spin { to { transform: rotate(360deg); } }

.app-loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--app-bg);
  z-index: 9999;
  font-family: system-ui, -apple-system, sans-serif;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--theme-track-idle);
  border-top-color: var(--theme-track-active);
  border-radius: 50%;
  animation: _spin 0.8s linear infinite;
}

.app-loading-msg {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.app-boot-error {
  max-width: 320px;
  border: 1px solid rgba(248, 113, 113, .45);
  border-radius: 8px;
  background: rgba(127, 29, 29, .18);
  color: #fecaca;
  padding: 12px 14px;
  font-size: 14px;
  text-align: center;
}

/* 12. Мобильный FAB — раскрытие снизу */
@keyframes slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.composer-slide-up { animation: slide-up 0.22s cubic-bezier(0.34,1.15,0.64,1); }

.composer-mobile-sheet {
  position: fixed;
  left: 10px;
  right: 10px;
  width: calc(100vw - 20px);
  max-width: calc(100vw - 20px);
  box-sizing: border-box;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible;
}

.composer-mobile-sheet .ui-c-161 {
  border-radius: 16px;
  overflow: visible;
  background: var(--composer-bg);
  box-shadow: var(--composer-shadow);
}

.composer-mobile-sheet .composer-clear-hint {
  right: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(50%);
  z-index: 140;
}

.color-modal-actions {
  gap: 10px;
}

body.list-dragging {
  cursor: grabbing;
  user-select: none;
}

body.list-dragging * {
  touch-action: none;
}

.list-draggable-row {
  transform: translate3d(0, 0, 0);
  transition:
    margin 0.24s cubic-bezier(.16, 1, .3, 1),
    background-color 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    opacity 0.16s ease,
    transform 0.24s cubic-bezier(.16, 1, .3, 1);
  will-change: margin, transform, opacity;
}

.list-drag-placeholder {
  opacity: 0.28;
  transform: scale(0.985);
}

.list-drag-over-before,
.list-drag-over-after {
  position: relative;
  transition:
    margin 0.24s cubic-bezier(.16, 1, .3, 1),
    opacity 0.16s ease,
    background-color 0.16s ease,
    transform 0.24s cubic-bezier(.16, 1, .3, 1);
}

.list-drag-over-before {
  margin-top: calc(var(--list-drag-gap, 44px) + 4px) !important;
}

.list-drag-over-after {
  margin-bottom: calc(var(--list-drag-gap, 44px) + 4px) !important;
}

.list-drag-over-before::before,
.list-drag-over-after::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.95);
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.12);
  pointer-events: none;
}

.list-drag-over-before::before {
  top: -4px;
}

.list-drag-over-after::after {
  bottom: -4px;
}

.list-drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 120;
  pointer-events: none;
  will-change: transform;
  backface-visibility: hidden;
}

.sidebar-folder-empty {
  margin: 2px 8px 8px 32px;
  padding: 8px 10px;
  border-radius: 8px;
  color: rgba(148, 163, 184, 0.9);
  font-size: 12px;
  line-height: 1.25;
  background: rgba(148, 163, 184, 0.08);
  border: 1px dashed rgba(148, 163, 184, 0.22);
}

.sidebar-drag-handle {
  width: 24px;
  height: 28px;
  flex: 0 0 24px;
  margin-left: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(107, 114, 128, 0.85);
  border-radius: 7px;
  touch-action: none;
  cursor: grab;
}

.sidebar-drag-handle:hover {
  color: rgba(148, 163, 184, 1);
  background: rgba(148, 163, 184, 0.1);
}

.sidebar-drag-handle:active {
  cursor: grabbing;
  color: rgba(209, 213, 219, 0.96);
  background: rgba(96, 165, 250, 0.14);
}

.steps-collapse-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px 8px 28px;
  color: rgb(148 163 184);
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid rgba(55, 65, 81, 0.24);
  transition: color 0.16s ease, background-color 0.16s ease;
}

.steps-collapse-toggle:hover {
  color: rgb(209 213 219);
  background: rgba(31, 41, 55, 0.32);
}

.steps-collapse-toggle span:nth-child(2) {
  flex: 1 1 auto;
  text-align: left;
}

.steps-collapse-toggle span:last-child {
  font-size: 11px;
  color: rgb(107 114 128);
}

.step-draggable {
  touch-action: pan-y;
  transform: translate3d(0, 0, 0);
  transition: transform 0.22s cubic-bezier(.16, 1, .3, 1), opacity 0.16s ease, background-color 0.16s ease;
  will-change: transform;
}

.step-drag-placeholder {
  opacity: 0.18;
  transform: scale(0.985);
}

.step-shift-up {
  transform: translate3d(0, calc(-1 * var(--step-drag-gap, 48px)), 0);
}

.step-shift-down {
  transform: translate3d(0, var(--step-drag-gap, 48px), 0);
}

.step-drag-handle {
  margin-left: -34px;
  width: 28px;
  height: 32px;
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(107, 114, 128, 0.9);
  border-radius: 6px;
  touch-action: none;
  cursor: grab;
}

.step-drag-handle:hover {
  color: rgba(209, 213, 219, 0.95);
  background: rgba(255, 255, 255, 0.06);
}

.step-drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 130;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px 12px 6px;
  border-radius: 10px;
  color: rgb(209 213 219);
  background: rgba(31, 41, 55, 0.96);
  border: 1px solid rgba(96, 165, 250, 0.45);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
  will-change: transform;
  backface-visibility: hidden;
}

.step-drag-ghost-grip {
  width: 28px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(148, 163, 184, 0.9);
  flex: 0 0 28px;
}

.step-drag-ghost-check {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  margin-top: 2px;
  border-radius: 999px;
  border: 2px solid rgb(107 114 128);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.step-drag-ghost-check-done {
  background: rgb(37 99 235);
  border-color: rgb(37 99 235);
}

.step-drag-ghost-title {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 14px;
  line-height: 20px;
  overflow-wrap: anywhere;
}

.search-result-group-head {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 28px;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 8px;
  color: rgb(156 163 175);
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid rgba(55, 65, 81, 0.18);
}

.search-result-group-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-result-group-title span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-group-count {
  flex: 0 0 auto;
  min-width: 26px;
  height: 22px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: rgb(107 114 128);
}

.search-result-group-chevron {
  justify-self: center;
  color: rgb(148 163 184);
}

.search-result-completed-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  color: rgb(107 114 128);
  font-size: 12px;
  font-weight: 600;
  border-top: 1px solid rgba(55, 65, 81, 0.14);
}

.search-result-completed-head span:last-child {
  margin-left: auto;
  min-width: 24px;
  height: 20px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.1);
}

@media (max-width: 767px) {
  .search-result-groups {
    width: 100%;
  }

  .search-result-group-head {
    min-height: 72px;
    grid-template-columns: minmax(0, 1fr) auto 34px;
    gap: 12px;
    padding: 0 28px 0 34px;
    font-size: 15px;
    border-bottom-color: rgba(55, 65, 81, 0.34);
  }

  .search-result-group-title {
    gap: 12px;
    font-size: 15px;
    font-weight: 700;
  }

  .search-result-group-title span:first-child {
    width: 28px;
    flex: 0 0 28px;
    text-align: center;
    font-size: 20px;
    line-height: 1;
  }

  .search-result-group-title span:last-child {
    min-width: 0;
  }

  .search-result-group-count {
    min-width: 30px;
    height: 30px;
    padding: 0 9px;
    font-size: 13px;
    color: rgb(156 163 175);
    background: rgba(31, 41, 55, 0.72);
  }

  .search-result-group-chevron {
    width: 26px;
    height: 26px;
    justify-self: end;
  }

  .search-result-completed-head {
    min-height: 56px;
    gap: 12px;
    padding: 0 34px;
    font-size: 15px;
    border-top: 0;
    border-bottom: 1px solid rgba(55, 65, 81, 0.3);
  }

  .search-result-completed-head svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
  }

  .search-result-completed-head span:nth-child(2) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .search-result-completed-head span:last-child {
    min-width: 30px;
    height: 28px;
    padding: 0 9px;
    font-size: 13px;
    color: rgb(156 163 175);
    background: rgba(31, 41, 55, 0.72);
  }

  .ui-c-154 {
    padding-left: 0.75rem;
  }

  .app-header .ui-c-173 {
    text-overflow: clip;
  }

  .mobile-title-toggle {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 18px;
    line-height: 1;
  }

  .mobile-title-toggle:hover,
  .mobile-title-toggle:active {
    background: rgba(255, 255, 255, 0.14);
  }

  .mobile-title-expanded {
    min-width: 0;
  }

  .mobile-title-full {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}
