:root {
  color-scheme: light dark;
  --bg: #f3f5fb; --card: #ffffff; --card-2: #f7f8fc; --text: #18203a; --muted: #6b7491; --line: #e6e9f2;
  --accent: #4357d6; --accent-soft: #eef0ff;
  --free: #0f8a5f; --free-soft: #e2f6ee; --busy: #d2423a; --busy-soft: #fdeceb;
  --lec: #e5e9ff; --lec-line: #4f63e0; --rec: #fff1da; --rec-line: #e59313;
  --shadow: 0 1px 2px rgb(20 30 70 / .05), 0 6px 24px rgb(20 30 70 / .07);
  --r: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1320; --card: #181d2d; --card-2: #1e2436; --text: #e8ebf5; --muted: #98a1bb; --line: #2a3147;
    --accent: #8796ff; --accent-soft: #252c4d;
    --free: #45d39b; --free-soft: #133428; --busy: #ff7f74; --busy-soft: #3a1c1c;
    --lec: #252f5c; --lec-line: #8796ff; --rec: #3b2c12; --rec-line: #f0a640;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 28px rgb(0 0 0 / .3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 Heebo, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* ---- hero ---- */
.hero { position: relative; color: #fff; overflow: hidden; padding-top: env(safe-area-inset-top); }
.hero-bg {
  position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(120% 140% at 100% 0%, #5b6cf0 0%, #2a3a9c 45%, #161f55 100%);
}
.hero-inner { position: relative; z-index: 1; max-width: 1040px; margin: 0 auto; padding: 22px 18px 18px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.hero h1 { margin: 0; font-size: 1.7rem; letter-spacing: -.01em; text-shadow: 0 2px 12px rgb(0 0 0 / .25); }
.hero-sub { margin: 2px 0 0; opacity: .9; text-shadow: 0 1px 8px rgb(0 0 0 / .3); }
.seg {
  display: inline-flex; gap: 4px; margin-top: 16px; padding: 4px; border-radius: 14px;
  background: rgb(255 255 255 / .14); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.seg button { border: 0; background: none; color: #fff; padding: 8px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; opacity: .85; }
.seg button[aria-selected="true"] { background: #fff; color: #1e2a6e; opacity: 1; box-shadow: 0 2px 8px rgb(0 0 0 / .15); }

/* ---- layout ---- */
main { max-width: 1040px; margin: 0 auto; padding: 16px 16px 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px; }
footer { max-width: 1040px; margin: 0 auto; padding: 8px 18px 28px; font-size: .8rem; color: var(--muted); }

/* ---- pickers ---- */
.pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; position: relative; z-index: 3; }
.free-pickers { grid-template-columns: 2fr 1fr 1fr auto; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field-row { display: flex; align-items: center; gap: 6px; }
.grow { flex: 1; min-width: 0; }
.input, .combo input {
  width: 100%; font: inherit; color: var(--text); background: var(--card-2);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .combo input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--card); }

.combo { position: relative; }
.combo-field { position: relative; }
.combo input { padding-inline-end: 60px; }
.combo-chev {
  position: absolute; inset-inline-end: 14px; top: 50%; width: 8px; height: 8px; pointer-events: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg);
}
.combo-clear {
  position: absolute; inset-inline-end: 32px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.combo-clear:hover { background: var(--line); color: var(--text); }
.combo-list {
  position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 20; margin: 0; padding: 6px; list-style: none;
  max-height: min(360px, 60vh); overflow-y: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 12px 40px rgb(20 30 70 / .18);
}
.combo-list li[role=option] { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.combo-list li.active { background: var(--accent-soft); }
.combo-list li[aria-selected="true"] .combo-label { color: var(--accent); font-weight: 700; }
.combo-label { font-weight: 500; }
.combo-sub { margin-inline-start: auto; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.combo-group { font-size: .72rem; font-weight: 700; color: var(--muted); padding: 10px 10px 4px; }
.combo-empty { padding: 12px; color: var(--muted); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.free { background: var(--free); box-shadow: 0 0 0 3px var(--free-soft); }
.dot.busy { background: var(--busy); box-shadow: 0 0 0 3px var(--busy-soft); }

.star { border: 0; background: none; cursor: pointer; font-size: 1.35rem; line-height: 1; color: var(--muted); padding: 4px; border-radius: 8px; }
.star:hover { background: var(--card-2); }
.star[aria-pressed="true"] { color: #f0b10f; }

/* ---- favorites ---- */
.favs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -2px 0 14px; }
.favs:empty { display: none; }
.favs-label { font-size: .8rem; font-weight: 700; color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 6px 13px; cursor: pointer; box-shadow: var(--shadow); font-size: .92rem;
}
.chip:hover { border-color: var(--accent); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip-sub { color: var(--muted); font-size: .78rem; }

/* ---- empty state ---- */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-icon { font-size: 2.6rem; margin-bottom: 6px; }

/* ---- status ---- */
.status { padding: 18px 20px 18px 20px; padding-inline-start: 26px; border: 0; position: relative; overflow: hidden; }
.status::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 6px; background: var(--muted); }
.status.free { background: linear-gradient(270deg, var(--card) 40%, var(--free-soft)); }
.status.free::before { background: var(--free); }
.status.busy { background: linear-gradient(270deg, var(--card) 40%, var(--busy-soft)); }
.status.busy::before { background: var(--busy); }
.status-head { display: flex; align-items: center; justify-content: space-between; }
.status-room { font-size: 1.05rem; font-weight: 700; }
.status-kicker { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-top: 6px; }
.status.free .status-kicker { color: var(--free); }
.status.busy .status-kicker { color: var(--busy); }
.status-big { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; margin: 2px 0; }
.status-in { font-size: 1rem; font-weight: 500; color: var(--muted); }
.status-sub { color: var(--muted); }

/* ---- week ---- */
.week-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.week-bar h2 { margin: 0; font-size: 1.1rem; }
.week-nav { display: flex; gap: 6px; }
.icon-btn, .pill-btn { border: 1px solid var(--line); background: var(--card-2); cursor: pointer; border-radius: 10px; font-weight: 600; }
.icon-btn { width: 38px; height: 38px; font-size: 1.3rem; line-height: 1; }
.pill-btn { padding: 8px 14px; }
.icon-btn:hover, .pill-btn:hover { border-color: var(--accent); color: var(--accent); }
.now-btn { height: 46px; }
.legend { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); margin-bottom: 12px; }
.lg { width: 12px; height: 12px; border-radius: 4px; display: inline-block; margin-inline-start: 8px; }
.lg:first-child { margin-inline-start: 0; }
.lg.lec { background: var(--lec); border: 2px solid var(--lec-line); }
.lg.rec { background: var(--rec); border: 2px solid var(--rec-line); }
.lg.gap { background: var(--free-soft); border: 2px dashed var(--free); }

.week { display: grid; grid-template-columns: 52px repeat(6, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.col-head { height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; border-bottom: 1px solid var(--line); background: var(--card-2); }
.col-head small { font-weight: 500; color: var(--muted); font-size: .75rem; }
.col-body { position: relative; height: 780px; /* 13 hours × 60px */ }
.col { border-inline-start: 1px solid var(--line); }
.col .col-body { background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 60px; }
.col.today .col-head { color: var(--accent); background: var(--accent-soft); }
.col.today .col-body { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.hours .col-body { background: var(--card-2); }
.hour { position: absolute; top: calc(var(--top) * 100%); inset-inline: 0; font-size: .72rem; color: var(--muted); text-align: center; margin-top: 3px; }
.ev {
  position: absolute; top: calc(var(--top) * 100% + 1px); height: calc(var(--h) * 100% - 2px); inset-inline: 4px;
  border-radius: 10px; padding: 4px 7px; overflow: hidden; font-size: .76rem; line-height: 1.25;
  border-inline-start: 4px solid; box-shadow: 0 1px 3px rgb(20 30 70 / .08);
}
.ev b { font-weight: 700; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ev span { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.lec { background: var(--lec); border-color: var(--lec-line); }
.ev.rec { background: var(--rec); border-color: var(--rec-line); }
.now-line { position: absolute; top: calc(var(--top) * 100%); inset-inline: 0; border-top: 2px solid var(--busy); z-index: 2; pointer-events: none; }
.now-line::before { content: ""; position: absolute; inset-inline-start: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--busy); }
bdi { unicode-bidi: isolate; direction: ltr; white-space: nowrap; }

/* ---- day agenda (phones) ---- */
.agenda { display: none; }
.day-pills { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 12px; }
.day-pill { display: flex; flex-direction: column; align-items: center; padding: 7px 0 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); cursor: pointer; font-weight: 700; }
.day-pill small { font-weight: 500; color: var(--muted); font-size: .72rem; }
.day-pill i { font-style: normal; color: var(--accent); height: 10px; line-height: 6px; letter-spacing: 1px; }
.day-pill.today { border-color: var(--accent); }
.day-pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.day-pill.on small, .day-pill.on i { color: rgb(255 255 255 / .85); }
.agenda-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ag { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; border-inline-start: 4px solid; }
.ag-time { font-size: .82rem; font-weight: 700; min-width: 86px; color: var(--muted); padding-top: 1px; }
.ag-what { display: flex; flex-direction: column; min-width: 0; }
.ag-what small { color: var(--muted); }
.ag.lec { background: var(--lec); border-color: var(--lec-line); }
.ag.rec { background: var(--rec); border-color: var(--rec-line); }
.ag.gap { background: var(--free-soft); border-color: var(--free); border-inline-start-style: dashed; color: var(--free); font-weight: 600; padding-block: 7px; }
.ag.now { outline: 2px solid var(--busy); outline-offset: 1px; }
.agenda-empty { text-align: center; padding: 18px; }

/* ---- free rooms ---- */
.section-title { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; margin: 6px 2px 10px; }
.count { font-size: .8rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 9px; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px; }
.room-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: start; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow);
  transition: transform .12s, border-color .12s;
}
.room-card:hover { transform: translateY(-2px); border-color: var(--free); }
.rc-name { font-weight: 700; font-size: 1.02rem; }
.rc-b { font-size: .8rem; color: var(--muted); }
.rc-until { font-size: .84rem; font-weight: 600; margin-top: 4px; }
.rc-until.free { color: var(--free); }
.rc-bar { align-self: stretch; height: 5px; border-radius: 3px; background: var(--card-2); margin-top: 6px; overflow: hidden; }
.rc-bar span { display: block; height: 100%; width: var(--pct, 0%); background: var(--free); border-radius: 3px; }
.busy-list { padding: 0; }
.busy-list summary { cursor: pointer; padding: 14px 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.busy-list ul { list-style: none; margin: 0; padding: 0; }
.busy-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.link { background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; text-align: start; }
.link:hover { color: var(--accent); }
.tag { font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; margin-inline-start: auto; white-space: nowrap; }
.tag.busy { color: var(--busy); background: var(--busy-soft); }

/* ---- phones ---- */
@media (max-width: 720px) {
  .hero h1 { font-size: 1.4rem; }
  .hero-top { flex-direction: column; align-items: flex-start; }
  .seg { display: flex; }
  .seg button { flex: 1; padding: 8px 6px; }
  .pickers { grid-template-columns: 1fr; }
  .free-pickers { grid-template-columns: 1fr 1fr; }
  .free-pickers > .field:first-child, .free-pickers .now-btn { grid-column: 1 / -1; }
  .week, .legend { display: none; }
  .agenda { display: block; }
  .status-big { font-size: 1.55rem; }
}
.week-bar h2 { white-space: nowrap; font-size: clamp(.95rem, 3.6vw, 1.1rem); }

/* a cut-off block opens to full size on hover / tap / keyboard focus */
.ev { transition: box-shadow .15s; outline: none; }
.ev:hover, .ev:focus-visible, .ev:focus {
  height: auto; min-height: calc(var(--h) * 100% - 2px); z-index: 5; overflow: visible;
  box-shadow: 0 8px 24px rgb(20 30 70 / .22);
}
.ev:hover b, .ev:focus b { -webkit-line-clamp: unset; }
.ev:hover span, .ev:focus span { white-space: normal; }

/* week arrows drawn with physical borders (‹ › are mirrored in RTL text) */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; }
.chev { width: 9px; height: 9px; border-top: 2.5px solid currentColor; border-right: 2.5px solid currentColor; }
.chev.right { transform: translateX(-2px) rotate(45deg); }
.chev.left { transform: translateX(2px) rotate(-135deg); }

/* room booking link */
.hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.book-btn {
  color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem; white-space: nowrap;
  padding: 7px 14px; border-radius: 999px; background: rgb(255 255 255 / .16); border: 1px solid rgb(255 255 255 / .3);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.book-btn:hover { background: rgb(255 255 255 / .28); }
.book-note { color: var(--muted); font-size: .88rem; margin: 0 2px 14px; }
@media (max-width: 720px) {
  .hero-top { flex-direction: column; align-items: flex-start; gap: 10px; }
  .hero-side { align-items: flex-start; }
}
.hero-top > div:first-child { flex: 1; min-width: 0; }
@media (max-width: 720px) {
  .book-btn { padding: 5px 11px; font-size: .8rem; }
}

button.book-btn { cursor: pointer; font: inherit; font-weight: 600; font-size: .9rem; }
@media (max-width: 720px) { button.book-btn { font-size: .8rem; } .hero-side { flex-direction: row; flex-wrap: wrap; } }
/* never offer installing inside the installed app */
@media (display-mode: standalone), (display-mode: window-controls-overlay), (display-mode: minimal-ui) {
  #install-btn { display: none !important; }
}
