/*
  Rel Time. One small stylesheet, no web fonts and no CDN. It is the CRM and CMS stylesheet
  with the same tokens, so all the apps look identical: change a token in one and carry it to the
  others. The timer, the project dots and the day tables at the end are this app's own.

  Design: "Rel Atelier" (DESIGN.md). An editorial, ledger-like look: a pure white canvas, one
  deep burgundy accent, obsidian text, hairline frames, square corners and no decorative
  shadows. Lists are tables; the interface is compact (a 48px bar, 13px table text, 7px cell
  padding) so a screen holds many rows. A day of entries is a table, never a card.

  Type: a grotesque sans for the brand, page titles and headings (Hanken Grotesk), Inter for
  everything else, tabular figures everywhere. Neither is bundled (the Content-Security-Policy
  allows only this origin), so each stack falls back to an installed grotesque.
*/

:root {
  --cms-canvas: #ffffff;
  --cms-surface: #fbfbfb;
  --cms-hover: #f7f7f7;
  --cms-chip: #f5f5f5;
  --cms-hairline: #e5e5e5;
  --cms-rule: #f0f0f0;
  --cms-ink: #0b0b0b;
  --cms-charcoal: #1a1a1a;
  --cms-muted: #5f5e5e;
  --cms-control: #8a7171;
  --cms-accent: #6b0f1a;
  --cms-accent-dark: #540b14;
  --cms-on-accent: #ffffff;
  --cms-removed: #f9eeef;
  --cms-added: #f2f2f2;
  --cms-shadow: 0 8px 30px rgba(11, 11, 11, 0.04);
  --cms-display: "Hanken Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --cms-sans: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --cms-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

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

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  /* The top bar and the editor's save bar are sticky: keep an anchored or focused field
     clear of both. */
  scroll-padding-top: 64px;
  scroll-padding-bottom: 72px;
}

