/* 365 счастливых дней — общая тема */
:root {
  --bg: #f4efe4;
  --bg-deep: #ece5d6;
  --card: #fffcf6;
  --card-soft: #f8f3e9;
  --line: #e6dfcf;
  --text: #2c2a24;
  --muted: #7d776a;
  --faint: #aaa395;
  --primary: #45684b;
  --primary-ink: #fffcf6;
  --primary-soft: #dfe8d5;
  --accent: #e8a33a;
  --danger: #b5604f;

  /* шкала дня: −3 … +3 */
  --s-3: #b65f4e;
  --s-2: #d98f78;
  --s-1: #ebc0a3;
  --s0: #ecd27c;
  --s1: #cfdcae;
  --s2: #9bb87f;
  --s3: #4e7a55;
  --s-empty: #ebe5d8;

  --goal-365: #e8a33a;
  --goal-125: #4f9a52;
  --goal-blue: #2f86b5;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(60, 50, 30, .05), 0 6px 24px rgba(60, 50, 30, .06);
  --serif: "Lora", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--primary); }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.serif { font-family: var(--serif); font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.hidden { display: none !important; }

/* ---------- каркас приложения ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 96px);
}
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
h1.title { font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.1; margin: 4px 0 0; letter-spacing: -.01em; }
.subtitle { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.round-btn {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: #f3e6cc; color: #b98a36;
}
.round-btn.plain { background: var(--card); color: var(--muted); box-shadow: var(--shadow); width: 40px; height: 40px; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 14px; }
.section-title { font-weight: 600; font-size: 16px; margin: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px; border-radius: 16px;
  background: var(--primary); color: var(--primary-ink);
  font-weight: 600; font-size: 15.5px;
  box-shadow: 0 6px 18px rgba(69, 104, 75, .25);
  transition: transform .12s ease, filter .12s ease;
  text-decoration: none;
}
.btn:active { transform: scale(.985); filter: brightness(.95); }
.btn.secondary { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.btn.ghost { background: transparent; color: var(--primary); box-shadow: none; min-height: 44px; }
.btn.danger { background: transparent; color: var(--danger); box-shadow: none; min-height: 44px; }
.btn.small { min-height: 40px; font-size: 14px; border-radius: 12px; width: auto; padding: 0 16px; }
.btn[disabled] { background: #c3cbbd; color: #f6f4ee; box-shadow: none; pointer-events: none; }
.link-row {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line);
  font-size: 13.5px; font-weight: 500; color: var(--text); width: 100%; text-align: left;
}
.hint { text-align: center; color: var(--faint); font-size: 12.5px; margin-top: 12px; }

/* ---------- нижняя навигация ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(250, 247, 240, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar nav { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0 12px; font-size: 11.5px; color: var(--muted); text-decoration: none; font-weight: 500; }
.tab .pill { width: 54px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: background .2s; }
.tab.active { color: var(--primary); font-weight: 600; }
.tab.active .pill { background: var(--primary-soft); }

/* ---------- календарь ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h2 { font-family: var(--serif); font-weight: 400; font-size: 21px; margin: 0; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: var(--bg-deep); }
.icon-btn[disabled] { opacity: .3; pointer-events: none; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 10.5px; color: var(--faint); font-weight: 600; text-transform: uppercase; padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 13.5px; font-weight: 500; color: var(--faint);
  position: relative; transition: transform .1s;
}
.cal-day.past { color: var(--muted); }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary); font-weight: 700; }
.cal-day.selected { outline: 2px solid var(--text); outline-offset: 2px; }
.cal-day:not([disabled]):active { transform: scale(.92); }
.cal-day[disabled] { cursor: default; }
.legend { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 16px; }
.legend span { height: 24px; border-radius: 7px; display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.legend-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }

/* цвета шкалы */
.sc-3 { background: var(--s-3); color: #fff8f2 !important; }
.sc-2 { background: var(--s-2); color: #fff8f2 !important; }
.sc-1 { background: var(--s-1); color: #6e4a37 !important; }
.sc0  { background: var(--s0);  color: #6c5a1e !important; }
.sc1  { background: var(--s1);  color: #4c5d33 !important; }
.sc2  { background: var(--s2);  color: #fbfdf5 !important; }
.sc3  { background: var(--s3);  color: #fbfdf5 !important; }

/* ---------- карточка дня ---------- */
.day-card { background: var(--primary-soft); border-radius: var(--radius); padding: 18px; }
.day-card.neg { background: #f4e2d8; }
.day-card.neutral { background: #f5ecd0; }
.day-card .date { font-size: 12.5px; color: var(--muted); }
.day-card .note { font-family: var(--serif); font-size: 19px; line-height: 1.35; margin: 10px 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 26px; padding: 0 9px; border-radius: 13px; font-weight: 700; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; border: 1px solid rgba(0,0,0,.12); font-size: 12.5px; background: rgba(255,255,255,.35); }
.chip svg.i { width: 14px; height: 14px; }
.empty-card { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 22px 18px; text-align: center; color: var(--muted); }

/* ---------- запись дня ---------- */
.entry-top { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; margin-bottom: 18px; }
.entry-top .date { text-align: center; font-size: 13.5px; font-weight: 500; }
.score-card .head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.score-card .face { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card-soft); transition: background .2s, color .2s; }
.score-card .face svg { width: 30px; height: 30px; }
.score-card .label { font-weight: 600; font-size: 16px; }
.score-card .value { margin-left: auto; font-family: var(--serif); font-size: 32px; line-height: 1; }
.scale { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.scale button {
  height: 52px; border-radius: 13px; font-weight: 700; font-size: 15px;
  opacity: .55; transform: scale(.96); transition: all .15s ease;
}
.scale button.on { opacity: 1; transform: scale(1.06); box-shadow: 0 0 0 2.5px var(--card), 0 0 0 4.5px currentColor; }
.scale.none button { opacity: 1; transform: none; }
.scale-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 10px; }
.factor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.factor {
  display: flex; align-items: center; gap: 9px; min-height: 46px;
  padding: 0 12px; border-radius: 13px; background: var(--card);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 14px; text-align: left; transition: background .15s, box-shadow .15s;
}
.factor .check { margin-left: auto; opacity: 0; color: var(--primary); }
.factor.on { background: var(--primary-soft); box-shadow: inset 0 0 0 1px #c3d3b5; }
.factor.on .check { opacity: 1; }
.factor.add { color: var(--primary); box-shadow: inset 0 0 0 1px var(--line); border: 1.5px dashed #c9d6bd; background: transparent; }
.factor-input { display: flex; gap: 8px; grid-column: 1 / -1; }
.field, textarea.field {
  width: 100%; border-radius: 13px; border: 1px solid var(--line); background: var(--card);
  padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: #b6c9a6; box-shadow: 0 0 0 3px rgba(69,104,75,.12); }
textarea.field { min-height: 110px; resize: vertical; line-height: 1.5; }
.voice {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border-radius: 13px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 13.5px; text-align: left; margin-top: 8px;
}
.voice .mic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.voice.rec .mic { background: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(181,96,79,.45); } 50% { box-shadow: 0 0 0 8px rgba(181,96,79,0); } }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 0 10px; }
.block-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.sticky-save { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 14px); margin-top: 22px; z-index: 5; }

/* ---------- тенденции ---------- */
.seg { display: inline-flex; background: var(--bg-deep); border-radius: 12px; padding: 3px; }
.seg button { padding: 7px 18px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.period { display: flex; align-items: center; gap: 2px; font-size: 13.5px; font-weight: 500; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.stat .num { font-family: var(--serif); font-size: 30px; line-height: 1.1; }
.stat .cap { font-size: 12px; color: var(--muted); margin-top: 4px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.factor-stat { display: grid; grid-template-columns: 36px 1fr auto; gap: 4px 12px; align-items: center; }
.factor-stat + .factor-stat { margin-top: 14px; }
.factor-stat .ico { grid-row: span 2; width: 36px; height: 36px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.factor-stat .bar { height: 6px; background: var(--bg-deep); border-radius: 3px; overflow: hidden; }
.factor-stat .bar span { display: block; height: 100%; background: var(--s2); border-radius: 3px; }
.factor-stat .avg { font-weight: 600; font-size: 13px; text-align: right; }
.insight { background: #f3ead6; border-radius: 16px; padding: 16px; display: flex; gap: 12px; font-size: 13.5px; }
.insight svg.i { color: #9c7a3c; margin-top: 2px; }

/* год в квадратиках */
.year-grid { display: grid; grid-template-columns: 26px repeat(31, 1fr); gap: 2.5px; align-items: center; }
.year-grid .m { font-size: 9.5px; color: var(--muted); font-weight: 600; text-transform: lowercase; }
:where(.year-grid) i { aspect-ratio: 1; border-radius: 2.5px; background: var(--s-empty); display: block; }
:where(.year-grid) i.x { background: transparent; }
:where(.year-grid) i.fut { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.year-grid i.t { box-shadow: 0 0 0 1.5px var(--text); }

/* ---------- цели ---------- */
.goal { display: grid; grid-template-columns: 112px 1fr; gap: 16px; }
.goal-tile {
  border-radius: 12px; aspect-ratio: 1; color: #fff; padding: 10px; position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
.goal-tile .big { font-family: var(--sans); font-weight: 800; font-size: 34px; line-height: 1; letter-spacing: -.02em; }
.goal-tile .cap { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; line-height: 1.2; }
.goal-tile svg.i { position: absolute; right: 10px; bottom: 10px; width: 30px; height: 30px; stroke-width: 1.5; }
.goal .kicker { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.goal .count { font-size: 15px; margin-top: 4px; }
.goal .count b { font-size: 24px; font-weight: 700; }
.goal .count span { color: var(--muted); }
.progress { height: 6px; background: var(--bg-deep); border-radius: 3px; overflow: hidden; margin: 8px 0 6px; }
.progress span { display: block; height: 100%; border-radius: 3px; transition: width .6s ease; }
.goal .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.goal .meta b { color: var(--text); font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.stepper button { width: 34px; height: 34px; border-radius: 10px; background: var(--card-soft); box-shadow: inset 0 0 0 1px var(--line); display: grid; place-items: center; }
.life-grid { display: grid; grid-template-columns: repeat(25, 1fr); gap: 3px; margin-top: 14px; }
.life-grid i { aspect-ratio: 1; border-radius: 2px; background: var(--bg-deep); }
.life-grid i.on { background: var(--goal-125); }
.life-grid i.now { background: var(--accent); }

/* ---------- листы / формы ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(40,35,25,.35); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { background: var(--bg); width: 100%; max-width: 480px; border-radius: 24px 24px 0 0; padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px); max-height: 90dvh; overflow: auto; animation: up .25s ease; }
.sheet h2 { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 0 0 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
label.lbl { display: block; font-size: 12.5px; color: var(--muted); margin: 14px 0 6px; font-weight: 500; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; }
.swatches button.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.icon-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-pick button { width: 42px; height: 42px; border-radius: 12px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); display: grid; place-items: center; }
.icon-pick button.on { background: var(--primary-soft); box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary); }
.templates { display: flex; gap: 8px; flex-wrap: wrap; }
.templates button { padding: 8px 12px; border-radius: 99px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; }

/* ---------- настройки ---------- */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > * { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; text-align: left; text-decoration: none; color: var(--text); }
.list > * + * { border-top: 1px solid var(--line); }
.list .ico { width: 34px; height: 34px; border-radius: 10px; background: var(--card-soft); display: grid; place-items: center; color: var(--primary); flex: none; }
.list .grow { flex: 1; min-width: 0; }
.list .sub { font-size: 12.5px; color: var(--muted); }
.list input[type=date], .list input[type=time], .list input[type=text] { border: 0; background: var(--card-soft); border-radius: 10px; padding: 8px 10px; max-width: 170px; }
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 24px 4px 8px; }

/* ---------- баннеры / тосты ---------- */
.banner { background: #f3ead6; border-radius: 14px; padding: 10px 14px; font-size: 12.5px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.banner b { font-weight: 600; }
.banner button { margin-left: auto; font-weight: 600; color: var(--primary); white-space: nowrap; }
.banner.evening { background: var(--primary); color: var(--primary-ink); }
.banner.evening button { color: #fff; text-decoration: underline; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%); background: var(--text); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; z-index: 60; animation: up .25s ease; max-width: calc(100% - 32px); text-align: center; }

.fade-in { animation: fadeUp .35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.year-grid.nolabels { grid-template-columns: repeat(31, 1fr); }
body.no-tabs .tabbar { display: none; }
body.no-tabs .app { padding-bottom: calc(env(safe-area-inset-bottom) + 32px); }
