:root {
  --bg:            #0d0c0a;
  --ink:           #f1efe4;
  --ink-mute:      #87837a;
  --ink-dim:       #4d4a44;
  --rule:          rgba(241, 239, 228, 0.08);
  --rule-strong:   rgba(241, 239, 228, 0.20);

  /* Starlabs identity — footer pulse only */
  --brand:         #ef4f23;
  --brand-glow:    rgba(239, 79, 35, 0.55);

  /* Semantic state — green / red */
  --available:     #4fa572;
  --available-soft:rgba(79, 165, 114, 0.12);
  --available-glow:rgba(79, 165, 114, 0.5);
  --available-bg:  rgba(79, 165, 114, 0.035);

  --busy:          #dc3a2a;
  --busy-soft:     rgba(220, 58, 42, 0.14);
  --busy-glow:     rgba(220, 58, 42, 0.55);
  --busy-bg:       rgba(220, 58, 42, 0.05);

  --offline:       #807c70;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 300;
  font-feature-settings: "ss01", "ss02";
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* film grain */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 0.96 0 0 0 0 0.85 0 0 0 0.18 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 100;
}

/* HEADER */
.head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 2.2vh 3vw;
  border-bottom: 1px solid var(--rule);
  position: relative;
  z-index: 2;
}
.brand { display: flex; align-items: center; gap: 1.1vw; }
.brand-logo { height: 3.2vh; width: auto; display: block; }
.brand-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75vw;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  color: var(--ink-mute);
  padding-left: 1.1vw;
  border-left: 1px solid var(--rule-strong);
}
.head-date {
  text-align: center;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 1.3vw;
  color: var(--ink-mute);
}
.clock {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 1.05vw;
  letter-spacing: 0.15em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* GRID */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
  z-index: 2;
  min-height: 0;
}
.grid > .tile + .tile { border-left: 1px solid var(--rule); }

.tile {
  position: relative;
  padding: 4.5vh 3.8vw 3.5vh;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 3.2vh;
  overflow: hidden;
  transition: background 800ms ease;
}
.tile.available { background: var(--available-bg); }
.tile.occupied  { background: var(--busy-bg); }

.tile::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
}
.tile.available::before { background: var(--available); box-shadow: 0 0 50px var(--available-glow); }
.tile.occupied::before  { background: var(--busy);      box-shadow: 0 0 50px var(--busy-glow); }
.tile.offline::before   { background: var(--offline); }
.tile.loading::before   { background: var(--rule-strong); }

.tile::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 1.6vw; height: 1.6vw;
  border-top: 1px solid var(--rule-strong);
  border-right: 1px solid var(--rule-strong);
  pointer-events: none;
}

.loading-inner {
  align-self: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95vw;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* meta row */
.tile-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8vw;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--ink-mute);
}
.tile-id { color: var(--ink); font-weight: 600; }
.indicator { display: inline-flex; align-items: center; gap: 0.7vw; }
.dot {
  width: 0.55vw; height: 0.55vw;
  border-radius: 50%;
  position: relative;
}
.available .dot { background: var(--available); color: var(--available); }
.occupied  .dot { background: var(--busy);      color: var(--busy); }
.offline   .dot { background: var(--offline);   color: var(--offline); }
.dot::after {
  content: '';
  position: absolute; inset: -0.35vw;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.35;
  animation: ring 2.8s ease-out infinite;
}
@keyframes ring {
  0%   { transform: scale(0.7); opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* room name */
.room {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 2.6vw;
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--ink);
}

/* hero */
.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 1.6vw;
  padding-bottom: 2.4vh;
  border-bottom: 1px solid var(--rule);
}
.hero-kicker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78vw;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  color: var(--ink-mute);
  margin-bottom: 1vh;
}
.available .hero-kicker { color: var(--available); }
.occupied  .hero-kicker { color: var(--busy); }
.offline   .hero-kicker { color: var(--offline); }

