:root {
  --bg: #f7f0e7;
  --panel: #fffdf9;
  --panel-strong: #f0e8df;
  --ink: #2b211c;
  --muted: #6e5a4e;
  --accent: #b8662d;
  --accent-dark: #824a1d;
  --line: #e3d7cb;
  --shadow: 0 15px 35px rgba(73, 48, 34, 0.12);
  --success: #2d6a4f;
  --success-soft: rgba(45, 106, 79, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #f8f3ee 0%, #efe3d3 100%);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.app-toast {
  position: fixed;
  z-index: 1000;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(34rem, calc(100% - 2rem));
  padding: 0.85rem 0.9rem;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-left: 4px solid var(--success);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 600;
}

.app-toast[hidden] {
  display: none;
}

.load-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(146, 43, 43, 0.35);
  border-left: 4px solid #922b2b;
  border-radius: 8px;
  background: #fff7f5;
}

.load-error[hidden] {
  display: none;
}

.load-error p {
  margin: 0;
  color: #702020;
}

.app-toast.error {
  border-left-color: #922b2b;
}

.toast-dismiss {
  flex: 0 0 2rem;
  width: 2rem;
  min-height: 2rem;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.page-shell {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 0.75rem 2.5rem;
  min-width: 0;
}

.topbar {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.top-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-self: flex-end;
}

.admin-trigger {
  padding: 0.5rem 0.8rem;
  min-height: 0;
  font-size: 0.8rem;
  opacity: 0.9;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  font-size: 0.7rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 0;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  backdrop-filter: blur(2px);
}

.schedule-panel,
.calendar-panel,
.admin-panel,
.signup-page {
  background: var(--panel);
}

.signup-page {
  padding: 1.25rem;
  transition: opacity 0.2s ease;
}

.signup-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.signup-header h2 {
  margin: 0;
}

.field-row {
  margin-bottom: 1rem;
}

.compact {
  margin-bottom: 0.8rem;
}

.two-up {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  margin-top: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 0.8rem 0.9rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(184, 102, 45, 0.1);
  outline: none;
}

textarea {
  resize: vertical;
}

button {
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
  min-height: 46px;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

button[type="submit"] {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.secondary {
  background: var(--panel-strong);
  color: var(--ink);
}

.schedule-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.7rem;
  color: var(--ink);
}

.helper-text,
.detail-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.admin-panel {
  margin-bottom: 1.5rem;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 0.8rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  background: #f9f2ea;
  color: var(--ink);
}

.delete-entry {
  background: rgba(186, 45, 45, 0.08);
  color: #9e2c2c;
  border: 1px solid rgba(186, 45, 45, 0.2);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  min-height: 0;
  min-width: 2.5rem;
  font-size: 1.15rem;
  line-height: 1;
}

.calendar-panel {
  margin-top: 1.5rem;
}

.calendar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  text-align: center;
}

.calendar-header h2 {
  margin: 0;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
}

.icon-button {
  width: 2.5rem;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  line-height: 1;
}

.month-label {
  min-width: 8rem;
  text-align: center;
  font-size: 1rem;
  color: var(--ink);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  width: 100%;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calendar-weekday {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 1.5rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
  margin-bottom: 1rem;
  width: 100%;
  min-width: 0;
}

.calendar-day {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  min-height: 110px;
  min-width: 0;
  width: 100%;
  padding: 0.45rem 0.32rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition:
    border-color 0.2s ease,
    transform 0.15s ease;
}

.calendar-day:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.calendar-day.muted {
  opacity: 0.55;
}

.calendar-day.selected {
  border-color: var(--accent);
  background: rgba(184, 102, 45, 0.04);
}

.calendar-day.disabled {
  opacity: 0.62;
  cursor: default;
  background: #f7f5f3;
}

.calendar-day:disabled {
  cursor: default;
  opacity: 0.62;
}

.day-number {
  font-weight: 700;
  font-size: 0.92rem;
}

.day-badges {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  width: 100%;
  margin-top: 0.2rem;
  min-width: 0;
}

.day-count {
  display: block;
  width: 100%;
  max-width: 100%;
  font-size: 0.54rem;
  line-height: 1.2;
  border-radius: 999px;
  padding: 0.18rem 0.28rem;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: center;
  letter-spacing: 0.01em;
}

.day-count.volunteer {
  color: var(--success);
  background: var(--success-soft);
}

.day-count.childcare {
  color: #922b2b;
  background: rgba(146, 43, 43, 0.1);
}

.day-count.open {
  color: #8b6400;
  background: rgba(241, 192, 0, 0.18);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 0.9rem;
  align-items: center;
  justify-content: center;
  margin-top: -0.2rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.legend-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(43, 33, 28, 0.2);
}

.legend-swatch.volunteer {
  background: var(--success-soft);
}

.legend-swatch.childcare {
  background: rgba(146, 43, 43, 0.34);
}

.legend-swatch.open {
  background: rgba(241, 192, 0, 0.5);
}

#day-details-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  transform: translateY(-5dvh);
  width: calc(100% - 1rem);
  max-width: 36rem;
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fffdf9;
}

#day-details-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

body:has(#day-details-dialog[open]) {
  overflow: hidden;
}

.day-details-close {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0.5rem 0;
  margin: 0;
}

.day-details-close button {
  width: 46px;
  height: 46px;
  padding: 0;
  background: var(--panel-strong);
  color: var(--ink);
}

#day-details-dialog .care-need-row,
#day-details-dialog .slot-summary {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

#day-details-dialog .care-need-row {
  flex-wrap: wrap;
}

