/* Мой дневник — iOS-нативная оболочка, sage-акцент. */

:root {
  color-scheme: light dark;

  --bg: #f2f2f7;
  --glow: rgba(220, 227, 166, 0.6);
  --surface: #ffffff;
  --text: #1c1c1e;
  --text-2: #636366;
  --text-3: #8e8e93;
  --sep: rgba(60, 60, 67, 0.16);
  --fill: rgba(118, 118, 128, 0.12);
  --sage: #6e7f22;
  --sage-strong: #55631a;
  --sage-soft: #dce3a6;
  --sage-tint: #eef1d6;
  --on-sage: #ffffff;
  --danger: #d70015;
  --bar: rgba(249, 249, 249, 0.94);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --glow: rgba(110, 127, 34, 0.22);
    --surface: #1c1c1e;
    --text: #f2f2f7;
    --text-2: #aeaeb2;
    --text-3: #8e8e93;
    --sep: rgba(255, 255, 255, 0.14);
    --fill: rgba(118, 118, 128, 0.24);
    --sage: #b7c46b;
    --sage-strong: #c9d47e;
    --sage-soft: #3a4416;
    --sage-tint: #232a10;
    --on-sage: #111111;
    --danger: #ff453a;
    --bar: rgba(28, 28, 30, 0.92);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.24);
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  color: var(--text);
  background:
    radial-gradient(120% 55% at 50% -8%, var(--glow), transparent 62%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body.sheet-open {
  overflow: hidden;
}

::selection {
  background: var(--sage-soft);
  color: var(--sage-strong);
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

button {
  font-family: inherit;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

.view {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 16px;
}

/* ---------------------------------------------------------------- */
/* Загрузка                                                          */
/* ---------------------------------------------------------------- */

.boot {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-3);
  font-size: 15px;
}

.boot img {
  width: 72px;
  height: 72px;
  border-radius: 17px;
}

/* ---------------------------------------------------------------- */
/* Онбординг                                                         */
/* ---------------------------------------------------------------- */

.onboarding {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
}

.onb-inner {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
}

.onb-icon {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  box-shadow: 0 12px 30px rgba(60, 70, 20, 0.18);
}

.onb-title {
  margin-top: 18px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
}

.onb-text {
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text-2);
}

.onb-form {
  margin-top: 24px;
  text-align: left;
}

.field-label {
  display: block;
  margin: 0 0 6px 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
}

.field {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--sep);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  appearance: none;
}

.field:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px var(--sage-tint);
}

.hint {
  min-height: 18px;
  margin: 7px 0 0 2px;
  font-size: 13px;
  color: var(--text-3);
}

.onb-form .btn {
  margin-top: 16px;
}

.onb-foot {
  margin-top: 18px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-3);
}

/* ---------------------------------------------------------------- */
/* Шапка дневника                                                    */
/* ---------------------------------------------------------------- */

.diary {
  padding-bottom: calc(164px + env(safe-area-inset-bottom, 0px));
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}

.top-text {
  flex: 1;
  min-width: 0;
}

.top h1 {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.sub {
  margin-top: 8px;
  max-width: 32em;
  font-size: 15px;
  line-height: 1.35;
  color: var(--text-2);
}

.icon-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text-2);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn-sm {
  width: 30px;
  height: 30px;
}

/* ---------------------------------------------------------------- */
/* Статус                                                            */
/* ---------------------------------------------------------------- */

.status {
  min-height: 22px;
  margin: 16px 2px 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  color: var(--text-3);
}

.status.is-saved {
  color: var(--sage-strong);
  font-weight: 500;
}

.status.is-saved::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage);
}

/* ---------------------------------------------------------------- */
/* Блоки и чипсы                                                     */
/* ---------------------------------------------------------------- */

.cards {
  margin-top: 4px;
}

.card {
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-sub {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-3);
}

.count {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--sage-soft);
  color: var(--sage-strong);
  font-size: 14px;
  font-weight: 650;
}

.card-question {
  margin: 14px 0 12px;
  font-size: 15px;
  color: var(--text-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 13px;
  border: 1px solid var(--sep);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.1s ease;
}

.chip:active {
  transform: scale(0.97);
}

.chip-check {
  display: none;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.chip[aria-pressed='true'] {
  background: var(--sage-soft);
  border-color: var(--sage);
  color: var(--sage-strong);
  font-weight: 550;
}

.chip[aria-pressed='true'] .chip-check {
  display: inline;
}

/* ---------------------------------------------------------------- */
/* Моя запись                                                        */
/* ---------------------------------------------------------------- */

.summary {
  margin-bottom: 4px;
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary-head h2 {
  font-size: 17px;
  font-weight: 650;
}

.summary-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--sage-strong);
}

.summary-body {
  margin-top: 12px;
}

.summary-empty {
  font-size: 15px;
  color: var(--text-3);
}

.chips-static {
  gap: 7px;
}

.chip-static {
  padding: 7px 11px;
  border-color: transparent;
  border-radius: 15px;
  background: var(--sage-tint);
  color: var(--sage-strong);
  font-size: 14px;
  cursor: default;
  pointer-events: none;
}

/* ---------------------------------------------------------------- */
/* Нижняя панель                                                     */
/* ---------------------------------------------------------------- */

.bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--sep);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

.bottom-row {
  display: flex;
  gap: 8px;
}

.bottom-row .btn {
  flex: 1;
}

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

.btn {
  min-height: 50px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.15s ease, transform 0.1s ease, background 0.15s ease;
}

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

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

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

