/* 少年培力園 活動報名系統 —— 共用樣式（手機優先） */

/*
 * 配色取自少年培力園的識別標誌。
 *
 * 標誌上的顏色很多（那是一台孩子畫的飛機），所以不是全部照搬 ——
 * 而是照著它們在標誌裡的份量分工，整個網站才會像同一套東西：
 *
 *   綠  #009245  飛機機身、「園」字        → 主色（連結、頁首、主要按鈕）
 *   橘  #f7941d  「力」字                  → 重點色（報名、簽到這種主要動作）
 *   藍  #29abe2  螺旋槳、輪子、「少」字     → 次要色（提示、標記）
 *   紅  #e8332a  機翼與尾翼               → 危險（刪除、錯誤）
 *   深藍 #1b4f9c 「年」「培」字            → 深色文字與標題
 *
 * 紫色（「新北市」）跟黃色（花心）份量太小，只留在標誌本身，
 * 不拉進介面裡，免得整個網站變成調色盤。
 */
:root {
  /* 主色：機身與「園」字的綠 */
  --leaf-900: #0a3d2a;
  --leaf-700: #00753a;
  --leaf-600: #00893f;
  --leaf-500: #009245;
  --leaf-300: #8ed6a8;
  --leaf-50: #eaf7ee;

  /* 重點色：「力」字的橘，用在主要行動按鈕 */
  --sun: #f7941d;
  --sun-dark: #d97a08;
  --sun-ink: #402200;
  --sun-50: #fef3e4;

  /* 次要色：螺旋槳與「少」字的藍 */
  --sky: #29abe2;
  --sky-dark: #1b4f9c;
  --sky-50: #e8f6fd;

  --danger: #e8332a;
  --danger-bg: #fdeceb;
  --ok: #00893f;
  --ok-bg: #e7f6ec;

  --ink: #16281f;
  --ink-soft: #4c6055;
  --ink-faint: #7b8c82;
  --line: #dbe6de;
  --card: #ffffff;
  --bg: #f4f8f5;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 51, 31, .06), 0 8px 24px rgba(20, 51, 31, .07);
  --shadow-sm: 0 1px 2px rgba(20, 51, 31, .08);
}

* { box-sizing: border-box; }

/*
 * hidden 屬性要真的隱藏。
 * 瀏覽器預設的 [hidden]{display:none} 會被我們自己寫的 display（例如
 * .field 的 flex、.activity-list 的 grid）蓋掉，所以這裡統一補一條。
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", -apple-system,
    BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--leaf-700); }

/* ---------------------------------------------------------------- 版面 */

/*
 * 置中容器只管左右留白，不要用 padding 簡寫。
 * 這兩個 class 幾乎都掛在 <main> 上，簡寫會連帶把上下的 padding 歸零，
 * 把 main 自己的上下留白蓋掉（class 的優先度高過元素選擇器），
 * 結果標題整個貼在頁首色塊下緣。分成左右、上下兩軸各自負責就不會打架。
 */
.wrap { max-width: 880px; margin: 0 auto; padding-inline: 16px; }
.wrap-wide { max-width: 1240px; margin: 0 auto; padding-inline: 16px; }

.site-header {
  background: linear-gradient(135deg, var(--leaf-900), var(--leaf-500));
  color: #fff;
  padding: 18px 0;
  /* 手機上「更多」的面板要以整條頁首為基準攤開，所以這裡要是定位元素 */
  position: relative;
}
.site-header a { color: #fff; text-decoration: none; }
.site-header .bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: rgba(255, 255, 255, .18);
  display: grid; place-items: center; font-size: 1.1rem;
}
/*
 * 換成培力園的標誌之後：底色改白的，讓飛機在深綠頁首上看得清楚。
 * 圖檔本身已經是裁好的飛機（旁邊的文字已經寫了名稱，不必重複），
 * 所以這裡用 contain 完整顯示就好。
 */
.brand .mark-logo {
  width: 54px; height: 36px; border-radius: 8px;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.site-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.site-nav a {
  padding: 6px 12px; border-radius: 999px; font-size: .92rem;
  background: rgba(255, 255, 255, .12);
}
.site-nav a:hover { background: rgba(255, 255, 255, .24); }
.site-nav a[aria-current="page"] { background: #fff; color: var(--leaf-900); font-weight: 700; }

/*
 * 後台頁首的「更多」：不常用的頁面收在這裡面。
 * 用 details/summary 做，不必自己處理開關狀態與鍵盤操作。
 */
.nav-more { position: relative; }
.nav-more > summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 999px; font-size: .92rem;
  background: rgba(255, 255, 255, .12);
}
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary:hover { background: rgba(255, 255, 255, .24); }
.nav-more > summary[aria-current="page"] {
  background: #fff; color: var(--leaf-900); font-weight: 700;
}
.nav-more-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  min-width: 190px; max-width: 78vw;
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
}
/* 面板裡是白底，字要換回深色，不能沿用頁首那組白字 */
.site-header .nav-more-panel a {
  background: none; color: var(--leaf-900); text-align: left;
  padding: 8px 12px; border-radius: 8px; font-size: .95rem;
}
.site-header .nav-more-panel a:hover { background: var(--leaf-50); }
.site-header .nav-more-panel a[aria-current="page"] {
  background: var(--leaf-50); font-weight: 700;
}
.nav-more-panel hr { border: none; border-top: 1px solid var(--line); margin: 6px 4px; }

