/*
 * Server-rendered pages (settings, approvals, accounts, import, consent, login, public pages) in the Swavo design.
 * Loaded after /static/design/{tokens,base,app}.css (packages/design); use only design tokens here.
 */

.app-main > h1:first-child {
  margin-bottom: var(--space-4);
}
.app-main > h1 + p,
.lead {
  color: var(--text-2);
}
h2 {
  margin: var(--space-8) 0 var(--space-3);
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-tight);
}
h3 {
  margin: var(--space-6) 0 var(--space-2);
  font-size: var(--text-lg);
}
p,
ul,
ol,
dl {
  margin: 0 0 var(--space-3);
}
a {
  color: var(--link);
}
.muted {
  color: var(--text-3);
}
.small,
.muted.small {
  font-size: var(--text-sm);
}
b,
strong {
  font-weight: var(--weight-semibold);
}
code {
  overflow-wrap: anywhere;
}

/* ---------- Sections (settings) and cards ---------- */
.section,
section.card {
  margin: 0 0 var(--space-5);
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.section > h2:first-child,
section.card > h2:first-child {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2-5, 0.625rem);
}
/* A small ember tick before each section heading: the approval dot of the logo. */
.section > h2:first-child::before {
  content: '';
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--accent-vivid);
  box-shadow: 0 0 0 4px var(--accent-soft-2);
}
.section > :last-child,
section.card > :last-child {
  margin-bottom: 0;
}
.section h3 {
  padding-top: var(--space-5);
  border-top: 1px solid var(--divider);
}
.section h3:first-of-type:is(h2 + p + h3, h2 + h3) {
  padding-top: 0;
  border-top: 0;
}
@media (max-width: 40rem) {
  .app-main {
    padding-top: var(--space-6);
  }
  .section,
  section.card {
    margin-inline: calc(var(--gutter) * -0.5);
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-lg);
  }
  .app-main > h1:first-child {
    font-size: var(--text-2xl);
  }
}

/* A clickable card (approvals list). */
a.card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'meta badge' 'title badge';
  align-items: center;
  gap: var(--space-1) var(--space-4);
  margin: 0 0 var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: var(--text);
  text-decoration: none;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}
a.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
a.card > .muted {
  grid-area: meta;
  font-size: var(--text-xs);
}
a.card .title {
  grid-area: title;
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  overflow-wrap: anywhere;
}
a.card > .badge {
  grid-area: badge;
}
a.card.status-pending::before {
  content: '';
  position: absolute;
  left: -1px;
  top: var(--space-4);
  bottom: var(--space-4);
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-vivid);
}

/* ---------- Badges ---------- */
.badge {
  justify-self: start;
  width: fit-content;
}
.status-pending .badge,
.badge.status-pending,
.badge.status-running,
.badge.status-retrying {
  background: var(--warning-soft);
  border-color: var(--warning-border);
  color: var(--warning);
}
.status-done .badge,
.badge.status-done {
  background: var(--success-soft);
  border-color: var(--success-border);
  color: var(--success);
}
.status-failed .badge,
.badge.status-failed,
.status-rejected .badge,
.badge.status-rejected {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}
.status-executing .badge {
  background: var(--info-soft);
  border-color: var(--info-border);
  color: var(--info);
}
.badge.rule-block {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}
.badge.rule-junk {
  background: var(--warning-soft);
  border-color: var(--warning-border);
  color: var(--warning);
}
.badge.rule-allow {
  background: var(--success-soft);
  border-color: var(--success-border);
  color: var(--success);
}
.app-main > .badge:first-of-type {
  margin-bottom: var(--space-4);
}

