:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --ink: #20201d;
  --muted: #6f716c;
  --line: #deded7;
  --panel: #ffffff;
  --ira: #2f7d62;
  --kirill: #3867a8;
  --kostya: #a45f2b;
  --danger: #be3d31;
  --shadow: 0 18px 60px rgba(26, 28, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.auth-screen div {
  width: min(420px, 100%);
}

.auth-screen h1 {
  margin: 0 0 10px;
  font-size: 30px;
  letter-spacing: 0;
}

.auth-screen p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-screen.is-hidden,
.app.is-locked {
  display: none;
}

.app {
  width: min(1280px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 26px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.title-block h1,
.section-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.title-block h1 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1;
}

.title-block p {
  margin: 8px 0 0;
  color: var(--muted);
}

.week-controls,
.people,
.section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.text-button,
.primary-button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
}

.icon-button {
  width: 44px;
  font-size: 25px;
  line-height: 1;
}

.text-button {
  padding: 0 14px;
}

.primary-button {
  min-width: 112px;
  border-color: #20201d;
  background: #20201d;
  color: white;
}

.people {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.person-toggle {
  --accent: #555;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, white);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, white);
  color: color-mix(in srgb, var(--accent) 72%, black);
}

.person-toggle input {
  accent-color: var(--accent);
}

.person-ira {
  --accent: var(--ira);
}

.person-kirill {
  --accent: var(--kirill);
}

.person-kostya {
  --accent: var(--kostya);
}

.entry-panel,
.conflicts,
.calendar-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.entry-panel {
  padding: 12px;
  margin-bottom: 12px;
}

form {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 2fr) repeat(3, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 5px;
}

label span {
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
}

.conflicts {
  padding: 12px;
  margin-bottom: 12px;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-heading h2 {
  font-size: 16px;
}

#conflictCount {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--danger);
  font-size: 13px;
}

.conflict-list {
  display: grid;
  gap: 6px;
}

.conflict-item,
.empty-state {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.conflict-item {
  color: var(--ink);
}

.conflict-item::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex: 0 0 auto;
}

.calendar-shell {
  overflow: auto;
}

.calendar {
  min-width: 980px;
  display: grid;
  grid-template-columns: 86px repeat(7, minmax(122px, 1fr));
  grid-template-rows: 48px repeat(16, 54px);
}

.corner,
.day-head,
.time-label,
.day-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.corner,
.day-head {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #fbfbf8;
}

.corner {
  left: 0;
  z-index: 6;
}

.day-head {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  font-size: 13px;
}

.day-head strong {
  font-size: 15px;
}

.time-label {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
  background: #fbfbf8;
  color: var(--muted);
  font-size: 12px;
}

.day-cell {
  position: relative;
  background:
    linear-gradient(to bottom, rgba(32, 32, 29, 0.05) 1px, transparent 1px) 0 26px / 100% 27px;
}

.event-layer {
  position: relative;
  grid-row: 2 / -1;
  pointer-events: none;
  z-index: 2;
}

.event-card {
  --person: #555;
  position: absolute;
  left: calc(4px + var(--lane) * 33.333%);
  width: calc(33.333% - 7px);
  min-height: 36px;
  overflow: hidden;
  padding: 6px 7px;
  border: 1px solid color-mix(in srgb, var(--person) 58%, white);
  border-left: 4px solid var(--person);
  border-radius: 8px;
  background: color-mix(in srgb, var(--person) 13%, white);
  pointer-events: auto;
}

.event-card.is-conflict {
  box-shadow: 0 0 0 2px rgba(190, 61, 49, 0.34);
}

.event-top {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}

.event-top strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.event-top button {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: color-mix(in srgb, var(--person) 74%, black);
  line-height: 1;
}

.event-card time,
.event-card p {
  display: block;
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: color-mix(in srgb, var(--person) 65%, black);
  font-size: 11px;
}

.event-card p {
  color: var(--ink);
}

@media (max-width: 860px) {
  .app {
    width: min(100vw - 18px, 760px);
    padding-top: 12px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  form {
    grid-template-columns: 1fr 1fr;
  }

  .wide,
  .primary-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  form {
    grid-template-columns: 1fr;
  }

  .week-controls {
    width: 100%;
  }

  .text-button {
    flex: 1;
  }
}