/*
 * 手機上導覽列會換行，「更多」可能停在任何位置，
 * 面板貼著它展開就會掉到畫面外。窄螢幕改成貼齊整條頁首攤開。
 */
@media (max-width: 650px) {
  .nav-more { position: static; }
  .nav-more-panel {
    left: 12px; right: 12px; top: calc(100% + 6px); max-width: none;
  }
}

/* 內容跟上面那條深色的頁首要拉開距離 */
main { padding-block: 40px 72px; }

.page-head { margin: 0 0 30px; }
.page-head h1 { font-size: 1.6rem; margin: 0 0 10px; line-height: 1.45; }
.page-head p { margin: 0; color: var(--ink-soft); line-height: 1.8; max-width: 62ch; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 0 40px;
  color: var(--ink-faint);
  font-size: .88rem;
}
.site-footer p { margin: 0 0 4px; }
/* 委辦單位：標誌下面那一行，比聯絡資訊再淡一階 */
.footer-org { font-size: .82rem; opacity: .85; }

/* ---------------------------------------------------------------- 元件 */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 26px 24px;
}
.card + .card { margin-top: 18px; }
/* 「歡迎回來」這種帶出舊資料的卡片，用標誌上螺旋槳的藍區隔開來 */
.card-sky { background: var(--sky-50); border-color: #b9e2f6; }

.section-title {
  font-size: 1.05rem; font-weight: 800; margin: 36px 0 14px;
  display: flex; align-items: center; gap: 8px;
}
/*
 * 這裡曾經有一條 .section-title:first-child { margin-top: 0 }。
 * 它把「已截止報名／額滿」的上方留白也一起吃掉了 —— 那個標題剛好是
 * <section> 的第一個元素，於是整段緊貼著上面的活動列表。
 * 真的需要靠齊上緣的地方（例如卡片裡的小標題）自己寫 margin-top:0 就好。
 */
.section-title::before {
  content: ''; width: 4px; height: 18px; border-radius: 2px; background: var(--leaf-500);
}

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.badge-open { background: var(--ok-bg); color: var(--ok); }
.badge-closed { background: #eef1ee; color: var(--ink-faint); }
.badge-full { background: var(--danger-bg); color: var(--danger); }
.badge-past { background: #e9ede9; color: #5c6a5e; }
.badge-soon { background: var(--sun-50); color: #8a5200; }
/* 額滿但還收候補：用標誌上的藍，跟「已額滿」的紅區隔開 */
.badge-wait { background: var(--sky-50); color: var(--sky-dark); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--leaf-700); color: #fff; font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--leaf-900); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--leaf-700); border-color: var(--line); }
.btn-ghost:hover { background: var(--leaf-50); }
/* 條件還沒滿足、按了也沒用的按鈕（例如還沒選月份）。按鈕上會寫原因。 */
.btn-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-sun {
  background: var(--sun); color: var(--sun-ink); font-size: 1.03rem; padding: 14px 22px;
}
.btn-sun:hover { background: var(--sun-dark); color: var(--sun-ink); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f6c3bf; }
/* 加 LINE 的按鈕用 LINE 自己的綠，一眼就認得出來這顆是去加好友的 */
.btn-line { background: #06c755; color: #fff; border-color: #06c755; }
.btn-line:hover { background: #05a648; border-color: #05a648; color: #fff; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 6px 12px; font-size: .86rem; border-radius: 8px; }
.btn-block { width: 100%; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-end { justify-content: flex-end; }
.spacer { flex: 1 1 auto; }

/* ---------------------------------------------------------------- 表單 */

/*
 * 每個欄位固定是「標題 → 輸入框」兩段。
 * 說明文字跟標題排在同一行（標題粗、說明淡），這樣說明就不會
 * 卡在標題與輸入框中間，把同一列右邊那格的輸入框往下推。
 */
.field {
  display: flex; flex-direction: column;
  margin-bottom: 22px;
}
.field > label, .field .field-label {
  font-weight: 700; font-size: .95rem; line-height: 1.5;
  margin: 0 0 8px;
  display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 0;
}
.req { color: var(--danger); margin-left: 3px; }
.help { color: var(--ink-faint); font-size: .84rem; line-height: 1.6; margin: 6px 0 0; }
/* 排在標題旁邊的說明：不加粗、不換段，空的就整個不佔位 */
.field > label > .help, .field .field-label > .help {
  font-weight: 400; margin: 0 0 0 10px;
}
.field > label > .help:empty, .field .field-label > .help:empty { display: none; }

input[type="text"], input[type="email"], input[type="tel"], input[type="date"],
input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; color: var(--ink); background: #fff;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--leaf-300); outline-offset: 1px; border-color: var(--leaf-500);
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }

.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font-size: .95rem; line-height: 1.4;
}
.choice:hover { border-color: var(--leaf-300); background: var(--leaf-50); }
.choice input { accent-color: var(--leaf-700); margin: 0; }
.choice:has(input:checked) {
  border-color: var(--leaf-500); background: var(--leaf-50); font-weight: 700;
}
/* 排課面板：日期欄不用撐滿整行，旁邊的按鈕才排得進同一列 */
.schedule .row input[type="date"] { width: auto; min-width: 170px; flex: 0 0 auto; }
.schedule .row { align-items: center; }

/* 已排定的上課日期，一天一顆，按 × 就拿掉 */
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 8px 6px 12px; border-radius: 999px;
  border: 1px solid var(--leaf-300); background: var(--leaf-50);
  font-size: .9rem; font-variant-numeric: tabular-nums;
}
.chip-fixed { border-style: dashed; background: #fff; }
.chip-note { color: var(--ink-faint); font-size: .78rem; padding-right: 4px; }
.chip-x {
  border: 0; background: none; cursor: pointer; padding: 0 4px;
  color: var(--ink-faint); font-size: 1.05rem; line-height: 1; border-radius: 999px;
}
.chip-x:hover { color: var(--danger); background: #fff; }

/*
 * 逐堂設定時間。堂數多的時候會很長，所以限制高度讓它自己捲，
 * 下面的「快速排課」才不會被推到看不見的地方。
 */
.session-times {
  margin-top: 12px; max-height: 260px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.session-times:not([hidden]) + * { margin-top: 12px; }
.session-time-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.session-time-row input[type="time"] { width: auto; flex: 0 0 auto; }
.session-time-date {
  flex: 0 0 92px; font-size: .9rem; font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

/*
 * 「其他（請填寫）」的自由填答格。
 * 原本用 flex:1 會把整列剩下的空間全部吃掉，一個「其他」拉得比
 * 男、女兩個選項加起來還長。改成不成長，維持一個夠打字的寬度就好。
 */
.choice-other { flex: 0 1 200px; min-width: 150px; }
.choice-other input[type="text"] { border: none; padding: 0; }
.choice-other input[type="text"]:focus { outline: none; }

.grid-2 { display: grid; gap: 0 20px; grid-template-columns: 1fr; }
.grid-2 .span-2 { grid-column: 1 / -1; }

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

  /*
   * 用 subgrid 讓同一列的欄位共用兩條列軌（標題／輸入框），
   * 這樣就算左邊標題一行、右邊標題連說明擠成兩行，
   * 兩個輸入框仍然對齊在同一條線上。
   * 不支援 subgrid 的瀏覽器會忽略這段，退回單純的直式排列，畫面仍可用。
   */
  .grid-2 > .field:not(.span-2) {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 2;
    align-content: start;
  }
  .grid-2 > .field:not(.span-2) > label { margin-bottom: 0; align-self: end; padding-bottom: 8px; }
}

fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 20px 6px; margin: 0 0 18px; background: #fff;
}
legend {
  font-weight: 800; padding: 0 10px; color: var(--leaf-700); font-size: 1.02rem;
}

/* ---------------------------------------------------------------- 提示 */

.notice { padding: 14px 16px; border-radius: 10px; margin: 0 0 18px; font-size: .94rem; line-height: 1.7; }
.notice-error { background: var(--danger-bg); color: #94211a; border: 1px solid #f6c3bf; }
.notice-ok { background: var(--ok-bg); color: #00653a; border: 1px solid #b2e0c2; }
.notice-info { background: var(--leaf-50); color: var(--leaf-900); border: 1px solid var(--leaf-300); }
.notice-warn { background: var(--sun-50); color: #8a5200; border: 1px solid #f7d9ac; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }

/*
 * 「報名不等於錄取」的紅字提醒。
 * 這件事最容易被誤會，所以刻意做得比一般提示醒目：
 * 白底、紅框、紅字，跟旁邊的綠色介面拉開對比。
 */
.notice-alert {
  background: #fff;
  border: 2px solid var(--danger);
  color: var(--danger);
}
.notice-alert .alert-main { font-weight: 800; font-size: 1.02rem; }
.notice-alert .alert-sub { font-size: .92rem; margin-top: 2px; }

/*
 * 報名表的容器。有內容時跟上面的活動資訊卡片拉開距離；
 * 用 :not(:empty) 是為了空的時候完全不佔位。
 */
.form-slot:not(:empty) { margin-top: 30px; }

/* 課程備註：條列式，比一般內文小一點，但不要小到看不清楚 */
.course-notes {
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 14px 16px; margin: 0 0 18px; font-size: .92rem; line-height: 1.8;
}
.course-notes-title { font-weight: 800; margin-bottom: 4px; }
.course-notes ol { margin: 0; padding-left: 1.4em; }
.course-notes li { margin: 2px 0; }

/*
 * 送出鈕底下的「填到一半會自動存」說明 + 清除鈕。
 * 手機上兩者疊成上下兩行，清除鈕才不會被擠成一條細長條。
 */
.draft-note {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 14px 0 0; padding-top: 14px; border-top: 1px dashed var(--line);
}
.draft-note .help { flex: 1 1 260px; }
.draft-note .btn { flex: 0 0 auto; }
@media (max-width: 560px) {
  .draft-note .btn { width: 100%; }
}

.empty {
  text-align: center; padding: 48px 20px; color: var(--ink-faint);
  background: #fff; border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty strong { display: block; color: var(--ink-soft); font-size: 1.05rem; margin-bottom: 4px; }

.loading { text-align: center; padding: 40px; color: var(--ink-faint); }

/* ---------------------------------------------------------------- 活動卡片 */

/* 一張活動一列，緊湊排列；活動再多也不會把首頁拉得很長 */
/* minmax(0, 1fr)：卡片內的地點是不換行的長字串，
   沒有這個限制格軌會被撐開，手機上整頁就會可以左右捲動 */
.activity-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }

.activity-card {
  display: flex; align-items: center; gap: 14px; min-width: 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 14px 16px;
  text-decoration: none; color: inherit;
}
.activity-card:hover { box-shadow: var(--shadow); border-color: var(--leaf-300); }

/* 已結束、已截止、額滿的活動在視覺上稍微退後，跟可以報名的區分開 */
.activity-card.is-past,
.activity-card.is-unavailable { background: #fafbfa; }
.activity-card.is-past .ac-title,
.activity-card.is-unavailable .ac-title { color: var(--ink-soft); }
.activity-card.is-past .date-chip,
.activity-card.is-unavailable .date-chip { background: #eef1ee; color: var(--ink-soft); }

.ac-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ac-title { font-weight: 700; font-size: 1rem; line-height: 1.45; }
/* 地點可能很長，收成一行並用省略號，卡片高度才固定 */
.ac-meta {
  color: var(--ink-faint); font-size: .86rem; line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-side {
  flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
}
.ac-seats { color: var(--ink-faint); font-size: .82rem; white-space: nowrap; }

.date-chip {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 50px; padding: 5px 8px; border-radius: 10px;
  background: var(--leaf-50); color: var(--leaf-700); line-height: 1.1; flex: none;
}
.date-chip .d { font-size: 1.15rem; font-weight: 800; }
.date-chip .m { font-size: .7rem; font-weight: 700; }

/* 收在「查看更多」後面的活動 */
.activity-more { margin-top: 10px; }
.more-btn { margin-top: 10px; font-size: .9rem; }

@media (max-width: 520px) {
  /* 手機上讓標題有完整寬度，狀態與人數移到下面一行 */
  .activity-card { flex-wrap: wrap; gap: 10px 12px; }
  .ac-body { flex-basis: calc(100% - 64px); }
  /* 手機寬度不夠，地點只會被截成省略號，不如整段收起來 */
  .ac-where { display: none; }
  .ac-side {
    flex-basis: 100%; flex-direction: row; align-items: center;
    justify-content: space-between; gap: 8px;
  }
}

/* ---------------------------------------------------------------- 表格 */

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  background: var(--leaf-50); font-weight: 700; color: var(--leaf-900);
  position: sticky; top: 0; z-index: 1;
}
tbody tr:hover { background: var(--leaf-50); }
tbody tr:last-child td { border-bottom: none; }
td.wrap-cell { white-space: normal; min-width: 200px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/*
 * 凍結姓名欄。
 *
 * 名單、學生總表這種表格欄位很多，往右拉看電話、學校的時候，
 * 左邊那一列是誰就看不到了 —— 很容易看錯行。把姓名（以及前面的序號）
 * 釘在左邊，捲到哪裡都知道自己在看誰。
 *
 * freeze-name  = 第一欄就是姓名
 * freeze-seq-name = 第一欄是序號、第二欄才是姓名
 *
 * 釘住的儲存格要自己畫底色（不然下面的內容會透出來）與右邊那條分隔線
 * （border-collapse 的表格捲動時邊框會跟著跑掉，所以用 box-shadow 畫）。
 */
.freeze-name th:first-child,
.freeze-name td:first-child,
.freeze-seq-name th:nth-child(-n+2),
.freeze-seq-name td:nth-child(-n+2) {
  position: sticky; z-index: 2; background: var(--card);
}
.freeze-name thead th:first-child,
.freeze-seq-name thead th:nth-child(-n+2) { z-index: 3; background: var(--leaf-50); }

.freeze-name th:first-child, .freeze-name td:first-child { left: 0; }
.freeze-seq-name th:nth-child(1), .freeze-seq-name td:nth-child(1) {
  left: 0; width: 56px; min-width: 56px;
}
.freeze-seq-name th:nth-child(2), .freeze-seq-name td:nth-child(2) { left: 56px; }

/* 凍結區塊的右邊界：讓人看得出來這兩欄是釘住的 */
.freeze-name th:first-child, .freeze-name td:first-child,
.freeze-seq-name th:nth-child(2), .freeze-seq-name td:nth-child(2) {
  box-shadow: 1px 0 0 var(--line);
}

/* 滑過整列時，釘住的那幾格也要跟著變色，不然會斷成兩截 */
.freeze-name tbody tr:hover td:first-child,
.freeze-seq-name tbody tr:hover td:nth-child(-n+2) { background: var(--leaf-50); }

/* 勾了「不錄取」的那一列：留著看得到，但一眼分得出不算在名單裡 */
tr.row-rejected td { color: var(--ink-faint); background: #fafbfa; }
tr.row-rejected td a { color: var(--ink-soft); }
.freeze-name tr.row-rejected td:first-child,
.freeze-seq-name tr.row-rejected td:nth-child(-n+2) { background: #fafbfa; }
.reject-box { white-space: nowrap; }

/* 活動列表：名稱是這一列的主角，比表格其他字大一階 */
/* td.wrap-cell 也有 min-width，要比它更明確才蓋得過去 */
td.act-cell { min-width: 232px; }
.act-title { font-weight: 700; font-size: 1.06rem; line-height: 1.4; }
.act-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.act-links .btn { padding: 2px 10px; }

/*
 * 月報的三張分佈表：欄寬固定成一樣的比例。
 * 不固定的話每張表會依自己的內容（「新莊區」vs「11歲以下」vs「一般」）
 * 決定欄寬，三張表的「人次」就會落在不同位置，上下看起來沒對齊。
 */
.stat-table { table-layout: fixed; }
.stat-table th:nth-child(1), .stat-table td:nth-child(1) { width: 56%; }
.stat-table th:nth-child(2), .stat-table td:nth-child(2) { width: 22%; }
.stat-table th:nth-child(3), .stat-table td:nth-child(3) { width: 22%; }

/* ---------------------------------------------------------------- 後台 */

.admin-body { background: #eef2ee; }
.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); margin-bottom: 26px; }
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.stat .n { font-size: 1.7rem; font-weight: 800; color: var(--leaf-700); line-height: 1.2; }
.stat .l { font-size: .84rem; color: var(--ink-faint); }
/* 手動填入的人次要看得出是加上去的，所以在卡片下面拆給人看 */
.stat-split {
  margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line);
  font-size: .76rem; color: var(--ink-faint);
}

.login-shell { min-height: 78vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.25rem; margin: 0 0 4px; }
.login-card p.sub { color: var(--ink-faint); font-size: .9rem; margin: 0 0 18px; }

.tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font: inherit; font-weight: 600; color: var(--ink-soft);
}
.tab[aria-selected="true"] {
  background: var(--leaf-700); color: #fff; border-color: var(--leaf-700);
}

.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 14px;
}
.toolbar .search { flex: 1 1 260px; min-width: 200px; }
/* 篩選用的下拉選單依內容寬度並排，不要各自佔滿一整行 */
.toolbar select { width: auto; min-width: 150px; flex: 0 1 auto; }

details.editor { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 18px; }
details.editor > summary {
  cursor: pointer; padding: 14px 18px; font-weight: 700; color: var(--leaf-700);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
details.editor > summary::-webkit-details-marker { display: none; }
details.editor > summary::before { content: '＋'; font-weight: 800; }
details.editor[open] > summary::before { content: '－'; }
details.editor > .editor-body { padding: 0 18px 18px; border-top: 1px solid var(--line); padding-top: 16px; }

dialog {
  border: none; border-radius: var(--radius); padding: 0; max-width: 560px; width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(11, 48, 64, .3);
}
dialog::backdrop { background: rgba(11, 48, 64, .45); }
dialog .dlg-head { padding: 18px 20px 0; font-weight: 800; font-size: 1.05rem; }
dialog .dlg-body { padding: 12px 20px; max-height: 70vh; overflow-y: auto; }
dialog .dlg-foot {
  padding: 14px 20px; border-top: 1px solid var(--line); display: flex;
  gap: 8px; justify-content: flex-end; background: #fafcfc;
}

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; font-size: .95rem; line-height: 1.6; }
.kv dt { color: var(--ink-faint); }
.kv dd { margin: 0; word-break: break-word; white-space: pre-wrap; }

.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  background: var(--leaf-50); color: var(--leaf-700); border-radius: 999px;
  padding: 2px 10px; font-size: .8rem; font-weight: 600;
}

/* 社團（經常性活動）的標記，跟方案分類那些淡綠的藥丸區隔開 */
.pill-club { background: var(--sky-50); color: var(--sky-dark); }

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

@media print {
  .site-header, .site-footer, .toolbar, .btn, .tabs { display: none !important; }
  body { background: #fff; }
  .table-scroll { border: none; overflow: visible; }
  th, td { white-space: normal; }
}

/* ================================================================
 * 前台行事曆
 *
 * 電腦與手機是兩種版型，不是同一種縮放：
 *   ≥ 900px  攤開成七欄月曆，一眼看完整個月
 *   < 900px  改成「有課的日子」由近到遠列下來
 * 兩種都畫在 DOM 裡，這裡決定哪一種要出現。
 * ================================================================ */

.cal-desktop { display: none; }
.cal-mobile { display: block; }

@media (min-width: 900px) {
  .cal-desktop { display: block; }
  .cal-mobile { display: none; }
}

.cal-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 16px;
}
.cal-month {
  margin: 0; font-size: 1.35rem; font-weight: 800; color: var(--leaf-900);
  font-variant-numeric: tabular-nums;
}

/* ---- 電腦版月曆 ---- */

.cal-grid-wrap {
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff;
}
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head-cell {
  padding: 10px 12px; font-weight: 800; font-size: .85rem;
  color: var(--leaf-900); background: var(--leaf-50);
  border-bottom: 1px solid var(--line);
}
.cal-head-cell.is-weekend { color: var(--ink-faint); }

.cal-cell {
  /* 一週七格、一個月最多六列，格子夠高才放得下同一天的兩三個活動 */
  min-height: 120px; padding: 8px; border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 5px;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-grid > .cal-cell:nth-last-child(-n+7) { border-bottom: 0; }
.cal-blank { background: #fafbfa; }
.cal-cell.is-today { background: var(--leaf-50); }

.cal-daynum {
  display: flex; align-items: center; gap: 6px;
  font-weight: 800; font-size: .95rem; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.cal-cell.is-today .cal-daynum { color: var(--leaf-700); }
.cal-today-tag {
  font-size: .68rem; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  background: var(--leaf-700); color: #fff;
}

/*
 * 一格活動：活動名稱自己一行，時間排在下面。
 *
 * 名稱跟時間排同一行的話，時間會把名稱擠成一欄一個字，
 * 「一眼看出這個月有什麼活動」就完全做不到了 —— 名稱才是重點，
 * 所以名稱獨佔一整行的寬度，時間退到下面用小字。
 * 狀態用左邊那條色帶表示，不另外放圓點來搶空間。
 */
.cal-event {
  display: block; text-decoration: none; padding: 5px 7px; border-radius: 7px;
  background: var(--leaf-50); border-left: 3px solid var(--leaf-500);
  font-size: .8rem; line-height: 1.35;
}
.cal-event:hover { background: #dcefe2; }
.cal-event-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--ink); font-weight: 700; word-break: break-word;
}
.cal-event-time {
  display: block; color: var(--ink-faint); font-size: .72rem;
  font-variant-numeric: tabular-nums; margin-top: 1px;
}
/* 額滿 / 已截止 / 已經過去的，用左邊色帶區分，不用再讀文字 */
.cal-event.is-full { background: var(--danger-bg); border-left-color: var(--danger); }
.cal-event.is-closed { background: #f1f4f2; border-left-color: #b6c1b9; }
.cal-event.is-past { background: #f4f6f4; border-left-color: #cdd6cf; opacity: .8; }
.cal-event.is-past .cal-event-title { font-weight: 600; color: var(--ink-soft); }

.cal-legend {
  display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px;
  font-size: .82rem; color: var(--ink-faint);
}
.cal-legend > span { display: inline-flex; align-items: center; gap: 7px; }
.cal-swatch {
  width: 26px; height: 14px; border-radius: 4px; border: 1px solid var(--line);
  border-left-width: 4px; border-left-style: solid; flex: 0 0 auto;
}
.cal-swatch.is-open { background: var(--leaf-50); border-left-color: var(--leaf-500); }
.cal-swatch.is-full { background: var(--danger-bg); border-left-color: var(--danger); }
.cal-swatch.is-closed { background: #f1f4f2; border-left-color: #b6c1b9; }

/* ---- 手機版清單 ---- */

.agenda-group-title {
  font-weight: 800; color: var(--leaf-900); margin: 18px 0 8px; font-size: .92rem;
}
.agenda-group-title:first-child { margin-top: 0; }

.agenda-day {
  display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line);
}
.agenda-day.is-past { opacity: .6; }
.agenda-date {
  flex: 0 0 46px; text-align: center; padding-top: 2px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.agenda-dnum {
  font-size: 1.5rem; font-weight: 800; line-height: 1; color: var(--leaf-900);
  font-variant-numeric: tabular-nums;
}
.agenda-dow { font-size: .72rem; color: var(--ink-faint); white-space: nowrap; }
.agenda-date.is-today .agenda-dnum,
.agenda-date.is-today .agenda-dow { color: var(--sun-dark); }

.agenda-items { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.agenda-item {
  display: block; text-decoration: none; padding: 10px 12px; border-radius: 10px;
  background: var(--leaf-50); border-left: 3px solid var(--leaf-700);
}
.agenda-title { font-weight: 800; color: var(--ink); line-height: 1.4; }
.agenda-meta {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-top: 4px; font-size: .82rem; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/*
 * 行事曆頁比其他頁寬 —— 月曆是七欄，880px 分下去每格只剩 120px，
 * 活動名稱會被擠成兩三個字。手機不受影響（本來就滿版）。
 */
.wrap-cal { max-width: 1240px; }

/* ================================================================
 * 前後測問卷（前台）
 *
 * 少年現場拿手機填，所以量表不用下拉選單，改成一整排按得到的按鈕：
 * 單手就按得到，也看得到 1 到 5 分別代表什麼意思。
 * ================================================================ */

.survey-q {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 18px 16px; margin-top: 14px;
}
.survey-q-text {
  display: flex; gap: 10px; align-items: baseline;
  font-weight: 700; line-height: 1.6; margin-bottom: 12px;
}
.survey-q-num {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 999px;
  background: var(--leaf-50); color: var(--leaf-700);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 800;
}
.survey-q textarea { width: 100%; }
.survey-choices { margin-top: 2px; }

/* 量表 1-5：手機一排五個，每個都夠大按得到 */
.scale-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 2px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; cursor: pointer; text-align: center; min-height: 74px;
  justify-content: center;
}
.scale-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.scale-num { font-size: 1.15rem; font-weight: 800; color: var(--ink-soft); line-height: 1; }
.scale-label { font-size: .68rem; color: var(--ink-faint); line-height: 1.3; }
.scale-item:hover { background: var(--leaf-50); }
/* 選中的那一格要一眼看得出來 —— 手機上滑過去很容易忘記自己選了哪個 */
.scale-item:has(input:checked) {
  background: var(--leaf-700); border-color: var(--leaf-700);
}
.scale-item:has(input:checked) .scale-num,
.scale-item:has(input:checked) .scale-label { color: #fff; }
.scale-item:has(input:focus-visible) { outline: 2px solid var(--sun); outline-offset: 2px; }

/* ---- 後台：前後測分頁 ---- */

.survey-stat-table td.num { font-variant-numeric: tabular-nums; }
.diff-up { color: var(--ok); font-weight: 800; }
.diff-down { color: var(--danger); font-weight: 800; }
.diff-same { color: var(--ink-faint); font-weight: 700; }
.survey-links { display: flex; flex-direction: column; gap: 10px; }
.survey-link-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.survey-link-row code {
  background: var(--leaf-50); padding: 3px 8px; border-radius: 6px;
  font-size: .85rem; word-break: break-all;
}

/* 後台單一活動頁的標題：活動名稱後面接現在看的是哪一頁 */
.head-view {
  margin-left: 10px; font-size: .95rem; font-weight: 700; vertical-align: middle;
  color: var(--leaf-700); background: var(--leaf-50);
  padding: 3px 12px; border-radius: 999px;
}

/*
 * 操作上的重要提醒（例如「第一次用這個網站都要填完整報名表」）。
 *
 * 用橘色，跟紅色的「報名≠錄取」與個資聲明分開 ——
 * 紅色留給「後果」與法定告知，這裡是「你等一下會遇到的事」。
 */
.notice-heads-up {
  background: var(--sun-50);
  border: 2px solid var(--sun);
  color: #7a4600;
}
.notice-heads-up .alert-main { font-weight: 800; font-size: 1.02rem; color: #a35a00; }
.notice-heads-up .alert-sub { font-size: .92rem; margin-top: 3px; color: #7a4600; }

/* 撞期提醒裡的清單：一天一行，不要有項目符號的縮排 */
.clash-list { margin: 8px 0 0; padding-left: 18px; }
.clash-list li { margin-bottom: 4px; }
.clash-list .badge { margin-left: 6px; }

/* ---------------------------------------------------------------- 使用說明 */

/* 三步驟：自己畫編號圓圈，不用瀏覽器預設的數字 */
.guide-steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.guide-steps > li {
  counter-increment: step;
  position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 20px 20px 64px;
  margin-bottom: 14px;
}
.guide-steps > li::before {
  content: counter(step);
  position: absolute; left: 18px; top: 20px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--leaf-700); color: #fff;
  font-weight: 800; font-size: .95rem;
  display: grid; place-items: center;
}
.guide-steps h3 { margin: 0 0 6px; font-size: 1.02rem; }
.guide-steps p { margin: 0 0 8px; }
.guide-steps p:last-child { margin-bottom: 0; }

.guide-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .guide-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .guide-grid { grid-template-columns: repeat(3, 1fr); } }
.guide-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 18px;
}
.guide-card h3 { margin: 0 0 6px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.guide-card p { margin: 0; color: var(--ink-soft); font-size: .93rem; }

/* 常見問題：點標題才展開，一次看得完整頁的問題有哪些 */
.faq {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 14px 18px; margin-bottom: 10px;
}
.faq > summary {
  cursor: pointer; font-weight: 700; display: flex; align-items: baseline; gap: 10px;
}
/* summary 改成 flex 之後瀏覽器自己的三角形會不見，補一個回來。
   兩個 marker 選擇器要分開寫 —— 併成一條的話，不認得 -webkit- 那個的
   瀏覽器會把整條規則丟掉，連 ::marker 也一起失效 */
.faq > summary::marker { content: ''; }
.faq > summary::-webkit-details-marker { display: none; }
.faq > summary::before { content: '＋'; color: var(--leaf-700); font-weight: 800; }
.faq[open] > summary::before { content: '－'; }
.faq[open] > summary { margin-bottom: 8px; }
.faq p { margin: 0; color: var(--ink-soft); }

.guide-list { margin: 0; padding-left: 20px; color: var(--ink-soft); }
.guide-list li { margin-bottom: 8px; }
.guide-list li:last-child { margin-bottom: 0; }

/* ------------------------------------------------------- 簽到頁的簽到情況 */

.ck-status { padding: 18px 18px; }
.ck-status-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.ck-count { margin: 10px 0 8px; font-size: 1.02rem; }
.ck-count strong { font-size: 1.6rem; color: var(--leaf-700); }
.ck-bar { height: 8px; border-radius: 999px; background: var(--leaf-50); overflow: hidden; }
.ck-bar-fill { height: 100%; background: var(--leaf-500); border-radius: 999px; }
.ck-sub { font-size: .92rem; margin: 16px 0 8px; }
/* 還沒到的用橘色、到了的用綠色，遠遠看一眼就分得出來 */
.ck-chip-pending { background: var(--sun-50); border-color: #f3d3a6; color: #8a5200; }
.ck-chip-done { background: var(--leaf-50); border-color: var(--leaf-300); color: var(--leaf-700); }

/* ------------------------------------------------------- 場地借用 */

/* 一天一段，日期當小標，同一天的借用排在一起 */
.day-block { margin-bottom: 22px; }
.day-head {
  font-size: .98rem; margin: 0 0 8px;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}

/* ------------------------------------------------------- 場地借用（前台） */

/* 借用表：一天一張卡（手機），或月曆格子（電腦） */
.bk-day { margin-bottom: 12px; padding: 16px 16px 12px; }
.bk-day-head { font-size: 1.02rem; margin-bottom: 8px; }
.bk-room-row {
  display: grid; grid-template-columns: 120px 1fr; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--line); align-items: start;
}
.bk-room-row:first-of-type { border-top: 0; }
.bk-room-name {
  font-weight: 700; color: var(--leaf-900); font-size: .93rem;
  /* 「💃 2F舞蹈教室」比其他空間長，窄螢幕要讓它換行而不是被切掉 */
  overflow-wrap: anywhere; line-height: 1.5;
}
.bk-room-slots { display: flex; flex-direction: column; gap: 6px; }
.bk-slot { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .93rem; }
.bk-time { color: var(--sky-dark); font-weight: 700; font-variant-numeric: tabular-nums; }
.bk-who { color: var(--ink-soft); }
.bk-slot-closed { color: var(--danger); }

/* 月曆：跟活動行事曆長得像，但格子裡放的是「時段＋空間」 */
.bk-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff;
}
.bk-grid-head {
  padding: 8px; text-align: center; font-weight: 800; font-size: .85rem;
  background: var(--leaf-50); color: var(--leaf-900); border-bottom: 1px solid var(--line);
}
.bk-cell {
  min-height: 104px; padding: 6px; text-align: left; font: inherit; cursor: pointer;
  background: #fff; border: 0; border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px;
}
.bk-cell:nth-child(7n) { border-right: 0; }
.bk-cell-blank { background: #fafbfa; cursor: default; }
.bk-cell-off { background: #f6f7f6; color: var(--ink-faint); }
.bk-cell-today { background: var(--leaf-50); }
.bk-cell-picked { outline: 2px solid var(--leaf-500); outline-offset: -2px; }
.bk-cell:hover:not(.bk-cell-blank) { background: var(--leaf-50); }
.bk-daynum { font-weight: 800; font-size: .9rem; color: var(--ink-soft); }
.bk-cell-items { display: flex; flex-direction: column; gap: 2px; }
.bk-cell-item {
  font-size: .72rem; line-height: 1.3; padding: 2px 5px; border-radius: 5px;
  background: var(--leaf-50); border-left: 3px solid var(--leaf-500);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bk-cell-item-closed { background: var(--danger-bg); border-left-color: var(--danger); }

/* 設備借用：一格一個品項，數量自己填 */
.eq-grid {
  display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  padding: 14px; border: 1px dashed var(--line); border-radius: 12px;
  background: #fafbfa; margin-bottom: 18px;
}
.eq-title { grid-column: 1 / -1; font-weight: 700; color: var(--leaf-900); font-size: .92rem; }
.eq-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: .9rem; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px;
}
.eq-item input { width: 64px; text-align: right; padding: 4px 8px; }

.footer-links { font-size: .92rem; margin-bottom: 6px; }

@media (max-width: 650px) {
  .bk-room-row { grid-template-columns: 104px 1fr; }
}

/*
 * 「建置中，請勿使用」的公告。
 * 刻意做得比一般提示更搶眼（斜紋 + 橘底），一進頁面就會看到 ——
 * 這是要擋住人在還沒上線的功能裡留下資料，客氣的小字擋不住。
 */
.wip {
  display: flex; flex-direction: column; gap: 4px;
  margin: 0 0 20px; padding: 16px 18px;
  border: 2px solid var(--sun-dark); border-radius: var(--radius);
  background:
    repeating-linear-gradient(45deg,
      var(--sun-50), var(--sun-50) 14px, #fde8c8 14px, #fde8c8 28px);
  color: var(--sun-ink);
}
.wip strong { font-size: 1.12rem; }
.wip span { font-size: .93rem; line-height: 1.7; }
