:root {
  --orange: #ED7100;
  --orange-deep: #C45D00;
  --gold: #FBC600;
  --gold-soft: #F8B500;
  --navy: #1B3A6B;
  --ink: #222222;
  --ink-soft: #555555;
  --ink-mute: #8a8a8a;
  --cream: #FAF7F2;
  --paper: #ffffff;
  --line: rgba(34, 34, 34, 0.10);
  --shadow: 0 8px 28px rgba(34, 34, 34, 0.10);
  --shadow-lift: 0 18px 50px rgba(34, 34, 34, 0.25);
}

/* ==============================
   編輯模式浮動工具列
   ============================== */
.edit-toolbar {
  position: fixed;
  top: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: rgba(34, 34, 34, 0.96);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(251, 198, 0, 0.35);
  font-size: 0.85rem;
  max-width: 95vw;
  flex-wrap: wrap;
  justify-content: center;
}
.edit-toolbar .edit-badge {
  background: linear-gradient(135deg, #ED7100, #FBC600);
  color: #222;
  padding: 0.25em 0.8em;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 0.85em;
  white-space: nowrap;
}
.edit-toolbar button {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 0.35em 0.85em;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85em;
  transition: all 0.15s;
  white-space: nowrap;
}
.edit-toolbar button:hover {
  background: #ED7100;
  border-color: #ED7100;
}
.edit-toolbar .edit-hint {
  color: rgba(255,255,255,0.6);
  font-size: 0.8em;
  margin-left: 0.4rem;
  white-space: nowrap;
}
body.edit-mode { padding-top: 3.5rem; }
.editable-field {
  outline: 2px dashed rgba(237, 113, 0, 0);
  outline-offset: 3px;
  border-radius: 4px;
  transition: outline-color 0.15s, background 0.15s;
  cursor: text;
}
.editable-field:hover {
  outline-color: rgba(237, 113, 0, 0.4);
  background: rgba(251, 198, 0, 0.08);
}
.editable-field:focus {
  outline: 2px solid #ED7100;
  background: rgba(251, 198, 0, 0.15);
}

/* 編輯模式：Modal 底部快速調整面板 */
.edit-quick-panel {
  background: linear-gradient(135deg, rgba(237, 113, 0, 0.06), rgba(251, 198, 0, 0.08));
  border-top: 2px dashed rgba(237, 113, 0, 0.35);
  padding: 0.9rem 1.2rem 1.1rem;
  font-size: 0.85rem;
}
.edit-quick-title {
  font-weight: 700;
  color: #ED7100;
  letter-spacing: 2px;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
}
.edit-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.6rem 0.9rem;
  margin-bottom: 0.7rem;
}
.edit-quick-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: #555;
  font-weight: 600;
}
.edit-quick-grid select,
.edit-quick-grid input {
  padding: 0.35em 0.55em;
  border: 1.5px solid rgba(237, 113, 0, 0.25);
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  font-size: 0.9em;
  color: #222;
  cursor: pointer;
}
.edit-quick-grid select:focus,
.edit-quick-grid input:focus {
  outline: 2px solid #ED7100;
  border-color: #ED7100;
}
.edit-danger-btn {
  background: rgba(200, 40, 40, 0.08);
  color: #c02828;
  border: 1.5px solid rgba(200, 40, 40, 0.3);
  padding: 0.4em 0.9em;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.8em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.edit-danger-btn:hover {
  background: #c02828;
  color: #fff;
}

/* 新增學員浮動按鈕（右下角） */
.add-student-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  background: linear-gradient(135deg, #ED7100, #FBC600);
  color: #fff;
  border: none;
  padding: 0.85em 1.4em;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(237, 113, 0, 0.4);
  transition: all 0.2s;
}
.add-student-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(237, 113, 0, 0.5);
}

/* 編輯模式提示：tab 和桌名可雙擊改 */
body.edit-mode .cat-tab:not([data-cat="all"]) {
  cursor: text;
  position: relative;
}
body.edit-mode .cat-tab:not([data-cat="all"])::after {
  content: "✏️";
  font-size: 0.7em;
  opacity: 0.4;
  margin-left: 0.3em;
}
body.edit-mode .seat-table-name {
  cursor: text;
}

