:root {
  --responsive-page-gutter: clamp(16px, 3vw, 48px);
  --responsive-page-max: 90rem;
  --text-caption-base: 1rem;
  --text-meta-base: 1.125rem;
  --text-body-base: 1.25rem;
  --text-lead-base: 1.375rem;
  --text-control-base: 1.25rem;
  --text-nav-base: 1.1875rem;
  --text-card-title-base: 1.5rem;
  --text-section-title-base: 1.875rem;
  --text-page-title-base: 2.25rem;
  --text-display-base: 2.75rem;
  --text-caption: var(--text-caption-base);
  --text-meta: var(--text-meta-base);
  --text-body: var(--text-body-base);
  --text-lead: var(--text-lead-base);
  --text-control: var(--text-control-base);
  --text-nav: var(--text-nav-base);
  --text-card-title: var(--text-card-title-base);
  --text-section-title: var(--text-section-title-base);
  --text-page-title: var(--text-page-title-base);
  --text-display: var(--text-display-base);
  font-size: 100%;
}

html {
  min-width: 320px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-size: var(--text-body);
  line-height: 1.75;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
p {
  overflow-wrap: anywhere;
}

h1 {
  font-size: var(--text-page-title) !important;
  line-height: 1.22;
  text-wrap: balance;
}

h2 {
  font-size: var(--text-section-title) !important;
  line-height: 1.3;
  text-wrap: balance;
}

h3 {
  font-size: var(--text-card-title) !important;
  line-height: 1.4;
  text-wrap: balance;
}

h4 {
  font-size: var(--text-lead) !important;
  line-height: 1.45;
}

p,
li {
  font-size: var(--text-body) !important;
  line-height: 1.8;
}

label,
input,
select,
textarea,
button,
.button,
.filter-button,
.action-button,
.logout-button {
  font-size: var(--text-control) !important;
}

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

input,
select,
button,
.button,
.filter-button,
.action-button,
.logout-button {
  min-height: 48px;
}

textarea {
  min-height: 7.5rem;
  line-height: 1.7;
}

a {
  font-size: inherit;
}

nav a,
header a,
.back,
.back-link,
.reset-link,
.read-more,
.section-link,
.card-link,
.news-button,
.album-back {
  font-size: var(--text-nav) !important;
  line-height: 1.5;
}

nav a,
header > a,
header .button,
header .back-link {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

h1 a,
h2 a,
h3 a,
h4 a {
  font-size: inherit !important;
  line-height: inherit;
}

header h1,
.brand,
.brand-title,
.album-brand strong {
  font-size: var(--text-nav) !important;
  line-height: 1.35;
}

.page-heading h1,
.page-heading h2,
main > .heading h1,
main > .heading h2,
.article-header h1,
.album-heading h1,
.album-detail-heading h1 {
  font-size: var(--text-page-title) !important;
}

.card h2,
.card h3,
.article-card h2,
.article-card h3,
.admin-card h3,
.album-card h2,
.news-content h3,
.event-content h3,
.empty-state h2,
.empty-state h3 {
  font-size: var(--text-card-title) !important;
}

.form-card h2,
.form-card h3,
.panel-heading h3,
.section-head h3,
.attachment-heading,
.article-gallery h2 {
  font-size: var(--text-section-title) !important;
}

.lead,
.excerpt,
.hero-description,
.about-copy > p:last-child {
  font-size: var(--text-lead) !important;
  line-height: 1.85;
}

small,
.meta,
.hint,
.muted,
.description,
.page-description,
.summary,
.subtitle,
.intro,
.help-text,
.result-summary,
.registration-meta,
.article-count,
.article-date,
.brand-subtitle,
.account-meta,
.self-note,
.attachment-help,
.attachment-meta,
.footer-text,
.user-info,
.message,
.form-message,
.page-message,
.preview-message,
.attachment-message,
.permission-note,
.status-chip,
.date,
time,
figcaption,
footer,
.pagination span,
.accounts-heading span,
.album-heading > span,
.album-detail-meta {
  font-size: var(--text-meta) !important;
  line-height: 1.7;
}

td,
th {
  font-size: var(--text-meta) !important;
  line-height: 1.65;
}

.badge,
.status,
.category,
.post-count,
.post-slug,
.slug,
.action-badge,
.cover-badge,
.character-count,
.service-number,
.photo-button span,
.attachment-field span {
  font-size: var(--text-caption) !important;
  line-height: 1.5;
}

.album-heading > p,
.album-detail-heading > div > p {
  font-size: var(--text-caption) !important;
}

.checkbox-field,
.person strong {
  font-size: var(--text-control) !important;
}

.lightbox-bar button,
.lightbox-stage > button {
  min-width: 48px;
  font-size: var(--text-section-title) !important;
}

.article-body {
  font-size: var(--text-body) !important;
  line-height: 1.9;
}

.article-body h2 {
  font-size: var(--text-section-title) !important;
}

.article-body h3 {
  font-size: var(--text-card-title) !important;
}

.article-body h4 {
  font-size: var(--text-lead) !important;
}

.article-body code,
.markdown-preview-content,
.attachment-field input,
.attachment-field textarea,
.attachment-action,
.delete-attachment {
  font-size: var(--text-caption) !important;
}

img,
video,
svg,
canvas {
  max-width: 100%;
}

.table-wrap,
.table-card {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

/* 後台工作區使用可用畫面寬度；登入頁維持聚焦的置中卡片。 */
.admin-page > header {
  padding-inline: var(--responsive-page-gutter) !important;
}

.admin-page > main,
.admin-page > .admin-main {
  width: calc(100% - (var(--responsive-page-gutter) * 2)) !important;
  max-width: none !important;
}

@media (min-width: 1100px) {
  .admin-page .cards {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

@media (min-width: 721px) and (max-width: 1099px) {
  .admin-page .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (min-width: 721px) {
  :root {
    --text-caption-base: 1.0625rem;
    --text-meta-base: 1.1875rem;
    --text-body-base: 1.375rem;
    --text-lead-base: 1.5rem;
    --text-control-base: 1.3125rem;
    --text-nav-base: 1.25rem;
    --text-card-title-base: 1.75rem;
    --text-section-title-base: 2.375rem;
    --text-page-title-base: 2.875rem;
    --text-display-base: 3.625rem;
  }
}

@media (min-width: 1600px) {
  :root {
    --responsive-page-gutter: clamp(48px, 4vw, 112px);
    --text-caption-base: 1.125rem;
    --text-meta-base: 1.25rem;
    --text-body-base: 1.5rem;
    --text-lead-base: 1.625rem;
    --text-control-base: 1.375rem;
    --text-nav-base: 1.375rem;
    --text-card-title-base: 2rem;
    --text-section-title-base: 2.75rem;
    --text-page-title-base: 3.375rem;
    --text-display-base: 4.25rem;
  }
}

@media (max-width: 720px) {
  body > main:not(.login-card) {
    width: calc(100% - 28px) !important;
    max-width: none !important;
  }

  .admin-page > header {
    padding-inline: 14px !important;
  }

  .admin-page .cards {
    grid-template-columns: 1fr !important;
  }

  .header-inner,
  header .nav {
    width: 100% !important;
    max-width: none !important;
  }

  header,
  .header-inner,
  header .nav,
  .admin-heading,
  .page-heading,
  .heading {
    min-width: 0;
  }

  .form-actions,
  .row-actions,
  .filter-actions,
  .heading-actions,
  .header-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 430px) {
  :root {
    --responsive-page-gutter: 14px;
  }

  nav a,
  header a {
    white-space: normal;
  }
}