/* ---------- Notes, hints, errors ---------- */
.hint,
p.hint {
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  background: var(--info-soft);
  color: var(--text);
  font-size: var(--text-sm);
}
.notice {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  background: var(--warning-soft);
}
/* The AI's reason for a request: dashed ember box with the sparkle (design pattern for AI content). */
.reason {
  position: relative;
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4) var(--space-3) calc(var(--space-4) + 1.4rem);
  border: 1px dashed var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  list-style: none;
}
.reason::before {
  content: '✦';
  position: absolute;
  left: var(--space-4);
  top: var(--space-3);
  color: var(--accent-vivid);
  line-height: 1.5;
}
.reason.small,
.deletions .reason {
  margin: var(--space-1) 0 0;
  padding: var(--space-1-5) var(--space-3) var(--space-1-5) calc(var(--space-3) + 1.2rem);
}
.reason.small::before,
.deletions .reason::before {
  left: var(--space-3);
  top: var(--space-1-5);
}
ul.reason {
  padding-left: calc(var(--space-4) + 1.4rem);
}
.error {
  color: var(--danger);
}
p.error,
.inline-error {
  margin: var(--space-3) 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: var(--weight-medium);
}
.inline-error {
  display: block;
}
.danger {
  color: var(--danger);
}
.notfound {
  padding: var(--space-12) 0;
  text-align: center;
}

/* ---------- Forms ---------- */
label {
  display: block;
  margin: 0 0 var(--space-3);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
label > :is(input:not([type='checkbox'], [type='radio']), select, textarea) {
  display: block;
  margin-top: var(--space-1-5);
  color: var(--text);
  font-weight: var(--weight-regular);
}
label > .muted {
  display: block;
  margin-top: var(--space-1);
  font-weight: var(--weight-regular);
}
label.check,
form.prefs label:has(> input[type='checkbox']),
form.prefs label:has(> input[type='radio']) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  min-height: var(--tap-target);
  margin: 0;
  color: var(--text);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
}
form.prefs label:has(> input[type='checkbox']) > .muted,
form.prefs label:has(> input[type='radio']) > .muted {
  flex-basis: 100%;
  margin: 0 0 var(--space-1) calc(1.125rem + var(--space-3));
  font-size: var(--text-sm);
}
form.prefs {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
form.prefs > button,
form.prefs > .buttons {
  justify-self: start;
}
form.prefs fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}
form.prefs fieldset label {
  flex: 1 1 12rem;
  margin: 0;
}
form.prefs fieldset label:has(> input[type='radio'], > input[type='checkbox']) {
  flex: 0 1 auto;
  min-height: 2.25rem;
}
fieldset {
  margin: 0 0 var(--space-3);
}
legend .muted {
  font-weight: var(--weight-regular);
}
.rule-form,
.import-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0 var(--space-3);
  align-items: end;
  margin-top: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.rule-form .buttons,
.import-form .buttons {
  grid-column: 1 / -1;
  margin: 0;
}
.import-form {
  max-width: 32rem;
  grid-template-columns: 1fr;
}
.address-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1-5);
  color: var(--text-2);
  font-weight: var(--weight-medium);
}
.address-input input {
  margin: 0 !important;
}

/* ---------- Buttons ---------- */
.buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4) 0 var(--space-2);
}
.buttons > button.primary {
  min-width: 9rem;
}
.select-bar .buttons > button.primary {
  min-width: 0;
}
/* Sign-in page: passkey and social sign-in buttons fill the card. */
.auth-card [data-passkey-login],
.auth-card form.social button {
  width: 100%;
  min-height: var(--control-height-lg);
}
.auth-card [data-passkey-login] {
  --btn-bg: var(--primary);
  --btn-fg: var(--text-on-primary);
  --btn-border: transparent;
  --btn-hover: var(--primary-hover);
  box-shadow: var(--shadow-sm);
}
.auth-card form.social {
  margin: 0 0 var(--space-2);
}
.auth-card form.prefs > button[type='submit']:last-child {
  --btn-bg: var(--primary);
  --btn-fg: var(--text-on-primary);
  --btn-border: transparent;
  --btn-hover: var(--primary-hover);
  justify-self: stretch;
  min-height: var(--control-height-lg);
}
.auth-card form.prefs {
  margin-bottom: var(--space-5);
}
.auth-card > p:last-of-type {
  margin-bottom: 0;
}
.auth-card .buttons {
  margin-bottom: 0;
}
.auth-card .buttons > button {
  flex: 1 1 8rem;
}