/* ==============================
   View 切換 tab（學員名冊 / 座位表）
   ============================== */
.view-tabs {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
}
.view-tab {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.7rem 1.8rem;
  font-size: 1rem;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 1.5px;
  transition: all 0.2s;
}
.view-tab:hover {
  border-color: var(--orange);
  color: var(--orange);
}
.view-tab.active {
  background: linear-gradient(135deg, var(--orange), var(--gold));
  color: #fff;
  border-color: var(--orange);
  box-shadow: 0 4px 14px rgba(237,113,0,0.3);
}

/* ==============================
   座位表頁面
   ============================== */
.seat-view {
  background: linear-gradient(180deg, var(--cream) 0%, #fff 60%);
  padding: 0.6rem 0.5rem 0.8rem;
  border-radius: 16px;
  margin-top: 0.3rem;
}
.seat-title {
  text-align: center;
  font-size: 1.15rem;
  color: var(--orange);
  font-weight: 700;
  letter-spacing: 3px;
  margin-bottom: 0.15rem;
}
.seat-subtitle {
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-mute);
  margin-bottom: 0.5rem;
  letter-spacing: 2px;
}
/* 教室佈局：桌子繞講台呈環狀，用絕對定位 */
.seat-classroom {
  position: relative;
  width: 100%;
  height: calc(100vh - 12rem);
  max-height: 60rem;
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(237, 113, 0, 0.02) 0%, rgba(251, 198, 0, 0.03) 100%);
  border: 2px dashed rgba(237, 113, 0, 0.15);
  border-radius: 16px;
  padding: 0.5rem;
}