body {
  margin: 0;
  background: var(--cms-canvas);
  color: var(--cms-ink);
  font-family: var(--cms-sans);
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ structure */

.skip-link {
  position: absolute;
  left: 8px;
  top: -4rem;
  padding: 8px 14px;
  background: var(--cms-canvas);
  color: var(--cms-accent);
  border: 1px solid var(--cms-accent);
  z-index: 30;
}

.skip-link:focus {
  top: 8px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0 28px;
  min-height: 48px;
  padding: 0 24px;
  background: var(--cms-canvas);
  border-bottom: 1px solid var(--cms-hairline);
  box-shadow: var(--cms-shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--cms-ink);
  text-decoration: none;
}

.brand:hover {
  color: var(--cms-ink);
}

.brand-name {
  font-family: var(--cms-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.brand-tag {
  padding-left: 10px;
  border-left: 1px solid var(--cms-hairline);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--cms-accent);
}

.main-nav {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 0 24px;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--cms-charcoal);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
}

.main-nav a:hover {
  color: var(--cms-accent);
}

.main-nav a[aria-current] {
  border-bottom-color: var(--cms-accent);
  color: var(--cms-ink);
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
}

.logout-form .who {
  color: var(--cms-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 56px;
}

main:focus {
  outline: none;
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  font-family: var(--cms-display);
  line-height: 1.2;
}

h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

h2 {
  margin-top: 24px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

p {
  margin: 0 0 10px;
}

a {
  color: var(--cms-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--cms-accent-dark);
}

code,
.mono {
  font-family: var(--cms-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 2px solid var(--cms-accent);
  outline-offset: 2px;
}

.muted {
  color: var(--cms-muted);
}

.small {
  font-size: 12px;
}

/* A second line in a table cell: a domain under a name, a date under a status. */
.sub {
  display: block;
  color: var(--cms-muted);
  font-size: 12px;
  font-weight: 400;
}

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

.nowrap {
  white-space: nowrap;
}

.breadcrumb {
  margin-bottom: 4px;
  color: var(--cms-muted);
  font-size: 12px;
}

.breadcrumb a {
  color: var(--cms-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--cms-accent);
  text-decoration: underline;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--cms-hairline);
}

.page-head h1 {
  margin: 0;
}

.page-head p {
  margin: 2px 0 0;
}

.lede {
  max-width: 62rem;
  margin: 0 0 14px;
  color: var(--cms-muted);
  font-size: 13px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions form {
  margin: 0;
}

/* ------------------------------------------------------ sheets: a framed table or form */

.sheet,
.card,
.panel {
  margin: 0 0 16px;
  background: var(--cms-canvas);
  border: 1px solid var(--cms-hairline);
}

.sheet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  padding: 6px 12px;
  background: var(--cms-surface);
  border-bottom: 1px solid var(--cms-hairline);
}

.sheet-head h2,
.sheet-head h3 {
  margin: 0;
  font-family: var(--cms-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cms-charcoal);
}

.sheet-head p {
  margin: 0;
  color: var(--cms-muted);
  font-size: 12px;
}

.sheet-body,
.card,
.panel {
  padding: 12px 16px;
}

.sheet > .sheet-body {
  padding: 12px;
}

.sheet > .table-wrap {
  margin: 0;
  border: 0;
}

.panel > h2 {
  margin-top: 0;
}

.sheet > .sheet-body > :last-child,
.card > :last-child,
.panel > :last-child {
  margin-bottom: 0;
}

.sheet + .sheet,
.table-wrap + .sheet {
  margin-top: 0;
}

.split {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
  margin-bottom: 16px;
}

.split > .sheet {
  margin-bottom: 0;
}

.split-wide {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  align-items: start;
  margin-bottom: 16px;
}

.split-wide > * {
  min-width: 0;
}

.stack > * + * {
  margin-top: 16px;
}

.drawer {
  margin: 0 0 16px;
  border: 1px solid var(--cms-hairline);
  background: var(--cms-canvas);
}

.drawer > summary {
  padding: 7px 12px;
  background: var(--cms-surface);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.drawer[open] > summary {
  border-bottom: 1px solid var(--cms-hairline);
}

.drawer > .sheet-body {
  padding: 12px;
}

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

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--cms-accent);
  border-radius: 0;
  background: var(--cms-accent);
  color: var(--cms-on-accent);
  font-family: var(--cms-sans);
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--cms-accent-dark);
  border-color: var(--cms-accent-dark);
  color: var(--cms-on-accent);
}

.button-secondary {
  background: var(--cms-canvas);
  color: var(--cms-ink);
  border-color: var(--cms-ink);
}

.button-secondary:hover {
  background: var(--cms-ink);
  border-color: var(--cms-ink);
  color: var(--cms-canvas);
}

.button-danger {
  background: var(--cms-canvas);
  color: var(--cms-accent);
  border-color: var(--cms-accent);
}

.button-danger:hover {
  background: var(--cms-accent);
  border-color: var(--cms-accent);
  color: var(--cms-on-accent);
}

.button-small {
  padding: 3px 10px;
}

/* The tertiary action: borderless, tracked capitals, a hairline 4px under the label. */
.link-action,
button.link-action {
  display: inline-block;
  padding: 0;
  border: 0;
  background: none;
  color: var(--cms-ink);
  font-family: var(--cms-sans);
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  white-space: nowrap;
  cursor: pointer;
}

.link-action:hover,
button.link-action:hover {
  background: none;
  color: var(--cms-accent);
}

button[hidden],
.js-only[hidden] {
  display: none;
}

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

form {
  margin: 0;
}

label,
legend {
  display: block;
  margin-bottom: 4px;
  color: var(--cms-charcoal);
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field {
  margin-bottom: 10px;
}

.field .help,
.help {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--cms-muted);
}

.req {
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--cms-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="tel"],
input[type="time"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
input[type="search"],
input[type="file"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--cms-control);
  border-radius: 0;
  background: var(--cms-canvas);
  color: var(--cms-ink);
  font: inherit;
  font-size: 14px;
  line-height: 20px;
}

input[type="file"] {
  padding: 4px 6px;
}

input[type="time"],
input[type="date"],
input[type="datetime-local"],
input[type="number"] {
  max-width: 12rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cms-accent);
  outline: 1px solid var(--cms-accent);
  outline-offset: 0;
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  vertical-align: -2px;
  accent-color: var(--cms-accent);
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--cms-accent);
  border-width: 2px;
  padding: 5px 9px;
}

fieldset {
  min-width: 0;
  margin: 0 0 10px;
  padding: 8px 12px 6px;
  border: 1px solid var(--cms-hairline);
}

fieldset > legend {
  padding: 0 6px;
  margin-bottom: 0;
}

fieldset.list-field {
  background: var(--cms-surface);
}

fieldset.list-item {
  background: var(--cms-canvas);
}

fieldset.image-field {
  background: var(--cms-surface);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 14px 6px 0;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--cms-ink);
}

