/* ---------- Colors ---------- */

:root {
  --accent: #3b7ea1;
  --on-accent: #ffffff;
  --bg: #f7f3ee;
  --surface: #fffdfa;
  --text: #1f2528;
  --text-muted: #4f5a60;
  --border: #ddd5cb;
  --error-bg: #fbeceb;
  --error-text: #8a2620;
  --focus: #1f5f80;
  --shadow: 0 1px 3px rgba(40, 30, 20, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161a1d;
    --surface: #20262a;
    --text: #eef1f2;
    --text-muted: #b4bec4;
    --border: #39434a;
    --error-bg: #3b1f1d;
    --error-text: #ffc9c4;
    --focus: #9fd3ef;
    --shadow: none;
  }
}

/* ---------- Base ---------- */

*,
*::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 Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* ---------- Buttons ---------- */

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  width: 100%;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  border: 2px solid var(--accent);
  font: inherit;
  font-size: 1.125rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

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

.button-secondary {
  background: transparent;
  color: var(--text);
}

.button:disabled {
  opacity: 0.7;
  cursor: progress;
}

.link-button {
  min-height: 48px;
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 1rem;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Login page ---------- */

.login {
  max-width: 26rem;
  margin: 0 auto;
  padding: 3.5rem 1rem 2rem;
}

.login h1 {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.login-welcome {
  margin: 0 0 2rem;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-form > label {
  font-weight: 600;
}

.login-form input[type="password"],
.login-form input[type="text"] {
  min-height: 52px;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.125rem;
}

.login-form input:focus-visible {
  border-color: var(--accent);
}

.show-password {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  color: var(--text-muted);
  cursor: pointer;
}

.show-password input {
  width: 1.375rem;
  height: 1.375rem;
  accent-color: var(--accent);
}

.login-error {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--error-bg);
  color: var(--error-text);
}

.login-form .button {
  margin-top: 0.5rem;
}

/* ---------- Dashboard ---------- */

.page-header,
.dashboard,
.page-footer {
  max-width: 60rem;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.page-header {
  padding-top: 2.25rem;
  padding-bottom: 1.25rem;
}

.page-header h1 {
  font-size: 2rem;
}

.subtitle {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 1.125rem;
}

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.status {
  margin: 1rem 0;
  color: var(--text-muted);
}

.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 700px) {
  .link-list {
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  }
}

/* ---------- Collapsible panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-heading {
  font-size: 1.25rem;
}

.panel-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  min-height: 56px;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.panel-toggle:focus-visible {
  outline-offset: -3px;
}

.panel-toggle::after {
  content: "";
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  border-right: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor;
  transform: translateY(-25%) rotate(45deg);
  transition: transform 0.15s ease;
}

.panel-toggle[aria-expanded="false"]::after {
  transform: rotate(-45deg);
}

.panel-body {
  padding: 0 1rem 1rem;
}

.instructions {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

/* ---------- Calendar toggles ---------- */

.calendar-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.calendar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.calendar-toggle[aria-pressed="true"] {
  border-color: var(--accent);
}

.calendar-toggle[aria-pressed="false"] {
  color: var(--text-muted);
  text-decoration: line-through;
}

.calendar-toggle .swatch {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
}

.calendar-toggle[aria-pressed="false"] .swatch {
  opacity: 0.3;
}

/* ---------- Appointment list ---------- */

.agenda {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.agenda-date {
  margin-bottom: 0.75rem;
  font-size: 1.0625rem;
  color: var(--text-muted);
}

.appt {
  margin-bottom: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 6px solid var(--accent);
  border-radius: 12px;
}

.appt-time {
  margin: 0;
  font-weight: 600;
  color: var(--text-muted);
}

.appt-title {
  margin: 0.125rem 0 0;
  font-size: 1.1875rem;
  line-height: 1.3;
}

.appt-meta {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.appt-details {
  margin-top: 0.5rem;
}

.appt-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--text-muted);
  cursor: pointer;
}

.appt-details p {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.roles {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.role {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.role-name {
  min-width: 5.5rem;
  font-weight: 700;
}

.role-person {
  font-weight: 600;
}

.role-person::before {
  content: "✓ ";
  color: var(--accent);
}

.role-open {
  color: var(--text-muted);
}

.role-action {
  margin-left: auto;
}

.button.button-small {
  width: auto;
  min-height: 44px;
  padding: 0.4rem 1rem;
  font-size: 1rem;
}

.form-error {
  flex-basis: 100%;
  margin: 0;
  color: var(--error-text);
}

.inline-form {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.inline-form label,
.todo-add label {
  font-weight: 600;
}

.inline-form input,
.todo-add input {
  min-height: 48px;
  width: 100%;
  padding: 0.5rem 0.875rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.inline-form input:focus-visible,
.todo-add input:focus-visible {
  border-color: var(--accent);
}

.inline-form-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.agenda-more {
  margin-top: 1rem;
}

/* ---------- List / Month switch ---------- */

.view-switch {
  display: inline-flex;
  margin-bottom: 1rem;
  border: 2px solid var(--accent);
  border-radius: 12px;
  overflow: hidden;
}

.view-button {
  min-height: 44px;
  min-width: 5.5rem;
  padding: 0.4rem 1rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.view-button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---------- Month view ---------- */

.month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.month-title {
  font-size: 1.1875rem;
  text-align: center;
}

.month-header .button:disabled {
  opacity: 0.35;
  cursor: default;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.month-weekday {
  padding: 0.25rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
}

.month-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 3.25rem;
  padding: 0.25rem 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.month-past {
  opacity: 0.55;
}

.month-today .month-date {
  background: var(--accent);
  color: var(--on-accent);
}

.month-day[aria-pressed="true"] {
  border: 2px solid var(--accent);
}

.month-date {
  min-width: 1.75rem;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
}

/* On phones each appointment is a colored dot; on wider screens it shows the time and title. */
.month-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.month-dot {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

.month-chip-text,
.month-more {
  display: none;
}

@media (min-width: 700px) {
  .month-day {
    align-items: stretch;
    min-height: 6.5rem;
    padding: 0.35rem;
  }

  .month-date {
    align-self: flex-start;
  }

  .month-chip-text,
  .month-more {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.8125rem;
    line-height: 1.35;
  }

  .month-more {
    color: var(--text-muted);
  }
}

.month-chip-open .month-chip-text {
  font-weight: 700;
}

.month-selected {
  margin-top: 1.25rem;
  scroll-margin-top: 1rem;
}

/* ---------- Questions ---------- */

.message-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message-form label {
  font-weight: 600;
}

.message-form textarea,
.message-form input {
  width: 100%;
  min-height: 48px;
  padding: 0.5rem 0.875rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.message-form textarea {
  resize: vertical;
}

.message-form textarea:focus-visible,
.message-form input:focus-visible {
  border-color: var(--accent);
}

.question-ask {
  margin-bottom: 1.5rem;
}

.question {
  margin-bottom: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.message-byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.6rem;
  margin: 0;
  font-size: 0.9375rem;
}

.message-name {
  font-weight: 700;
}

.message-time {
  color: var(--text-muted);
}

.message-text {
  margin: 0.25rem 0 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  margin-top: 0.25rem;
}

.replies {
  margin-top: 0.75rem;
  padding-left: 0.875rem;
  border-left: 3px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ---------- To-do list ---------- */

.todo-add {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.todo-add-row {
  display: flex;
  gap: 0.5rem;
}

.todo-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.todo {
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.todo-text {
  margin: 0 0 0.25rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.todo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
}

.todo-is-done .todo-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.todo-by {
  color: var(--text-muted);
}

.todo-done summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Embeds ---------- */

.embed {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}

.embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.embed-fallback {
  margin: 0;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-muted);
}

.embed-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.embed-actions:empty {
  display: none;
}

@media (min-width: 700px) {
  .embed-actions .button {
    width: auto;
    display: inline-flex;
  }
}

/* ---------- Footer ---------- */

.page-footer {
  padding-top: 2rem;
  padding-bottom: 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

.page-footer p {
  margin: 0 0 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
  .panel-toggle::after {
    transition: none;
  }
}