#day-details-dialog .care-need-row + .care-need-row {
  margin-top: 0.75rem;
}

#day-details-dialog .volunteer-day-button {
  width: auto;
  margin-top: 0;
  flex-shrink: 0;
}

#day-details-dialog .date-detail {
  border: 0;
  border-radius: 0;
}

.date-detail {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff8f2 0%, #fffdf9 100%);
  padding: 1rem;
}

.volunteer-day-button {
  width: 100%;
  margin-top: 1rem;
}

.date-detail h3 {
  margin-bottom: 0.8rem;
}

.admin-detail-list {
  display: grid;
  gap: 0.75rem;
}

.admin-no-volunteers {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid var(--muted);
  border-radius: 4px;
  background: var(--panel-strong);
  font-weight: 600;
}

.admin-day-care .admin-childcare-form {
  margin-top: 1rem;
}

.admin-day-care .admin-care-notes {
  margin-bottom: 1rem;
}

.admin-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.75rem 0.8rem;
}

.admin-detail-row strong {
  display: block;
  margin-bottom: 0.2rem;
}

.admin-delete-entry {
  flex-shrink: 0;
}

.admin-pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.admin-page-button {
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  background: #fff;
}

.admin-page-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.slot-summary {
  display: grid;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.8rem 0.9rem;
}

.slot-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
  word-break: break-word;
}

.slot-row:first-child {
  border-top: none;
  padding-top: 0;
}

.current-volunteers {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.current-volunteers h4 {
  margin: 0 0 0.25rem;
}

.volunteer-summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.volunteer-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
}

.volunteer-summary-row + .volunteer-summary-row {
  border-top: 1px solid var(--line);
}

.volunteer-shift strong,
.volunteer-shift span,
.volunteer-total strong,
.volunteer-total span {
  display: block;
}

.volunteer-shift {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.volunteer-shift span {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.volunteer-total {
  text-align: right;
}

.volunteer-total strong {
  color: var(--success);
  font-size: 1.5rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.volunteer-total span {
  color: var(--muted);
  font-size: 0.75rem;
}

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

.admin-childcare-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.admin-childcare-section h3 {
  margin-bottom: 0.75rem;
}

.admin-childcare-form {
  margin-bottom: 1rem;
}

.childcare-list {
  display: grid;
  gap: 0.75rem;
}

.care-row,
.care-need-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.8rem 0.9rem;
}

.care-detail-block {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.8rem 0.9rem;
}

.care-detail-block h4 {
  margin: 0 0 0.6rem;
}

.childcare-volunteer-button {
  flex-shrink: 0;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  background: rgba(184, 102, 45, 0.03);
}

@media (min-width: 768px) {
  #day-details-dialog {
    inset: 0;
    margin: auto;
  }

  .page-shell {
    padding: 2rem 1rem 3rem;
  }

  .topbar {
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-end;
    margin-bottom: 1.5rem;
  }

  .topbar > div:last-child {
    width: 100%;
  }

  .layout {
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
  }

  .two-up {
    grid-template-columns: repeat(2, minmax(200px, 1fr));
    gap: 1rem;
  }

  .calendar-weekdays {
    gap: 0.5rem;
    font-size: 0.76rem;
  }

  .calendar-grid {
    gap: 0.5rem;
  }

  .calendar-day {
    min-height: 112px;
    padding: 0.7rem 0.65rem;
  }

  .day-number {
    font-size: 1rem;
  }

  .day-count {
    font-size: 0.62rem;
  }

  .slot-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
  }
}