.days {
  background: transparent;
}

.field-errors,
.field-warnings {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  font-size: 12px;
}

.field-errors li,
.field-warnings li {
  margin-top: 3px;
  padding: 3px 8px;
  border-left: 2px solid var(--cms-accent);
}

.field-errors li {
  background: var(--cms-removed);
  color: var(--cms-accent-dark);
  font-weight: 600;
}

.field-warnings li {
  background: var(--cms-surface);
  border-left-color: var(--cms-charcoal);
  color: var(--cms-charcoal);
}

.counter {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--cms-muted);
}

.counter.over {
  color: var(--cms-ink);
  font-weight: 600;
}

/* Fields sit in a grid: short ones side by side, long ones across the whole row. */
.form-grid {
  display: grid;
  gap: 0 16px;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  align-items: start;
}

.form-grid > .field-wide,
.form-grid > fieldset {
  grid-column: 1 / -1;
}

.form-group {
  margin: 0 0 14px;
}

.form-group > h2,
.form-group > summary {
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--cms-hairline);
  font-family: var(--cms-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cms-charcoal);
}

.form-group > .help {
  margin: -2px 0 8px;
}

details.form-group {
  padding: 6px 12px 2px;
  border: 1px solid var(--cms-hairline);
}

details.form-group > summary {
  margin: 0 0 6px;
  padding-bottom: 0;
  border: 0;
  cursor: pointer;
}

details.form-group[open] > summary {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--cms-hairline);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--cms-hairline);
}

/* In the editor the bar stays at the foot of the window so Save is always in reach. */
.panel > form > .form-actions,
.panel > .form-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 14px -16px -12px;
  padding: 9px 16px;
  background: var(--cms-canvas);
  box-shadow: var(--cms-shadow);
}

.inline-form {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}

.inline-form label {
  margin: 0;
}

.inline-form input,
.inline-form select {
  width: auto;
}

/* A short form laid out across the page: fields in a row, then the button. */
.row-form {
  display: grid;
  gap: 0 12px;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  align-items: end;
}

.row-form .field {
  margin-bottom: 0;
}

.row-form > .field-wide {
  grid-column: 1 / -1;
}

.row-form > .actions {
  align-self: end;
}

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

.notice,
.form-error,
.alert {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid var(--cms-hairline);
  border-left: 3px solid var(--cms-charcoal);
  background: var(--cms-surface);
  color: var(--cms-ink);
  font-size: 13px;
}

.form-error,
.alert-error {
  border-left-color: var(--cms-accent);
  background: var(--cms-removed);
  color: var(--cms-accent-dark);
}

.alert-warn {
  border-left-color: var(--cms-charcoal);
}

.alert > :last-child {
  margin-bottom: 0;
}

.alert h2 {
  margin: 0 0 4px;
  font-family: var(--cms-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.alert ul {
  margin: 2px 0 0;
  padding-left: 18px;
}

.alert p {
  margin: 0 0 4px;
}

.error-summary {
  margin-bottom: 12px;
}

.error-summary a {
  color: inherit;
  font-weight: 600;
}

/* ------------------------------------------------------------------ chips */

.pill {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--cms-hairline);
  border-radius: 0;
  background: var(--cms-chip);
  color: var(--cms-charcoal);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}

/* Approved / active: white, burgundy type, burgundy edge. */
.pill-ok {
  background: var(--cms-canvas);
  color: var(--cms-accent);
  border-color: var(--cms-accent);
}

/* Needs a look: white with an obsidian edge. */
.pill-warn {
  background: var(--cms-canvas);
  color: var(--cms-ink);
  border-color: var(--cms-charcoal);
}

/* Blocks publishing: solid burgundy. */
.pill-error {
  background: var(--cms-accent);
  color: var(--cms-on-accent);
  border-color: var(--cms-accent);
}

/* A built-in look: in the library, but choosing it applies nothing. */
.pill-builtin {
  background: var(--cms-chip);
  color: var(--cms-charcoal);
  border-color: var(--cms-control);
  border-style: dashed;
}

/* The 6px live dot: the one round shape in the system. */
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--cms-accent);
  vertical-align: 1px;
}

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

.table-wrap {
  margin: 0 0 16px;
  overflow-x: auto;
  background: var(--cms-canvas);
  border: 1px solid var(--cms-hairline);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.35;
}

