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

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app { position: relative; height: 100%; }
.num { font-variant-numeric: tabular-nums; }
.lb { font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; font-weight: 600; color: var(--ink-faint); }
.soft { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.hot { color: var(--hot); }

/* ---------- полотно ---------- */
#field {
  position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-top), var(--bg) 70%);
  touch-action: none; overflow: hidden;
}

/* Пятна дышат вразнобой: одинаковый ритм читался бы как пульсация интерфейса,
   а не как «карта живая». Длительность и фаза берутся из id сферы, поэтому
   характер пятна не меняется между запусками. */
.blob {
  position: absolute; display: flex; flex-direction: column;
  /* Форма задаётся и здесь, не только в кейфреймах: до старта анимации
     (и при prefers-reduced-motion) пятно иначе рисуется квадратом. */
  border-radius: 52% 48% 47% 53% / 49% 53% 47% 51%;
  align-items: center; justify-content: center; text-align: center;
  line-height: 1.08; border: 0; padding: 0; margin: 0;
  color: var(--on-glaze); cursor: grab; touch-action: none;
  --sway: 12px;
  will-change: border-radius, transform;
  transition: opacity .25s ease, filter .25s ease;
}
.blob:active { cursor: grabbing; }
.blob .nm {
  font-size: 15px; font-weight: 600; letter-spacing: -.01em; padding: 0 8px;
  max-width: 100%; overflow: hidden; word-break: break-word; hyphens: auto;
}
.blob .ct { font-size: 10.5px; font-weight: 600; opacity: .85; margin-top: 2px; letter-spacing: .04em; }
.blob:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
.blob.dragging { z-index: 5; animation-play-state: paused; }

/* Пятна не просто меняют форму — они медленно плывут. Амплитуда небольшая
   (--sway, обычно 10–18 px) и у каждого своя, поэтому карта дышит, но вещи
   остаются там, куда их поставили: найти сферу глазами всё так же легко. */
@keyframes drift-a {
  0%   { border-radius: 58% 42% 47% 53% / 49% 55% 45% 51%;
         transform: translate(calc(-50% - var(--sway)), calc(-50% + var(--sway) * .55)) rotate(0deg) scale(1); }
  25%  { border-radius: 44% 56% 59% 41% / 57% 44% 56% 43%;
         transform: translate(calc(-50% + var(--sway) * .7), calc(-50% - var(--sway))) rotate(3deg) scale(1.022); }
  55%  { border-radius: 52% 48% 41% 59% / 43% 57% 43% 57%;
         transform: translate(calc(-50% + var(--sway)), calc(-50% + var(--sway) * .8)) rotate(-2deg) scale(.99); }
  80%  { border-radius: 49% 51% 52% 48% / 51% 49% 51% 49%;
         transform: translate(calc(-50% - var(--sway) * .4), calc(-50% + var(--sway) * .2)) rotate(1deg) scale(1.008); }
  100% { border-radius: 58% 42% 47% 53% / 49% 55% 45% 51%;
         transform: translate(calc(-50% - var(--sway)), calc(-50% + var(--sway) * .55)) rotate(0deg) scale(1); }
}
@keyframes drift-b {
  0%   { border-radius: 47% 53% 56% 44% / 54% 46% 54% 46%;
         transform: translate(calc(-50% + var(--sway) * .8), calc(-50% - var(--sway) * .6)) rotate(0deg) scale(1); }
  30%  { border-radius: 60% 40% 44% 56% / 42% 58% 42% 58%;
         transform: translate(calc(-50% - var(--sway)), calc(-50% - var(--sway) * .2)) rotate(-4deg) scale(1.03); }
  60%  { border-radius: 41% 59% 53% 47% / 56% 43% 57% 44%;
         transform: translate(calc(-50% - var(--sway) * .3), calc(-50% + var(--sway))) rotate(2deg) scale(.985); }
  85%  { border-radius: 53% 47% 49% 51% / 47% 52% 48% 53%;
         transform: translate(calc(-50% + var(--sway) * .5), calc(-50% + var(--sway) * .3)) rotate(-1deg) scale(1.01); }
  100% { border-radius: 47% 53% 56% 44% / 54% 46% 54% 46%;
         transform: translate(calc(-50% + var(--sway) * .8), calc(-50% - var(--sway) * .6)) rotate(0deg) scale(1); }
}

