:root {
  --bg: #f2f5f7;
  --surface: #ffffff;
  --surface-2: #f7fafb;
  --text: #0f1c26;
  --muted: #62737f;
  --line: #e2e8ec;
  --accent: #0e7490;
  --accent-deep: #0b5563;
  --accent-soft: #e2f2f5;
  --due: #b54708;
  --due-soft: #fef3c7;
  --done: #067647;
  --done-soft: #dcfae6;
  --miss: #b42318;
  --miss-soft: #fee4e2;
  --shadow: 0 1px 2px rgba(15, 28, 38, .05), 0 10px 30px rgba(15, 28, 38, .07);
  --radius: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1016;
    --surface: #121b23;
    --surface-2: #0f1820;
    --text: #e8eef3;
    --muted: #90a1ae;
    --line: #22303a;
    --accent: #22a3bf;
    --accent-deep: #0b5563;
    --accent-soft: #10323b;
    --due-soft: #3a2a10;
    --done-soft: #0d2f1f;
    --miss-soft: #3a1a16;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.is-locked {
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
  margin: 0 auto;
}

/* ---------------------------------------------------------------- шапка */

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 0;
}

.topbar__center {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.topbar__date {
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0 0 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

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

.topbar__cycle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: #cbd5dd;
}

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

/* ---------------------------------------------------------------- цикл */

.dots {
  display: flex;
  gap: 8px;
  padding: 0 4px;
}

.dot {
  flex: 1;
  display: grid;
  place-items: center;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}

.dot:active {
  transform: scale(.96);
}

.dot.is-current {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(14, 116, 144, .28);
}

.daybar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.daybar[hidden] {
  display: none;
}

.daybar .btn--small {
  background: var(--surface);
  color: var(--accent);
}

/* ---------------------------------------------------------------- герой */

.hero {
  position: relative;
  overflow: hidden;
  padding: 22px 22px 20px;
  border-radius: 26px;
  background: linear-gradient(160deg, #12839f 0%, #0b5563 100%);
  box-shadow: 0 18px 40px rgba(11, 85, 99, .22);
  color: #fff;
  transition: background .4s ease;
}

.hero::after {
  content: "";
  position: absolute;
  right: -50px;
  bottom: -90px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  pointer-events: none;
}

.hero[data-mode="act"] {
  background: linear-gradient(160deg, #d97706 0%, #b54708 100%);
  box-shadow: 0 18px 40px rgba(181, 71, 8, .26);
}

.hero[data-mode="done"] {
  background: linear-gradient(160deg, #12b981 0%, #067647 100%);
  box-shadow: 0 18px 40px rgba(6, 118, 71, .24);
}

.hero[data-mode="missed"],
.hero[data-mode="plan"] {
  background: linear-gradient(160deg, #64748b 0%, #334155 100%);
  box-shadow: 0 18px 40px rgba(51, 65, 85, .22);
}

.hero__kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  opacity: .82;
}

.hero[data-mode="act"] .hero__kicker::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: blink 1.6s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

.hero__title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

.hero__time {
  margin: 6px 0 0;
  font-size: 52px;
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.hero__time:empty {
  display: none;
}

.hero__meta {
  margin: 8px 0 0;
  font-size: 13.5px;
  opacity: .84;
}

.hero__actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.hero__actions:empty {
  display: none;
}

.hero__actions .btn--primary {
  flex: 1;
  background: #fff;
  color: var(--accent-deep);
}

.hero__actions .btn--ghost {
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

/* --------------------------------------------------------------- кнопки */

.btn {
  padding: 13px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, opacity .15s ease, background .15s ease;
}

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

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

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

.btn--wide {
  width: 100%;
}

.btn--small {
  padding: 9px 14px;
  border-radius: 11px;
  font-size: 14px;
}

.setting .btn--small {
  background: var(--accent-soft);
  color: var(--accent);
}

.setting .btn--small:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

.btn:disabled {
  opacity: .55;
  cursor: default;
}

.link {
  align-self: center;
  padding: 10px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

/* ---------------------------------------------------------------- план */

.plan {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px;
}

.plan__title {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.plan__count {
  color: var(--muted);
  font-size: 13px;
}

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

.plan__tomorrow {
  margin: 2px 4px 0;
  color: var(--muted);
  font-size: 12.5px;
}

.point {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .18s, transform .12s, opacity .2s;
}

.point:active {
  transform: scale(.995);
}

.point[data-status="due"],
.point[data-status="meal_due"] {
  border-left-color: var(--due);
}

.point[data-status="done"] {
  border-left-color: var(--done);
}

.point[data-status="missed"] {
  border-left-color: var(--miss);
}

.point[data-status="skipped"] {
  opacity: .55;
}

.point[data-status="plan"] {
  cursor: default;
}

.point__main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.point__time {
  min-width: 50px;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.point__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.point__title {
  font-size: 15px;
  font-weight: 600;
}

.point__hint {
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.point__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.point__value {
  color: var(--done);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.pill {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.point[data-status="due"] .pill,
.point[data-status="meal_due"] .pill {
  border-color: transparent;
  background: var(--due-soft);
  color: var(--due);
}

.point[data-status="done"] .pill {
  border-color: transparent;
  background: var(--done-soft);
  color: var(--done);
}

.point[data-status="missed"] .pill {
  border-color: transparent;
  background: var(--miss-soft);
  color: var(--miss);
}

.footnote {
  margin: 4px 4px 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

/* --------------------------------------------------------------- шторка */

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

.sheet[hidden] {
  display: none;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 24, .52);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.sheet__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow: auto;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  animation: sheet-up .22s ease;
}

@keyframes sheet-up {
  from { opacity: .5; transform: translateY(26px); }
  to { opacity: 1; transform: none; }
}

.sheet__grip {
  width: 38px;
  height: 4px;
  margin: 0 auto 4px;
  border-radius: 999px;
  background: var(--line);
}

.sheet__title {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
}

.sheet__sub {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sheet__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.sheet__error {
  margin: -4px 0 0;
  color: var(--miss);
  font-size: 13px;
}

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

  .sheet__panel {
    border-radius: 24px;
    max-height: 88dvh;
  }
}

/* ----------------------------------------------------------- поле значения */

.value-field {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
}

.value-field__input {
  flex: 1;
  min-width: 0;
  padding: 4px 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 32px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.value-field__unit {
  color: var(--muted);
  font-size: 14px;
}

/* -------------------------------------------------------------- настройки */

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

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

.setting__hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.setting__group {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
}

.time-row input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

/* ---------------------------------------------------------------- тост */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: min(92vw, 460px);
  padding: 12px 18px;
  border-radius: 14px;
  background: #101820;
  color: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity .2s ease, transform .2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------- отчёт на печать */

.report {
  display: none;
  color: #101820;
  font-size: 10.5pt;
  line-height: 1.45;
}

.report__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8pt;
  border-bottom: 1.4pt solid #101820;
}

.report__title {
  margin: 0;
  font-size: 19pt;
  font-weight: 700;
  letter-spacing: -.01em;
}

.report__period {
  margin: 4pt 0 0;
  color: #444;
  font-size: 10pt;
}

.report__generated {
  margin: 0;
  color: #666;
  font-size: 8.5pt;
  text-align: right;
}

.report__stats {
  margin: 10pt 0 0;
  color: #222;
  font-size: 10pt;
}

.report__table {
  width: 100%;
  margin-top: 10pt;
  border-collapse: collapse;
  font-size: 9.5pt;
}

.report__table th {
  padding: 4pt 6pt;
  border-bottom: 1.2pt solid #101820;
  font-weight: 600;
  text-align: left;
}

.report__table td {
  padding: 4pt 6pt;
  border-bottom: .4pt solid #c9ced4;
  vertical-align: top;
}

.report__table th:nth-child(1) { width: 17%; }
.report__table th:nth-child(2) { width: 8%; }
.report__table th:nth-child(3) { width: 10%; }
.report__table th:nth-child(4) { width: 33%; }
.report__table th:nth-child(5) { width: 17%; }
.report__table th:nth-child(6) { width: 15%; }

.report__note {
  margin-top: 14pt;
  color: #666;
  font-size: 8.5pt;
}

@media screen {
  body.is-print-preview {
    background: #e8ecef;
  }

  body.is-print-preview .app {
    display: none;
  }

  body.is-print-preview .report {
    display: block;
    max-width: 794px;
    margin: 24px auto;
    padding: 48px 44px;
    background: #fff;
    box-shadow: 0 12px 40px rgba(16, 24, 32, .12);
  }
}

@media print {
  @page {
    size: A4;
    margin: 14mm 12mm;
  }

  html,
  body {
    min-height: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  .app,
  .sheet,
  .toast {
    display: none !important;
  }

  .report {
    display: block;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  .report__table thead {
    display: table-header-group;
  }

  .report__table tr {
    page-break-inside: avoid;
  }
}
