/*
 * Calendar Agent — International Typographic Style.
 *
 * One sans family, flush-left/ragged-right type, hierarchy by size and weight
 * alone, an explicit column grid, black rules instead of boxes and shadows,
 * square corners, and a single signal red. Mirrors the Gmail Agent stylesheet
 * so the sibling dashboards read as one family.
 */

:root {
  --ink: #111;
  --paper: #fff;
  --grey: #6b6b6b;
  --hair: #d4d4d4;
  --wash: #f3f3f3;
  --red: #e30613;
  --ok: #111;
  --font: "Helvetica Neue", Helvetica, Arial, "Nimbus Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: 1.5rem;
  --measure: 72rem;
  --rule: 2px solid var(--ink);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}

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

.wrap, main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main { padding-top: 3rem; padding-bottom: 6rem; }

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

.site-header { border-bottom: var(--rule); }

.site-header .wrap {
  display: grid;
  grid-template-columns: 3fr 9fr;
  gap: var(--gutter);
  align-items: end;
  padding-top: 1.25rem;
  padding-bottom: .9rem;
}

.wordmark {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark::before {
  content: "";
  display: block;
  width: .9rem;
  height: .9rem;
  margin-bottom: .6rem;
  background: var(--red);
}

.site-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gutter);
  flex-wrap: wrap;
}

.site-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }

.site-nav a, .site-user a {
  color: var(--ink);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  padding-bottom: .2rem;
  border-bottom: 3px solid transparent;
}
.site-nav a:hover, .site-user a:hover { border-bottom-color: var(--ink); }
.site-nav a[aria-current="page"], .site-user a[aria-current="page"] { border-bottom-color: var(--red); }

.site-user { display: flex; align-items: baseline; gap: .75rem; font-size: .9rem; }
.site-user .role {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--grey);
}
.site-user button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--grey);
  font: inherit;
  font-size: .9rem;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.site-user button:hover { color: var(--red); background: none; }

/* ---------------------------------------------------------------- type */

h1 {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -.035em;
  margin: 0 0 2.5rem;
  max-width: 18ch;
}

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.005em;
  margin: 3.5rem 0 1.25rem;
  padding-top: .6rem;
  border-top: var(--rule);
}

h3 { font-size: 1rem; font-weight: 700; margin: 2rem 0 .75rem; }

p { margin: 0 0 1rem; max-width: 68ch; }

a { color: var(--ink); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--red); }

strong { font-weight: 700; }

code, pre, kbd {
  font-family: var(--mono);
  font-size: .85em;
}
code { background: var(--wash); padding: .05em .3em; word-break: break-all; }
pre {
  background: var(--wash);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  border-left: 4px solid var(--ink);
  line-height: 1.5;
}
pre code { background: none; padding: 0; word-break: normal; }

.muted { color: var(--grey); font-size: .875rem; }
.label {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--grey);
  margin-bottom: .3rem;
}

/* ---------------------------------------------------------------- messages */

.error, .ok, .notice {
  max-width: 68ch;
  padding: .55rem 0 .55rem .9rem;
  border-left: 4px solid var(--red);
  font-weight: 500;
}
.error { color: var(--red); }
.ok { border-left-color: var(--ink); color: var(--ok); }
.notice { border-left-color: var(--ink); background: var(--wash); padding-right: .9rem; margin: 0 0 1.5rem; }
td.error, span.error, td .error { border: 0; padding: 0; }

.banner {
  border-bottom: var(--rule);
  background: var(--red);
  color: var(--paper);
}
.banner .wrap { padding-top: .7rem; padding-bottom: .7rem; font-weight: 500; }
.banner a { color: var(--paper); font-weight: 700; }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin: 0 0 1.5rem;
}
th {
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 .75rem .5rem 0;
  border-bottom: var(--rule);
  vertical-align: bottom;
}
td {
  padding: .6rem .75rem .6rem 0;
  border-bottom: 1px solid var(--hair);
  vertical-align: top;
}
tr:last-child td { border-bottom-color: var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* Timetable: the day label only on the first row of each day. */
.agenda td.day { font-weight: 700; white-space: nowrap; width: 9rem; }
.agenda tr.new-day td { border-top: 1px solid var(--ink); }
.agenda tr.new-day:first-child td, .agenda tr:first-child td { border-top: 0; }
.agenda td.when { white-space: nowrap; width: 8rem; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- facts */

.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0 var(--gutter);
  margin: 0 0 1rem;
  border-top: var(--rule);
}
.facts > div { padding: .7rem 0 1rem; border-bottom: 1px solid var(--hair); }
.facts dt { margin: 0; }
.facts dd { margin: 0; font-size: 1.05rem; font-weight: 500; overflow-wrap: anywhere; }

.numerals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gutter);
  margin: 0 0 1.5rem;
}
.numerals > div { border-top: var(--rule); padding-top: .6rem; }
.numerals .figure {
  display: block;
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.04em;
  margin: .4rem 0 .5rem;
}
.numerals .sub { font-size: .85rem; color: var(--grey); }