/* Замолчавшая сфера замирает: ни движения, ни блика, ни цвета. */
.blob.silent {
  animation: none !important;
  transform: translate(-50%, -50%) !important;
  border-radius: 52% 48% 45% 55% / 48% 52% 48% 52%;
  background: none !important; box-shadow: none !important;
  border: 2px dashed var(--cold); color: var(--cold);
}
.blob.silent .ct { opacity: 1; }

/* Неразобранная мысль: бесцветная капля между сферами. Пока у неё нет места,
   она и выглядит как ничьё. */
.blob.loose .nm { font-weight: 500; }
.blob.loose.over { border-color: var(--ink); border-style: solid; }

/* Просроченное дело обведено — видно, не читая подписи. */
.blob.overdue { outline: 2.5px solid var(--hot); outline-offset: 3px; }

/* Сфера, над которой держат каплю: подсвечивается, чтобы было ясно, куда упадёт. */
.blob.target { outline: 3px dashed var(--ink); outline-offset: 6px; }

.blob .badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px;
  border-radius: 10px; background: var(--surface); color: var(--ink);
  font-size: 11px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; padding: 0 5px;
  box-shadow: 0 2px 6px -2px rgba(0, 0, 0, .4);
}

.field-hint { position: absolute; left: 16px; bottom: calc(var(--sheet-peek) + 78px); }
.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 32px;
  text-align: center; color: var(--ink-soft);
}

/* ---------- верхняя пилюля ---------- */
.pill {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); display: flex; gap: 2px; padding: 3px; z-index: 4;
  background: var(--surface); border-radius: 22px;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .35);
}
.pill button {
  font: inherit; font-size: 11px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; border: 0; background: none; color: var(--ink-faint);
  padding: 9px 14px; border-radius: 18px; cursor: pointer; min-height: 38px;
}
.pill button[aria-selected="true"] { background: var(--ink); color: var(--bg); }

/* ---------- крошки ---------- */
#crumbs {
  position: absolute; top: max(62px, calc(env(safe-area-inset-top) + 50px));
  left: 50%; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border-radius: 18px; padding: 5px 12px;
  box-shadow: 0 4px 14px -8px rgba(0, 0, 0, .35); max-width: calc(100% - 32px);
}
#crumbs:empty { display: none; }
#crumbs button {
  font: inherit; font-size: 12px; font-weight: 600; border: 0; background: none;
  color: var(--ink-faint); padding: 3px 0; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px;
}
#crumbs button:last-child { color: var(--ink); }

/* ---------- шторка ---------- */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--sheet-shadow);
  height: var(--sheet-height); transition: height .32s cubic-bezier(.32, .72, 0, 1);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.dragging { transition: none; }
