/* Календарь мероприятий HOMEART — мини-апп Telegram.
   Дизайн-система HOMEART, режим Quiet: off/mist + ink, amber только как метка, emerald — «сделано». */

@font-face { font-family: "Brand Sans"; src: url("fonts/Montserrat-Light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Brand Sans"; src: url("fonts/Montserrat-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Brand Sans"; src: url("fonts/Montserrat-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --bg: #fafaf8;            /* ha-off */
  --surface: #ffffff;
  --muted: #f2f1ee;         /* ha-mist */
  --fog: #e8e7e3;           /* ha-fog */
  --fg: #1a1a1a;            /* ha-ink */
  --fg-2: #585654;          /* ha-graphite */
  --fg-3: #a49e96;          /* ha-stone — только неактивное */
  --line: rgba(26, 26, 26, 0.10);
  --line-strong: rgba(26, 26, 26, 0.32);
  --mark: #b8691f;          /* ha-amber — метка «сегодня», не текст */
  --ok: #2a6b52;            /* ha-emerald */
  --ok-wash: #e0ebe4;
  --err: #8b2e2a;           /* ha-claret */
  --err-text: #8b2e2a;
  --btn-bg: #1a1a1a;
  --btn-fg: #fafaf8;
  --focus: #1a1a1a;
  --shadow: 0 2px 6px rgba(26, 26, 26, 0.06), 0 12px 28px rgba(26, 26, 26, 0.08);

  --font: "Brand Sans", "Museo Sans Cyrl", "Helvetica Neue", Arial, system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --gut: 16px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1a1a1a;            /* ha-ink */
  --surface: #2b2b2b;       /* ha-ink-soft */
  --muted: #2b2b2b;
  --fog: #3d3d3d;           /* ha-slate */
  --fg: #fafaf8;
  --fg-2: #a49e96;          /* ha-stone */
  --fg-3: #7a7772;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.34);
  --mark: #c9a76a;          /* brass */
  --ok: #6a9a82;
  --ok-wash: rgba(106, 154, 130, 0.16);
  --err: #b5655f;
  --err-text: #fafaf8;
  --btn-bg: #fafaf8;
  --btn-fg: #1a1a1a;
  --focus: #fafaf8;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 12px 28px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern", "lnum";
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Демо-оболочка Telegram (только вне Telegram) ---------- */
.tg-head {
  position: sticky; top: 0; z-index: 30;
  height: 52px; display: flex; align-items: center; gap: 8px;
  padding: 0 8px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.tg-head .tg-title { flex: 1; text-align: center; font-weight: 500; font-size: 15px; line-height: 1.2; }
.tg-head .tg-title small { display: block; font-weight: 400; font-size: 12px; color: var(--fg-2); }
.tg-head button { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 999px; }
.tg-head button[hidden] { visibility: hidden; display: grid; }
.tg-main {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.tg-main button {
  width: 100%; height: 48px; border-radius: 10px;
  background: var(--btn-bg); color: var(--btn-fg); font-weight: 500; font-size: 15px;
  transition: transform 160ms var(--ease), opacity 160ms var(--ease);
}
.tg-main button:active { transform: scale(0.985); }
body.demo.has-main .app { padding-bottom: 88px; }

/* ---------- Каркас ---------- */
.app { min-height: 100vh; padding-bottom: 32px; }
.tabs {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  display: flex; gap: 4px; padding: 10px var(--gut) 10px;
}
body.demo .tabs { top: 52px; }
.tabs button {
  flex: 1; height: 36px; border-radius: 999px; font-size: 13px; font-weight: 500;
  color: var(--fg-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}
.tabs button[aria-selected="true"] { background: var(--fg); color: var(--bg); }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  font-size: 11px; line-height: 18px; text-align: center; background: var(--err); color: #fafaf8;
}

.screen { animation: enter 200ms var(--ease); }
@keyframes enter { from { opacity: 0.4; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } * { transition: none !important; } }

.pad { padding: 0 var(--gut); }
h1, h2, h3 { margin: 0; font-weight: 300; }
.h-sec {
  font-size: 13px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg-2); margin: 28px var(--gut) 8px;
}
.empty { padding: 20px var(--gut); color: var(--fg-2); }
.empty p { margin: 0 0 12px; }

/* ---------- Календарь ---------- */
.month-bar { display: flex; align-items: center; gap: 4px; padding: 8px var(--gut) 12px; }
.month-bar h1 { flex: 1; font-size: 26px; line-height: 1.15; letter-spacing: -0.01em; }
.month-bar h1 span { color: var(--fg-2); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 999px; color: var(--fg); }
.icon-btn:active { background: var(--muted); }
.link-btn { font-size: 13px; font-weight: 500; padding: 8px 10px; border-radius: 999px; border: 1px solid var(--line-strong); }

.grid { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 calc(var(--gut) - 4px); }
.grid .wd { text-align: center; font-size: 12px; color: var(--fg-2); padding-bottom: 6px; }
.day {
  position: relative; height: 50px; margin: 2px; border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 16px; font-weight: 300; font-variant-numeric: tabular-nums;
  transition: background-color 160ms var(--ease);
}
.day:active { background: var(--muted); }
.day.out { color: var(--fg-3); }
.day.past { color: var(--fg-2); }
.day.today .num { font-weight: 500; }
.day.today::after {
  content: ""; position: absolute; inset: 3px; border-radius: 4px; border: 1px solid var(--mark);
}
.day.sel { background: var(--fg); color: var(--bg); }
.day.sel::after { display: none; }
.dots { display: flex; gap: 3px; height: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.dots i.x { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }

.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px var(--gut) 4px; }
.day-head h2 { font-size: 20px; }
.day-head span { font-size: 13px; color: var(--fg-2); }

/* ---------- Строка мероприятия ---------- */
.ev-list { border-top: 1px solid var(--line); margin: 0 var(--gut); }
.ev-row {
  display: grid; grid-template-columns: 52px 1fr; gap: 12px; width: 100%; text-align: left;
  padding: 16px 0; border-bottom: 1px solid var(--line);
  transition: background-color 160ms var(--ease);
}
.ev-row:active { background: var(--muted); }
.ev-date { display: flex; flex-direction: column; }
.ev-date b { font-size: 30px; line-height: 1; font-weight: 300; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.ev-date span { font-size: 12px; color: var(--fg-2); margin-top: 4px; }
.ev-body { display: flex; flex-direction: column; min-width: 0; }
.ev-title { display: block; font-size: 16px; font-weight: 500; line-height: 1.3; text-wrap: pretty; }
.ev-meta { display: block; font-size: 13px; color: var(--fg-2); margin-top: 2px; }
.ev-foot { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: 13px; }
.ev-row.past .ev-date b, .ev-row.past .ev-title { color: var(--fg-2); }
.ev-row.cancelled .ev-title { text-decoration: line-through; color: var(--fg-2); }
.cd { font-weight: 500; }
.cd.soon { display: inline-flex; align-items: center; gap: 6px; }
.cd.soon::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--mark); }
.prog { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-2); }
.bar { display: inline-flex; gap: 2px; }
.bar i { width: 8px; height: 4px; border-radius: 1px; background: var(--fog); }
.bar i.on { background: var(--ok); }
.flag { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--fg-2); }
.flag.warn { border-color: var(--err); color: var(--err-text); }

/* ---------- Чипы-фильтры ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px var(--gut) 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 14px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line-strong); color: var(--fg); white-space: nowrap;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.toggle-line { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--gut) 8px; font-size: 13px; color: var(--fg-2); }

/* ---------- Задачи ---------- */
.notice {
  margin: 4px var(--gut) 12px; padding: 14px 16px; border-radius: 8px; background: var(--muted);
  display: grid; gap: 10px; font-size: 14px;
}
.notice p { margin: 0; }
.btn {
  height: 44px; padding: 0 18px; border-radius: 999px; font-weight: 500; font-size: 14px;
  background: var(--btn-bg); color: var(--btn-fg); justify-self: start;
}
.btn.ghost { background: none; color: var(--fg); border: 1px solid var(--line-strong); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }

.tasks { margin: 0 var(--gut); border-top: 1px solid var(--line); }
.task { display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.check {
  width: 26px; height: 26px; margin-top: 1px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); display: grid; place-items: center; color: transparent;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease), color 180ms var(--ease);
}
.check svg.i { width: 16px; height: 16px; stroke-width: 2; }
.task.done .check { background: var(--ok); border-color: var(--ok); color: #fafaf8; }
.task.done .task-text { color: var(--fg-2); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.task-text { font-size: 15px; line-height: 1.35; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: 13px; color: var(--fg-2); }
.task-meta .due.over { color: var(--err-text); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.task-meta .due.over::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--err); }
.who { color: var(--fg); }
.no-dm { font-size: 12px; color: var(--fg-2); display: inline-flex; align-items: center; gap: 4px; }
.no-dm svg.i { width: 14px; height: 14px; }
.ev-link { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; text-align: left; }
.task-actions { margin-top: 8px; }

/* ---------- Карточка ---------- */
.card-head { padding: 12px var(--gut) 0; }
.card-head h1 { font-size: 28px; line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
.card-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.tag { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--muted); }
.status { font-size: 13px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-strong); }
.status.confirmed { border-color: var(--ok); color: var(--ok); }
.status.cancelled { border-color: var(--err); color: var(--err-text); }
:root[data-theme="dark"] .status.confirmed { color: var(--fg); }
.when {
  margin: 20px var(--gut) 0; padding: 16px; border-radius: 8px; background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 12px;
}
.when .big { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.when .big b { font-size: 20px; font-weight: 400; }
.dl { display: grid; grid-template-columns: 24px 1fr; gap: 10px 10px; align-items: start; font-size: 14px; }
.dl svg.i { color: var(--fg-2); margin-top: 1px; }
.dl small { display: block; color: var(--fg-2); font-size: 12px; }
.prose { padding: 0 var(--gut); font-size: 15px; line-height: 1.6; white-space: pre-line; max-width: 68ch; }
.prose p { margin: 0 0 8px; }
.steps { list-style: none; margin: 0 var(--gut); padding: 0; border-top: 1px solid var(--line); }
.steps li { display: grid; grid-template-columns: 24px 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.4; }
.steps li::before { content: counter(step); counter-increment: step; font-size: 13px; color: var(--fg-2); font-variant-numeric: tabular-nums; padding-top: 1px; }
.steps { counter-reset: step; }
.remind { margin: 0 var(--gut); border-top: 1px solid var(--line); }
.remind li { list-style: none; display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.remind ul { margin: 0; padding: 0; }
.remind .st { color: var(--fg-2); font-size: 13px; }
.remind .st.sent { color: var(--ok); }
:root[data-theme="dark"] .remind .st.sent { color: var(--fg-2); }
.trail { padding: 20px var(--gut) 8px; font-size: 12px; color: var(--fg-2); }
.card-actions { display: flex; gap: 8px; padding: 16px var(--gut) 0; }

/* ---------- Форма ---------- */
.form { padding: 4px var(--gut) 24px; }
.form h1 { font-size: 26px; margin: 8px 0 4px; }
.form .lead { color: var(--fg-2); font-size: 14px; margin: 0 0 8px; }
.fs { border: 0; margin: 0; padding: 0; }
.fs legend {
  font-size: 13px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-2);
  padding: 28px 0 4px;
}
.field { display: grid; gap: 6px; padding: 10px 0; }
.field > label, .field > .lbl { font-size: 13px; font-weight: 500; }
.field .req { color: var(--fg-2); font-weight: 400; }
.field .hint { font-size: 12px; color: var(--fg-2); margin-top: -2px; }
.in {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: 16px; line-height: 1.4; transition: border-color 160ms var(--ease);
}
.in::placeholder { color: var(--fg-2); opacity: 0.85; }
.in:focus { outline: none; border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg); }
textarea.in { min-height: 96px; resize: vertical; }
.in.bad { border-color: var(--err); box-shadow: 0 0 0 1px var(--err); }
.err-msg { font-size: 13px; color: var(--err-text); display: flex; gap: 6px; align-items: center; }
.err-msg::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--err); flex: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { flex: 1; height: 36px; border-radius: 999px; font-size: 13px; color: var(--fg-2); }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.sugg .chip { height: 30px; font-size: 13px; }

