:root {
  color-scheme: light dark;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #eceef2;
  --ink: #14161a;
  --muted: #6f7683;
  --line: rgba(20, 22, 26, 0.08);
  --line-strong: #cbd0d8;
  --accent: #2f6bff;
  --accent-soft: rgba(47, 107, 255, 0.16);
  --on-accent: #ffffff;
  --danger: #d44242;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 20px rgba(16, 24, 40, 0.05);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c0f;
    --surface: #15171b;
    --surface-soft: #1e2127;
    --ink: #f1f3f6;
    --muted: #969ca7;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: #3a3f48;
    --accent: #4c82ff;
    --accent-soft: rgba(76, 130, 255, 0.22);
    --on-accent: #ffffff;
    --danger: #ff7b7b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.22);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button,
textarea,
input {
  font: inherit;
  color: inherit;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg);
}

/* ---------- Верхняя строка: дата и стрелки ---------- */

.topbar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 6px;
  padding: calc(var(--safe-top) + 6px) 10px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.nav-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.nav-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.nav-btn:active {
  transform: scale(0.92);
}

.nav-btn svg {
  width: 22px;
  height: 22px;
}

.date-wrap {
  position: relative;
  min-width: 0;
}

.date-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 100%;
  min-height: 50px;
  padding: 6px 8px;
  border-radius: 14px;
  transition: background 0.15s;
}

.date-btn:hover,
.date-btn:active {
  background: var(--surface-soft);
}