.grip { padding: 9px 0 4px; cursor: grab; touch-action: none; flex: none; }
.grip span { display: block; width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto; }
.sheet-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 2px 16px 8px; flex: none;
}
.sheet-head h2 { font-size: 18px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 9px; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.sheet-body { flex: 1; overflow-y: auto; padding: 0 16px 96px; -webkit-overflow-scrolling: touch; }

/* ---------- строки дел ---------- */
.task { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; }
.check {
  width: 26px; height: 26px; border-radius: 50%; flex: none; padding: 0; cursor: pointer;
  border: 2px solid var(--line-strong); background: none; position: relative;
}
.check::before { content: ""; position: absolute; inset: -9px; }
.check.on { background: var(--ink); border-color: var(--ink); }
.check.on::after {
  content: ""; position: absolute; left: 8px; top: 4px; width: 5px; height: 10px;
  border: solid var(--bg); border-width: 0 2px 2px 0; transform: rotate(42deg);
}
.task .name {
  flex: 1; min-width: 0; background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
.task.done .name { color: var(--ink-faint); text-decoration: line-through; }
.task.missed .name { color: var(--cold); }
.tag {
  font-size: 10px; letter-spacing: .07em; text-transform: uppercase; font-weight: 600;
  border-radius: 20px; padding: 5px 10px; white-space: nowrap; flex: none;
  background: var(--surface-2); color: var(--ink-soft); border: 0; cursor: pointer;
  min-height: 30px;
}
.tag.hot { background: var(--hot-bg); color: var(--hot); }
.tag.cold { background: var(--surface-2); color: var(--cold); }
.into {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0; background: none;
  color: var(--ink-faint); font-size: 19px; cursor: pointer; line-height: 1;
}
.kids { font-size: 11px; font-weight: 600; color: var(--ink-faint); flex: none; }

/* Пустое пятно с плюсом — точка добавления новой сферы прямо на карте. */
.blob.add { box-shadow: none !important; }
.blob.add .nm { font-weight: 300; }

/* Заголовок сферы в шторке — кнопка: открывает её карточку. */
.head-btn {
  display: flex; align-items: center; gap: 9px; font: inherit; font-size: 18px;
  font-weight: 600; color: var(--ink); background: none; border: 0; padding: 0;
  cursor: pointer; text-align: left; min-height: 34px;
}
.head-btn .faint { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }

/* Кружки красок в карточке сферы. */
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; flex: none;
}
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }

/* Кнопка «назад»: крошки мелкие, а возвращаться нужно часто. */
#crumbs .back {
  font-size: 22px; line-height: 1; color: var(--ink); padding: 0 4px 3px;
  min-width: 26px;
}

/* Заголовок группы на корне: он же кнопка входа в сферу. */
.group {
  display: flex; align-items: center; gap: 9px; width: 100%;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  background: none; border: 0; padding: 16px 0 6px; cursor: pointer; text-align: left;
}
.group .lb { margin-left: auto; }

/* ---------- ранг ---------- */
.rank {
  font-family: var(--font-num); font-size: 15px; font-weight: 600; color: var(--ink-faint);
  width: 20px; text-align: right; flex: none; font-variant-numeric: tabular-nums;
}

/* ---------- обзор ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.bar-row:first-child { border-top: 0; }
.bar-name { width: 78px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; min-width: 0; }
.bar { display: block; height: 9px; border-radius: 5px; min-width: 3px; }
.bar.closed { opacity: .34; margin-top: 3px; }
.bar-delta { width: 36px; flex: none; text-align: right; font-weight: 600; }

/* ---------- ввод ---------- */
.quick {
  position: absolute; left: 12px; right: 12px; z-index: 6;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 9px;
  background: var(--ink); color: var(--bg); border-radius: 28px; padding: 8px 8px 8px 17px;
  box-shadow: 0 10px 26px -12px rgba(0, 0, 0, .7);
}
.quick input {
  flex: 1; min-width: 0; background: none; border: 0; font: inherit; font-size: 15px;
  color: var(--bg); padding: 8px 0;
}
.quick input::placeholder { color: var(--bg); opacity: .58; }
.quick input:focus { outline: none; }
.quick button {
  width: 38px; height: 38px; border-radius: 50%; border: 0; flex: none; cursor: pointer;
  background: var(--bg); color: var(--ink); font-size: 22px; line-height: 1; font-weight: 300;
}

