:root {
  --paper: #fff;
  --ink: #1a1916;
  --muted: #6f6a62;
  --line: #dedede;
  --card: #fff;
  --time: 52px;
  --peek: 0px;
  --col: max(200px, calc(100vw - var(--time) - var(--peek)));
  --slot: 128px;
  --slot-line: 28px;
  --head: 0px;
  --halls: 7;
  --shadow: 0 1px 0 rgba(26, 25, 22, 0.04);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, a { font: inherit; color: inherit; }

.top {
  flex: none;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mast-tools {
  flex: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

.mode {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 36px;
  border: 0;
  border-radius: 4px;
  background: #eaeaea;
  color: var(--ink);
  padding: 0;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, color 140ms ease;
}

.mode svg {
  width: 22px;
  height: 22px;
}

.mode:active,
.mode[aria-pressed="true"] {
  transform: scale(0.92);
}

.mode[aria-pressed="true"] {
  background: var(--ink);
  color: #f7f4ee;
}

#favorites[aria-pressed="true"] {
  background: #f08aaf;
  color: var(--ink);
}

#favorites[aria-pressed="true"] svg path {
  fill: currentColor;
}

.mode:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.brand { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.kicker {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 720;
  letter-spacing: -0.03em;
}

.title-full { display: none; }

.place {
  display: none;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.days {
  flex: none;
  display: flex;
  gap: 2px;
  padding: 0;
  background: #eaeaea;
  border-radius: 4px;
}

.days button {
  border: 0;
  background: transparent;
  border-radius: 4px;
  min-height: 36px;
  min-width: 44px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.days button[aria-selected="true"] {
  background: var(--ink);
  color: #f7f4ee;
}

.halls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.halls::-webkit-scrollbar { display: none; }

.halls button {
  flex: none;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 4px;
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  color: var(--ink);
}

.halls button[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #f7f4ee;
}

body.is-hours .halls button {
  font-variant-numeric: tabular-nums;
}

.section {
  margin: 8px 0 0;
  min-height: 1.2em;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-footer {
  flex: none;
  position: sticky;
  bottom: 0;
  z-index: 6;
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.site-footer a {
  color: var(--ink);
  font-weight: 400;
  text-decoration: none;
}

.site-footer a:hover {
  color: #1f6ac6;
}

.site-footer a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.board {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--time);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

body.is-hours .board {
  scroll-padding-left: 0;
  overflow-y: hidden;
}

.hour-board {
  position: relative;
  display: flex;
  align-items: stretch;
  width: max-content;
  height: 100%;
}

.hour-col {
  flex: none;
  width: max(200px, calc(100vw - var(--peek)));
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.hour-col.is-empty {
  flex: none;
  width: max-content;
  min-width: max-content;
}

.hour-col.is-empty .hall-head {
  display: flex;
}

.hour-col.is-empty .hall-head strong {
  white-space: nowrap;
}

.hour-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.hour-list::-webkit-scrollbar { display: none; }

.hour-col .hall-head {
  position: static;
  flex: none;
  overflow: visible;
  border-right: 0;
  scroll-snap-align: none;
}

.hour-col .hall-head strong {
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.hour-col .card {
  scroll-snap-align: none;
}

.grid {
  position: relative;
  display: grid;
  grid-template-columns: var(--time) repeat(var(--halls, 7), var(--col));
  grid-template-rows: var(--head) repeat(16, minmax(var(--slot), auto));
  width: max-content;
  min-height: min-content;
}

.col-line {
  grid-row: 2 / -1;
  z-index: 2;
  pointer-events: none;
  border-right: 1px solid var(--line);
}

.rule {
  grid-column: 2 / -1;
  z-index: 0;
  pointer-events: none;
  border-bottom: 1px solid var(--line);
}

.corner,
.hall-head {
  display: none;
}

.corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 5;
  grid-column: 1;
  grid-row: 1;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.hall-head {
  position: sticky;
  top: 0;
  z-index: 3;
  grid-row: 1;
  scroll-snap-align: start;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
  padding: 10px 12px 8px;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
}

.hall-head strong {
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.hall-head span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tick {
  background: var(--paper);
  position: sticky;
  left: 0;
  z-index: 2;
  grid-column: 1;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0 0 8px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
}

.tick.hour {
  color: var(--ink);
  font-weight: 680;
}

.tick.is-line {
  padding: 0 0 0 8px;
  line-height: 27px;
}

.card {
  scroll-snap-align: start;
  margin: 0;
  padding: 10px 12px 10px 12px;
  border: 0;
  background: var(--card);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  position: relative;
  z-index: 1;
  border-bottom: 1px solid var(--line);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.card:hover {
  background: #f6f6f6;
}

.card.is-favorite {
  background: #ffeceb;
}

.card.is-favorite:hover {
  background: rgb(247, 183, 207);
}

.card.is-secondary {
  background: #fef7e2;
}

.card.is-secondary:hover {
  background: rgb(249, 216, 115);
}

.card:active { transform: scale(0.985); }

.card:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.when-line {
  margin: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card-top .when-line {
  flex: none;
}

.where {
  margin: 0;
  min-width: 0;
  font-size: 13px;
  font-weight: 680;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kind {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 680;
}

.person + .person { margin-top: 8px;}

.name {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.org {
  margin: 1px 0 0;
  font-size: 13px;
  line-height: 1.25;
  color: var(--muted);
}

.card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 450;
  font-style: italic;
  letter-spacing: -0.01em;
  min-height: 1.3em;
}

.card[data-span="1"]:has(.card-links) {
  padding-top: 8px;
  padding-bottom: 8px;
}

.card[data-span="1"]:has(.card-links) .card-links {
  margin-top: 0;
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
  align-items: center;
}

.card-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--ink);
  text-decoration: none;
  margin: 4px;
}

.card-link svg {
  width: auto;
  height: 24px;
  display: block;
  flex: none;
}

.card-link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.link-tip {
  position: fixed;
  z-index: 20;
  max-width: min(320px, calc(100vw - 16px));
  padding: 6px 8px;
  border-radius: 4px;
  background: var(--ink);
  color: #f7f4ee;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(26, 25, 22, 0.18);
}

.now {
  grid-column: 1 / -1;
  z-index: 4;
  pointer-events: none;
  position: relative;
}

.now::before {
  content: "";
  position: absolute;
  left: 0;
  right: 8px;
  top: calc(var(--fraction, 0) * 100%);
  height: 2px;
  background: #c23b22;
}

.now::after {
  content: "сейчас";
  position: absolute;
  left: 8px;
  top: calc(var(--fraction, 0) * 100% - 9px);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: #c23b22;
  border-radius: 99px;
  padding: 1px 6px;
}

dialog {
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  background: transparent;
}

dialog::backdrop {
  background: rgba(26, 25, 22, 0.46);
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(86dvh, 760px);
  overflow: auto;
  background: #fff;
  border-radius: 8px 8px 0 0;
  padding: 16px 20px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(26, 25, 22, 0.16);
}

.grab {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: #d9d3c8;
  margin: 4px auto 14px;
}

.sheet-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.sheet-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 600;
  margin: 12px 0 4px;
}

.sheet-kind {
  margin: 10px 0 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}

.sheet h2 {
  margin: 8px 0 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 720;
}

.sheet-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
  color: var(--muted);
}

.people {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  
}

.people li {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.people .portrait {
  display: block;
  width: 100px;
  height: 100px;
  object-fit: cover;
  flex: none;
  background: #eaeaea;
  border-radius: 4px;
}

.people .who {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.people strong { font-size: 24px; font-weight: 700; padding-bottom: 2px;}

.people span,
.role {
  color: var(--muted);
  font-size: 14px;
}

.materials { margin-top: 16px; }

.materials-label {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.material-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.material-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 4px;
  background: #d9edf2;
  text-decoration: none;
  font-weight: 600;
}

.material-link-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.material-links svg {
  width: 22px;
  height: 22px;
  flex: none;
}

.material-links a::after {
  content: "↗";
  flex: none;
  color: var(--muted);
}

.marks {
  margin-top: 18px;
  display: flex;
  gap: 8px;
}

.favorite {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  padding: 8px 10px;
  border: 0;
  border-radius: 4px;
  background: #ffd6e6;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.favorite svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.favorite[aria-pressed="true"] {
  background: #f08aaf;
}

.favorite.is-secondary {
  background: #fff3c4;
}

.favorite.is-secondary[aria-pressed="true"] {
  background: #f0c84a;
}

.favorite[aria-pressed="true"] svg path {
  fill: currentColor;
}

.favorite:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.close {
  margin-top: 8px;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 4px;
  background: var(--ink);
  color: #f7f4ee;
  font-weight: 650;
  cursor: pointer;
}

.empty-favorites {
  margin: 0;
  padding: 28px 20px;
  color: var(--muted);
  font-size: 15px;
}

@media (min-width: 840px) {
  :root { --peek: 0px; --head: 52px; }
  .grid {
    width: max(100%, calc(var(--time) + var(--halls) * 200px));
    grid-template-columns: var(--time) repeat(var(--halls), minmax(200px, 1fr));
  }
  .hour-board {
    display: grid;
    grid-template-columns: var(--hour-cols);
    grid-template-rows: minmax(0, 1fr);
    width: max(100%, var(--hour-min, 100%));
  }
  .hour-col {
    width: auto;
    min-width: 0;
  }
  .hour-col.is-empty {
    width: max-content;
  }
  .masthead { align-items: center; }
  .mast-tools { gap: 10px; }
  .top  { padding-left: 24px; padding-right: 24px; }
  h1 { font-size: 32px; }
  .title-full { display: inline; }
  .title-short { display: none; }
  .place { display: block; }
  .corner { display: block; }
  .hall-head { display: flex; }
  .halls,
  .section { display: none; }
  .card-links { gap: 8px;}
  .card-link {
    width: 24px;
    height: 24px;
    margin: 0;
  }
  .card-link svg {
    width: 18px;
    height: 18px;
  }
  .sheet {
    width: 600px;
    left: 50%;
    right: auto;
    translate: -50% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .card:active { transform: none; }
  .mode { transition: none; }
}
