:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-sunk: #f8f9fb;
  --text: #1d2530;
  --muted: #5f6b7a;
  --line: #e2e6eb;
  --field-line: #cdd3da;
  --accent: #1f5fbf;
  --accent-hover: #194f9f;
  --accent-soft: #e8f0fb;
  --ok: #17803d;
  --ok-hover: #12672f;
  --ok-soft: #e6f4ea;
  --no: #c4322b;
  --no-hover: #a52a24;
  --no-soft: #fbeaea;
  --warn: #8a5a00;
  --warn-soft: #fdf2d8;
  --neutral-soft: #eef0f3;
  --radius: 12px;
  --radius-small: 10px;
  --focus-ring: 0 0 0 3px rgba(31, 95, 191, 0.28);
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

p {
  margin: 0 0 12px;
}

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-user form {
  margin: 0;
}

.topbar-name {
  font-size: 14px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40vw;
}

.link-button {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* Page */

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.narrow {
  max-width: 440px;
  margin: 0 auto;
}

.back {
  display: inline-block;
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.back::before {
  content: "\2190\00a0";
}

.kicker {
  margin: 8px 0 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.page-title {
  margin: 4px 0 12px;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.lead {
  margin: 0 0 16px;
  color: var(--muted);
}

.hint {
  margin: 10px 0;
  font-size: 14px;
  color: var(--muted);
}

.empty {
  margin: 8px 0;
  font-size: 15px;
  color: var(--muted);
}

.section {
  margin-top: 28px;
}

.section-tight {
  margin-top: 20px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.3;
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e5e8ec;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.footer-link {
  margin: 32px 0 0;
  text-align: center;
  font-size: 15px;
}

.pre {
  white-space: pre-wrap;
}

.plain-list {
  margin: 0;
  padding-left: 18px;
}

/* Notices */

.messages {
  margin-bottom: 4px;
}

.notice {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: var(--radius-small);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.notice p {
  margin: 0;
}

.notice p + p,
.notice p + ul,
.notice ul + form {
  margin-top: 8px;
}

.notice-success {
  background: var(--ok-soft);
  border-color: #bfe3c9;
  color: #12602e;
}

.notice-error {
  background: var(--no-soft);
  border-color: #f1c4c1;
  color: #9d2722;
}

.notice-info {
  background: var(--accent-soft);
  border-color: #c8d9f2;
  color: #1b4f9c;
}

.notice-warning {
  background: var(--warn-soft);
  border-color: #f0dca8;
  color: #6e4700;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.button-block {
  display: flex;
  width: 100%;
}

.button-block + .button-block,
.form-actions + .button-block {
  margin-top: 10px;
}

.button-small {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 15px;
}

.button-primary {
  background: var(--accent);
  color: #ffffff;
}

.button-primary:hover {
  background: var(--accent-hover);
}

.button-secondary {
  background: var(--surface);
  border-color: var(--field-line);
  color: var(--text);
}

.button-secondary:hover {
  border-color: var(--muted);
}

.button-danger {
  background: var(--no);
  color: #ffffff;
}

.button-danger:hover {
  background: var(--no-hover);
}

.button-danger-outline {
  background: var(--surface);
  border-color: var(--no);
  color: var(--no);
}

.button-ok {
  background: var(--ok);
  color: #ffffff;
}

.button-ok:hover {
  background: var(--ok-hover);
}

.button-no {
  background: var(--surface);
  border-color: var(--no);
  color: var(--no);
}

.button-no:hover {
  background: var(--no-soft);
}

.button.is-chosen {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px currentColor;
}

.button-ok.is-chosen {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--ok);
}

/* Cards */

.card {
  display: block;
  margin: 10px 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.card-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.card-link:hover {
  border-color: #b9c6d8;
}

.card-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.card-kicker {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.card-meta {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.card .card-meta + .card-meta {
  margin-top: 2px;
}

.card-action {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.card-problem {
  font-size: 13px;
  font-weight: 600;
  color: var(--no);
}

.card-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
}

/* Badges and tallies */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  line-height: 22px;
  white-space: nowrap;
}

.badge-r-pending,
.badge-s-cancelled {
  background: var(--neutral-soft);
  color: #4b5563;
}

.badge-r-accepted,
.badge-s-approved {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-r-declined,
.badge-s-rejected {
  background: var(--no-soft);
  color: var(--no);
}

.badge-s-pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.tally {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  font-size: 14px;
  color: var(--muted);
}

.tally-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tally-item::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aab2bd;
}

.tally-accepted::before {
  background: var(--ok);
}

.tally-declined::before {
  background: var(--no);
}

/* Forms */

.form {
  margin: 0;
}

.field {
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.label {
  display: block;
  margin: 0 0 6px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
}

.optional {
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
}

.help {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.error {
  margin: 6px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--no);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="date"],
input[type="time"],
select,
textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

input[type="text"],
input[type="email"],
input[type="url"],
textarea {
  -webkit-appearance: none;
  appearance: none;
}

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235f6b7a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.field-has-error input,
.field-has-error select,
.field-has-error textarea {
  border-color: var(--no);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 340px) {
  .row {
    grid-template-columns: 1fr;
  }
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segment {
  position: relative;
  display: block;
}

.segment input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segment span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-small);
  background: var(--surface);
  font-weight: 600;
}

.segment input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.segment input:focus-visible + span {
  box-shadow: var(--focus-ring);
}

.checklist {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.field-has-error .checklist {
  border-color: var(--no);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.check:first-child {
  border-top: 0;
}

.check input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.check-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.check-busy {
  font-size: 13px;
  color: var(--warn);
}

.checklist .empty {
  margin: 0;
  padding: 12px 14px;
}

.details {
  margin: 12px 0;
}

.details > summary {
  padding: 6px 0;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.details[open] > summary {
  margin-bottom: 8px;
}

.details-danger > summary {
  color: var(--no);
}

.details-edit {
  margin: 0 0 16px;
  padding: 2px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.details-edit > summary {
  padding: 10px 0;
}

.details-edit[open] > summary {
  margin-bottom: 4px;
}

.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;
}

.form-actions {
  margin: 20px 0 0;
}

/* Facts */

.facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

.facts > div {
  display: grid;
  gap: 1px;
}

.facts dt {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.facts-compact {
  margin: 12px 0 4px;
}

/* Meeting page */

.detail-head {
  margin: 4px 0 16px;
}

.detail-head .page-title {
  margin-top: 8px;
}

.detail-when {
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 600;
}

.detail-place {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.people {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.person:first-child {
  border-top: 0;
}

.person-name {
  font-weight: 500;
}

.person-note {
  flex-basis: 100%;
  font-size: 14px;
  color: var(--muted);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0 8px;
}

.history {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.history li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.history-time {
  margin-right: 6px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Preview */

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

.mail-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  font-size: 16px;
}

.recipients {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.mail-preview {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface-sunk);
}

.mail-meta {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.mail-text {
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
}

.mail-preview .hint:last-child {
  margin-bottom: 0;
}

/* Answer page */

.answer-box {
  margin: 16px 0 12px;
}

.answer-current {
  margin: 0 0 12px;
}

.answer-prompt {
  margin: 0 0 12px;
  font-size: 15px;
}

.answer-buttons {
  display: grid;
  gap: 12px;
  margin: 0 0 12px;
}

input::placeholder {
  color: #8a94a3;
}

.answer-buttons .button-block + .button-block {
  margin-top: 0;
}

/* Calendar */

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 4px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.week-step {
  flex: none;
  padding: 6px 4px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.week-label {
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.week-today {
  margin: 8px 0 0;
  font-size: 15px;
  text-align: center;
}

.day {
  margin-top: 20px;
}

.day-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.3;
}

.today {
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  line-height: 22px;
}

.day-empty {
  margin: 0;
  padding: 10px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