/* ---------- карточка дела ---------- */
.modal { position: absolute; inset: 0; z-index: 10; display: flex; align-items: flex-end; }
.modal-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .38); border: 0; width: 100%; }
.modal-card {
  position: relative; width: 100%; background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 16px 16px 26px;
  padding-bottom: calc(26px + env(safe-area-inset-bottom));
  box-shadow: var(--sheet-shadow); animation: rise .28s cubic-bezier(.32, .72, 0, 1);
}
@keyframes rise { from { transform: translateY(16px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-card input[type="text"] {
  width: 100%; font: inherit; font-size: 17px; font-weight: 600; color: var(--ink);
  background: var(--surface-2); border: 0; border-radius: var(--radius); padding: 12px 13px;
}
.modal-card input:focus { outline: 2px solid var(--ink); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.chip {
  font: inherit; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line-strong);
  background: none; color: var(--ink-soft); border-radius: 20px; padding: 9px 13px;
  cursor: pointer; min-height: var(--tap);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip.danger { color: var(--hot); border-color: var(--hot-bg); }
.btn {
  font: inherit; font-size: 14px; font-weight: 600; border: 0; border-radius: var(--radius);
  background: var(--ink); color: var(--bg); padding: 13px 18px; cursor: pointer; min-height: var(--tap);
}
.btn.ghost { background: var(--surface-2); color: var(--ink); }

/* ---------- поиск, режимы, отмена, история ---------- */
.modes { display: flex; gap: 8px; padding: 10px 0 4px; }
.search { padding: 4px 0 8px; }
.search input {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface-2); border: 0; border-radius: var(--radius);
  padding: 11px 13px; min-height: var(--tap);
}
.search input:focus { outline: 2px solid var(--ink); }

/* Полоса отмены висит над вводом: удаление должно быть обратимым, пока
   человек ещё смотрит на экран. */
.undo {
  position: absolute; left: 12px; right: 12px; z-index: 7;
  bottom: calc(68px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: var(--bg); border-radius: var(--radius);
  padding: 12px 14px; font-size: 13.5px;
  box-shadow: 0 10px 26px -12px rgba(0, 0, 0, .7);
  animation: rise .2s ease-out;
}
.undo span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.undo-btn {
  font: inherit; font-size: 13px; font-weight: 700; border: 0; background: none;
  color: var(--bg); text-decoration: underline; cursor: pointer; padding: 4px;
}

/* Закрытая строка гаснет до ответа сервера — отклик должен быть мгновенным. */
.task.leaving { opacity: .38; transition: opacity .2s ease; }

.day { padding: 14px 0 6px; border-top: 1px solid var(--line); }
.day:first-of-type { border-top: 0; }
.day-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.day-name { font-size: 13px; font-weight: 600; width: 108px; flex: none; }
.day-bar { height: 8px; border-radius: 4px; background: var(--ink); opacity: .18; }
.day-item { display: flex; align-items: center; gap: 9px; padding: 5px 0 5px 8px; font-size: 13.5px; }
.day-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- настройки ---------- */
.setting {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-top: 1px solid var(--line); font-size: 14px;
}
.setting > span:first-child { flex: 1; }
.setting input {
  width: 72px; font: inherit; font-size: 15px; text-align: right; color: var(--ink);
  background: var(--surface-2); border: 0; border-radius: var(--radius);
  padding: 9px 10px; min-height: 40px;
}
.setting input:focus { outline: 2px solid var(--ink); }
.setting .faint { width: 66px; font-size: 12px; }

/* ---------- помидор ---------- */
.focus-card { text-align: center; }
.focus-title {
  font-size: 17px; font-weight: 600; margin: 6px 0 18px;
  overflow-wrap: anywhere;
}
.focus-dial { position: relative; width: 210px; margin: 0 auto 18px; }
.focus-dial svg { width: 100%; height: auto; transform: rotate(-90deg); }
.dial-bg { fill: none; stroke: var(--line); stroke-width: 6; }
.dial-run {
  fill: none; stroke: var(--ink); stroke-width: 6; stroke-linecap: round;
  transition: stroke-dashoffset .3s linear;
}
.focus-time {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 42px; font-weight: 600; letter-spacing: -.02em;
}

.hint { color: var(--ink-soft); font-size: 13px; line-height: 1.5; padding: 10px 0; }
#theme {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 6;
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--surface); color: var(--ink-soft); font-size: 17px; line-height: 1;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .35);
}
#theme:active { transform: scale(.94); }

#status {
  position: absolute; top: max(58px, calc(env(safe-area-inset-top) + 46px));
  right: 14px; z-index: 5;
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600;
  color: var(--ink-faint);
}
#status[data-state="offline"] { color: var(--hot); }

/* На широком экране телефонная раскладка разваливается: шторка съедает всё, а
   карты не видно. Поэтому от 860 px это две колонки — полотно и постоянная
   панель справа, — и шторка перестаёт быть шторкой. */