caption {
  padding: 6px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--cms-muted);
  border-bottom: 1px solid var(--cms-hairline);
}

th,
td {
  padding: 7px 12px;
  text-align: left;
  vertical-align: middle;
  border-top: 1px solid var(--cms-rule);
}

thead th {
  padding-top: 6px;
  padding-bottom: 6px;
  background: var(--cms-surface);
  border-top: 0;
  border-bottom: 1px solid var(--cms-charcoal);
  color: var(--cms-charcoal);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:first-child > th,
tbody tr:first-child > td {
  border-top: 0;
}

caption + tbody tr:first-child > th,
caption + tbody tr:first-child > td {
  border-top: 0;
}

tbody tr:hover {
  background: var(--cms-hover);
}

tbody th {
  font-weight: 600;
}

td.top,
th.top {
  vertical-align: top;
}

.num {
  text-align: right;
  white-space: nowrap;
}

/* Rows of facts: a label cell and a value cell. */
table.kv th {
  width: 10rem;
  color: var(--cms-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

table.kv tbody tr:hover {
  background: none;
}

td .value {
  display: block;
  max-width: 40rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

td .sub + .sub {
  margin-top: 1px;
}

td .actions {
  flex-wrap: nowrap;
  gap: 10px;
}

td.actions-cell {
  white-space: nowrap;
  text-align: right;
}

td.actions-cell .actions {
  justify-content: flex-end;
}

td input[type="text"],
td input[type="search"],
td select {
  padding: 3px 8px;
  font-size: 13px;
  line-height: 18px;
}

td .inline-form input[type="text"] {
  width: 11rem;
}

.diff-removed {
  background: var(--cms-removed);
  box-shadow: inset 2px 0 0 var(--cms-accent);
}

.diff-added {
  background: var(--cms-added);
  box-shadow: inset 2px 0 0 var(--cms-charcoal);
}

/* A row of controls that belong to the table under it: its search box, say. */
.table-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 16px;
  margin-bottom: 8px;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--cms-muted);
}

/* ------------------------------------------------------------------ leads */

/* The status filter: a row of tabs with a count each, the open one underlined. */
.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
  margin: 0 0 10px;
  border-bottom: 1px solid var(--cms-hairline);
}

.status-tabs a {
  display: inline-block;
  margin-bottom: -1px;
  padding: 6px 12px;
  border-bottom: 2px solid transparent;
  color: var(--cms-charcoal);
  font-size: 13px;
  text-decoration: none;
}

.status-tabs a:hover {
  background: var(--cms-hover);
}

.status-tabs a[aria-current] {
  border-bottom-color: var(--cms-accent);
  color: var(--cms-accent);
  font-weight: 600;
}

.status-tabs .count {
  color: var(--cms-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.filter-form {
  display: flex;
  margin: 0 0 12px;
}

/* A person's own words keep their line breaks. */
.prewrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note-form {
  max-width: 48rem;
  margin: 0 0 16px;
}

.thumb {
  display: block;
  width: 56px;
  height: 40px;
  object-fit: cover;
  border: 1px solid var(--cms-hairline);
  background: var(--cms-surface);
}

.copy-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.copy-box input {
  flex: 1 1 20rem;
  width: auto;
  font-family: var(--cms-mono);
  font-size: 12px;
}

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

.editor {
  display: grid;
  gap: 20px;
  grid-template-columns: 11rem minmax(0, 1fr);
  align-items: start;
}

.editor > * {
  min-width: 0;
}

.side-nav {
  position: sticky;
  top: 64px;
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--cms-hairline);
}

.side-nav a {
  display: block;
  padding: 6px 10px;
  border-bottom: 1px solid var(--cms-rule);
  border-left: 2px solid transparent;
  color: var(--cms-charcoal);
  font-size: 13px;
  text-decoration: none;
}

.side-nav a:hover {
  background: var(--cms-hover);
  color: var(--cms-ink);
}

.side-nav a[aria-current="page"] {
  background: var(--cms-surface);
  border-left-color: var(--cms-accent);
  color: var(--cms-ink);
  font-weight: 600;
}

/* ------------------------------------------------------ login and error pages */

.login,
.error-page {
  max-width: 24rem;
  margin: 40px auto;
  padding: 20px 24px;
  background: var(--cms-canvas);
  border: 1px solid var(--cms-hairline);
}

.error-page {
  max-width: 40rem;
}

.login h1,
.error-page h1 {
  margin-bottom: 14px;
}

.login-form p {
  margin-bottom: 12px;
}

.login-form button {
  width: 100%;
}

.error-page ul {
  margin: 0 0 10px;
  padding-left: 18px;
}

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

@media (max-width: 64rem) {
  .split-wide {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 52rem) {
  .editor {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
    display: flex;
    flex-wrap: wrap;
    border-top: 0;
  }

  .side-nav a {
    border: 1px solid var(--cms-hairline);
    margin: 0 -1px -1px 0;
  }

  .site-header {
    padding: 8px 16px;
    gap: 6px 20px;
  }

  .main-nav a {
    min-height: 32px;
  }
}

/* A table marked .stack becomes a list of label and value pairs; each cell carries its own
   data-label. */
@media (max-width: 40rem) {
  main {
    padding: 14px 14px 48px;
  }

  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  table.stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  table.stack,
  table.stack tbody,
  table.stack tr,
  table.stack td,
  table.stack tbody th {
    display: block;
  }

  table.stack tr {
    padding: 6px 0;
    border-top: 1px solid var(--cms-hairline);
  }

  table.stack tbody tr:first-child {
    border-top: 0;
  }

  table.stack td,
  table.stack tbody th {
    border: 0;
    padding: 2px 12px;
  }

  /* The label floats left and the value flows beside it, so a cell that holds a chip, a dot
     and a second line stays in one piece. */
  table.stack td {
    overflow: hidden;
  }

  table.stack td[data-label]::before {
    content: attr(data-label);
    float: left;
    width: 7.5rem;
    padding-right: 8px;
    color: var(--cms-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  table.stack td.nowrap {
    white-space: normal;
  }

  table.stack caption {
    display: block;
  }

  table.stack tbody th.num,
  table.stack td.num {
    text-align: left;
  }

  table.stack td .actions {
    flex-wrap: wrap;
  }

  table.stack td.actions-cell {
    text-align: left;
  }

  table.stack td.actions-cell .actions {
    justify-content: flex-start;
  }

  .form-grid,
  .row-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel > form > .form-actions,
  .panel > .form-actions {
    margin: 14px -12px -12px;
    padding: 9px 12px;
  }

  .sheet-body,
  .card,
  .panel {
    padding: 10px 12px;
  }

  .login,
  .error-page {
    margin: 16px auto;
    padding: 16px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  button,
  .button,
  a {
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  }
}


/* ------------------------------------------------------------------- Time */

/* A late task or a waiting family: the accent colour, plus the word, never colour alone. */
.late {
  color: var(--cms-accent);
  font-weight: 600;
}

.stats td,
.stats th {
  white-space: nowrap;
}

.stats .big {
  font-size: 20px;
  font-family: var(--cms-display);
  font-weight: 600;
  line-height: 1.2;
}

.bar {
  display: inline-block;
  height: 8px;
  min-width: 1px;
  background: var(--cms-accent);
  vertical-align: middle;
}


/* The running timer: the elapsed time is the biggest thing on the page. */
.timer-face {
  margin: 0 0 4px;
  font-family: var(--cms-display);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.timer-what {
  margin: 0 0 12px;
}

.timer-running {
  border-color: var(--cms-accent);
}

/* A project's colour: the palette is fixed because the Content-Security-Policy forbids an inline
   style, so a free colour could not be drawn. */
.dot-burgundy { background: #6b0f1a; }
.dot-ink { background: #0b0b0b; }
.dot-navy { background: #1f3a5f; }
.dot-forest { background: #2f5d3a; }
.dot-amber { background: #b7791f; }
.dot-plum { background: #6b3a6b; }
.dot-teal { background: #1f6f6f; }
.dot-rose { background: #c0506a; }

table caption .day-total {
  float: right;
  color: var(--cms-muted);
  font-weight: 500;
}

.week-total {
  margin-left: auto;
  align-self: center;
  color: var(--cms-muted);
}

.week-total strong {
  color: var(--cms-ink);
}

/* Keeps a checkbox level with the labelled fields beside it. */
.label-gap {
  display: block;
  min-height: 1.45em;
}

details.sheet > summary {
  cursor: pointer;
  list-style: none;
}

details.sheet > summary::-webkit-details-marker {
  display: none;
}

details.sheet > summary h2::after {
  content: " +";
  color: var(--cms-muted);
}

details.sheet[open] > summary h2::after {
  content: " -";
}
