:root {
  color-scheme: light;
  --page: #f5f8f7;
  --ink: #243b3c;
  --muted: #566a69;
  --accent: #23635e;
  --accent-hover: #184d49;
  --accent-soft: #e4efec;
  --line: #dce5e1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }

body { margin: 0; }

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

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

.page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(3rem, 7vw, 7rem);
  max-width: 74rem;
  min-height: 100svh;
  margin-inline: auto;
  padding: clamp(2rem, 6vw, 5rem) clamp(1.25rem, 5vw, 4rem);
}

.profile {
  flex: 0 1 21rem;
  min-width: 0;
}

.portrait {
  display: block;
  width: min(100%, 16.25rem);
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 28%;
  border-radius: 1rem;
  background: #e5e7df;
}

.profile-copy { margin-top: 2rem; }

h1, h2, h3, p { margin: 0; }

h1 {
  font-size: clamp(2.25rem, 3.7vw, 3rem);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: 0.04em;
}

.doctor-title {
  display: inline-block;
  margin-left: 0.65rem;
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.specialty {
  margin-top: 0.85rem;
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.6;
}

.position {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.8;
}

.appointments {
  flex: 1 1 32rem;
  min-width: 0;
  container-type: inline-size;
  scroll-margin-top: 1.5rem;
}

.section-heading {
  margin-bottom: 1.75rem;
  padding-top: 1.25rem;
  border-top: 3px solid var(--accent);
}

h2 {
  font-size: clamp(1.375rem, 2.2vw, 1.75rem);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.03em;
}

.schedule {
  width: 100%;
  table-layout: fixed;
  border-spacing: 0;
  border-collapse: separate;
  text-align: center;
  font-size: 1rem;
}

.schedule caption {
  padding-bottom: 1rem;
  color: var(--muted);
  font-size: 0.9375rem;
  text-align: left;
  letter-spacing: 0.04em;
}

.time-column { width: 3.75rem; }

.schedule th,
.schedule td {
  padding: 0.5rem 0.25rem;
  line-height: 1.5;
  font-weight: 400;
}

.schedule thead th {
  padding-block: 0.5rem 1rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.schedule tbody th {
  padding-right: 0.5rem;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

.schedule tbody th,
.schedule tbody td {
  height: 4.5rem;
  padding-block: clamp(0.5rem, 2cqi, 0.875rem);
  border-bottom: 1px solid var(--line);
}

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

.clinic {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding-block: clamp(0.5rem, 2cqi, 0.875rem);
  padding-inline: clamp(1px, 5cqi - 0.875rem, 0.75rem);
  border-radius: 0.4rem;
  background: var(--accent-soft);
}

.clinic-name {
  color: #205950;
  font-weight: 650;
}

.clinic-location,
.clinic-room {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 0.25em;
  max-width: 100%;
}

.clinic-location {
  font-size: 0.9375rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.booking { margin-top: 1.75rem; }

.hospital {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-block: 1.25rem;
}

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

.hospital-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

h3 {
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 600;
}

.hospital-role {
  color: var(--muted);
  font-size: 0.875rem;
}

.booking-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.875rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease;
}

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

@media (hover: hover) {
  .button:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
  }

  .button-secondary:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 1;
  transform: translateY(-200%);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: #fff;
}

.skip-link:focus { transform: translateY(0); }

/* Stack when the portrait and weekly schedule no longer fit side by side. */
@media (max-width: 52rem) {
  .page {
    max-width: 42rem;
    min-height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 2.25rem;
    padding-block: 2.5rem;
  }

  .profile {
    display: flex;
    align-items: center;
    gap: clamp(1rem, 4vw, 2rem);
    flex-basis: auto;
  }

  .portrait {
    flex: 0 0 auto;
    width: clamp(6rem, 25vw, 8.75rem);
    border-radius: 0.75rem;
  }

  .profile-copy { margin-top: 0; }

  h1 { font-size: clamp(1.75rem, 5.5vw, 2.5rem); }

  .doctor-title {
    font-size: 0.9375rem;
    margin-left: 0.4rem;
  }

  .specialty {
    font-size: 1rem;
    margin-top: 0.5rem;
    letter-spacing: 0.025em;
  }

  .position {
    margin-top: 0.5rem;
    font-size: 0.9375rem;
    line-height: 1.65;
  }

  .appointments { flex-basis: auto; }
  .section-heading { margin-bottom: 1.25rem; }
  .booking { margin-top: 1rem; }
}

@media (max-width: 30rem) {
  .page { padding: 1.75rem 1rem; }
  .time-column { width: 2.75rem; }
  .schedule td { padding-inline: 0; }
  .schedule tbody th { padding-right: 0; }
  .schedule tbody th, .schedule tbody td { height: 4rem; }
  .hospital { gap: 0.75rem; }
  .hospital-heading, .booking-actions { width: 100%; }
  .button { flex: 1; }
}

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