:root {
  --primary: #7c5cfc;
  --primary-dark: #5840c9;
  --secondary: #f7c8d0;
  --background: #faf7f2;
  --surface: #ffffff;
  --text: #2e2e2e;
  --muted: #737373;
  --line: #e8e0d8;
  --danger: #d93636;
  --warning: #fff4c2;
  --success: #3f8f51;
  --focus: #1e88e5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  min-width: 320px;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.nav {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1120px;
  padding: 14px 20px;
}

.brand {
  color: var(--primary-dark);
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mobile-menu {
  display: none;
}

.nav-links a {
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
}

.nav-links a:hover {
  background: #f0ece7;
  color: var(--text);
}

.page {
  margin: 0 auto;
  max-width: 1120px;
  padding: 28px 20px 48px;
  width: 100%;
}

.site-footer {
  margin: 0 auto;
  max-width: 1120px;
  padding: 0 20px 26px;
  width: 100%;
}

.site-footer-inner {
  align-items: center;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.88rem;
  font-weight: 700;
  gap: 8px 14px;
  justify-content: center;
  padding: 12px 16px;
  text-align: center;
}

.site-footer-inner span + span {
  color: var(--primary-dark);
}

.hero {
  align-items: center;
  background: linear-gradient(135deg, #fff 0%, #fff7f9 44%, #f0fbff 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr auto;
  margin-bottom: 22px;
  padding: 32px;
}

.hero.compact {
  display: block;
}

.hero h1,
.page-heading h1,
.panel h1 {
  font-size: 2.6rem;
  line-height: 1.05;
  margin: 0 0 12px;
}

.hero p,
.page-heading p {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0;
  max-width: 720px;
}

.hero-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-actions {
  justify-content: flex-end;
}

.button,
button.button {
  align-items: center;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 800;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  text-align: center;
  word-break: normal;
}

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

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

.button.secondary {
  background: var(--secondary);
  color: #5a2430;
}

.button.ghost {
  background: #f0ece7;
  color: var(--text);
}

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

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.calendar-panel {
  overflow: hidden;
  padding: 16px;
}

.calendar-heading {
  align-items: end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.label-short {
  display: none;
}

.page-heading {
  margin-bottom: 18px;
}

.page-heading h1,
.section-title h2 {
  margin: 0;
}

.section-title {
  margin-bottom: 14px;
}

.eyebrow {
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

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

.event-list {
  display: grid;
  gap: 10px;
}

.event-row {
  align-items: center;
  background: #fbfaf8;
  border: 1px solid #eee7df;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 14px 1fr;
  padding: 12px;
}

.event-row:hover {
  border-color: #d6cfc7;
}

.event-row.is-important {
  background: #fff9dc;
  border-color: #f0d86d;
}

.category-dot {
  border-radius: 999px;
  height: 14px;
  width: 14px;
}

.event-main {
  display: grid;
  gap: 2px;
}

.event-main small {
  color: var(--muted);
}

.family-layout {
  align-items: start;
}

.member-list {
  display: grid;
  gap: 12px;
}

.member-card {
  align-items: start;
  background: #fbfaf8;
  border: 1px solid #eee7df;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  padding: 14px;
}

.member-card h3,
.member-card p {
  margin: 0;
}

.member-card h3 {
  margin-bottom: 4px;
}

.member-card p + p {
  margin-top: 3px;
}

.form {
  display: grid;
  gap: 18px;
}

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

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #d8d0c8;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  outline: 3px solid rgba(30, 136, 229, 0.18);
}

.checks {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.check {
  align-items: center;
  background: #fbfaf8;
  border: 1px solid #eee7df;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  padding: 12px;
}

.check input {
  min-height: auto;
  width: auto;
}

.alert {
  border-radius: 8px;
  margin: 0 0 16px;
  padding: 14px 16px;
}

.alert ul {
  margin-bottom: 0;
}

.alert-danger {
  background: #ffe8e8;
  border: 1px solid #f3b5b5;
  color: #7a1d1d;
}

.alert-success {
  background: #e9f8ed;
  border: 1px solid #b9e2c2;
  color: #1f6b31;
}

.alert-warning {
  background: var(--warning);
  border: 1px solid #ead675;
  color: #604d00;
}

.debug-box {
  background: #2e2e2e;
  border-radius: 8px;
  color: #fff;
  overflow: auto;
  padding: 16px;
  white-space: pre-wrap;
}

.diagnostic-panel {
  margin-top: 18px;
}

.diagnostic-list {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

.diagnostic-list div {
  background: #fbfaf8;
  border: 1px solid #eee7df;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.diagnostic-list dt {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

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

code {
  background: #f0ece7;
  border-radius: 6px;
  padding: 2px 5px;
}

.delete-panel {
  max-width: 680px;
}

.password-panel {
  margin: 40px auto 0;
  max-width: 520px;
}

.fc {
  --fc-border-color: #e5ded6;
  --fc-button-bg-color: var(--primary);
  --fc-button-border-color: var(--primary);
  --fc-button-hover-bg-color: var(--primary-dark);
  --fc-button-hover-border-color: var(--primary-dark);
  --fc-today-bg-color: #fff8df;
}

.fc .fc-toolbar {
  flex-wrap: wrap;
  gap: 10px;
}

.fc .fc-button {
  border-radius: 8px;
  font-weight: 800;
}

.fc .fc-toolbar-title {
  font-size: 1.35rem;
  line-height: 1.2;
}

.fc .fc-button {
  min-height: 38px;
  padding: 6px 10px;
}

.fc .fc-daygrid-day-frame {
  min-height: 82px;
}

.fc .fc-event-title,
.fc .fc-list-event-title {
  overflow-wrap: anywhere;
}

.fc .fc-list-event-title a,
.fc .fc-list-event-time {
  white-space: normal;
}

@media (max-width: 1024px) {
  .page {
    max-width: 100%;
    padding: 22px 16px 40px;
  }

  .hero h1,
  .page-heading h1,
  .panel h1 {
    font-size: 2.25rem;
  }
}

@media (max-width: 780px) {
  .nav,
  .hero {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .nav {
    display: grid;
    gap: 12px;
    max-width: 100%;
  }

  .nav-links,
  .hero-actions,
  .page-actions {
    justify-content: flex-start;
  }

  .nav-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-links a,
  .button {
    width: 100%;
  }

  .grid.two,
  .form-grid,
  .checks,
  .member-card {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 24px;
  }

  .calendar-heading {
    align-items: stretch;
    display: grid;
  }

  .page-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page {
    padding: 14px 10px 28px;
  }

  .site-header {
    position: sticky;
  }

  .nav {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    padding: 10px;
  }

  .brand {
    display: block;
    font-size: 1rem;
    margin-bottom: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-links {
    display: none;
  }

  .mobile-menu {
    display: block;
    position: relative;
  }

  .mobile-menu summary {
    background: #f7f3ee;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
    list-style: none;
    min-height: 38px;
    padding: 7px 12px;
  }

  .mobile-menu summary::-webkit-details-marker {
    display: none;
  }

  .mobile-menu[open] summary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
  }

  .mobile-menu-links {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 40px rgba(46, 46, 46, 0.16);
    display: grid;
    gap: 4px;
    min-width: 230px;
    padding: 8px;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 20;
  }

  .mobile-menu-links a {
    border-radius: 8px;
    color: var(--text);
    font-weight: 800;
    padding: 10px 12px;
    width: auto;
  }

  .mobile-menu-links a:hover {
    background: #f7f3ee;
  }

  .hero,
  .panel {
    padding: 14px;
  }

  .hero {
    gap: 14px;
    margin-bottom: 14px;
  }

  .calendar-panel {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    margin-left: -10px;
    margin-right: -10px;
    overflow-x: auto;
    padding: 8px;
  }

  #calendar {
    min-width: 0;
  }

  .hero h1,
  .page-heading h1,
  .panel h1 {
    font-size: 1.55rem;
    line-height: 1.15;
  }

  .page-heading p,
  .hero p {
    font-size: 0.94rem;
  }

  .page-heading {
    margin-bottom: 12px;
  }

  .calendar-heading {
    gap: 12px;
  }

  .calendar-heading .eyebrow {
    display: none;
  }

  .page-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .label-full {
    display: none;
  }

  .label-short {
    display: inline;
  }

  .button,
  button.button {
    min-height: 40px;
    padding: 8px 10px;
  }

  .form {
    gap: 14px;
  }

  .event-row {
    gap: 10px;
    padding: 10px;
  }

  .member-card {
    padding: 12px;
  }

  .fc .fc-toolbar {
    align-items: center;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 7px;
    margin-bottom: 0.7em;
  }

  .fc .fc-toolbar-chunk {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    min-width: 0;
  }

  .fc .fc-toolbar-chunk:first-child {
    justify-content: flex-start;
  }

  .fc .fc-toolbar-chunk:last-child {
    justify-content: flex-end;
  }

  .fc .fc-toolbar-title {
    font-size: 1rem;
    text-align: center;
    width: 100%;
  }

  .fc .fc-button {
    font-size: 0.78rem;
    min-height: 36px;
    padding: 6px 7px;
  }

  .fc .fc-prev-button,
  .fc .fc-next-button {
    min-width: 40px;
    padding-left: 0;
    padding-right: 0;
    width: 40px;
  }

  .fc .fc-footer-toolbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    margin-top: 0.7em;
  }

  .fc .fc-footer-toolbar .fc-toolbar-chunk {
    justify-content: center;
  }

  .fc .fc-footer-toolbar .fc-toolbar-chunk:first-child {
    justify-content: flex-start;
  }

  .fc .fc-footer-toolbar .fc-toolbar-chunk:last-child {
    justify-content: flex-end;
  }

  .fc .fc-daygrid-day-frame {
    min-height: 54px;
  }

  .fc .fc-col-header-cell-cushion,
  .fc .fc-daygrid-day-number {
    font-size: 0.78rem;
    padding: 3px;
  }

  .fc .fc-daygrid-event {
    font-size: 0.72rem;
    line-height: 1.2;
    white-space: normal;
  }

  .fc .fc-list-day-cushion {
    background: #f7f3ee;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 8px;
  }

  .fc-theme-standard .fc-list {
    border: 0;
  }

  .fc .fc-list-table {
    border-collapse: separate;
    border-spacing: 0 8px;
  }

  .fc .fc-list-day td {
    background: transparent;
    border: 0;
    padding: 0;
  }

  .fc .fc-list-event td {
    background: #fff;
    border-bottom: 1px solid var(--line);
    border-top: 1px solid var(--line);
  }

  .fc .fc-list-event td:first-child {
    border-left: 1px solid var(--line);
    border-radius: 8px 0 0 8px;
  }

  .fc .fc-list-event td:last-child {
    border-radius: 0 8px 8px 0;
    border-right: 1px solid var(--line);
  }

  .fc .fc-list-event-dot {
    height: 10px;
    width: 10px;
  }

  .fc .fc-list-event-title,
  .fc .fc-list-event-time {
    font-size: 0.88rem;
    padding: 8px 6px;
  }

  .fc .fc-list-event-time {
    white-space: nowrap;
    width: 86px;
  }
}

@media (max-width: 420px) {
  .page {
    padding-left: 8px;
    padding-right: 8px;
  }

  .form-actions {
    display: grid;
  }

  .hero h1,
  .page-heading h1,
  .panel h1 {
    font-size: 1.38rem;
  }

  .hero,
  .panel {
    padding: 12px;
  }

  .calendar-panel {
    margin-left: -8px;
    margin-right: -8px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .fc .fc-button {
    font-size: 0.74rem;
    padding-left: 6px;
    padding-right: 6px;
  }
}