/* ---------- Copy rows (connector URL, secrets) ---------- */
.copy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}
.copy code {
  flex: 1 1 14rem;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
.copy code.secret {
  font-weight: var(--weight-semibold);
}
.copy > .muted {
  flex-basis: 100%;
}
.copy button {
  min-height: 2.25rem;
  font-size: var(--text-sm);
}

/* ---------- Tables, lists ---------- */
table.messages {
  margin: 0 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.section table.messages {
  background: var(--surface-2);
}
table.messages td {
  overflow-wrap: anywhere;
}
table.messages td.pick {
  width: 2.5rem;
}
table.messages tr.skipped td {
  color: var(--text-3);
  text-decoration: line-through;
}
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tr.log-error td {
  color: var(--danger);
}
.table,
.section:has(table) {
  overflow-x: auto;
}
@media (max-width: 40rem) {
  table.messages,
  table.messages tbody,
  table.messages tr,
  table.messages td {
    display: block;
    width: 100%;
  }
  table.messages thead {
    display: none;
  }
  table.messages tr {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--divider);
  }
  table.messages tr:last-child {
    border-bottom: 0;
  }
  table.messages td {
    padding: var(--space-1) var(--space-3);
    border: 0;
  }
  table.messages td.num {
    text-align: left;
  }
  table.messages td.pick {
    width: auto;
  }
}
dl.headers {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-1-5) var(--space-4);
  margin: var(--space-4) 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  font-size: var(--text-sm);
}
dl.headers dt {
  color: var(--text-3);
  font-weight: var(--weight-medium);
}
dl.headers dd {
  margin: 0;
  overflow-wrap: anywhere;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
pre.body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--divider);
}
.row:first-of-type {
  border-top: 0;
}
ol.steps {
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
ol.steps li {
  position: relative;
  margin: 0 0 var(--space-4);
  padding-left: 2.5rem;
  counter-increment: step;
}
ol.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -0.1rem;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--text-on-primary);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}
ol.steps li.done::before {
  content: '✓';
  background: var(--success-fill);
  color: #fff;
}
ol.steps li.done b {
  color: var(--text-3);
  text-decoration: line-through;
}
details.identity {
  margin: var(--space-1) 0 var(--space-3);
}
details.identity summary {
  color: var(--text-3);
}

/* ---------- Approvals: pick several and decide together ---------- */
.select-bar {
  position: sticky;
  top: calc(var(--app-bar-height) + var(--space-2));
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-md);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.select-bar .buttons {
  flex: 1 1 auto;
  justify-content: flex-end;
  margin: 0;
}
.select-bar label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  color: var(--text);
  font-size: var(--text-md);
}
@media (max-width: 40rem) {
  .select-bar .buttons {
    flex-basis: 100%;
  }
  .select-bar .buttons > button {
    flex: 1 1 100%;
  }
  a.card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'meta' 'title' 'badge';
    padding: var(--space-4);
  }
  a.card > .badge {
    margin-top: var(--space-1);
  }
}
.pick-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.pick-row > input[type='checkbox'],
.pick-row > .pick-spacer {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 1.5rem;
}
.pick-row > .card {
  flex: 1;
  min-width: 0;
}

