/* 台中市召會行動報導 — 共用樣式（建置頁面、編輯器、預覽、匯出 HTML 共用這一份）
   版面參考 docs/DESIGN_REFERENCE.md；手機版優先。 */

:root {
  --bg: #f5f5f2;
  --ink: #16324f;
  --muted: #5a6a7a;
  --gold: #836427;
  --gold-light: #c9a865;
  --link: #2f6fb2;
  --line: #e4e3de;
  --card: #fff;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  border-top: 3px solid var(--gold-light); /* 頁首頂端細金線 */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

img {
  max-width: 100%;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- 頁首 ---------- */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 10;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}

.brand .logo {
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
}

.brand-text small {
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 1.5px;
}

.main-nav {
  display: none;
}

.main-nav a,
.menu-panel a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 2px;
}

.menu {
  position: relative;
}

.menu summary {
  list-style: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  display: grid;
  place-items: center;
  cursor: pointer;
}

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

.burger,
.burger::before,
.burger::after {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
  position: relative;
}

.burger::before,
.burger::after {
  content: "";
  position: absolute;
  left: 0;
}

.burger::before {
  top: -5px;
}

.burger::after {
  top: 5px;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: 48px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 180px;
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  box-shadow: 0 8px 30px rgba(22, 50, 79, 0.12);
}

.menu-panel a {
  padding: 10px 18px;
}

.menu-panel a[aria-current="page"] {
  color: var(--gold);
}

@media (min-width: 900px) {
  .main-nav {
    display: flex;
    gap: 28px;
  }

  .main-nav a {
    padding: 20px 0 18px;
    border-bottom: 2px solid transparent;
  }

  .main-nav a[aria-current="page"],
  .main-nav a:hover {
    border-bottom-color: var(--gold-light);
  }

  .menu {
    display: none;
  }
}

/* ---------- 內容容器與頁尾 ---------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 0;
  flex: 1 0 auto;
}

.site-footer {
  background: var(--ink);
  color: #f0ede6;
  font-size: 14px;
  text-align: center;
  padding: 52px 0 30px;
  margin-top: 56px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.site-footer p {
  margin: 0 0 6px;
}

.footer-brand {
  letter-spacing: 2px;
  font-weight: 700;
}

/* ---------- 麵包屑、標題、細線 ---------- */
.breadcrumb {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--link);
}

.page-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 3px;
  margin: 0;
  color: var(--ink);
}

.hairline {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 22px 0 0;
}

/* ---------- 列表頁工具列 ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 18px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-block;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 1px;
}

.chip[aria-current="page"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.year-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
}

.year-filter select,
.field select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
}

.empty {
  color: var(--muted);
  padding: 40px 0;
  text-align: center;
}

/* ---------- 卡片 ---------- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.card {
  display: grid;
  grid-template-columns: 138px 1fr;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  min-height: 104px;
}

.card:hover .card-title {
  color: var(--link);
}

.card-img {
  display: block;
  background: var(--line);
}

.card-img img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 104px;
  object-fit: cover;
}

.card-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px;
  min-width: 0;
}

.card-cat {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 3px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.card-date {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-top: auto;
}

@media (min-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 20px;
    justify-content: start;
  }
  /* 行動列表只有一筆時，卡片維持可讀寬度，不要變成窄的三分之一欄 */
  .card-grid.action-list > .card {
    max-width: 520px;
  }

  .card {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .card-img img {
    aspect-ratio: 16 / 10;
    height: auto;
    min-height: 0;
  }
}

/* ---------- 分頁 ---------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 28px 0 0;
}

.pagination a,
.pagination span {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  min-width: 34px;
  text-align: center;
}

.pagination [aria-current="page"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.pagination .gap {
  border-color: transparent;
  background: transparent;
}

/* ---------- 單篇報導 ---------- */
.article {
  max-width: 760px;
  margin: 0 auto;
}

.kicker {
  font-size: 13.5px;
  color: var(--gold);
  letter-spacing: 3px;
  margin: 0;
}

.article-title {
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1.45;
  margin: 14px 0 16px;
  overflow-wrap: anywhere;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin: 0;
}

.meta-item dt {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 3px;
}

.meta-item dd {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.meta-item dd a {
  color: var(--link);
  text-decoration: none;
}

.article-body {
  font-size: 16px;
  line-height: 1.95;
  overflow-wrap: anywhere;
}

.article-body p {
  margin: 0 0 18.4px;
}

.article-body h2,
.section-title {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 1.5;
}

.article-body h2 {
  margin: 36px 0 14px;
  padding-left: 14px;
  position: relative;
}

.article-body h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.35em;
  width: 4px;
  height: 0.9em;
  background: var(--gold-light);
  border-radius: 2px;
}

