:root {
  --paper: #fafaf9;
  --card: #ffffff;
  --ink: #1b1d21;
  --muted: #7d828b;
  --line: #e7e7e4;
  --soft: #f0f0ed;
  --busy: #e5484d;
  --free: #2f9e6d;
  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 6px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--paper); }
body {
  margin: 0; color: var(--ink); line-height: 1.45;
  font: 18px/1.45 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 34px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 12px; font-weight: 650; }
h2 { font-size: 22px; margin: 0 0 4px; font-weight: 620; letter-spacing: -0.01em; }
h3 { font-size: 20px; margin: 0; font-weight: 620; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.err { color: var(--busy); min-height: 1.4em; margin-top: 10px; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px 80px; }
main.wide { max-width: 1040px; }
main.narrow { max-width: 420px; padding-top: 14vh; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: rgba(250,250,249,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top > :first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; margin-bottom: 14px; }

input, select {
  font: inherit; color: inherit; width: 100%; padding: 14px 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-md); outline: none;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
form { display: flex; flex-direction: column; gap: 10px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 16px; color: var(--muted); }

button { font: inherit; cursor: pointer; }
.btn {
  background: var(--ink); color: #fff; border: 0; border-radius: var(--r-md); padding: 14px 22px; font-weight: 560;
}
.btn:hover { opacity: .88; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.small { padding: 9px 14px; font-size: 16px; }
.btn.danger { background: #fdecec; color: var(--busy); }
.link { background: none; border: 0; padding: 4px 6px; color: var(--muted); font-size: 16px; }
.link:hover { color: var(--ink); text-decoration: underline; }

/* month picker */
.monthbar { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 8px; }
.monthbar button { width: 46px; height: 46px; border: 1px solid var(--line); background: var(--card); border-radius: 50%; font-size: 26px; line-height: 1; }
.monthbar button:disabled { opacity: .3; cursor: default; }
.dow, .days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.dow span { text-align: center; font-size: 15px; color: var(--muted); padding-bottom: 4px; }
.days { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.day {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: var(--r-md); font-size: 19px;
  background: var(--soft); cursor: pointer;
}
.day.blank { background: none; cursor: default; }
.day.off { background: none; color: #c4c6ca; cursor: default; }
.day.sel { background: var(--ink); color: #fff; font-weight: 600; }

/* time strips */
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sum { font-size: 16px; margin: 2px 0 12px; min-height: 1.4em; }
.strip {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 10px;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.hr b { display: block; font-size: 14px; font-weight: 500; color: var(--muted); margin-bottom: 3px; }
.cl { display: flex; gap: 2px; }
.cl i { flex: 1; height: 48px; background: var(--soft); border-radius: 4px; cursor: pointer; }
.cl i.on { background: var(--busy); }
.readonly .cl i { cursor: default; }
.strip:last-child { margin-bottom: 0; }


#status { font-size: 16px; white-space: nowrap; }
#status.bad { color: var(--busy); }

/* admin */
.tabs { display: flex; gap: 4px; flex: 1; justify-content: center; }
.tabs button { background: none; border: 0; padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 520; }
.tabs button.on { background: var(--ink); color: #fff; }
@media (max-width: 640px) {
  .top { flex-wrap: wrap; }
  .tabs { order: 3; flex-basis: 100%; justify-content: flex-start; overflow-x: auto; }
}

.hm { overflow-x: auto; padding-bottom: 6px; }
.hm-row { display: grid; grid-template-columns: 100px repeat(var(--n), minmax(15px, 1fr)); gap: 2px; margin-bottom: 2px; min-width: calc(100px + var(--n) * 17px); }
.hm-label { position: sticky; left: 0; background: var(--card); font-size: 15px; line-height: 28px; white-space: nowrap; z-index: 1; }
.hm-h { font-size: 13px; color: var(--muted); line-height: 14px; }
.hm-row i { height: 28px; border-radius: 3px; cursor: pointer; }
.hm-row i.cur { outline: 2px solid var(--ink); outline-offset: 1px; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); margin: 10px 0 14px; }
.legend span.bar { flex: 0 0 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, hsl(0 70% 58%), hsl(50 70% 58%), hsl(105 70% 42%)); }
#detail { margin-top: 14px; padding: 12px 14px; border-radius: var(--r-md); background: var(--soft); font-size: 17px; min-height: 56px; }
#detail p { margin: 0 0 4px; }

.rrow { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); align-items: baseline; }
.rrow:first-child { border-top: 0; }
.rdate { flex: 0 0 130px; font-weight: 560; font-size: 17px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #e6f5ee; color: #1b6b48; border-radius: 999px; padding: 4px 13px; font-size: 17px; }
.chip small { opacity: .75; }
.filter { display: flex; align-items: center; gap: 10px; margin: 10px 0 8px; font-size: 17px; }
.filter select { width: auto; padding: 8px 12px; }

.person { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.person:first-child { border-top: 0; }
.person .who { flex: 1 1 180px; min-width: 0; }
.person .who b { display: block; overflow-wrap: anywhere; }
.person .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.person.excluded .who b { color: var(--muted); text-decoration: line-through; }
.tag { font-size: 14px; background: var(--soft); color: var(--muted); border-radius: 999px; padding: 2px 8px; margin-left: 6px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

dialog { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; width: min(560px, calc(100% - 24px)); max-height: 86vh; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: rgba(20,20,20,.35); }
dialog .card { padding: 14px; }
.dlghead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

@media (prefers-reduced-motion: no-preference) {
  .day, .cl i, .btn { transition: background-color .12s; }
}

/* акцент: «НЕ могу» */
.banner {
  background: #fdecec; border: 1px solid #f4c3c5; color: #8f1d22; border-radius: var(--r-md);
  padding: 14px 16px; margin-bottom: 14px; font-size: 18px; line-height: 1.35;
}
.banner b { display: block; font-size: 21px; margin-bottom: 2px; color: #b3262b; }
.banner span { display: block; color: #6d2a2d; font-size: 17px; }
.notice { background: var(--soft); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 14px; font-weight: 560; }
.days.cant .day.sel { background: #fff4e0; color: #8a5a00; border: 2px dashed #e0a030; font-weight: 600; }
.days.cant .day.sel.part { background: #fdecec; color: #8f1d22; border: 2px solid var(--busy); }
.days.cant .day.sel.full { background: var(--busy); color: #fff; border: 2px solid var(--busy); }
.swatch { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--muted); margin-top: 12px; }
.swatch i { width: 18px; height: 18px; border-radius: 5px; background: var(--busy); display: inline-block; flex: none; box-sizing: border-box; }
.swatch i.s-none { background: #fff4e0; border: 2px dashed #e0a030; }
.swatch i.s-part { background: #fdecec; border: 2px solid var(--busy); }
.card.unmarked .sum { color: #8a5a00; font-weight: 560; }
.card.fullday .sum { color: var(--busy); font-weight: 560; }
.allday { width: 100%; font: inherit; font-weight: 600; padding: 14px; margin-bottom: 14px; border-radius: var(--r-md); border: 2px solid var(--busy); background: #fff; color: var(--busy); cursor: pointer; }
.allday:hover { background: #fdecec; }
.card.fullday .allday { background: var(--busy); color: #fff; }
.neg { color: var(--busy); }
dialog.intro { max-width: 460px; }
dialog.intro h2 { font-size: 26px; line-height: 1.2; margin-bottom: 12px; }
dialog.intro ol { padding-left: 22px; margin: 0 0 14px; }
dialog.intro li { margin-bottom: 8px; }
dialog.intro .btn { width: 100%; margin-top: 6px; }
dialog.intro .big { background: #fdecec; border-radius: var(--r-md); padding: 12px 14px; color: #8f1d22; margin-bottom: 14px; }

.monthnote { background: #fff6e0; border: 1px solid #f1dca0; color: #6b5200; border-radius: var(--r-md); padding: 10px 12px; margin-top: 14px; font-size: 16px; line-height: 1.5; }
.monthnote[hidden] { display: none; }
.monthnote button { margin: 2px 0 2px 6px; padding: 3px 12px; border: 1px solid #e3c675; background: #fff; border-radius: 999px; color: inherit; font-size: 16px; }