/* 講台（永遠在正下方） */
.seat-stage {
  position: absolute;
  bottom: 2%;
  left: 50%;
  transform: translateX(-50%);
  width: 28%;
  background: linear-gradient(135deg, #1a1a1a, #333);
  color: var(--gold);
  padding: 0.5rem 0.8rem;
  text-align: center;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 5px;
  border: 2px solid var(--gold);
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

.seat-table {
  position: absolute;
  background: transparent;
  transition: all 0.2s;
  width: 30%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto auto;
  gap: 0.25rem 0.4rem;
  align-items: stretch;
  justify-items: stretch;
}

/* 上方短邊 & 下方短邊：橫排跨欄 */
.seat-slot-top,
.seat-slot-bottom {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
  align-items: center;
}
.seat-slot-top    { grid-row: 1; }
.seat-slot-bottom { grid-row: 3; }

/* 左右兩側直向容器 */
.seat-slot-left {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  justify-content: center;
  align-items: flex-end;
  padding-right: 0.15rem;
}
.seat-slot-right {
  grid-column: 3;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  justify-content: center;
  align-items: flex-start;
  padding-left: 0.15rem;
}
.seat-table:hover {
  border-color: var(--orange);
  box-shadow: 0 8px 24px rgba(237,113,0,0.15);
  z-index: 2;
}

/* 8 張桌子絕對位置（照原圖真實佈局） */
/* 上排：療癒租茶(左上) / 鉅瑋(右上)，中間留空 */
.seat-table[data-position="top-left"]    { top:  2%; left:  2%; }
.seat-table[data-position="top-right"]   { top:  2%; right: 2%; }
/* 和計生財 在中央偏上 */
.seat-table[data-position="top-center"]  { top: 22%; left: 36%; }
/* 中排：Money(左中) / 88 瘦(右中) */
.seat-table[data-position="middle-left"] { top: 40%; left:  2%; }
.seat-table[data-position="middle-right"]{ top: 40%; right: 2%; }
/* 現金王 在正中央 */
.seat-table[data-position="middle-center"]{top: 55%; left: 36%; }
/* 下排：郡一隊(左下) / 豐收(右下)，中間留給講台 */
.seat-table[data-position="bottom-left"] { top: 72%; left:  2%; }
.seat-table[data-position="bottom-right"]{ top: 72%; right: 2%; }

.seat-table-name {
  grid-column: 2;
  grid-row: 2;
  align-self: stretch;
  background: linear-gradient(135deg, var(--ink) 0%, #1a1a1a 100%);
  color: var(--gold);
  padding: 0.9rem 0.4rem;
  border-radius: 5px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 4px;
  border: 2px solid var(--orange);
  writing-mode: vertical-rl;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  min-width: 2.2rem;
}
.seat-member {
  display: inline-flex;
  align-items: center;
  gap: 0.15em;
  background: var(--paper);
  color: var(--ink);
  padding: 0.2em 0.55em;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1.5px solid rgba(237,113,0,0.35);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  line-height: 1.15;
}
.seat-member:hover {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
  transform: scale(1.08);
}
.seat-member.no-photo {
  opacity: 0.6;
  font-style: italic;
}
.seat-member .seat-nickname {
  font-size: 0.75em;
  color: var(--orange);
  font-weight: 700;
  margin-right: 0.15em;
}
.seat-member:hover .seat-nickname { color: var(--gold); }

@media (max-width: 900px) {
  .seat-classroom { aspect-ratio: 2 / 3; }
  .seat-table { width: 30%; }
  .seat-member { font-size: 0.65rem; padding: 0.2em 0.45em; }
  .seat-table-name { font-size: 0.8rem; letter-spacing: 1px; }
}
@media (max-width: 640px) {
  .seat-classroom {
    aspect-ratio: auto;
    padding: 0.5rem;
  }
  .seat-table {
    position: static;
    width: 100%;
    margin-bottom: 0.7rem;
  }
  .seat-stage {
    position: static;
    transform: none;
    width: auto;
    margin: 0.5rem 0;
  }
  .seat-member { font-size: 0.85rem; padding: 0.35em 0.75em; }
  .seat-table-name { font-size: 1rem; letter-spacing: 3px; }
}

/* ==============================
   根字級 — 斷點式自動放大
   手機 15 / 平板 16 / MacBook 17 / 大螢幕 20
   ============================== */
html {
  font-size: 16px;
}
@media (min-width: 1024px) { html { font-size: 17px; } }
@media (min-width: 1600px) { html { font-size: 19px; } }
@media (min-width: 2000px) { html { font-size: 21px; } }
@media (max-width: 480px)  { html { font-size: 15px; } }


* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Montserrat", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  line-height: 1.7;
  font-size: 1rem;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ===== 封面 ===== */
.cover {
  background:
    radial-gradient(ellipse at top right, rgba(237, 113, 0, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at bottom left, rgba(251, 198, 0, 0.12) 0%, transparent 55%),
    linear-gradient(135deg, #1a1a1a 0%, #222 100%);
  color: var(--cream);
  padding: 3.5rem 2.5rem 3rem;
}

.cover-inner {
  max-width: 100rem;
  margin: 0 auto;
  text-align: center;
}

.cover-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  letter-spacing: 4px;
  color: var(--gold);
  margin-bottom: 1.2rem;
  padding: 0.4rem 1.2rem;
  border: 1px solid rgba(251, 198, 0, 0.4);
  border-radius: 999px;
  text-transform: uppercase;
}

.cover-date {
  display: inline-block;
  font-size: 1.6rem;
  letter-spacing: 6px;
  color: var(--gold);
  border-top: 1px solid rgba(251, 198, 0, 0.3);
  border-bottom: 1px solid rgba(251, 198, 0, 0.3);
  padding: 0.7rem 2rem;
  margin-bottom: 1.8rem;
  font-weight: 300;
}

.cover-title {
  font-size: clamp(2.5rem, 5.5vw, 5rem);
  letter-spacing: 6px;
  font-weight: 700;
  margin-bottom: 0.9rem;
  color: #fff;
  text-shadow: 0 2px 24px rgba(237, 113, 0, 0.3);
}

.cover-subtitle {
  font-size: 1.3rem;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 3px;
  margin-bottom: 2.2rem;
}

.cover-meta {
  display: inline-flex;
  gap: 2.2rem;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 2px;
  flex-wrap: wrap;
  justify-content: center;
}

.cover-meta span strong {
  color: var(--orange);
  font-weight: 700;
  margin-right: 0.4rem;
  font-size: 1.35rem;
}

/* ===== 主體 ===== */
.main {
  max-width: 100rem;
  margin: 0 auto;
  padding: 2.2rem 2.5rem 5rem;
}

/* ===== 分類 tabs ===== */
.cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 2rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
  justify-content: center;
}

.cat-tab {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 0.6rem 1.4rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
  cursor: pointer;
  letter-spacing: 1.5px;
  transition: all 0.2s;
  font-family: inherit;
  font-weight: 500;
}

.cat-tab:hover {
  border-color: var(--orange);
  color: var(--orange);
  transform: translateY(-1px);
}

.cat-tab.active {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
  box-shadow: 0 4px 14px rgba(237, 113, 0, 0.3);
}

.cat-tab .count {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.85rem;
  opacity: 0.85;
  font-weight: 600;
}

/* ===== 學員卡網格 ===== */
.cat-section { margin-bottom: 3.2rem; }

.cat-heading {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin-bottom: 1.4rem;
  padding-bottom: 0.7rem;
  border-bottom: 2px solid var(--orange);
}

.cat-heading h2 {
  font-size: 1.7rem;
  color: var(--ink);
  letter-spacing: 2px;
  font-weight: 700;
}

.cat-heading .count {
  font-size: 1rem;
  color: var(--ink-mute);
  letter-spacing: 1px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1.1rem;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1rem 1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  position: relative;
  overflow: hidden;
  text-align: center;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--orange), var(--gold));
  opacity: 0;
  transition: opacity 0.2s;
}

.card:hover {
  border-color: var(--orange);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.card:hover::before { opacity: 1; }

.card-avatar {
  width: 6.5rem;
  height: 6.5rem;
  border-radius: 50%;
  overflow: hidden;
  background: var(--cream);
  border: 3px solid var(--gold);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(237, 113, 0, 0.15);
}

.card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
}

.card-avatar.no-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--orange);
  background: linear-gradient(135deg, rgba(237,113,0,0.08), rgba(251,198,0,0.12));
  font-weight: 700;
}