@media (min-width: 860px) {
  #field { right: 400px; }

  /* Без карты список занимает весь экран: в правой колонке он выглядел бы
     полоской рядом с пустотой. Ширину строки держим читаемой. */
  #app[data-tab="focus"] .sheet,
  #app[data-tab="review"] .sheet,
  #app[data-tab="plan"] .sheet { left: 0; width: 100%; border-left: 0; }
  #app[data-tab="focus"] .sheet-head,
  #app[data-tab="review"] .sheet-head,
  #app[data-tab="focus"] .sheet-body,
  #app[data-tab="review"] .sheet-body,
  #app[data-tab="plan"] .sheet-head,
  #app[data-tab="plan"] .sheet-body {
    max-width: 760px; margin: 0 auto; width: 100%;
  }
  #app[data-tab="focus"] .quick { left: 50%; right: auto; transform: translateX(-50%); width: 720px; }
  #app[data-tab="focus"] .pill,
  #app[data-tab="review"] .pill,
  #app[data-tab="plan"] .pill { right: auto; left: 50%; transform: translateX(-50%); }
  #app[data-tab="focus"] #theme,
  #app[data-tab="review"] #theme,
  #app[data-tab="plan"] #theme { right: 20px; top: 20px; }
  #app[data-tab="focus"] #status,
  #app[data-tab="review"] #status,
  #app[data-tab="plan"] #status { right: 68px; top: 26px; }
  .sheet {
    left: auto; right: 0; top: 0; width: 400px; height: 100% !important;
    border-radius: 0; border-left: 1px solid var(--line);
    box-shadow: none; transition: none;
  }
  .grip { display: none; }
  .sheet-head { padding-top: 22px; }
  .pill { left: auto; right: 424px; transform: none; }
  #crumbs { left: 24px; transform: none; top: 22px; }
  #theme { right: 424px; top: 68px; }
  #status { right: 470px; top: 74px; }
  .quick { left: auto; right: 16px; width: 368px; }
  .modal { justify-content: flex-end; align-items: center; }
  .modal-card { max-width: 420px; margin-right: 24px; border-radius: var(--radius-lg); }
  .sheet-body { padding-bottom: 108px; }
}

/* Низкое окно (ноутбук в альбомной, разделённый экран): шторка не должна
   занимать половину, иначе от карты остаётся полоска. */
@media (max-height: 560px) and (max-width: 859px) {
  .sheet { max-height: 58%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ---------- календарь ---------- */
/* Четвёртая вкладка не помещается в узкий экран прежними отступами. */
/* Четвёртая вкладка не помещалась: полоса налезала на переключатель темы. */
@media (max-width: 430px) {
  .pill { left: 12px; transform: none; }
  .pill button { padding: 9px 8px; letter-spacing: .02em; font-size: 10.5px; }
}

.cal-day {
  border-top: 1px solid var(--line); padding: 12px 0 4px;
}
.cal-day:first-of-type { border-top: 0; }
.cal-day.free { padding: 7px 0 3px; opacity: .5; }
.cal-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px;
}
.cal-name { font-weight: 650; font-size: 14.5px; }
.cal-day.today .cal-name { color: var(--accent); }
.cal-free { margin-left: auto; font-size: 12px; }
.cal-free.over { color: var(--hot); font-weight: 650; }
/* Полоса загрузки: сколько от дневной ёмкости занято. Перебор виден цветом,
   а не только цифрой — глазом ловится быстрее. */
.cal-load {
  height: 5px; border-radius: 3px; background: var(--line);
  overflow: hidden; margin-bottom: 8px;
}
.cal-load span { display: block; height: 100%; background: var(--ink-faint); }
.cal-load span.over { background: var(--hot); }
.cal-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
  cursor: pointer; font-size: 14px;
}
.cal-item .cal-title { flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.cal-item.late .cal-title { color: var(--hot); }
.cal-est { font-size: 11.5px; letter-spacing: .06em; color: var(--ink-faint); }
.cal-est.none { opacity: .45; }
.cal-est.late-mark { color: var(--hot); letter-spacing: .04em; }
