:root {
  --bg: #F6F4F0;
  --surface: #fff;
  --border: #E4E0D8;
  --text: #1F1D1A;
  --muted: #7D786F;
  --terra: #C44B2B;
  --amber: #D4920A;
  --amber-bg: #FFF8E7;
  --red: #B82F2F;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { overflow-x: clip; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 1rem;
  max-width: 960px;
  margin: 0 auto;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* --- Header --- */

.hdr {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 1.25rem;
}
.site-t {
  font-size: 1.25rem;
  font-weight: 700;
}
.week-l {
  font-size: 0.8rem;
  color: var(--muted);
}
.clk-t {
  font-family: ui-monospace, 'SFMono-Regular', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.clk-d {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

/* --- Search --- */

.srch { margin-bottom: 1.5rem; }
.srch-bar { position: relative; }
.srch-ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.srch-in {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 2.5rem 0 38px;
  border: 2px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
}
.srch-in::placeholder { color: var(--muted); }
.srch-in:focus { border-color: var(--text); }
.srch-n {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.73rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: none;
}
.srch-n.vis { display: block; }
.srch-res {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* --- Search result cards --- */

.sr-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 0.5rem;
  align-items: start;
  background: var(--amber-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  box-shadow: inset 3px 0 0 var(--amber);
}
.sr-name {
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sr-ph {
  font-family: ui-monospace, 'SFMono-Regular', monospace;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.sr-ph:hover { text-decoration: underline; }
.sr-evs {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  min-width: 0;
}
.sr-evl {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 1px;
}
.sr-rm {
  font-weight: 700;
  color: var(--terra);
}
.sr-et { color: var(--muted); min-width: 0; }
.sr-etm {
  font-family: ui-monospace, 'SFMono-Regular', monospace;
  font-size: 0.73rem;
  color: var(--muted);
}
.sr-em {
  font-size: 0.7rem;
  color: var(--muted);
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-em a { color: inherit; text-decoration: none; }
.sr-em a:hover { text-decoration: underline; }

/* --- Room grid --- */

.rooms { margin-bottom: 1.75rem; }
.rg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.rc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  min-width: 0;
}
.rc.act {
  border-color: var(--amber);
  background: var(--amber-bg);
}
.rc.s-hl { border-color: var(--terra); }
.rn {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--terra);
  line-height: 1.1;
  margin-bottom: 2px;
}
.rs {
  font-size: 0.75rem;
  line-height: 1.35;
  min-width: 0;
}
.rs-line {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.rs-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.act-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
  animation: dotPulse 2s ease-in-out infinite;
}
.rs-time {
  font-family: ui-monospace, 'SFMono-Regular', monospace;
  font-size: 0.7rem;
  color: var(--muted);
}
.rs-next {
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: 3px;
  padding-top: 3px;
  border-top: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rs-nt {
  font-family: ui-monospace, 'SFMono-Regular', monospace;
}
.rs-free, .rs-free-r { color: var(--muted); }
.rs-more {
  font-size: 0.65rem;
  color: var(--muted);
}

/* --- Schedule --- */

.day { margin-bottom: 0.25rem; }
.day.hid { display: none; }
.dh {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.5rem 0 0.3rem;
  border-bottom: 2px solid var(--text);
  margin-bottom: 0.2rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}
.dh.today { border-bottom-color: var(--amber); }
.dh.sun { border-bottom-color: var(--red); }
.dn {
  font-weight: 700;
  font-size: 1.05rem;
  text-transform: capitalize;
}
.dn.sun { color: var(--red); }
.dd {
  font-size: 0.8rem;
  color: var(--muted);
}
.db {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--amber);
}
.hl {
  font-size: 0.75rem;
  color: var(--red);
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.noev {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.6rem 0;
}
.evs { padding: 0.15rem 0 1rem; }

/* --- Events ---
   Time column: 80px fits "13:30–14:30" (11ch mono at 0.78rem).
   Body: 375 - 32 pad - 80 col - 10 gap = 253px.
*/

.ev {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 0 0.6rem;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.ev:last-child { border-bottom: none; }
.ev.act {
  box-shadow: inset 3px 0 0 var(--amber);
  background: var(--amber-bg);
  border-bottom-color: transparent;
}
.ev.upc {
  box-shadow: inset 3px 0 0 rgba(212, 146, 10, 0.35);
  background: rgba(255, 248, 231, 0.5);
  border-bottom-color: transparent;
}
.ev.past { opacity: 0.45; }
.ev.s-miss { display: none; }
.ev-t {
  font-family: ui-monospace, 'SFMono-Regular', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 1px;
  line-height: 1.3;
}
.ev-t span { display: block; }
.ev-b { min-width: 0; }
.ev-tr {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.ev-rm {
  font-weight: 700;
  color: var(--terra);
  white-space: nowrap;
}
.ev-ti { font-weight: 500; }
.ev-st {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--amber);
}
.ev-st.soon { color: var(--muted); }
.ev-cat {
  font-size: 0.73rem;
  color: var(--amber);
  font-weight: 500;
  margin-top: 1px;
}
.ev-cat::before { content: '\2615\0020'; }

/* --- People details --- */

.ev-p { margin-top: 4px; }
.ev-p summary {
  font-size: 0.73rem;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ev-p summary::-webkit-details-marker { display: none; }
.ev-p summary::before { content: '\25B8'; font-size: 0.65rem; }
.ev-p[open] summary::before { transform: rotate(90deg); }
.ev-pl { padding: 3px 0 0 14px; }
.pr {
  padding: 2px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}
.pr:last-child { border-bottom: none; }
.pr-n { font-weight: 500; }
.pr-r { color: var(--muted); font-size: 0.7rem; }
.pr-c {
  font-family: ui-monospace, 'SFMono-Regular', monospace;
  font-size: 0.73rem;
  color: var(--muted);
  margin-top: 1px;
  overflow-wrap: anywhere;
}
.pr-c a { color: inherit; text-decoration: none; }
.pr-c a:hover { text-decoration: underline; }

/* --- Animation --- */

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* --- Responsive --- */

@media (min-width: 420px) {
  .rg { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 700px) {
  body { padding: 1.5rem 2rem; }
  .hdr {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
  }
  .clk { text-align: right; flex-shrink: 0; }
  .clk-t { font-size: 1.8rem; }
  .srch-bar { max-width: 480px; }
  .rg {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }
  .rc { padding: 10px 12px; }
  .rn { font-size: 1.25rem; }
  .ev {
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 0 0.75rem;
    padding: 8px 12px;
  }
  .ev-t { font-size: 0.83rem; }
  .dn { font-size: 1.1rem; }
}

@media print {
  body { padding: 0.5cm; background: white; }
  .srch, .rooms { display: none; }
  .dh { position: static; background: white; }
  .ev.past { opacity: 1; }
  .ev.act, .ev.upc { box-shadow: none; background: none; }
  .day.hid { display: block; }
  .clk-t { font-size: 1rem; }
}