.card-no {
  font-size: 0.72rem;
  color: var(--orange);
  font-weight: 600;
  letter-spacing: 2px;
}

.card-family-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.82rem;
  background: linear-gradient(135deg, #C9A24B 0%, #B8892F 100%);
  color: #1B3A6B;
  padding: 0.35em 1em;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(184, 137, 47, 0.2);
}

.card-family-badge .fam-heart {
  color: #1B3A6B;
  font-size: 0.95em;
}

.card-family-badge .fam-sep {
  opacity: 0.5;
}

.card-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 1px;
  line-height: 1.3;
  word-break: break-word;
}

.card-name .nickname {
  display: block;
  font-size: 0.85rem;
  color: var(--orange);
  font-weight: 500;
  margin-top: 2px;
  letter-spacing: 1px;
}

.card-title {
  font-size: 0.78rem;
  color: var(--ink-mute);
  letter-spacing: 1px;
}

.card-company {
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.5;
  word-break: break-word;
  min-height: 2.6em;
}

/* 推薦人 chip — 統一寬度、統一高度 */
.card-referrer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  height: 2.2rem;
  font-size: 0.85rem;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-soft) 100%);
  color: #4a2f00;
  padding: 0 0.75rem;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: auto;
  line-height: 1.2;
  box-sizing: border-box;
  overflow: hidden;
}

.card-referrer .referrer-label {
  flex-shrink: 0;
  font-size: 0.65rem;
  background: rgba(74, 47, 0, 0.18);
  color: #4a2f00;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1;
}

.card-referrer .referrer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-weight: 700;
}

.card-referrer.empty {
  justify-content: center;
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink-mute);
  font-style: italic;
  font-weight: 400;
  font-size: 0.8rem;
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.7rem;
  z-index: 100;
  backdrop-filter: blur(6px);
}

.modal-backdrop.show { display: flex; }

