/* шрифты лежат на нашем сервере (OFL), отдельно латиница и кириллица */
@font-face { font-family: "Unbounded"; font-weight: 500; font-display: swap; src: url("/static/fonts/unbounded-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Unbounded"; font-weight: 500; font-display: swap; src: url("/static/fonts/unbounded-500-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-weight: 700; font-display: swap; src: url("/static/fonts/unbounded-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Unbounded"; font-weight: 700; font-display: swap; src: url("/static/fonts/unbounded-700-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Manrope"; font-weight: 200 800; font-display: swap; src: url("/static/fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-weight: 200 800; font-display: swap; src: url("/static/fonts/manrope-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

:root {
  --bg: #f5f4fa; --surface: #ffffff; --fg: #26233a; --muted: #8a86a3; --line: #e6e3f0; --today: #efeafd; --accent: #6c5ce7;
  --sticker-ink: #ffffff; --danger: #d63031;
  --font-display: "Unbounded", "Manrope", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16141f; --surface: #1f1c2b; --fg: #ece9f7; --muted: #8f8aa8; --line: #2e2a3e; --today: #29233f; --accent: #a99bff;
    --sticker-ink: #16141f; --danger: #ff7675; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16141f; --surface: #1f1c2b; --fg: #ece9f7; --muted: #8f8aa8; --line: #2e2a3e; --today: #29233f; --accent: #a99bff;
  --sticker-ink: #16141f; --danger: #ff7675; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
button, input, select { font: inherit; color: inherit; }
.wrap {
  max-width: 1640px; margin: 0 auto;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
  padding-block: 48px 64px; display: flex; flex-direction: column; gap: 22px;
}
header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: 1.75rem; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
h1 small { display: block; font-family: var(--font-body); font-weight: 500; font-size: .85rem; color: var(--muted); letter-spacing: .02em; margin-top: 4px; }
h2, h3 { font-family: var(--font-display); font-weight: 500; margin: 0; }
h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.tools { display: flex; align-items: center; gap: 14px; }
.monthnav { display: flex; align-items: center; gap: 8px; }
.monthnav span { font-family: var(--font-display); font-weight: 500; font-size: 1rem; min-width: 9em; text-align: center; text-transform: capitalize; }
.iconbtn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; font-size: 1.1rem; flex: 0 0 auto;
}
.iconbtn:hover:not(:disabled) { border-color: var(--accent); }
.iconbtn:disabled { opacity: .35; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* аватар: фото, эмодзи или первая буква */
.ava {
  --u: var(--accent); width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; overflow: hidden;
  display: grid; place-items: center; background: color-mix(in srgb, var(--u) 22%, var(--surface));
  border: 2px solid var(--u); font-family: var(--font-display); font-weight: 500; font-size: 1rem; color: var(--u); line-height: 1;
}
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ava.emo { font-size: 1.15rem; }
.ava.big { width: 84px; height: 84px; font-size: 2.2rem; border-width: 3px; }
.mebtn { border: 0; background: transparent; padding: 0; cursor: pointer; border-radius: 50%; }
.mebtn .ava { width: 42px; height: 42px; }

.board { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; overflow: hidden; }
.scroller { overflow-x: auto; scrollbar-width: thin; }
table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
th, td { padding: 0; }
.pad-l { width: var(--pad-l, 0px); min-width: var(--pad-l, 0px); }
.pad-r { width: var(--pad-r, 0px); min-width: var(--pad-r, 0px); }
.side {
  position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--line);
  text-align: left; width: 247px; min-width: 247px; padding-inline: 23px 18px;
}
thead .side { font-size: .94rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.dayhead { width: 52px; min-width: 52px; padding-block: 16px 10px; text-align: center; font-weight: 500; }
.dayhead b { display: block; font-family: var(--font-display); font-weight: 500; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.dayhead span { display: block; font-size: .83rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dayhead.weekend span { color: #ff8fb1; }
.today { background: var(--today); }
.dayhead.today b, .dayhead.today span { color: var(--accent); }

.person-row th, .person-row td { padding-block: 21px 8px; border-top: 1px solid var(--line); }
.person { display: flex; align-items: center; gap: 12px; }
.person-name { font-family: var(--font-display); font-weight: 500; font-size: 1.3rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat { display: block; font-size: .99rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat b { color: var(--fg); font-weight: 700; }
.perfect-dot { display: block; width: 8px; height: 8px; margin: 0 auto; border-radius: 50%; background: var(--u, var(--accent)); }

.habit-row .side { font-size: 1.09rem; color: var(--muted); white-space: nowrap; }
.habit-row .side > span { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; }
.habit-row .side .hl { overflow: hidden; text-overflow: ellipsis; }
.hic { width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center; color: var(--sticker-ink); flex: 0 0 auto; background: var(--c); }
.hic svg { width: 14px; height: 14px; }
.hic .e, .st .e { font-size: 13px; line-height: 1; }
.habit-row.archived .side > span { opacity: .55; }
.habit-row td { text-align: center; padding-block: 4px; }
.habit-row.last td, .habit-row.last th { padding-bottom: 18px; }

.st {
  --c: var(--muted); width: 39px; height: 39px; padding: 0; cursor: pointer; border-radius: 50%; margin: 0 auto;
  border: 1.5px dashed var(--line); background: transparent; color: var(--muted);
  display: grid; place-items: center; transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.st svg { width: 20px; height: 20px; opacity: .4; }
.st .e { font-size: 18px; opacity: .35; filter: grayscale(1); }
.st:hover:not(:disabled) { border-color: var(--c); }
.st[aria-pressed="true"] {
  background: var(--c); border: 2px solid var(--surface); color: var(--sticker-ink);
  box-shadow: 0 3px 8px color-mix(in srgb, var(--c) 40%, transparent); transform: rotate(var(--r, 0deg));
}
.st[aria-pressed="true"] svg, .st[aria-pressed="true"] .e { opacity: 1; filter: none; }
.st:disabled { cursor: default; }
.st:disabled[aria-pressed="false"] { opacity: .3; }
.st.ro:disabled[aria-pressed="false"] { opacity: .45; border-style: dotted; }
.st.pop { animation: pop .32s ease; }
@keyframes pop { 0% { transform: scale(.7) rotate(0); } 60% { transform: scale(1.15) rotate(var(--r, 0deg)); } 100% { transform: scale(1) rotate(var(--r, 0deg)); } }

.status { font-size: .82rem; color: var(--muted); text-align: center; min-height: 1.2em; }
.status.bad { color: var(--danger); }

/* кнопки и поля */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 18px; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
label, .lbl { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); font-weight: 600; }
input:not([type=color]):not([type=file]), select {
  border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px; color: var(--fg); font-weight: 500; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.err { color: var(--danger); font-size: .9rem; min-height: 1.3em; }
.note { color: var(--muted); font-size: .85rem; min-height: 1.2em; }
.note.ok { color: #00b894; } .note.bad { color: var(--danger); }

/* вход */
.wrap.login { min-height: 100vh; justify-content: center; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 32px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 16px; }

/* профиль */
dialog {
  border: 1px solid var(--line); border-radius: 28px; padding: 0; background: var(--surface); color: var(--fg);
  width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgb(20 18 30 / .45); }
.dlg { display: flex; flex-direction: column; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 8px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg section { padding: 18px 24px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.dlg-head + section { border-top: 0; }
.dlg-foot { padding: 16px 24px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.pf-top { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.pf-ava-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.emoji-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -6px; }
.emoji-picks button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 1.1rem; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: -6px; }
.sw { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; background: var(--c); padding: 0; }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--fg); }
input[type=color] { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; padding: 2px; background: var(--bg); cursor: pointer; }

.hb { display: grid; grid-template-columns: 30px 1fr 36px 170px auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.hb .hic { width: 30px; height: 30px; }
.hb .hic svg { width: 17px; height: 17px; }
.hb .icon-pick { display: flex; gap: 6px; }
.hb .icon-pick select { flex: 1; }
.hb .icon-pick input { width: 52px; text-align: center; }
.hb .mv { display: flex; gap: 4px; }
.hb .mv .iconbtn { width: 32px; height: 32px; font-size: .9rem; }

@media (max-width: 600px) {
  .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 24px 48px; }
  .side { width: 140px; min-width: 140px; padding-inline: 12px 8px; }
  .person .ava { display: none; }
  .person-name { font-size: 1.05rem; }
  h1 { font-size: 1.35rem; }
  .hb { grid-template-columns: 30px 1fr auto; }
  .hb .icon-pick { grid-column: 2 / -1; }
  .hb .mv { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) { .st, .st.pop { transition: none; animation: none; } }