.article-body h3 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  margin: 28px 0 10px;
}

.article-body blockquote {
  margin: 24px 0;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--gold-light);
  color: var(--muted);
}

.article-body blockquote p:last-child {
  margin-bottom: 0;
}

.article-body ul,
.article-body ol {
  padding-left: 1.4em;
  margin: 0 0 18.4px;
}

.figure {
  margin: 35.2px 0;
}

.cover {
  margin-top: 28px;
}

.figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(22, 50, 79, 0.12);
}

.figure figcaption {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
  line-height: 1.6;
}

.img-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 1px dashed var(--gold-light);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
  background: #fbfaf6;
}

.share {
  margin: 40px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.share-title {
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--gold);
  margin: 0 0 12px;
  font-weight: 700;
}

.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  font: inherit;
  font-size: 14px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 20px;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
}

.pill:hover {
  border-color: var(--gold-light);
}

.prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 32px;
}

.pn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 18px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.pn-empty {
  background: transparent;
  border-style: dashed;
}

.pn-next {
  text-align: right;
}

.pn-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
}

.pn-title {
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.related {
  max-width: 1200px;
  margin: 48px auto 0;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-title {
  margin: 0;
}

.section-head .page-title,
.section-head .section-title {
  white-space: nowrap;
  flex: 0 0 auto;
}

.more {
  font-size: 13px;
  color: var(--link);
  text-decoration: none;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .article-title {
    font-size: 30px;
  }
}

/* ---------- 編輯器 ---------- */
.editor-intro {
  color: var(--muted);
  font-size: 14px;
  margin: 10px 0 0;
}

.editor-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.editor-tabs button {
  flex: 1;
}

.editor-tabs button[aria-selected="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.editor-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.editor-layout[data-view="form"] .editor-preview,
.editor-layout[data-view="preview"] .editor-form {
  display: none;
}

.editor-form,
.editor-preview {
  min-width: 0;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 16px;
  letter-spacing: 2px;
  margin: 0 0 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.field label,
.field .label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
}

.field .req {
  color: #a33;
  margin-left: 2px;
}

.field input[type="text"],
.field input[type="date"],
.field textarea {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
}

.field textarea {
  min-height: 320px;
  line-height: 1.7;
  resize: vertical;
}

.field textarea.short {
  min-height: 80px;
}

.hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 14px;
}

.md-help {
  font-size: 13px;
  color: var(--muted);
  background: #fbfaf6;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 0 0 8px;
}

.md-help summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.md-help code,
.hint code {
  background: #f0eee8;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

.image-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
}

.image-item img {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
}

.image-item .name {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.image-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

a.btn {
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
}

.btn {
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn.small {
  font-size: 12.5px;
  padding: 5px 12px;
}

.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.btn.danger {
  color: #a33;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.errors {
  margin: 12px 0 0;
  padding: 10px 14px 10px 32px;
  font-size: 13px;
  color: #8a2a2a;
  background: #fbf1f0;
  border: 1px solid #f0d6d3;
  border-radius: var(--radius);
}

.errors:empty {
  display: none;
}

.status {
  font-size: 13px;
  color: var(--muted);
  min-height: 1.5em;
  margin: 8px 0 0;
}

.preview-frame {
  width: 100%;
  height: 75vh;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

@media (min-width: 640px) {
  .row-2 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  .editor-tabs {
    display: none;
  }

  .editor-layout,
  .editor-layout[data-view] {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .editor-layout[data-view] .editor-preview,
  .editor-layout[data-view] .editor-form {
    display: block;
  }

  .editor-preview {
    position: sticky;
    top: 16px;
    align-self: start;
  }

  .preview-frame {
    height: calc(100vh - 80px);
  }
}

/* 匯出的單一 HTML／預覽：沒有選單 */
.standalone .container {
  padding-top: 24px;
}

/* ---------- 生成報導的版面樣式（render.mjs 的 layout-*） ---------- */
/* 見證署名：Markdown 以單獨一段的 *—— 姓名* 表示 */
.article-body p:has(> em:only-child) {
  text-align: right;
  color: var(--gold);
  font-weight: 700;
}

.article-body p:has(> em:only-child) em {
  font-style: normal;
}

/* 圖文交錯：照片左右交錯、文字繞圖 */
@media (min-width: 640px) {
  .layout-alternate .article-body .figure {
    width: 46%;
    margin: 6px 0 18px;
  }

  .layout-alternate .article-body .figure:nth-of-type(odd) {
    float: left;
    margin-right: 24px;
  }

  .layout-alternate .article-body .figure:nth-of-type(even) {
    float: right;
    margin-left: 24px;
  }

  .layout-alternate .article-body h2,
  .layout-alternate .article-body blockquote {
    clear: both;
  }

  .layout-alternate .article-body::after {
    content: "";
    display: block;
    clear: both;
  }
}

/* 雙欄專題：寬版、內文兩欄 */
@media (min-width: 900px) {
  .layout-columns .article {
    max-width: 1040px;
  }

  .layout-columns .article-body {
    column-count: 2;
    column-gap: 44px;
    column-rule: 1px solid var(--line);
  }

  .layout-columns .article-body .figure,
  .layout-columns .article-body blockquote {
    break-inside: avoid;
    margin: 0 0 22px;
  }

  .layout-columns .article-body h2 {
    break-after: avoid;
    margin-top: 0;
  }
}

/* ---------- 協作平台 ---------- */
.app-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.app-home {
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--ink);
  text-decoration: none;
}

.app-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.app-user {
  flex-wrap: wrap;
}
.app-user .btn,
.app-user .role-badge,
.app-user [class*='badge'] {
  white-space: nowrap;
  overflow-wrap: normal;
  flex: none;
}

.mode-badge,
.role-badge {
  font-size: 12px;
  color: var(--gold);
  border: 1px solid var(--gold-light);
  border-radius: 999px;
  padding: 2px 10px;
}

.demo-code {
  background: #fdf8ea;
  border: 1px solid var(--gold-light);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
}

.app-status:empty {
  display: none;
}

.login {
  max-width: 520px;
  margin: 24px auto;
}

.field input[type="email"],
.field input[type="url"],
.field input[type="number"],
.field input:not([type]),
.material-form input[type="url"],
.material-form input:not([type]) {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
}

/* 下拉選單：選項文字很長（例如「行動負責人（只能管自己被指派的行動）」）時不撐破 390px 版面 */
.field select {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.field input[type="file"] {
  max-width: 100%;
  font-size: 14px;
}

.field input[type="date"] {
  min-width: 0;
}
.field input[type="date"]::-webkit-calendar-picker-indicator {
  width: 24px;
  height: 24px;
  cursor: pointer;
}
.date-hint {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted, #666);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
}

.table-scroll .table {
  min-width: 560px;
  margin-bottom: 0;
}

.checkbox,
.radio {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

fieldset.field {
  border: 0;
  padding: 0;
  margin: 0 0 14px;
  min-width: 0;
}

.section-head .actions {
  margin-left: auto;
}

.action-card .card-text {
  padding: 16px 18px;
}

.action-desc {
  white-space: pre-wrap;
  color: var(--muted);
}

/* 行動功能主分頁列：置於標題上方，捲動時吸頂 */
:root {
  --app-tabs-sticky-h: 64px;
}
html {
  scroll-padding-top: var(--app-tabs-sticky-h);
}
.breadcrumb:has(+ .app-tabs) {
  margin-bottom: 12px;
}
.a4-editor,
.a4-frame,
.tab-panel {
  scroll-margin-top: var(--app-tabs-sticky-h);
}

.app-tabs {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 6px;
  margin: 0 -24px 20px;
  padding: 8px 24px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.app-tabs .tab {
  flex: 1 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
}

.app-tabs .tab:hover {
  border-color: var(--ink);
}

.app-tabs .tab:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.app-tabs .tab[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 700;
}

.app-tabs .tab-icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.app-tabs .tab-label {
  display: inline;
}

@media (min-width: 800px) {
  .app-tabs .tab {
    flex: 1 1 0;
  }
}

.settings .presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.settings .presets .pill {
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.range-row {
  display: grid;
  grid-template-columns: 7.5em 1fr 4.5em;
  align-items: center;
  gap: 10px;
}

.range-row input[type="range"] {
  width: 100%;
  accent-color: var(--ink);
}

.range-value {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 14px;
}

.layout-choice {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layout-choice legend {
  width: 100%;
  margin-bottom: 2px;
}

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

.layout-card {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 400;
  letter-spacing: 0;
}

.layout-card:hover {
  border-color: var(--ink);
}

.layout-card:has(input:checked) {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.layout-card > input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.layout-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 210 / 297;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f5f5f2;
}

.layout-card-name {
  display: block;
  margin-top: 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
}

@media (max-width: 799px) {
  .layout-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 479px) {
  .layout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .layout-card {
    padding: 5px;
  }
  .layout-card-name {
    font-size: 12px;
  }
}

.photo-item {
  grid-template-columns: 64px 1fr auto auto;
}

.photo-item input:not([type]) {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  min-width: 0;
}

/* 390px：縮圖＋主圖＋移除一列，圖說輸入框獨立一整列，不會擠到只剩幾個字寬 */
@media (max-width: 479px) {
  .photo-item {
    grid-template-columns: 64px 1fr auto;
    grid-template-areas: 'img radio del' 'cap cap cap';
  }
  .photo-item > img {
    grid-area: img;
  }
  .photo-item > input {
    grid-area: cap;
    width: 100%;
  }
  .photo-item > .radio {
    grid-area: radio;
  }
  .photo-item > .btn {
    grid-area: del;
  }
}

.video-list {
  padding-left: 1.2em;
  font-size: 14px;
}

.video-list li {
  margin: 4px 0;
}

.video-list button {
  margin-left: 8px;
}

progress {
  width: 100%;
}

.material-list {
  display: grid;
  gap: 14px;
}

.material-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.material-title {
  font-size: 17px;
  margin: 4px 0;
}

.material-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.8;
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.thumbs img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--line);
}

.generate-actions {
  margin: 8px 0 12px;
}

.report-stats {
  font-size: 14px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.report-stats:empty {
  display: none;
}

.a4-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 12px 0;
}

.a4-page {
  margin: 0;
}

.a4-page img {
  display: block;
  width: 100%;
  aspect-ratio: 210 / 297;
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(22, 50, 79, 0.1);
  background: #fff;
}

.a4-page figcaption {
  margin-top: 8px;
  text-align: center;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

dialog.dialog,
.dialog {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  max-width: 560px;
  width: calc(100% - 32px);
  max-height: 85vh;
  overflow: auto;
}

dialog.dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.dialog-message {
  white-space: pre-wrap;
  margin: 0 0 12px;
}

.dialog-input {
  width: 100%;
}

.video-pick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.video-pick-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.hint.warning {
  color: #7a5b00;
  background: #fff3c4;
  border: 1px solid #e6c200;
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 8px;
}

.output-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.output-preview {
  max-width: 100%;
  max-height: 65vh;
}

.output-preview-frame {
  width: 100%;
  height: 65vh;
  border: 1px solid var(--line);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--card);
  margin-bottom: 16px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  overflow-wrap: anywhere;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.inline-form .field {
  flex: 1 1 220px;
}

.inline-form > .btn {
  margin-bottom: 14px;
}

/* ---------- 使用教學（導覽）：深藍／金色、高對比 ---------- */
.tour-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.tour-blocker {
  position: fixed;
  inset: 0;
}
.tour-root.no-target .tour-blocker {
  background: rgba(6, 16, 30, 0.78);
}
.tour-hole {
  position: fixed;
  border: 3px solid #c9a865;
  border-radius: 10px;
  box-shadow: 0 0 0 200vmax rgba(6, 16, 30, 0.78), 0 0 0 6px rgba(201, 168, 101, 0.35);
  pointer-events: none;
  transition: left 0.2s ease, top 0.2s ease, width 0.2s ease, height 0.2s ease;
}
.tour-bubble {
  position: fixed;
  box-sizing: border-box;
  width: 380px;
  max-width: calc(100vw - 24px);
  padding: 16px 18px 14px;
  background: #16324f;
  color: #ffffff;
  border: 2px solid #c9a865;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  line-height: 1.7;
  outline: none;
}
.tour-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.tour-count {
  color: #e6cf98;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
}
.tour-title {
  margin: 0 0 6px;
  color: #e6cf98;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
}
.tour-text {
  margin: 0;
  font-size: 16px;
  color: #ffffff;
}
.tour-note {
  margin: 8px 0 0;
  font-size: 14px;
  color: #e6cf98;
}
.tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.tour-btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 2px solid #ffffff;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.tour-btn.primary {
  background: #c9a865;
  border-color: #c9a865;
  color: #0d2136;
}
.tour-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.tour-btn:focus-visible,
.tour-skip:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}
.tour-skip {
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 15px;
  text-decoration: underline;
  cursor: pointer;
}
.tour-toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  /* width: max-content 避免 left:50% 只剩半個視窗可排，文字被擠成直排 */
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 12px;
  width: max-content;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  padding: 12px 16px;
  background: #f7f1e4;
  color: #16324f;
  border: 2px solid #c9a865;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(13, 33, 54, 0.28);
  font-weight: 700;
}
.tour-toast > span {
  flex: 1 1 auto;
  text-align: center;
}
.tour-toast-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
}
.tour-toast .tour-btn,
.tour-toast .tour-skip {
  flex-shrink: 0;
  white-space: nowrap;
}
.tour-toast .tour-skip {
  color: #16324f;
}
.tour-toast .tour-btn:focus-visible,
.tour-toast .tour-skip:focus-visible {
  outline-color: #16324f;
}
@media (prefers-reduced-motion: reduce) {
  .tour-hole {
    transition: none;
  }
}

/* ---------- v3：協作者分列輸入、常用聯絡人 ---------- */
.collab-rows {
  display: grid;
  gap: 8px;
}

.collab-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) auto;
  gap: 8px;
  align-items: center;
}

.collab-row input {
  min-width: 0;
}

.collab-editor .actions {
  margin: 8px 0 4px;
}

.contacts-box {
  margin: 6px 0 14px;
}

.contacts-box > .label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.contact-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-wrap {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  overflow: hidden;
}

.chip-wrap:hover {
  border-color: var(--gold-light);
}

.contact-chip {
  font: inherit;
  font-size: 13px;
  border: 0;
  border-radius: 0;
  padding: 6px 4px 6px 12px;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  max-width: 260px;
}

.contact-chip b {
  font-weight: 600;
}

.chip-email {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-x {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 10px 0 6px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.chip-x:hover {
  color: #b42318;
}

.row-actions {
  white-space: nowrap;
}

.row-actions .btn + .btn {
  margin-left: 6px;
}

/* ---------- v3：行動錄音與逐字稿 ---------- */
.recordings {
  margin: 18px 0;
}

.recordings h2 {
  margin-top: 0;
}

.notice {
  font-size: 14px;
  background: #fbf6ea;
  border: 1px solid var(--gold-light);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.transcribe-progress {
  background: #fbfaf6;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 14px;
}

.transcribe-progress progress {
  margin: 6px 0;
}

.transcribe-progress .hint {
  display: block;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.paste-transcript,
.rules-box {
  margin: 12px 0;
}

.paste-transcript > summary,
.rules-box > summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--link);
  padding: 6px 0;
}

.recording-list {
  display: grid;
  gap: 12px;
  margin: 12px 0;
}

.recording-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.recording-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.recording-head .hint {
  font-variant-numeric: tabular-nums;
}

.recording-detail {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

textarea.transcript {
  font-size: 14px;
  line-height: 1.8;
  min-height: 12em;
}

.rules-editor {
  margin-top: 8px;
}

.rep-rows {
  display: grid;
  gap: 6px;
  margin-bottom: 6px;
}

.rep-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.rep-row input {
  min-width: 0;
}

.rep-row .arrow {
  color: var(--muted);
}

@media (max-width: 479px) {
  .collab-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .collab-row input[name='collab-name'] {
    grid-column: 1;
    grid-row: 2;
  }

  .collab-row .btn {
    grid-row: 1 / span 2;
  }
}

.table td[data-testid='member-name'] {
  white-space: nowrap;
}

/* 載入中的佔位（行動頁先出外框，素材陸續載入） */
.skeleton {
  height: 72px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #ece9e1 0%, #f6f4ee 50%, #ece9e1 100%);
  background-size: 200% 100%;
  animation: skeleton 1.2s ease-in-out infinite;
  margin: 12px 0;
}

.skeleton.short {
  height: 40px;
  width: 60%;
}

@keyframes skeleton {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

form[aria-busy='true'] button[type='submit'],
button[aria-busy='true'] {
  cursor: progress;
  opacity: 0.7;
}

.danger-zone {
  margin-top: 28px;
  border-color: #f0c8c4;
}

.danger-zone h2 {
  margin-top: 0;
  font-size: 18px;
  color: #b42318;
}

/* 素材表單：標題右邊選類型；素材依類別分組，每組下面「＋ 再新增一篇」 */
.material-form-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 8px;
}

.material-form-head h2 {
  margin: 0;
}

.kind-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.kind-picker .label {
  font-size: 13px;
  color: var(--muted);
}

.kind-picker select {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  width: auto;
  min-width: 108px;
}

.material-group {
  margin: 0 0 24px;
}

.material-group-title {
  font-size: 17px;
  margin: 8px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.material-group > .material-card + .material-card {
  margin-top: 12px;
}

.add-same-kind {
  margin-top: 12px;
  width: 100%;
  border-style: dashed;
}

.site-footer .footer-version {
  font-size: 12px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* 總管理者選取模式 */
.select-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 12px;
  margin: 0 0 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.select-toolbar .select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.select-count {
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: auto;
}

.action-card.selectable {
  position: relative;
  cursor: pointer;
  padding-left: 44px;
}

.action-card.selectable .select-box {
  position: absolute;
  left: 16px;
  top: 22px;
  width: 18px;
  height: 18px;
  accent-color: var(--navy, #1f2d4a);
}

.action-card.selected {
  border-color: var(--gold-light);
  box-shadow: 0 0 0 2px var(--gold-light) inset;
}

.card-owner {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* 單位／區域編輯器 */
.unit-rows {
  display: grid;
  gap: 6px;
  margin: 6px 0;
}

.unit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 6px;
  align-items: center;
}

.unit-row input {
  min-width: 0;
}

.kind-pickers {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.unit-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--navy, #16324f);
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}

/* 生成報導：依單位分組勾選 */
.pick-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin: 8px 0;
}

.pick-group-head {
  font-size: 15px;
}

.pick-group-items {
  padding-left: 26px;
}

/* A4 頁面安排 */
.plan-mode {
  display: grid;
  gap: 4px;
}

.plan-rows {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.plan-row {
  display: grid;
  grid-template-columns: 5em minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  background: #fbfaf6;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.plan-page {
  font-weight: 700;
  padding-top: 5px;
  font-variant-numeric: tabular-nums;
}

.plan-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.plan-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.plan-chip.on {
  background: var(--navy, #16324f);
  border-color: var(--navy, #16324f);
  color: #fff;
}

.plan-chip:focus-within {
  outline: 2px solid var(--gold-light);
  outline-offset: 2px;
}

.plan-warn:not(:empty) {
  color: #b42318;
}

/* ---- 使用說明（#/help） ---- */
.help-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 20px;
}
.help-toc-link {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.help-toc-link:hover {
  border-color: var(--gold-light);
}
.help-section {
  scroll-margin-top: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
}
.help-section h2 {
  font-size: 20px;
  margin: 8px 0;
}
.help-section ul {
  margin: 0;
  padding-left: 1.3em;
  line-height: 1.8;
}


/* 生成頁：網頁報導／A4 圖檔分頁 */
.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.mode-tabs .tab {
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 18px;
}

.mode-tabs .tab.active,
.mode-tabs .tab[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.mode-panel[hidden] {
  display: none;
}

.public-link {
  display: inline-block;
  margin-left: 8px;
  font-size: 13px;
  word-break: break-all;
}

.public-frame {
  min-height: 70vh;
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
}

.outputs-list {
  display: grid;
  gap: 8px;
}

.output-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.output-kind {
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.a4-page canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 210 / 297;
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(22, 50, 79, 0.1);
  background: #fff;
}

.a4-page-no {
  display: inline-block;
  margin-right: 8px;
}

.settings-a4 {
  margin-bottom: 12px;
}



/* A4 拖拉編輯器：預覽改為單欄可操作頁面，不再用縮圖格 */
.a4-pages.a4-editor,
.a4-pages.a4-pages-editor-host {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  grid-template-columns: none;
}

.a4-pages-editor-host { width: 100%; }
.a4-editor { outline: none; }
.a4-editor-toolbar { display: flex; gap: 8px; justify-content: flex-start; width: 100%; margin: 0 0 12px; }
.a4-editor-toolbar .btn { min-width: 72px; }
.a4-editor-toolbar .btn:disabled { opacity: 0.45; cursor: default; }
.a4-editor-pages { display: flex; flex-direction: column; gap: 28px; align-items: stretch; width: 100%; }
.a4-editor-figure { margin: 0; width: 100%; }
.a4-editor-page { position: relative; width: 100%; margin: 0 auto; background: #fff; box-shadow: 0 2px 16px rgba(31, 45, 61, 0.14); border: 1px solid #E4E3DE; overflow: hidden; touch-action: none; }
.a4-editor-canvas { display: block; width: 100%; height: 100%; }
.a4-overlay { position: absolute; inset: 0; }
.a4-frame { position: absolute; box-sizing: border-box; border: 1px dashed transparent; cursor: move; touch-action: none; }
.a4-frame:hover { border-color: #7FB3D5; }
.a4-frame.selected { border: 2px solid #2F6DA3; background: rgba(47, 109, 163, 0.06); }
.a4-frame.is-locked { cursor: default; }
.a4-frame.is-locked.selected { border-color: #5A6A7A; background: rgba(90, 106, 122, 0.08); }
.a4-frame-image { cursor: move; }
.a4-frame-title, .a4-frame-text, .a4-frame-caption, .a4-frame-meta { cursor: move; }
.a4-handle { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid #2F6DA3; border-radius: 50%; box-sizing: border-box; z-index: 5; }
/* 熱區主要向外擴，避免矮框（標題）被南北控制點吃掉而無法拖曳 */
.a4-handle::after { content: ""; position: absolute; }
.a4-handle-n::after { top: -18px; left: -18px; right: -18px; height: 28px; }
.a4-handle-s::after { bottom: -18px; left: -18px; right: -18px; height: 28px; }
.a4-handle-e::after { right: -18px; top: -18px; bottom: -18px; width: 28px; }
.a4-handle-w::after { left: -18px; top: -18px; bottom: -18px; width: 28px; }
.a4-handle-nw::after, .a4-handle-ne::after, .a4-handle-se::after, .a4-handle-sw::after { width: 28px; height: 28px; }
.a4-handle-nw::after { right: auto; bottom: auto; left: -18px; top: -18px; }
.a4-handle-ne::after { left: auto; bottom: auto; right: -18px; top: -18px; }
.a4-handle-se::after { left: auto; top: auto; right: -18px; bottom: -18px; }
.a4-handle-sw::after { right: auto; top: auto; left: -18px; bottom: -18px; }
.a4-handle-nw { left: -7px; top: -7px; cursor: nwse-resize; }
.a4-handle-n { left: calc(50% - 7px); top: -7px; cursor: ns-resize; }
.a4-handle-ne { right: -7px; top: -7px; cursor: nesw-resize; }
.a4-handle-e { right: -7px; top: calc(50% - 7px); cursor: ew-resize; }
.a4-handle-se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.a4-handle-s { left: calc(50% - 7px); bottom: -7px; cursor: ns-resize; }
.a4-handle-sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.a4-handle-w { left: -7px; top: calc(50% - 7px); cursor: ew-resize; }
.a4-guide-v { position: absolute; top: 0; bottom: 0; width: 1px; background: #C0392B; z-index: 6; pointer-events: none; }
.a4-guide-h { position: absolute; left: 0; right: 0; height: 1px; background: #C0392B; z-index: 6; pointer-events: none; }
.a4-text-editor { position: absolute; z-index: 8; box-sizing: border-box; padding: 6px; font: 400 16px/1.6 "Noto Sans TC", sans-serif; color: #1F2D3D; background: #fff; border: 2px solid #2F6DA3; border-radius: 4px; resize: none; outline: none; }
.a4-crop { position: absolute; overflow: hidden; border: 2px solid #2F6DA3; box-sizing: border-box; z-index: 7; cursor: move; touch-action: none; }
.a4-crop-img { position: absolute; max-width: none; user-select: none; pointer-events: none; }
.a4-crop-hint { position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 6px 8px; font-size: 13px; line-height: 1.5; color: #fff; background: rgba(22, 50, 79, 0.85); border-radius: 4px; text-align: center; pointer-events: none; }
.a4-editor-caption { margin-top: 8px; font-size: 13px; color: #5A6A7A; text-align: center; }
.a4-page-actions { display: flex; gap: 8px; margin: 8px 0 4px; flex-wrap: wrap; }
@media (pointer: coarse) {
  .a4-handle { width: 22px; height: 22px; }
  .a4-handle-nw { left: -11px; top: -11px; }
  .a4-handle-n { left: calc(50% - 11px); top: -11px; }
  .a4-handle-ne { right: -11px; top: -11px; }
  .a4-handle-e { right: -11px; top: calc(50% - 11px); }
  .a4-handle-se { right: -11px; bottom: -11px; }
  .a4-handle-s { left: calc(50% - 11px); bottom: -11px; }
  .a4-handle-sw { left: -11px; bottom: -11px; }
  .a4-handle-w { left: -11px; top: calc(50% - 11px); }
  .a4-handle-n::after, .a4-handle-s::after { height: 44px; }
  .a4-handle-e::after, .a4-handle-w::after { width: 44px; }
  .a4-handle-nw::after, .a4-handle-ne::after, .a4-handle-se::after, .a4-handle-sw::after { width: 44px; height: 44px; }
  .a4-handle-n::after { top: -30px; }
  .a4-handle-s::after { bottom: -30px; }
  .a4-handle-e::after { right: -30px; }
  .a4-handle-w::after { left: -30px; }
  .a4-handle-nw::after { left: -30px; top: -30px; }
  .a4-handle-ne::after { right: -30px; top: -30px; }
  .a4-handle-se::after { right: -30px; bottom: -30px; }
  .a4-handle-sw::after { left: -30px; bottom: -30px; }
  .a4-editor-page { touch-action: none; }
}
@media (max-width: 640px) {
  .a4-editor-pages { gap: 20px; }
  .a4-text-editor { font-size: 16px; }
}

.theme-choice {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 400;
  letter-spacing: 0;
}
.theme-card:hover { border-color: var(--ink); }
.theme-card:has(input:checked) {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
.theme-card > input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.theme-thumb {
  display: block;
  width: 100%;
  height: 56px;
  border: 1px solid var(--c-line, var(--line));
  border-radius: 4px;
  background-color: var(--c-bg, #fff);
  position: relative;
  overflow: hidden;
}
.theme-thumb::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 16px;
  background: var(--c-navy);
}
.theme-thumb::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 22px;
  height: 3px;
  background: var(--c-gold-light);
  border-radius: 1px;
}
.theme-thumb[data-pattern="dots"] {
  background-image: radial-gradient(var(--c-line) 1px, transparent 1.4px);
  background-size: 8px 8px;
}
.theme-thumb[data-pattern="grid"] {
  background-image: linear-gradient(var(--c-line) 1px, transparent 1px), linear-gradient(90deg, var(--c-line) 1px, transparent 1px);
  background-size: 10px 10px;
}
.theme-thumb[data-pattern="lines"] {
  background-image: repeating-linear-gradient(0deg, transparent 0 6px, var(--c-line) 6px 7px);
}
.theme-thumb[data-pattern="paper"] {
  background-image: repeating-linear-gradient(0deg, transparent 0 3px, var(--c-paper) 3px 4px);
}
.theme-thumb[data-pattern="frame"] {
  box-shadow: inset 0 0 0 2px var(--c-gold-light), inset 0 0 0 4px var(--c-line);
}
.theme-thumb[data-pattern="corner"]::after {
  background: transparent;
  box-shadow: inset 8px 0 0 -6px var(--c-gold), inset 0 8px 0 -6px var(--c-gold);
  height: auto;
  bottom: 6px;
  top: 20px;
  left: 6px;
  right: 6px;
}
.theme-thumb[data-pattern="doubleRule"]::after {
  height: 2px;
  box-shadow: 0 4px 0 0 var(--c-gold);
}
.theme-thumb[data-pattern="none"]::after { opacity: 0.35; }
.theme-card-name {
  display: block;
  margin-top: 5px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}
@media (max-width: 799px) {
  .theme-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 479px) {
  .theme-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .theme-card-name { font-size: 12px; }
}

/* ---------- 回應式修正：窄螢幕觸控、輸入字級、協作者卡片 ---------- */
@media (max-width: 639px) {
  /* 放在所有輸入框規則之後，避免被 13px 蓋掉；iOS 才不會點選時放大畫面 */
  .field input,
  .field select,
  .field textarea,
  .material-form input,
  .photo-item input:not([type]),
  .photo-item input[type="text"],
  .collab-row input,
  .inline-form input {
    font-size: 16px;
  }

  /* 頂列「使用教學／使用說明／登出」與列表「編輯／刪除」至少 40px */
  .app-bar .btn,
  .app-user .btn,
  .material-card .btn,
  .row-actions .btn,
  .btn.small {
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* 協作者表改為卡片，Email 與權限完整可見 */
  .members-scroll {
    overflow-x: visible;
  }
  .members-scroll .table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 10px;
    background: transparent;
  }
  .members-scroll thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .members-scroll tbody,
  .members-scroll tr,
  .members-scroll td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  .members-scroll tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 14px;
  }
  .members-scroll td {
    border-bottom: 0;
    padding: 6px 0;
    display: grid;
    grid-template-columns: 4.5em 1fr;
    gap: 8px;
    align-items: start;
    overflow-wrap: anywhere;
  }
  .members-scroll td::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 1px;
  }
  .members-scroll td[data-testid='member-name'] {
    white-space: normal;
  }
  .members-scroll td.row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
  }
  .members-scroll td.row-actions::before {
    flex: none;
    padding: 0;
  }
}
