:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --ink: #1f1e1d;
  --muted: #8a8782;
  --line: #e6e3dd;
  --accent: #d97757;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 30, 29, .05), 0 4px 16px rgba(31, 30, 29, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px 0;
}

/* ---------- Шапка ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 6px 0 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand__mark {
  font-size: 30px;
  line-height: 1;
  color: var(--accent);
}

.brand h1 { margin: 0; font-size: 21px; letter-spacing: -.01em; }
.brand__sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.week-nav { display: flex; align-items: center; gap: 8px; }

.week-label {
  min-width: 210px;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  font-size: 17px;
  transition: box-shadow .15s, border-color .15s;
}

.icon-btn:hover { border-color: var(--muted); box-shadow: var(--shadow); }

.text-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  padding: 7px 14px;
  font-size: 13.5px;
  transition: box-shadow .15s, border-color .15s;
}

.text-btn:hover { border-color: var(--muted); box-shadow: var(--shadow); }

/* ---------- Участники ---------- */

.people-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 18px;
}

.people-hint { font-size: 13.5px; color: var(--muted); }

.people-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 190px;
  padding: 7px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}

.chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip:hover { border-color: var(--pc); }

.chip__dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--pc);
}

.chip--me {
  background: var(--pc);
  border-color: var(--pc);
  color: #fff;
  font-weight: 600;
}

.chip--me .chip__dot { background: rgba(255, 255, 255, .85); }

.people-bar .text-btn { margin-left: auto; }

/* ---------- Календарь ---------- */

.grid-wrap { overflow-x: auto; padding-bottom: 6px; }

.calendar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  min-width: 920px;
}

.day {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--card);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.day--today { border-color: var(--accent); }

.day__head { padding: 0 2px 4px; }

.day__name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 15px;
}

.day__badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: lowercase;
}

.day__date { margin-top: 2px; font-size: 13px; color: var(--muted); }

/* ---------- Слот ---------- */

.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  width: 100%;
  min-height: 86px;
  padding: 12px;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  transition: border-color .15s, background .15s;
}

.slot__time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--muted);
}

.slot__who {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.slot--free .slot__who { color: var(--muted); }

.slot--free:not(:disabled):hover { border-color: var(--accent); background: #faf3ef; }

.slot--taken {
  border-style: solid;
  border-color: var(--pc);
  background: var(--pc);
}

.slot--taken .slot__time { color: rgba(255, 255, 255, .8); }
.slot--taken .slot__who { color: #fff; font-weight: 700; }

.slot:disabled { opacity: .45; pointer-events: none; }

.slot__now {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  animation: nowblink 2.2s ease-in-out infinite;
}

.slot--taken .slot__now { background: rgba(255, 255, 255, .92); color: var(--pc); }

@keyframes nowblink { 50% { opacity: .55; } }

.slot__hint {
  position: absolute;
  right: 11px;
  bottom: 10px;
  font-size: 12px;
  color: var(--accent);
  opacity: 0;
  transition: opacity .15s;
}

.slot--taken .slot__hint { color: rgba(255, 255, 255, .95); }

.slot:not(:disabled):hover .slot__hint { opacity: 1; }

.cal-note {
  grid-column: 1 / -1;
  padding: 48px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Подвал ---------- */

.foot {
  padding: 22px 2px 26px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Диалог участников ---------- */

.dialog {
  width: 400px;
  max-width: calc(100vw - 32px);
  padding: 20px;
  border: none;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(31, 30, 29, .25);
}

.dialog::backdrop { background: rgba(31, 30, 29, .35); }

.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog__head h2 { margin: 0; font-size: 18px; }

.plist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  margin: 14px 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.plist li { display: flex; align-items: center; gap: 10px; }

.plist__swatch {
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  background: var(--pc);
}

.plist__name {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}

.plist__name:hover { border-color: var(--line); }
.plist__name:focus { border-color: var(--muted); background: #faf9f7; outline: none; }

.plist__del {
  width: 28px;
  height: 28px;
  flex: none;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}

.plist__del:hover { background: #fbeeee; color: #c92a2a; }

.plist__empty { color: var(--muted); font-size: 13.5px; }

.add-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.add-form__label { font-size: 13px; font-weight: 600; color: var(--muted); }

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

.sw {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--pc);
}

.sw--used { opacity: .3; }

.sw--sel { box-shadow: 0 0 0 2.5px var(--card), 0 0 0 4.5px var(--ink); }

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

.add-row input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.btn--primary {
  padding: 9px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn--primary:hover { filter: brightness(.94); }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 10px;
  background: #2c2b29;
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}

.toast--show { opacity: 1; transform: translate(-50%, 0); }
