/* 主題色：取自北醫體育事務處的酒紅 #a41f39，調淡成玫瑰粉系 */
:root {
  --rose-900: #8c2236;
  --rose-700: #b3405a;   /* 主色（按鈕、標題） */
  --rose-500: #d9748a;
  --rose-300: #f0b4c1;
  --rose-100: #fbe4e9;
  --rose-50:  #fff5f7;   /* 背景 */
  --cream:    #fffaf3;
  --ink:      #4a3439;
  --ink-soft: #8a7076;
  --line:     #f3d3da;
  --radius:   22px;
  --accent:   #fdeccf;
  --glow:     179, 64, 90;
  --shadow:   0 6px 20px rgba(var(--glow), .12);
}

/* 選雙和校區時整頁換成藍色 */
body.theme-blue {
  --rose-900: #1d4e72;
  --rose-700: #2f6f9c;
  --rose-500: #5b9bc7;
  --rose-300: #a8cce5;
  --rose-100: #e0eff9;
  --rose-50:  #f3f9fd;
  --cream:    #f6fafd;
  --ink:      #2e3d48;
  --ink-soft: #6c8090;
  --line:     #cde2f0;
  --accent:   #d8f0ee;
  --glow:     47, 111, 156;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; }
body {
  font-family: "Huninn", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, var(--rose-100) 0 70px, transparent 71px),
    radial-gradient(circle at 92% 22%, var(--accent) 0 46px, transparent 47px),
    radial-gradient(circle at 85% 92%, var(--rose-100) 0 90px, transparent 91px),
    var(--rose-50);
  transition: background-color .3s;
  min-height: 100vh;
  line-height: 1.6;
}

.wrap {
  max-width: 480px; margin: 0 auto;
  padding: 28px max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---------- 標頭 ---------- */
.hero { text-align: center; margin-bottom: 22px; }
.hero .badge {
  display: inline-block; font-size: 13px; color: var(--rose-700);
  background: #fff; border: 1.5px dashed var(--rose-300);
  padding: 3px 14px; border-radius: 999px; margin-bottom: 10px;
}
.hero h1 { font-size: 26px; margin: 4px 0 6px; color: var(--rose-900); letter-spacing: 1px; }
.hero p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.hero .deco { font-size: 30px; display: block; margin-bottom: 4px; animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-6deg); } }

/* ---------- 選單頁大按鈕 ---------- */
.choices { display: grid; gap: 14px; }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px; text-align: left; cursor: pointer;
  box-shadow: var(--shadow); font: inherit; color: inherit;
  transition: transform .15s, border-color .15s;
  text-decoration: none;
}
.choice:active { transform: scale(.97); }
.choice:hover { border-color: var(--rose-300); }
.choice .icon {
  flex: none; width: 54px; height: 54px; border-radius: 18px;
  display: grid; place-items: center; font-size: 28px; background: var(--rose-100);
}
.choice.alt .icon { background: var(--accent); }
.choice b { display: block; font-size: 18px; color: var(--rose-900); }
.choice small { color: var(--ink-soft); font-size: 13px; }
.choice .arrow { margin-left: auto; color: var(--rose-300); font-size: 22px; }

/* ---------- 表單卡片 ---------- */
.card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 18px; margin-bottom: 14px; border: 1.5px solid var(--line);
}
.card h2 {
  font-size: 16px; margin: 0 0 14px; color: var(--rose-700);
  display: flex; align-items: center; gap: 8px;
}
.card h2 .num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--rose-700); color: #fff;
  display: grid; place-items: center; font-size: 13px;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 14px; margin-bottom: 6px; }
.field label .req { color: var(--rose-500); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

input[type=text], input[type=tel], input[type=email], textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--cream); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 11px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--rose-500); box-shadow: 0 0 0 4px var(--rose-100); }
.invalid input, .invalid .chips, .invalid .stepper { border-color: var(--rose-500) !important; }
.invalid .err { display: block; }
.err { display: none; color: var(--rose-700); font-size: 12px; margin-top: 4px; }

/* 人數加減 */
.stepper {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--cream); border: 1.5px solid var(--line); border-radius: 14px; padding: 6px;
}
.stepper button {
  width: 42px; height: 42px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--rose-100); color: var(--rose-900); font-size: 22px; font-family: inherit;
}
.stepper button:active { transform: scale(.92); }
.stepper input {
  width: 90px; text-align: center; border: none; background: transparent;
  font: inherit; font-size: 22px; color: var(--rose-900); outline: none;
}
.stepper span { color: var(--ink-soft); font-size: 14px; margin-right: 8px; }