.date-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.date-title > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.date-title svg {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.date-sub {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Невидимый нативный input: по нажатию на дату открывается системный календарь */
.date-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Список задач ---------- */

.board {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 14px 14px 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.tasks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.check {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: 1px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.check:hover {
  border-color: var(--accent);
}

.check:active {
  transform: scale(0.9);
}

.check svg {
  width: 16px;
  height: 16px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s, transform 0.15s;
}

.task.is-done .check {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.task.is-done .check svg {
  opacity: 1;
  transform: none;
}

.task-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.task-text {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  transition: color 0.15s;
}

.task.is-done .task-text {
  color: var(--muted);
  text-decoration: line-through;
}

.task-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-meta {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.task-del {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: -3px -2px 0 0;
  border-radius: 50%;
  color: var(--muted);
  opacity: 0.55;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}

.task-del:hover {
  background: var(--surface-soft);
  color: var(--danger);
  opacity: 1;
}

.task-del svg {
  width: 16px;
  height: 16px;
}

/* ---------- Пустой день ---------- */

.empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 24px 56px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
}

.empty-icon svg {
  width: 27px;
  height: 27px;
}

.empty-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.empty-hint {
  max-width: 250px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Нижняя строка: задача и файл ---------- */

.composer {
  position: relative;
  z-index: 5;
  padding: 8px 12px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 2px 8px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.file-chip svg {
  flex: none;
  width: 14px;
  height: 14px;
}

.file-chip .file-name {
  max-width: 190px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.file-chip .file-size {
  flex: none;
  opacity: 0.75;
}

.file-remove {
  display: grid;
  flex: none;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: -3px;
  border-radius: 50%;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.file-remove:hover {
  background: var(--line);
  color: var(--ink);
}

.file-remove svg {
  width: 12px;
  height: 12px;
}

.composer-form {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.attach-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.attach-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.attach-btn:active {
  transform: scale(0.92);
}

.attach-btn svg {
  width: 21px;
  height: 21px;
}

.task-input {
  flex: 1;
  min-width: 0;
  max-height: 132px;
  padding: 9px 4px;
  overflow-y: auto;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px;
  line-height: 1.4;
  resize: none;
}

.task-input::placeholder {
  color: var(--muted);
}

.send-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
}

.send-btn:not(:disabled):active {
  transform: scale(0.92);
}

.send-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

.file-input {
  display: none;
}

.composer-hint {
  display: none;
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}

/* ---------- Уведомление об удалении ---------- */

.toast {
  position: absolute;
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 9px 9px 9px 16px;
  border-radius: 14px;
  background: #22252c;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  color: #f4f5f7;
  font-size: 13.5px;
  transform: translateX(-50%);
  animation: toast-in 0.18s ease-out;
}

.toast-action {
  flex: none;
  padding: 7px 10px;
  border-radius: 9px;
  color: #9dbcff;
  font-size: 13.5px;
  font-weight: 600;
}

.toast-action:hover {
  background: rgba(255, 255, 255, 0.08);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
}

@media (hover: hover) and (pointer: fine) {
  .composer-hint {
    display: block;
  }
}

@media (min-width: 720px) {
  .app {
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }
}

/* ---------- Вход и заставка ---------- */

.splash {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.splash-logo {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(47, 107, 255, 0.22);
  animation: splash-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes splash-pulse {
  from {
    opacity: 0.75;
    transform: scale(0.96);
  }
}

.login {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
  overflow-y: auto;
  background: var(--bg);
}

.login-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: min(360px, 100%);
  text-align: center;
}

.login-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 20px;
  box-shadow: 0 12px 32px rgba(47, 107, 255, 0.24);
}

.login-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: var(--surface);
  font-size: 17px;
  text-align: center;
  letter-spacing: 0.06em;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-submit {
  width: 100%;
  height: 52px;
  margin-top: 12px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
}

.login-submit:active {
  transform: scale(0.99);
}

.login-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-error {
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 13.5px;
  line-height: 1.35;
}

.login-note {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--ink);
  text-align: center;
}

/* ---------- Неразобранное ---------- */

.date-sub.is-warn {
  color: var(--accent);
}

.day-empty {
  margin: 0;
  padding: 8px 2px 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.unsorted {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.section-head {
  margin: 0 2px 12px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.section-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.section-empty {
  margin: 0;
  padding: 14px 2px;
  color: var(--muted);
  font-size: 13px;
}

.task--unsorted {
  padding-left: 14px;
}

.task-actions {
  display: flex;
  flex: none;
  gap: 2px;
  margin: -2px -4px 0 0;
}

.task-edit {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--muted);
  opacity: 0.65;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}

.task-edit:hover {
  background: var(--surface-soft);
  color: var(--accent);
  opacity: 1;
}

.task-edit svg {
  width: 16px;
  height: 16px;
}

.task-actions .task-del {
  width: 32px;
  height: 32px;
  margin: 0;
  opacity: 0.65;
}

.task-edit-input {
  width: 100%;
  min-height: 76px;
  padding: 9px 11px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  resize: vertical;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.btn {
  padding: 8px 13px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.3;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn--ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.btn--ghost:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

button.file-chip {
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--muted);
}

button.file-chip:hover {
  background: var(--line);
  color: var(--ink);
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
}

@media (max-height: 540px) {
  .login-card {
    margin: auto 0;
  }
}

/* ---------- Установка приложения ---------- */

.install-banner {
  display: flex;
  align-items: center;
  flex: none;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.install-banner-main {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 10px;
  min-width: 0;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  transition: background 0.15s, transform 0.1s;
}

.install-banner-main:hover {
  background: var(--accent-soft);
}

.install-banner-main:active {
  transform: scale(0.995);
}

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

.install-banner-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.install-banner-arrow {
  flex: none;
  width: 15px;
  height: 15px;
  margin-left: auto;
  opacity: 0.75;
}

.install-banner-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.install-banner-close:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.install-banner-close svg {
  width: 16px;
  height: 16px;
}

.install-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.install-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.44);
  animation: install-fade 0.18s ease-out;
}

.install-sheet-panel {
  position: relative;
  width: min(480px, 100%);
  max-height: calc(100dvh - 20px);
  padding: 14px 20px calc(20px + var(--safe-bottom));
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.28);
  animation: install-sheet-in 0.22s ease-out;
}

.install-sheet-grip {
  display: block;
  width: 38px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: 99px;
  background: var(--line-strong);
}

.install-sheet-logo {
  display: block;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
}

.install-sheet-title {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
}

.install-steps {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.install-steps ol {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.install-steps li::marker {
  color: var(--accent);
  font-weight: 700;
}

.install-steps strong {
  color: var(--ink);
}

.install-steps svg {
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

.install-sheet-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.install-sheet-close {
  width: 100%;
  height: 48px;
  margin-top: 18px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.1s, opacity 0.15s;
}

.install-sheet-close:active {
  transform: scale(0.99);
}

@keyframes install-fade {
  from {
    opacity: 0;
  }
}

@keyframes install-sheet-in {
  from {
    opacity: 0.6;
    transform: translateY(18px);
  }
}

@media (display-mode: standalone) {
  .install-banner {
    display: none !important;
  }
}

@media (min-width: 720px) {
  .install-sheet {
    align-items: center;
    padding: 24px;
  }

  .install-sheet-panel {
    border-radius: 22px;
    padding-bottom: 22px;
  }
}