.modal {
  background: var(--cream);
  border-radius: 16px;
  width: 92vw;
  max-width: 120rem;
  height: 92vh;
  max-height: calc(100vh - 24px);
  position: relative;
  box-shadow: var(--shadow-lift);
  border-top: 5px solid var(--orange);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#modal-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.modal-layout {
  display: grid;
  grid-template-columns: 22% 30% 48%;
  gap: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.modal-left {
  background: linear-gradient(160deg, #fff 0%, var(--cream) 100%);
  padding: 1.5em 1.2em;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.7em;
  overflow: hidden;
  min-height: 0;
}

.modal-middle {
  padding: 1.5em 1.3em;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.7em;
  overflow: hidden;
  min-height: 0;
  background: rgba(255, 255, 255, 0.4);
}

.modal-right {
  padding: 1.5em 1.3em;
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  font-size: 1.4rem;
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--orange);
  color: #fff;
  transform: rotate(90deg);
}

.modal-avatar {
  width: 12em;
  height: 12em;
  border-radius: 50%;
  overflow: hidden;
  background: var(--cream);
  border: 4px solid var(--gold);
  flex-shrink: 0;
  box-shadow: 0 8px 24px rgba(237, 113, 0, 0.25);
}

.modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
}

.modal-avatar.no-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5em;
  color: var(--orange);
  background: linear-gradient(135deg, rgba(237,113,0,0.08), rgba(251,198,0,0.12));
  font-weight: 700;
}

.modal-info {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.modal-no {
  font-size: 0.82rem;
  color: var(--orange);
  letter-spacing: 4px;
  font-weight: 700;
  padding: 0.3rem 0.85rem;
  background: rgba(237, 113, 0, 0.08);
  border-radius: 999px;
  white-space: nowrap;
}

.modal-name {
  font-size: 2.1rem;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
}

.modal-name .nickname {
  display: block;
  font-size: 1.3rem;
  color: var(--orange);
  font-weight: 600;
  margin: 0.4rem 0 0;
  letter-spacing: 1px;
}

.modal-birthday {
  font-size: 0.9rem;
  color: var(--ink-soft);
  letter-spacing: 1px;
  background: rgba(34, 34, 34, 0.06);
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
}

/* 中間公司區塊 */
.company-block {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
}

.family-tag {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.9em;
  background: linear-gradient(135deg, #FFE5B4 0%, #FFCC80 100%);
  color: #7a4a00;
  padding: 0.35em 0.85em;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid rgba(237, 113, 0, 0.25);
}

.company-label {
  font-size: 0.85rem;
  color: var(--orange);
  letter-spacing: 4px;
  font-weight: 700;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--orange);
}

.company-name {
  font-size: 1.5rem;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}

.company-title {
  font-size: 1rem;
  color: var(--ink-soft);
  font-weight: 500;
  margin-top: -0.35rem;
}

.company-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85em 1.1em;
  display: flex;
  flex-direction: column;
  gap: 0.4em;
}

.company-section-label {
  font-size: 0.78rem;
  color: var(--orange);
  letter-spacing: 2px;
  font-weight: 700;
}

.company-section-body {
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.65;
  word-break: break-word;
  font-weight: 500;
}

.company-section-body.referrer-body {
  color: #4a2f00;
  background: linear-gradient(135deg, rgba(251, 198, 0, 0.15), rgba(248, 181, 0, 0.12));
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  font-weight: 700;
}

.company-summary-section {
  background: linear-gradient(160deg, rgba(237, 113, 0, 0.04), rgba(251, 198, 0, 0.06));
  border-color: rgba(237, 113, 0, 0.15);
}

.company-summary-body {
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--ink);
  font-weight: 500;
}

.company-link-wrap {
  display: flex;
  justify-content: flex-start;
}

.company-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--orange-deep);
  border: 1.5px solid var(--orange);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}

.company-link:hover {
  background: var(--orange);
  color: #fff;
}

/* Q1 / Q2 / Q3 區塊 */
.qa-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85em 1em 0.85em 1.4em;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  position: relative;
  min-width: 0;
}

.qa-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 5px;
  height: 100%;
  background: linear-gradient(180deg, var(--orange), var(--gold));
  border-radius: 14px 0 0 14px;
}