.t-edit { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 8px; margin-bottom: 10px; background: var(--surface); }
.t-edit .top { display: grid; grid-template-columns: 1fr 40px; gap: 8px; align-items: start; }
.t-edit .icon-btn { color: var(--fg-2); }
.who-wrap { position: relative; }
.who-list { display: grid; border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; background: var(--surface); overflow: hidden; }
.who-list button { text-align: left; padding: 10px 12px; font-size: 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.who-list button:last-child { border-bottom: 0; }
.who-list button span { color: var(--fg-2); font-size: 12px; }
.add-line { display: inline-flex; align-items: center; gap: 6px; height: 40px; font-weight: 500; font-size: 14px; }
.opt { display: grid; grid-template-columns: 24px 1fr; gap: 12px; align-items: start; padding: 12px 0 8px; cursor: pointer; }
.opt input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--fg); cursor: pointer; }
.opt b { display: block; font-weight: 500; font-size: 15px; }
.opt small { display: block; font-size: 13px; color: var(--fg-2); line-height: 1.45; margin-top: 2px; }
.rem-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rem-add { display: inline-flex; align-items: center; gap: 6px; }
.rem-add .in { width: 76px; min-height: 32px; height: 32px; padding: 4px 10px; font-size: 14px; border-radius: 999px; }
.rem-preview { font-size: 13px; color: var(--fg-2); }
.danger-line { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.danger-line button { color: var(--err-text); font-weight: 500; font-size: 14px; height: 40px; }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40; transform: translate(-50%, 12px);
  max-width: calc(100% - 32px); width: max-content;
  background: var(--fg); color: var(--bg); padding: 12px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
body.demo.has-main .toast { bottom: 88px; }