.hero-number {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 5.2vw;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.available .hero-number { color: var(--available); }
.occupied  .hero-number { color: var(--busy); }

.hero-side { padding-bottom: 1.6vh; min-width: 0; }
.hero-side .lbl {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7vw;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
  margin-bottom: 0.7vh;
}
.hero-side .val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 1.4vw;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.hero-side .subj {
  margin-top: 0.4vh;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 1.1vw;
  color: var(--ink-mute);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* schedule */
.schedule { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.schedule-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.8vh;
}
.schedule-head .h {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78vw;
  text-transform: uppercase;
  letter-spacing: 0.34em;
  color: var(--ink-mute);
}
.schedule-head .count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7vw;
  letter-spacing: 0.25em;
  color: var(--ink-dim);
  text-transform: uppercase;
}

.slot-list { display: flex; flex-direction: column; overflow: hidden; }
.slot {
  display: grid;
  grid-template-columns: 11vw 1fr auto;
  align-items: center;
  gap: 1.8vw;
  padding: 1.6vh 0;
  padding-left: 1vw;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.slot:last-child { border-bottom: none; }
.slot-time {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 1.15vw;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.slot-subject {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 1.5vw;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slot-len {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78vw;
  color: var(--ink-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.slot.past .slot-time,
.slot.past .slot-subject,
.slot.past .slot-len { color: var(--ink-dim); }
.slot.past .slot-subject {
  text-decoration: line-through;
  text-decoration-color: rgba(241,239,228,0.15);
  text-decoration-thickness: 1px;
}

.slot.current {
  background: linear-gradient(90deg, var(--busy-soft) 0%, transparent 80%);
  margin: 0 -1.5vw;
  padding-left: 1.5vw;
  padding-right: 1.5vw;
  border-bottom-color: transparent;
  border-radius: 2px;
}
.slot.current::before {
  content: '';
  position: absolute; left: 0; top: 10%; bottom: 10%;
  width: 3px;
  background: var(--busy);
  box-shadow: 0 0 16px var(--busy-glow);
}
.slot.current .slot-time,
.slot.current .slot-subject { color: var(--ink); }
.slot.current .slot-len    { color: var(--busy); font-weight: 600; }

/* empty/error */
.schedule-empty {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 4vh 0;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 1.7vw;
  color: var(--ink-mute);
  line-height: 1.3;
}
.schedule-empty small {
  font-family: 'JetBrains Mono', monospace;
  font-style: normal;
  font-size: 0.75vw;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 1.2vh;
}
.error-block { padding: 3vh 0; }
.error-block .lbl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75vw;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 1vh;
}
.error-block .msg {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.5vw;
  color: var(--ink-mute);
  line-height: 1.3;
}

/* FOOTER */
.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.8vh 3vw;
  border-top: 1px solid var(--rule);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7vw;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  color: var(--ink-dim);
  position: relative;
  z-index: 2;
}
.foot .live { display: inline-flex; align-items: center; gap: 0.6vw; }
.foot .live::before {
  content: '';
  width: 0.4vw; height: 0.4vw; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 12px var(--brand-glow);
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.25; }
}

/* entrance — only on first paint; re-renders skip the fade */
@keyframes rise {
  from { opacity: 0; transform: translateY(1.5vh); }
  to   { opacity: 1; transform: none; }
}
.head  { animation: rise 0.7s cubic-bezier(.2,.7,.2,1) both; animation-delay: 0.05s; }
.tile  { animation: rise 0.9s cubic-bezier(.2,.7,.2,1) both; }
.tile:nth-child(1) { animation-delay: 0.15s; }
.tile:nth-child(2) { animation-delay: 0.28s; }
.foot  { animation: rise 0.7s cubic-bezier(.2,.7,.2,1) both; animation-delay: 0.42s; }

/* After first render: no entrance animation on re-rendered tiles */
body.booted .tile { animation: none; }