.btn-secondary {
  background: var(--fill);
  color: var(--sage-strong);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-block {
  width: 100%;
}

/* ---------------------------------------------------------------- */
/* Баннер установки и notices                                        */
/* ---------------------------------------------------------------- */

.install-banner {
  margin-top: 14px;
  padding: 12px 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--sage-soft);
  border-radius: 14px;
  background: var(--sage-tint);
}

.install-banner-text {
  flex: 1;
  min-width: 0;
}

.install-banner-text strong {
  display: block;
  font-size: 14px;
  font-weight: 650;
  color: var(--sage-strong);
}

.install-banner-text p {
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--text-2);
}

.install-banner-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.link-btn {
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--sage-strong);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.notice {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--sage-soft);
  border-radius: 14px;
  background: var(--sage-tint);
  text-align: left;
}

.notice strong {
  font-size: 14px;
  color: var(--sage-strong);
}

.notice p {
  margin: 5px 0 6px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-2);
}

.notice-compact {
  margin: 18px 0;
}

/* ---------------------------------------------------------------- */
/* Журнал                                                            */
/* ---------------------------------------------------------------- */

.journal {
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin: 0 -16px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
  border-bottom: 1px solid var(--sep);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

.nav-back {
  justify-self: start;
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--sage-strong);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.nav-title {
  font-size: 17px;
  font-weight: 650;
  text-align: center;
  white-space: nowrap;
}

.navbar .icon-btn {
  justify-self: end;
}

.journal-head {
  padding: 18px 4px 0;
}

.journal-sub {
  font-size: 15px;
  font-weight: 500;
}

.journal-count {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-3);
}

.day {
  margin-top: 22px;
}

.day-title {
  margin: 0 4px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.list {
  padding: 0 14px;
  margin-top: 0;
}

.entry {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--sep);
}

.entry:last-child {
  border-bottom: 0;
}

.entry-time {
  padding-top: 1px;
  font-size: 15px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.entry-body {
  min-width: 0;
}

.entry-labels {
  font-size: 15px;
  font-weight: 550;
  line-height: 1.3;
  color: var(--sage-strong);
  overflow-wrap: anywhere;
}

.entry-meta {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-3);
}

.entry-count {
  align-self: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.mood-5 { color: #43a047; }
.mood-4 { color: #7cb342; }
.mood-3 { color: #fb8c00; }
.mood-2 { color: #f4511e; }
.mood-1 { color: #e53935; }

.empty {
  padding: 70px 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--text-2);
}

.empty-icon {
  margin-bottom: 14px;
  color: var(--sage);
  opacity: 0.75;
}

.empty h2 {
  font-size: 20px;
  color: var(--text);
}

.empty p {
  max-width: 280px;
  margin: 8px 0 20px;
  font-size: 15px;
  line-height: 1.4;
}

.empty .btn {
  min-width: 170px;
}

.fatal {
  max-width: 480px;
  padding-top: calc(40px + env(safe-area-inset-top, 0px));
}

.fatal h1 {
  font-size: 26px;
  line-height: 1.15;
}

.fatal p {
  margin-top: 12px;
  font-size: 15px;
  color: var(--text-2);
}

/* ---------------------------------------------------------------- */
/* Шторки                                                            */
/* ---------------------------------------------------------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sheet-backdrop.is-open {
  opacity: 1;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-height: 88dvh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18);
  transform: translateY(102%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.sheet.is-open {
  transform: none;
}

.sheet-grabber {
  width: 36px;
  height: 5px;
  margin: 2px auto 8px;
  border-radius: 3px;
  background: var(--sep);
}

.sheet-head {
  padding: 2px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-head h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sheet-text {
  margin-bottom: 18px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-2);
}

.sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.sheet-actions .btn {
  flex: 1;
}

.settings {
  padding-bottom: 4px;
}

.group {
  margin-top: 18px;
}

.group-title {
  margin: 0 4px 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

.group .list {
  padding: 0 14px;
  border-radius: 14px;
  background: var(--fill);
}

.row {
  width: 100%;
  padding: 13px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--sep);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.row:last-child {
  border-bottom: 0;
}

.row-value {
  font-size: 16px;
  color: var(--text-3);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
}

.chev {
  color: var(--text-3);
  font-size: 20px;
  line-height: 1;
}

.row-danger,
.row-danger .chev {
  color: var(--danger);
}

.privacy-note {
  margin: 18px 4px 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-3);
}

.steps {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-n {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--sage-soft);
  color: var(--sage-strong);
  font-size: 13px;
  font-weight: 700;
}

.steps b {
  font-size: 15px;
}

.steps p {
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-2);
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  max-width: calc(100% - 40px);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 18px;
  background: rgba(28, 28, 30, 0.92);
  color: #ffffff;
  font-size: 14px;
  line-height: 1.3;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.toast-action {
  padding: 2px 0;
  border: 0;
  background: none;
  color: #c9d47e;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

/* ---------------------------------------------------------------- */
/* Планшет и десктоп                                                 */
/* ---------------------------------------------------------------- */

@media (min-width: 560px) {
  .app {
    max-width: 480px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    border-left: 1px solid var(--sep);
    border-right: 1px solid var(--sep);
  }

  .view {
    padding-left: 20px;
    padding-right: 20px;
  }

  .navbar {
    margin-left: -20px;
    margin-right: -20px;
  }

  .bottom {
    left: 50%;
    right: auto;
    width: 480px;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
  }

  .sheet {
    left: 50%;
    width: 480px;
    border-radius: 20px 20px 0 0;
    transform: translate(-50%, 102%);
  }

  .sheet.is-open {
    transform: translate(-50%, 0);
  }
}

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