.state { font-weight: 700; }
.state::before {
  content: "";
  display: inline-block;
  width: .6em;
  height: .6em;
  margin-right: .4em;
  background: var(--ink);
}
.state.bad { color: var(--red); }
.state.bad::before { background: var(--red); }
.state.off::before { background: var(--paper); border: 2px solid var(--ink); }

/* ---------------------------------------------------------------- forms */

input, select, textarea, button { font: inherit; color: inherit; }

input[type="text"], input[type="password"], input[type="number"], input[type="time"],
input:not([type]), select, textarea {
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  padding: .5rem .6rem;
  font-size: .95rem;
  min-width: 0;
}
textarea { width: 100%; font-family: var(--mono); font-size: .85rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 1px;
}
input.wide, select.wide { width: 100%; }
input[type="checkbox"] { accent-color: var(--ink); width: 1rem; height: 1rem; vertical-align: -.15em; margin: 0 .4rem 0 0; }

button, .button {
  display: inline-block;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  padding: .5rem 1rem;
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--red); border-color: var(--red); color: var(--paper); }
button.secondary, .button.secondary { background: var(--paper); color: var(--ink); }
button.secondary:hover, .button.secondary:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
button.danger { background: var(--paper); color: var(--red); border-color: var(--red); }
button.danger:hover { background: var(--red); color: var(--paper); }
button.small { padding: .25rem .6rem; font-size: .8rem; border-width: 1px; }
button:disabled { opacity: .35; cursor: not-allowed; background: var(--ink); border-color: var(--ink); }

form { margin: 0 0 1rem; }
form.inline { display: inline; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 0 0 1rem; }
.actions form { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin: 0 0 1rem; }
.row label { display: flex; flex-direction: column; }
.stack { display: grid; gap: 1rem; max-width: 26rem; margin: 0 0 1.5rem; }
.stack label { display: flex; flex-direction: column; }
.check { display: block; margin: .3rem 0; font-size: .95rem; }

/* Config: label column on the left, control on the right — a two-column grid. */
.field {
  display: grid;
  grid-template-columns: 4fr 8fr;
  gap: .4rem var(--gutter);
  padding: 1rem 0;
  border-bottom: 1px solid var(--hair);
}
.field-head strong { display: block; font-size: .95rem; }
.field-head .muted { display: block; margin-top: .2rem; font-size: .8rem; line-height: 1.4; }
.field-control { min-width: 0; }
.field-control input:not([type="checkbox"]):not([type="number"]):not([type="time"]),
.field-control select { width: 100%; }
.field-control .pair { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.field-control .pair label { display: flex; flex-direction: column; }
.submit-bar {
  position: sticky;
  bottom: 0;
  background: var(--paper);
  border-top: var(--rule);
  padding: .9rem 0;
  margin-top: 2rem;
}

/* ---------------------------------------------------------------- misc */

.lede { font-size: 1.2rem; line-height: 1.4; max-width: 52ch; margin-bottom: 2rem; }

.secret {
  display: block;
  font-family: var(--mono);
  font-size: 1rem;
  background: var(--wash);
  border-left: 4px solid var(--red);
  padding: .8rem 1rem;
  word-break: break-all;
  user-select: all;
  margin: .5rem 0 1rem;
}

.secret code { background: none; padding: 0; font-size: inherit; }

.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, max-content); gap: .4rem 2rem; }

.qr svg { display: block; margin: 0 0 1.5rem; }

.auth-panel { max-width: 26rem; }
.auth-panel h1 { margin-bottom: 2rem; }

dialog {
  border: var(--rule);
  border-radius: 0;
  padding: 1.5rem 1.75rem;
  max-width: 32rem;
  box-shadow: none;
}
dialog::backdrop { background: rgba(255, 255, 255, .85); }
dialog h2 { margin-top: 0; border-top: 0; padding-top: 0; font-size: 1.5rem; }
dialog form { text-align: right; margin: 0; }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 760px) {
  :root { --gutter: 1rem; }
  main { padding-top: 2rem; }
  .site-header .wrap { grid-template-columns: 1fr; gap: .9rem; }
  .wordmark br { display: none; }
  .field { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .numerals { grid-template-columns: 1fr; }
  .field-control .pair { grid-template-columns: 1fr; }
  table { font-size: .85rem; }
  .agenda td.day, .agenda td.when { width: auto; }
}

.row label.grow { flex: 1 1 20rem; }
