/* ---------------------------------------------------------------------------
   blmr - meeting room booking
   No build step. Plain CSS, custom properties, light and dark.
   The Content-Security-Policy forbids inline styles, so everything lives here.
   --------------------------------------------------------------------------- */

:root {
  --bg:        #fbfbff;
  --surface:   #ffffff;
  --ink:       #1d1e20;
  --ink-2:     #40424f;
  --muted:     #6b6e80;
  --line:      #e6e6f0;
  --line-2:    #d3d4e2;

  --brand:     #5652e6;
  --brand-ink: #ffffff;
  --brand-dim: #ecebfd;

  --free:      #ffffff;
  --free-edge: #e2e2ee;
  --booked:    #eceaf6;
  --booked-ink:#4a4766;
  --mine:      #ddf1e4;
  --mine-edge: #86c69b;
  --mine-ink:  #1d5733;
  --closed:    #f3f3f7;

  --ok:        #1d7a45;
  --ok-bg:     #e4f5ea;
  --warn:      #8a5a00;
  --warn-bg:   #fdf2dc;
  --err:       #a8231f;
  --err-bg:    #fdeceb;
  --info-bg:   #e9eefc;
  --info:      #1f4699;

  --radius:    10px;
  --radius-sm: 7px;
  --shadow:    0 1px 2px rgba(29, 30, 32, .05), 0 2px 8px rgba(29, 30, 32, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #14151a;
    --surface:   #1c1d24;
    --ink:       #f0f0f5;
    --ink-2:     #c9cad6;
    --muted:     #9598ab;
    --line:      #2b2d38;
    --line-2:    #3a3d4b;

    --brand:     #8b86ff;
    --brand-ink: #15151f;
    --brand-dim: #272a45;

    --free:      #20222a;
    --free-edge: #31343f;
    --booked:    #2e2b45;
    --booked-ink:#c3bfe8;
    --mine:      #1d4030;
    --mine-edge: #3f7a57;
    --mine-ink:  #a8e6c0;
    --closed:    #191a20;

    --ok:        #7fd3a0;
    --ok-bg:     #1a3326;
    --warn:      #f0c97a;
    --warn-bg:   #352a12;
    --err:       #f5a9a5;
    --err-bg:    #3a1d1c;
    --info-bg:   #1d2742;
    --info:      #a9c2ff;

    --shadow:    0 1px 2px rgba(0, 0, 0, .3);
  }
}

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

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  background: var(--brand-dim);
  padding: .1em .35em;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- layout ------------------------------------------------------------- */

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}
.shell-narrow { max-width: 420px; padding-top: 8vh; }

.section { margin: 32px 0; }
.section-title {
  font-size: 15px; font-weight: 600; letter-spacing: .01em;
  color: var(--ink-2); margin: 0 0 12px;
}
.count { color: var(--muted); font-weight: 400; }
.page-title { font-size: 22px; margin: 0 0 16px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.is-dim { opacity: .58; }
.crumb { margin: 0 0 12px; font-size: 14px; }

/* --- top bar ------------------------------------------------------------ */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { font-weight: 650; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }

.nav { display: flex; gap: 2px; flex: 1 1 auto; flex-wrap: wrap; }
.nav a {
  padding: 6px 11px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.is-active { background: var(--brand-dim); color: var(--brand); }

.topbar-user { display: flex; align-items: center; gap: 10px; }
.whoami {
  font-size: 14px; color: var(--muted); max-width: 16ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* --- cards and forms --------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-auth { padding: 28px; }
.card-form { padding: 20px; }
.empty { text-align: center; color: var(--muted); }

.auth-title { font-size: 20px; margin: 0 0 6px; }
.auth-sub { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.auth-foot { margin: 18px 0 0; font-size: 14px; }
.auth-note { margin: 14px 0 0; font-size: 13px; color: var(--muted); }

.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-items: end;
}
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-actions-span { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-inline { flex: 1 1 200px; }
.field-label { font-size: 13px; font-weight: 550; color: var(--ink-2); }
.field-optional { font-weight: 400; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], input[type="search"], input[type="file"], select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
  min-width: 0;
  /* 16px keeps iOS Safari from zooming when a field gains focus. */
  font-size: 16px;
}
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
input[type="file"] { padding: 7px; }

/* --- buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  font: inherit; font-size: 14px; font-weight: 550;
  padding: 9px 15px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  /* Comfortable tap target on a phone. */
  min-height: 40px;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-sm { font-size: 13px; padding: 6px 11px; min-height: 34px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.07); background: var(--brand); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--bg); }
.btn-danger { color: var(--err); border-color: var(--line-2); }
.btn-danger:hover { background: var(--err-bg); }

/* --- alerts ------------------------------------------------------------- */

.alert {
  border-radius: var(--radius);
  padding: 11px 14px;
  margin: 0 0 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-success { background: var(--ok-bg);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-error   { background: var(--err-bg);  color: var(--err);  border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-info    { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }

/* --- pills -------------------------------------------------------------- */

.pill {
  display: inline-block;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--closed); color: var(--muted);
  vertical-align: middle;
}
.pill-today     { background: var(--brand-dim); color: var(--brand); }
.pill-ok        { background: var(--ok-bg); color: var(--ok); }
.pill-off       { background: var(--closed); color: var(--muted); }
.pill-cancelled { background: var(--err-bg); color: var(--err); }
.pill-locked    { background: var(--warn-bg); color: var(--warn); }
.pill-admin     { background: var(--brand-dim); color: var(--brand); }
.pill-you       { background: var(--info-bg); color: var(--info); }

/* --- board header ------------------------------------------------------- */

.board-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 16px;
}
.board-date { display: flex; align-items: center; gap: 10px; }
.board-date .page-title { margin: 0; }
.datenav { display: flex; align-items: center; gap: 6px; }
.datenav input[type="date"] { width: auto; }

/* --- the grid ----------------------------------------------------------- */

.grid-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: max-content;
}
.grid th, .grid td { border-bottom: 1px solid var(--line); }
.grid tbody tr:last-child th, .grid tbody tr:last-child td { border-bottom: 0; }

.grid-room-head, .grid-room {
  position: sticky; left: 0; z-index: 2;
  background: var(--surface);
  border-right: 1px solid var(--line-2);
  text-align: left;
  min-width: 148px; max-width: 200px;
}
.grid-room-head {
  z-index: 3;
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 8px 12px;
}
.grid-room { padding: 10px 12px; vertical-align: middle; }
.room-name { display: block; font-weight: 600; font-size: 14px; }
.room-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }

.grid-slot-head {
  font-size: 11px; font-weight: 600; color: var(--muted);
  padding: 8px 0 6px;
  min-width: 62px;
  border-bottom: 1px solid var(--line-2);
}

.slot { padding: 3px; vertical-align: middle; height: 54px; }

.slot-free { background: var(--free); }
.slot-link {
  display: flex; align-items: center; justify-content: center;
  height: 100%; min-height: 46px;
  border: 1px dashed var(--free-edge);
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.slot-link:hover {
  background: var(--brand-dim);
  border-color: var(--brand);
  border-style: solid;
  color: var(--brand);
  text-decoration: none;
}
.slot-plus { font-size: 17px; font-weight: 400; line-height: 1; }

.slot-closed { background: var(--closed); }

.slot-booked {
  background: var(--booked);
  color: var(--booked-ink);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  text-align: left;
}
.slot-booked.is-mine {
  background: var(--mine);
  color: var(--mine-ink);
  box-shadow: inset 0 0 0 1px var(--mine-edge);
}
.slot-who   { display: block; font-size: 13px; font-weight: 650; line-height: 1.25;
              overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-when  { display: block; font-size: 11px; opacity: .85; font-variant-numeric: tabular-nums; }
.slot-title { display: block; font-size: 11px; opacity: .8;
              overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.legend {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  margin-top: 12px; font-size: 12px; color: var(--muted);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch {
  width: 13px; height: 13px; border-radius: 4px; display: inline-block;
  border: 1px solid var(--free-edge);
}
.swatch-free   { background: var(--free); border-style: dashed; }
.swatch-booked { background: var(--booked); border-color: transparent; }
.swatch-mine   { background: var(--mine); border-color: var(--mine-edge); }
.legend-note { margin-left: auto; }

/* --- booking form summary ---------------------------------------------- */

.summary {
  display: grid; gap: 10px 20px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin: 0 0 20px; padding: 14px;
  background: var(--bg); border-radius: var(--radius);
}
.summary dt { font-size: 12px; color: var(--muted); margin: 0; }
.summary dd { margin: 2px 0 0; font-weight: 550; font-size: 15px; }

/* --- lists -------------------------------------------------------------- */

.booking-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.booking-item {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.booking-list-quiet .booking-item { box-shadow: none; background: transparent; }
.booking-main { flex: 1 1 260px; min-width: 0; }
.booking-room  { display: block; font-weight: 650; }
.booking-when  { display: block; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.booking-title { display: block; font-size: 13px; color: var(--muted); }
.booking-meta  { display: block; font-size: 12px; color: var(--muted); }

.room-cards, .user-cards { display: grid; gap: 12px; }
.room-card-head, .user-id {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.room-card-foot { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

.user-card { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.user-card-main { flex: 1 1 260px; min-width: 0; }
.user-card .user-id { margin-bottom: 4px; }
.user-email { font-size: 14px; color: var(--ink-2); word-break: break-all; }
.user-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: inline; }

/* --- tables ------------------------------------------------------------- */

.table-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }

/* --- filter bars -------------------------------------------------------- */

.filterbar {
  display: flex; gap: 10px; align-items: end; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filterbar-wide { padding: 16px; }
.filterbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- room access list --------------------------------------------------- */

.pill-lock    { background: var(--warn-bg); color: var(--warn); }
.pill-private { background: var(--info-bg); color: var(--info); }

.btn-xs { font-size: 12px; padding: 4px 8px; min-height: 28px; }

.access {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.access > summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.access > summary::marker { color: var(--muted); }
.access > summary .sm { font-weight: 400; }

.member-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 12px;
  padding: 0;
  list-style: none;
}
.member {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.member.is-dim { opacity: .55; }

.member-who {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
  min-width: 0;
}
.member-name  { font-weight: 600; font-size: 14px; }
.member-email { color: var(--muted); font-size: 12.5px; word-break: break-all; }

.member-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.member-actions form { margin: 0; }

.member-add {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding-top: 4px;
}
.member-add .field { flex: 1 1 220px; margin: 0; }

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  font-size: 14px;
}
.check input { width: 17px; height: 17px; accent-color: var(--brand); }

/* --- narrow screens ----------------------------------------------------- */

@media (max-width: 700px) {
  .member { align-items: flex-start; }
  .member-actions { width: 100%; }
  .member-add .field { flex-basis: 100%; }
  .shell { padding: 16px 12px 56px; }
  .topbar-inner { gap: 10px; padding: 9px 12px; }
  .nav { order: 3; width: 100%; }
  .nav a { padding: 6px 9px; font-size: 13px; }
  .whoami { display: none; }
  .board-head { align-items: flex-start; }
  .datenav { width: 100%; }
  .datenav input[type="date"] { flex: 1 1 auto; }
  .page-title { font-size: 19px; }
  .grid-room-head, .grid-room { min-width: 116px; max-width: 136px; }
  .grid-slot-head { min-width: 56px; }
  .user-card-actions { width: 100%; }
}