/* 選擇膠囊 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; border: 1.5px solid transparent; border-radius: 14px; }
.chip {
  font: inherit; font-size: 14px; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 7px 14px; transition: all .15s;
}
.chip[aria-pressed=true] {
  background: var(--rose-700); border-color: var(--rose-700); color: #fff;
}

/* 場館行事曆 */
.cal-empty {
  text-align: center; color: var(--ink-soft); font-size: 14px;
  background: var(--cream); border: 1.5px dashed var(--line); border-radius: 14px; padding: 22px 10px;
}
.cal, .cal-legend { --c-main: #c0485f; --c-soft: #fbe4e9; --c-head: #b3405a; }
.cal-blue.cal, .cal-blue.cal-legend { --c-main: #3f86b8; --c-soft: #e2f0fa; --c-head: #2f6f9c; }
.cal { border: 1.5px solid transparent; border-radius: 14px; }
.cal-row { display: grid; grid-template-columns: 36px repeat(5, 1fr); gap: 4px; }
.cal-row + .cal-row { margin-top: 6px; }
.cal-day {
  text-align: center; font-size: 14px; color: #fff; background: var(--c-head);
  border-radius: 10px; padding: 4px 0;
}
.cal-gap { text-align: center; color: var(--ink-soft); font-size: 14px; line-height: 1; margin: 4px 0; }
.cal-axis, .cal-col { position: relative; height: var(--h); }
.cal-axis span {
  position: absolute; right: 2px; transform: translateY(-50%);
  font-size: 10px; color: var(--ink-soft); line-height: 1;
}
.cal-axis span:first-child { transform: none; }
.cal-col {
  border-radius: 10px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--hour) - 1px), #f1e3e6 calc(var(--hour) - 1px) var(--hour))
    0 var(--off) / 100% 100% no-repeat,
    #fcf8f8;
}
.cal-blk {
  position: absolute; left: 1px; right: 1px; border-radius: 9px;
  font: inherit; font-size: 10px; line-height: 1.25; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2px; overflow: hidden; white-space: pre-line; word-break: break-all;
}
.cal-blk small { font-size: 9.5px; opacity: .85; }
.cal-blk.busy { background: #e7e7e7; color: #999; }
.cal-blk.free {
  background: #fff; border: 1.5px dashed var(--c-main); color: var(--c-main);
  cursor: pointer; transition: transform .12s, background .12s;
}
.cal-blk.free::after { content: "+"; font-size: 16px; line-height: 1; opacity: .55; }
.cal-blk.free:active { transform: scale(.94); }
.cal-blk.free[aria-pressed=true] { background: var(--c-main); border-style: solid; color: #fff; }
.cal-blk.free[aria-pressed=true]::after { content: "✓"; opacity: 1; }
.cal-legend { display: flex; gap: 12px; justify-content: center; font-size: 12px; color: var(--ink-soft); margin-top: 8px; }
.cal-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 4px; vertical-align: -1px; }
.lg-free { border: 1.5px dashed var(--c-main); }
.lg-on { background: var(--c-main); }
.lg-busy { background: #ececec; }
.invalid .chips { padding: 4px; }

/* 送出 */
.submit {
  width: 100%; border: none; cursor: pointer; font: inherit;
  font-size: 18px; color: #fff; padding: 15px; border-radius: 999px;
  background: linear-gradient(135deg, var(--rose-500), var(--rose-700));
  box-shadow: 0 8px 18px rgba(var(--glow), .3); letter-spacing: 2px;
  margin-top: 6px;
}
.submit:active { transform: scale(.98); }
.submit:disabled { opacity: .6; }

.back { display: inline-block; color: var(--ink-soft); font-size: 14px; text-decoration: none; margin-bottom: 10px; }

/* 完成畫面 */
.done { text-align: center; padding: 30px 10px; }
.done .big { font-size: 56px; }
.done h2 { color: var(--rose-900); margin: 8px 0; }
.done p { color: var(--ink-soft); margin: 0 0 18px; }

/* 預覽用的 Flex 卡片模擬 */
.flex-mock {
  max-width: 320px; margin: 0 auto; text-align: left; background: #fff;
  border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.flex-mock .hd { background: var(--rose-100); padding: 14px 16px; }
.flex-mock .hd small { color: var(--rose-700); font-size: 12px; }
.flex-mock .hd b { display: block; color: var(--rose-900); font-size: 18px; }
.flex-mock .bd { padding: 12px 16px; font-size: 14px; }
.flex-mock .row { display: flex; gap: 10px; padding: 3px 0; }
.flex-mock .row span:first-child { color: var(--ink-soft); flex: none; width: 64px; }
.flex-mock .row span:last-child { flex: 1; min-width: 0; }
.flex-mock .ft { padding: 0 16px 14px; }
.flex-mock .ft div {
  text-align: center; background: var(--rose-700); color: #fff; border-radius: 10px; padding: 8px; font-size: 14px;
}

/* 小元件 */
.preview-badge {
  position: fixed; top: 10px; right: 10px; z-index: 50;
  background: #fff3c9; color: #8a6400; font-size: 12px;
  padding: 3px 10px; border-radius: 999px; border: 1px solid #f1d98a;
}
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--rose-900); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 60;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { text-align: center; color: var(--ink-soft); font-size: 12px; margin-top: 22px; }
.nw { white-space: nowrap; }

/* 教室切換 */
.room-tabs { --c-main: #c0485f; display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.room-tabs.cal-blue { --c-main: #3f86b8; }
.room-tab {
  flex: none; font: inherit; font-size: 13px; cursor: pointer;
  border: 1.5px solid var(--c-main); color: var(--c-main); background: #fff;
  border-radius: 12px; padding: 6px 12px;
}
.room-tab[aria-pressed=true] { background: var(--c-main); color: #fff; }
.room-tab .cnt {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; border-radius: 9px;
  font-size: 11px; background: #fff; color: var(--c-main); margin-left: 2px; padding: 0 4px;
}
.room-tab[aria-pressed=false] .cnt { background: var(--c-main); color: #fff; }

/* 提醒小框 */
.notice {
  font-size: 12.5px; line-height: 1.5; color: #8a6400;
  background: #fff8e1; border: 1px solid #f3dfa2; border-radius: 12px;
  padding: 8px 12px 8px 30px; margin-bottom: 10px; position: relative;
}
.notice::before { content: "💡"; position: absolute; left: 10px; top: 8px; font-size: 13px; }

/* 電腦版 LINE／一般瀏覽器開啟時的提示 */
.external-banner {
  position: sticky; top: 0; z-index: 70; text-align: center;
  background: var(--rose-700); color: #fff; font-size: 13px; padding: 8px 12px;
}

/* ---------- 報名資訊：開關與截止日 ---------- */
.info-text { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.deadline {
  display: inline-block; font-size: 12px; line-height: 1.4; margin-top: 4px;
  padding: 2px 10px; border-radius: 999px;
  background: var(--rose-50); color: var(--ink-soft); border: 1px solid var(--line);
}

/* 未開放：灰色、不能按 */
.choice.closed { cursor: not-allowed; opacity: .65; filter: grayscale(.6); box-shadow: none; }
.choice.closed:active { transform: none; }
.choice.closed small { letter-spacing: 1px; font-style: italic; }
.choice.closed .arrow { visibility: hidden; }

/* 1：剩兩週內 → 截止日變粉色 */
.choice[data-urgency="1"] .deadline { background: var(--rose-100); color: var(--rose-700); border-color: var(--rose-300); }

/* 2：剩一週內 → 橘色＋邊框慢慢呼吸 */
.choice[data-urgency="2"] { border-color: #f4b183; animation: breathe 2.4s ease-in-out infinite; --pulse: 244, 150, 80; }
.choice[data-urgency="2"] .deadline { background: #fff1e4; color: #c25e12; border-color: #f4b183; }

/* 3：剩三天內 → 紅色＋明顯脈衝＋截止日跳動 */
.choice[data-urgency="3"] { border-color: #e05a6f; animation: breathe 1.4s ease-in-out infinite; --pulse: 224, 70, 95; }
.choice[data-urgency="3"] .deadline { background: #e0465f; color: #fff; border-color: #e0465f; font-weight: bold; animation: nudge 1.4s ease-in-out infinite; }

/* 4：今天截止 → 最強：快速脈衝＋搖晃＋閃爍 */
.choice[data-urgency="4"] { border-color: #d62f4b; animation: breathe .9s ease-in-out infinite, shake 3s ease-in-out infinite; --pulse: 214, 47, 75; }
.choice[data-urgency="4"] .deadline { background: #d62f4b; color: #fff; border-color: #d62f4b; font-weight: bold; animation: blink .9s ease-in-out infinite; }

/* 已過截止日：還能按，只是溫和提醒 */
.choice[data-urgency="past"] .deadline { background: #f2f2f2; color: #8a8a8a; border-color: #e2e2e2; }

@keyframes breathe {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 0 rgba(var(--pulse), .45); }
  50%      { box-shadow: var(--shadow), 0 0 0 8px rgba(var(--pulse), 0); }
}
@keyframes nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes shake {
  0%, 88%, 100% { transform: translateX(0); }
  90% { transform: translateX(-3px) rotate(-.5deg); }
  92% { transform: translateX(3px) rotate(.5deg); }
  94% { transform: translateX(-2px); }
  96% { transform: translateX(2px); }
}

/* 使用者關閉動畫時不閃 */
@media (prefers-reduced-motion: reduce) {
  .choice[data-urgency], .choice[data-urgency] .deadline { animation: none !important; }
}