/* ---------- Busy buttons ---------- */
button[aria-busy='true'] {
  cursor: progress;
}
button[aria-busy='true']::after {
  content: '';
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Public pages (homepage, privacy policy, imprint) ---------- */
main.public {
  max-width: 46rem;
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
}
main.public > h1:first-child {
  font-size: var(--text-4xl);
}
main.public ul {
  padding-left: 1.2rem;
}
main.public li {
  margin: var(--space-1) 0;
}
main.public hr {
  margin: var(--space-8) 0;
}
main.public .buttons a.button.primary {
  min-height: var(--control-height-lg);
  padding: 0 var(--space-6);
}

/* Approving an AI action is the one green button (design pattern: .btn-success). */
button.primary:is([data-post*='/approve'], [data-post-selected*='/approve']) {
  --btn-bg: var(--success-fill);
  --btn-fg: #fff;
  --btn-hover: #136b41;
}

/* ---------- Operator area (/admin) ---------- */
form.stack {
  display: grid;
  max-width: 34rem;
  margin: 0 0 var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
form.stack .buttons {
  margin-bottom: 0;
}

/* ---------- Workspace: a sidebar across all signed-in users (calendar, contacts, tasks, approvals) ----------
 * docs/auth.md, "Several users in one browser". The same shell as the webmail: sidebar left, one content column.
 * Users are told apart by colour (packages/design/app.css [data-hue] → --user) and a label.
 */
.ws-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--app-bar-height));
}
.ws-side {
  position: sticky;
  top: var(--app-bar-height);
  align-self: start;
  max-height: calc(100vh - var(--app-bar-height));
  overflow-y: auto;
  padding: var(--space-6) var(--space-3) var(--space-8) max(var(--space-3), env(safe-area-inset-left, 0px));
}
.app-main.ws-main {
  max-width: var(--width-content);
  margin: 0;
  padding-left: var(--space-6);
}
.side-title {
  margin: var(--space-5) var(--space-3) var(--space-1);
  color: var(--text-3);
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}
.ws-side > .side-title:first-child {
  margin-top: 0;
}
.ws-side .person-label {
  margin-top: var(--space-3);
}
.side-account {
  margin: var(--space-2) var(--space-3) var(--space-1);
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-extra {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}
.side-link {
  display: flex;
  align-items: center;
  gap: var(--space-2-5, 0.625rem);
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast);
}
.side-link .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-link:hover {
  background: var(--surface-3);
  color: var(--text);
}
.side-link.current {
  background: var(--surface);
  color: var(--text);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-sm);
}
.side-link .count {
  min-width: 1.5rem;
  padding: 0 0.4rem;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  line-height: 1.375rem;
  text-align: center;
}
.side-new {
  width: 100%;
  margin-bottom: var(--space-2);
}
.side-target,
.side-note {
  margin: 0 var(--space-1) var(--space-4);
  color: var(--text-3);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}
.side-target .person-dot {
  margin-right: 0.35em;
}
.side-target-where {
  display: block;
  margin-top: 0.15rem;
}
.side-target b {
  color: var(--text-2);
}
.notice.ok {
  border-color: var(--success-border);
  background: var(--success-soft);
}
.owner-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: calc(var(--space-4) * -1) 0 var(--space-5);
  color: var(--text-2);
}
.person-block .person-label {
  margin: var(--space-5) 0 var(--space-2);
  padding: 0;
}
.person-block:first-of-type .person-label {
  margin-top: var(--space-2);
}
a.card .person-chip {
  color: var(--text-2);
  font-weight: var(--weight-semibold);
}
.user-bar .person-chip {
  vertical-align: middle;
}
ul.plain {
  padding: 0;
  list-style: none;
}
ul.plain li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1-5) 0;
}

/* Forms of the workspace (new event, contact, task). */
.stack-form {
  display: grid;
  max-width: 40rem;
  padding: var(--space-5) var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.stack-form .buttons {
  margin-bottom: 0;
}
.when-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0 var(--space-3);
}
label.target select {
  font-weight: var(--weight-medium);
}