.qa-label {
  font-size: 0.95rem;
  letter-spacing: 3px;
  color: var(--orange);
  font-weight: 700;
}

.qa-question {
  font-size: 1rem;
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: 0.3px;
  word-break: break-word;
  overflow-wrap: break-word;
}

.qa-answer {
  font-size: 1.15rem;
  color: var(--ink);
  line-height: 1.75;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  margin-top: 0.35rem;
  font-weight: 500;
}

.qa-answer .empty {
  color: var(--ink-mute);
  font-style: italic;
  font-weight: 400;
}

.modal-footer {
  padding: 0.9rem 2rem;
  background: #1a1a1a;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.8rem;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
}

.modal-footer .brand-orange { color: var(--orange); font-weight: 700; }

/* ==============================
   響應式斷點
   ============================== */

/* 平板直式 / 小螢幕 (< 1024px) — Modal 改成上下堆疊 */
@media (max-width: 1023px) {
  .modal { width: 96vw; height: 92vh; }
  .modal-layout { grid-template-columns: 1fr; }
  .modal-left {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 1.6rem 1.2rem;
  }
  .modal-middle {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 1.6rem 1.4rem;
  }
  .modal-right { padding: 1.6rem 1.4rem 2rem; }
  .modal-avatar { width: 10rem; height: 10rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
  .card-avatar { width: 5.5rem; height: 5.5rem; }
}

/* 手機 (< 640px) */
@media (max-width: 639px) {
  .main { padding: 1.5rem 1.2rem 3.5rem; }
  .cover { padding: 2.5rem 1.2rem 2rem; }
  .cover-title { font-size: 2.4rem; letter-spacing: 3px; }
  .cover-subtitle { font-size: 1rem; }
  .cover-date { font-size: 1.2rem; letter-spacing: 4px; padding: 0.5rem 1.3rem; }
  .cover-meta { flex-direction: column; gap: 0.6rem; }

  .cat-tabs { gap: 0.4rem; }
  .cat-tab { padding: 0.4rem 0.9rem; font-size: 0.8rem; }

  .grid { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
  .card { padding: 0.9rem 0.7rem; }
  .card-avatar { width: 4.5rem; height: 4.5rem; }
  .card-name { font-size: 1rem; }
  .card-company { font-size: 0.75rem; min-height: 2.2em; }
  .card-referrer { font-size: 0.75rem; height: 1.9rem; }
  .card-referrer .referrer-label { font-size: 0.6rem; padding: 0.15rem 0.4rem; }

  .modal-backdrop { padding: 0; }
  .modal { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  .modal-avatar { width: 8rem; height: 8rem; }
  .modal-name { font-size: 1.7rem; }
  .modal-name .nickname { font-size: 1.05rem; }
  .company-name { font-size: 1.25rem; }
  .modal-left { padding: 1.3rem 1rem; gap: 0.8rem; }
  .modal-middle { padding: 1.3rem 1rem; }
  .modal-right { padding: 1.3rem 1rem 1.6rem; }
  .qa-card { padding: 1rem 1rem 1rem 1.5rem; }
  .qa-answer { font-size: 1rem; }
}

/* ============ 0709 桃園活動：搜尋列 + O/M 標籤 + 雙欄 Modal ============ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin: 0 0 1.1rem;
}
#search-input {
  flex: 1;
  min-width: 240px;
  padding: 0.72rem 1.1rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(237, 113, 0, 0.15);
}
.role-filter {
  display: flex;
  gap: 0.4rem;
}
.role-chip {
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.role-chip:hover { border-color: var(--orange); color: var(--orange); }
.role-chip.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.card-role {
  display: inline-block;
  margin: 0.15rem auto 0.1rem;
  padding: 0.14rem 0.6rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-family: 'Montserrat', 'Noto Sans TC', sans-serif;
}
.card-role.role-o { background: rgba(237, 113, 0, 0.12); color: var(--orange-deep); }
.card-role.role-m { background: rgba(251, 198, 0, 0.22); color: #8a6d00; }

.modal-role {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.modal-role.role-o { background: rgba(237, 113, 0, 0.12); color: var(--orange-deep); }
.modal-role.role-m { background: rgba(251, 198, 0, 0.22); color: #8a6d00; }

/* 這場沒有 Q&A：Modal 改雙欄 */
.modal-layout.no-qa { grid-template-columns: 30% 70%; }
.modal-layout.no-qa .modal-middle { border-right: none; }

.no-result {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-mute);
  font-size: 1rem;
}

.seat-pending {
  text-align: center;
  padding: 4.5rem 1rem;
  color: var(--ink-soft);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 2.2;
  background: var(--paper);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.seat-pending small { font-size: 0.85rem; color: var(--ink-mute); font-weight: 400; }

@media (max-width: 640px) {
  .search-bar { gap: 0.5rem; }
  #search-input { min-width: 100%; }
}

/* 無 Q&A 時 Modal 縮成內容高度、窄版置中 */
.modal:has(.modal-layout.no-qa) {
  width: min(92vw, 880px);
  height: auto;
  max-height: 92vh;
}
.modal-layout.no-qa { grid-template-columns: 34% 66%; }
.modal-layout.no-qa .modal-left { padding: 2rem 1.4rem; }
.modal-layout.no-qa .modal-middle { padding: 2rem 1.8rem; }

/* 修正：無照片頭像的 em 基準會被自身 font-size 放大，改用 rem 固定尺寸 */
.modal-avatar.no-photo {
  width: 11rem;
  height: 11rem;
  font-size: 4rem;
}

/* 手機：無 Q&A Modal 改直排、可捲動 */
@media (max-width: 639px) {
  .modal:has(.modal-layout.no-qa) { overflow-y: auto; }
  .modal-layout.no-qa { grid-template-columns: 1fr; overflow: visible; }
  .modal-layout.no-qa .modal-left { border-right: none; overflow: visible; padding: 1.5rem 1rem 0.5rem; }
  .modal-layout.no-qa .modal-middle { overflow: visible; padding: 1rem 1.2rem 1.5rem; }
}

/* ============ 業務力風格：方正滿版大圖 ============ */
.card-avatar {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: none;
}
.card-avatar img { object-position: center top; }
.card-avatar.no-photo { font-size: 4.5rem; border-radius: 14px; }

.modal-avatar {
  width: 100%;
  max-width: 16rem;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  border: 3px solid var(--gold);
}
.modal-avatar.no-photo {
  width: 12rem;
  height: 12rem;
  border-radius: 16px;
  font-size: 4rem;
}

/* ============ 課堂式座位表（5 排 × 5 桌 × 3 人） ============ */
.seat-class-wrap {
  background: var(--paper);
  border-radius: 18px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.seat-stage-front {
  background: linear-gradient(135deg, var(--ink) 0%, #3a3a3a 100%);
  color: var(--gold);
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.5em;
  padding: 0.8rem;
  border-radius: 10px;
  margin-bottom: 1.4rem;
  border-bottom: 3px solid var(--orange);
}
.seat-class-grid {
  display: grid;
  gap: 0.7rem;
  min-width: 640px;
}
.seat-desk {
  background: var(--cream);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.55rem 0.6rem;
  min-height: 5.2rem;
}
.seat-desk.vacant { opacity: 0.55; }
.seat-desk-label {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-mute);
  margin-bottom: 0.35rem;
  letter-spacing: 0.05em;
}
.seat-desk-people {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.seat-person {
  display: block;
  background: var(--paper);
  border-radius: 6px;
  padding: 0.22rem 0.45rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat-person:hover { border-color: var(--orange); color: var(--orange-deep); }
.seat-person.empty {
  color: var(--ink-mute);
  text-align: center;
  cursor: default;
  background: transparent;
}
.seat-person.empty:hover { border-color: transparent; color: var(--ink-mute); }
.seat-person-nick {
  color: var(--orange);
  font-weight: 700;
  margin-right: 0.3em;
  font-size: 0.78em;
}
.seat-note {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-top: 1rem;
}
.seat-note.pending-note { color: var(--ink-mute); }