/* Calendar: a week, all users' calendars on top of each other, each event in its owner's colour. */
.week-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
}
.week-nav .button {
  min-width: 2.5rem;
}
.week-label {
  margin: 0 0 0 var(--space-2);
  font-size: var(--text-lg);
}
.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.day {
  min-height: 14rem;
  padding: var(--space-2) var(--space-1-5) var(--space-3);
}
.day + .day {
  border-left: 1px solid var(--border-subtle);
}
.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
  margin: 0 0 var(--space-2);
  padding: 0 var(--space-1);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.day.today .day-head > span {
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--text-on-primary);
}
.day-add {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  color: var(--text-3);
  font-size: var(--text-md);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--duration-fast);
}
.day:hover .day-add,
.day-add:focus-visible {
  opacity: 1;
}
.day-add:hover {
  background: var(--surface-3);
  color: var(--text);
}
.day-events {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.day-empty {
  margin: var(--space-2) var(--space-1);
  color: var(--text-3);
  font-size: var(--text-xs);
}
.ev {
  display: block;
  padding: 0.3rem 0.45rem 0.3rem 0.55rem;
  border-left: 3px solid var(--user);
  border-radius: var(--radius-xs) var(--radius-sm) var(--radius-sm) var(--radius-xs);
  background: var(--user-soft);
  color: var(--text);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.ev:hover {
  filter: brightness(0.97);
  box-shadow: var(--shadow-xs);
}
.ev-allday {
  background: var(--user);
  color: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .ev-allday {
    color: var(--ink-950);
  }
}
:root[data-theme='dark'] .ev-allday {
  color: var(--ink-950);
}
.ev-time {
  display: block;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
}
.ev-title {
  font-weight: var(--weight-medium);
}
.ev-cancelled .ev-title {
  text-decoration: line-through;
}
.ev-open {
  border-left-style: dashed;
  background: transparent;
  outline: 1px dashed var(--user);
  outline-offset: -1px;
}
.invitations {
  margin-top: var(--space-6);
}

/* Tasks and contacts: one list across users, each row with its owner's colour. */
.quick-add {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0 var(--space-3);
  margin: 0 0 var(--space-2);
  padding: var(--space-4) var(--space-5) var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.quick-add .grow {
  flex: 1 1 14rem;
}
.quick-add > button {
  margin-bottom: var(--space-3);
}
.tasks,
.contacts {
  margin: var(--space-4) 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  list-style: none;
}
.task,
.contact > a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 3rem;
  padding: var(--space-2) var(--space-4);
}
.task + .task,
.contact + .contact {
  border-top: 1px solid var(--border-subtle);
}
.task form {
  margin: 0;
  line-height: 0;
}
.app .task-check {
  width: 1.375rem;
  min-width: 0;
  height: 1.375rem;
  min-height: 0;
  padding: 0;
  border: 2px solid var(--user);
  border-radius: var(--radius-full);
  background: transparent;
  box-shadow: none;
}
.app .task-check,
.day-add {
  position: relative;
}
/* Small marks, thumb-sized hit areas (about 44 px). */
.app .task-check::after,
.day-add::after {
  content: '';
  position: absolute;
  inset: -0.6rem;
}
.app .task-check:hover {
  background: var(--user-soft);
}
.task.done .task-check {
  background: var(--user);
}
.task-title {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-weight: var(--weight-medium);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.task-title:hover {
  text-decoration: underline;
}
.task.done .task-title {
  color: var(--text-3);
  text-decoration: line-through;
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}
.task-meta > span {
  display: inline-flex;
  align-items: center;
}
.task-meta .person-dot {
  margin-right: 0.4em;
  vertical-align: 0;
}
.task-meta .overdue {
  color: var(--danger);
  font-weight: var(--weight-semibold);
}
.badge.prio {
  padding: 0.1rem 0.45rem;
  background: var(--accent-soft-2);
  color: var(--accent-text);
  font-size: var(--text-2xs);
}
.empty-row {
  padding: var(--space-6) var(--space-4);
  text-align: center;
}
.search-row {
  display: flex;
  gap: var(--space-2);
  max-width: 34rem;
}
.search-row input {
  flex: 1;
}
.contact > a {
  color: var(--text);
  text-decoration: none;
}
.contact > a:hover {
  background: var(--row-hover);
}
.contact .avatar {
  background: var(--user-soft);
  color: var(--user);
  box-shadow: inset 0 0 0 1px var(--user-soft);
}
.contact-name {
  flex: 1;
  min-width: 0;
  font-weight: var(--weight-medium);
  overflow-wrap: anywhere;
}
.contact-meta {
  text-align: right;
  overflow-wrap: anywhere;
}
dl.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
}
dl.facts dt {
  color: var(--text-3);
  font-weight: var(--weight-semibold);
}
dl.facts dd {
  margin: 0;
}
dd.pre {
  white-space: pre-wrap;
}

@media (max-width: 64rem) {
  .week {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .day:nth-child(5) {
    border-left: 0;
  }
  .day:nth-child(n + 5) {
    border-top: 1px solid var(--border-subtle);
  }
}
@media (max-width: 48rem) {
  .ws-shell {
    display: block;
    min-height: 0;
  }
  .ws-side {
    position: static;
    max-height: none;
    padding: var(--space-4) var(--gutter) 0;
    border-bottom: 1px solid var(--border-subtle);
  }
  .ws-side .side-links {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-1-5);
  }
  .ws-side .side-link {
    flex: none;
    min-height: 2.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    font-size: var(--text-sm);
  }
  .ws-side .side-link.current {
    border-color: var(--user, var(--border-strong));
  }
  .ws-side .person-label,
  .ws-side .side-title {
    margin-top: var(--space-3);
  }
  .side-extra {
    margin-top: var(--space-3);
    padding-top: 0;
    border-top: 0;
  }
  .app-main.ws-main {
    padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  }
  .week {
    grid-template-columns: minmax(0, 1fr);
  }
  .day {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    gap: var(--space-2);
    min-height: 0;
  }
  .day + .day,
  .day:nth-child(5) {
    border-left: 0;
    border-top: 1px solid var(--border-subtle);
  }
  .day-head {
    align-self: start;
    flex-wrap: wrap;
    white-space: normal;
  }
  .day-add {
    opacity: 1;
  }
  .task {
    flex-wrap: wrap;
    row-gap: var(--space-1);
  }
  .task-title {
    flex-basis: calc(100% - 2.6rem);
  }
  .task-meta {
    flex-basis: 100%;
    justify-content: start;
    padding-left: calc(1.375rem + var(--space-3));
  }
}

/* Spaces (private, organisations) under a login, and empty states (accounts are created lazily). */
.side-space {
  margin: var(--space-3) var(--space-3) var(--space-1);
  color: var(--text-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.side-empty {
  margin: 0 var(--space-3) var(--space-2);
}
.empty-state {
  max-width: 40rem;
}
.empty-state h2 {
  margin-top: 0;
}

/* "Verfügbarkeit prüfen" on the event form. */
.availability {
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.availability h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-md);
}
.availability ul.plain {
  margin: 0;
}
.avail {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 var(--space-3);
  border-left: 3px solid var(--border-strong);
  padding-left: var(--space-3) !important;
}
.avail b {
  overflow-wrap: anywhere;
}
.avail .muted {
  grid-column: 1 / -1;
}
.avail-state {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.avail.free {
  border-left-color: var(--success);
}
.avail.free .avail-state {
  color: var(--success);
}
.avail.busy {
  border-left-color: var(--danger);
}
.avail.busy .avail-state {
  color: var(--danger);
}
.avail.unknown .avail-state {
  color: var(--text-3);
}

/* ---------- Settings: sub-navigation (in the workspace sidebar shell), overview cards, checklist ----------
 * src/web/settings.ts. Wide screens: the groups as a left column with a one-line hint. Phones: one scrolling row of
 * pills above the title (the current one scrolled into view by app.js).
 */
.settings-link {
  min-height: 3.25rem;
  padding-block: var(--space-2);
}
.settings-link > .icon {
  flex: none;
  color: var(--text-3);
}
.settings-link.current > .icon {
  color: var(--accent-text);
}
.settings-link-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: var(--leading-snug);
}
.settings-link-text .name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.settings-link-hint {
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-external {
  color: var(--text-3);
}
.settings-body {
  max-width: calc(var(--width-narrow) + 8rem);
}
@media (max-width: 48rem) {
  .ws-side:has(.settings-nav) {
    padding-bottom: var(--space-3);
  }
  .ws-side .settings-nav .side-title {
    display: none;
  }
  .ws-side .settings-nav .side-links {
    flex-wrap: nowrap;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  .ws-side .settings-nav .side-links::-webkit-scrollbar {
    display: none;
  }
  .ws-side .settings-link {
    min-height: 2.5rem;
    padding: 0 var(--space-3);
    scroll-snap-align: start;
  }
  .ws-side .settings-link > .icon {
    width: 18px;
    height: 18px;
  }
  .ws-side .settings-link.current {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--text-on-primary);
  }
  .ws-side .settings-link.current > .icon {
    color: inherit;
  }
  .settings-link-hint {
    display: none;
  }
}

.settings-avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-full);
  background: var(--user, var(--primary));
  color: var(--text-on-primary);
  font-weight: var(--weight-bold);
}
.settings-avatar.small {
  width: 1.75rem;
  height: 1.75rem;
  font-size: var(--text-xs);
}
.settings-avatar.large {
  width: 3rem;
  height: 3rem;
  font-size: var(--text-xl);
}
.settings-profile,
.settings-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.settings-user {
  margin: 0;
}
.hint.managed {
  border-color: var(--info-border);
  background: var(--info-soft);
}

/* Overview: one card per group with a few facts, each with a state dot. */
.settings-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-4);
  margin: 0 0 var(--space-5);
}
a.settings-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}
a.settings-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
a.settings-card.attention {
  border-color: var(--warning-border);
}
.settings-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-2-5, 0.625rem);
  font-family: var(--font-display);
  font-size: var(--text-lg);
}
.settings-card-head .icon {
  color: var(--accent-text);
}
.settings-card ul {
  display: grid;
  gap: var(--space-1-5);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-2);
  font-size: var(--text-sm);
}
.settings-card li {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.settings-card li::before {
  content: '';
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  transform: translateY(-0.05em);
}
.settings-card li.ok::before {
  background: var(--success-fill);
}
.settings-card li.warn {
  color: var(--warning);
  font-weight: var(--weight-medium);
}
.settings-card li.warn::before {
  background: var(--amber-500);
}

/* Erste Schritte: progress bar and checklist. */
.progress {
  display: block;
  width: 100%;
  height: 0.5rem;
  margin: 0 0 var(--space-4);
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--success-fill);
  appearance: none;
}
.progress::-webkit-progress-bar {
  background: var(--surface-3);
}
.progress::-webkit-progress-value {
  border-radius: var(--radius-full);
  background: var(--success-fill);
}
.progress::-moz-progress-bar {
  border-radius: var(--radius-full);
  background: var(--success-fill);
}
.checklist,
.next-steps {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.checklist li {
  display: flex;
  gap: var(--space-3);
}
.checklist li > div {
  display: grid;
  gap: var(--space-1-5);
  justify-items: start;
  min-width: 0;
}
.checklist .check {
  flex: none;
  width: 1.375rem;
  height: 1.375rem;
  margin-top: 0.05rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-full);
}
.checklist li.done .check {
  border-color: var(--success-fill);
  background: var(--success-fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E") center / 0.8rem no-repeat;
}
.checklist li.done b {
  color: var(--text-3);
}
.app :where(.button, a.button).small {
  min-height: var(--control-height-sm);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}
details.getting-started {
  margin: 0 0 var(--space-5);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
}
details.getting-started > summary {
  cursor: pointer;
}
details.getting-started[open] > summary {
  margin-bottom: var(--space-4);
}

/* No account yet: next steps. */
.next-steps li {
  display: grid;
  gap: var(--space-1-5);
  justify-items: start;
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
