/* ==========================================================================
   Workshop 報名系統
   ========================================================================== */

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

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #1b2333;
  --ink-2: #475467;
  --ink-3: #7a8699;
  --line: #e3e8ef;
  --line-2: #d0d8e3;

  --brand: #1d5fc4;
  --brand-ink: #164a9b;
  --brand-soft: #eaf1fd;

  --ok: #157a4b;      --ok-soft: #e3f4eb;    --ok-bar: #22a565;
  --warn: #9a5f00;    --warn-soft: #fdf1d8;  --warn-bar: #e59a14;
  --bad: #b8322a;     --bad-soft: #fdeaea;   --bad-bar: #da4a3f;
  --info: #1d5fc4;    --info-soft: #eaf1fd;
  --muted: #5f6b7d;   --muted-soft: #eef1f5; --muted-bar: #a9b3c2;

  --admin: #7c4a03;   --admin-soft: #fff8ea; --admin-line: #f0dcb4;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .04);
  --shadow-hover: 0 2px 4px rgba(16, 24, 40, .06), 0 12px 28px rgba(16, 24, 40, .10);
  --font: "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Heiti TC", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.7 var(--font); }
h1, h2, h3 { margin: 0; line-height: 1.35; }
p { margin: 0; }
a { color: var(--brand); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: .9em; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 20px; }
.main { padding-top: 28px; padding-bottom: 64px; min-height: calc(100vh - 150px); }
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .main { padding-top: 20px; }
}

/* ---------------------------------------------------------------- 頁首 */

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0;
         color: var(--ink); text-decoration: none; font-weight: 700; font-size: 17px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
              background: var(--brand); color: #fff; flex: none; }
.brand-mark .icon { width: 20px; height: 20px; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; line-height: 1.35; }
.user-name { font-weight: 600; font-size: 14px; }
.user-name .id-tag { padding: 0 7px; margin-right: 2px; font-size: 11.5px; vertical-align: 1px; }
.user-mail { font-size: 12px; color: var(--ink-3); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
        font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip-admin { background: var(--admin-soft); color: var(--admin); border: 1px solid var(--admin-line); }
@media (max-width: 600px) {
  .brand { font-size: 16px; }
  .user-mail { display: none; }
  .chip-admin { padding: 4px 8px; font-size: 12px; }
}

.site-footer { border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; padding: 20px 0 28px; }

/* 自動登入的提示列（JS 跳轉前顯示，可以取消） */
.auto-login { background: var(--brand-soft); border-bottom: 1px solid #c8d8f4; color: var(--brand-ink); font-size: 14px; }
.auto-login-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-height: 46px; padding-top: 6px; padding-bottom: 6px; }
.auto-login .btn { margin-left: auto; }
.spinner { width: 16px; height: 16px; flex: none; border: 2px solid rgba(29, 95, 196, .25); border-top-color: var(--brand);
           border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ---------------------------------------------------------------- 按鈕、標籤 */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px;
       border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); color: var(--ink);
       font: inherit; font-size: 14px; font-weight: 600; line-height: 1.35; text-decoration: none;
       white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { background: #f6f8fb; border-color: #bfc9d6; }
.btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgba(29, 95, 196, .35); outline-offset: 2px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-danger { color: var(--bad); border-color: #eec3bf; }
.btn-danger:hover { background: var(--bad-soft); border-color: #e2a29b; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-3); font-weight: 500; }
.btn-quiet:hover { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.btn-lg { padding: 12px 20px; font-size: 16px; border-radius: 12px; }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { background: var(--muted-soft); border-color: var(--line); color: var(--ink-3); cursor: not-allowed; }
form.is-submitting button[type="submit"] { opacity: .6; pointer-events: none; }

.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 10px; border-radius: 999px;
         font-size: 12.5px; font-weight: 700; line-height: 1.7; white-space: nowrap; }
.badge .icon { width: 14px; height: 14px; }
.badge-ok    { background: var(--ok-soft);    color: var(--ok); }
.badge-warn  { background: var(--warn-soft);  color: var(--warn); }
.badge-bad   { background: var(--bad-soft);   color: var(--bad); }
.badge-info  { background: var(--info-soft);  color: var(--info); }
.badge-muted { background: var(--muted-soft); color: var(--muted); }
.badge-mine  { background: var(--brand);      color: #fff; }

.meter { height: 8px; border-radius: 999px; background: #e8ecf2; overflow: hidden; }
.meter > span { display: block; height: 100%; min-width: 0; border-radius: inherit; background: var(--ok-bar); }
.meter-warn  > span { background: var(--warn-bar); }
.meter-bad   > span { background: var(--bad-bar); }
.meter-info  > span { background: var(--brand); }
.meter-muted > span { background: var(--muted-bar); }

/* ---------------------------------------------------------------- 訊息 */

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; margin-bottom: 20px;
          border: 1px solid transparent; border-radius: 12px; font-size: 14.5px; }
.notice .icon { width: 20px; height: 20px; margin-top: 2px; }
.notice-success { background: var(--ok-soft);   border-color: #bfe3cd; color: #0e5a36; }
.notice-error   { background: var(--bad-soft);  border-color: #f0c3be; color: #8c2019; }
.notice-info    { background: var(--info-soft); border-color: #c8d8f4; color: #173f80; }

.empty { text-align: center; padding: 52px 24px; background: var(--surface); border: 1px dashed var(--line-2);
         border-radius: var(--radius); color: var(--ink-2); }
.empty > .icon { width: 40px; height: 40px; color: var(--ink-3); }
.empty h1, .empty h2 { font-size: 19px; color: var(--ink); margin: 12px 0 6px; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }

/* ---------------------------------------------------------------- 頁面標題 */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; }
.lead { color: var(--ink-2); margin-top: 4px; }
.eyebrow { font-size: 13px; font-weight: 700; color: var(--brand); letter-spacing: .04em; margin-bottom: 2px; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 16px; color: var(--ink-2);
        text-decoration: none; font-size: 14px; }
.back:hover { color: var(--brand); }
@media (max-width: 600px) {
  .page-head h1 { font-size: 22px; }
}

.admin-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; margin-bottom: 22px;
              background: var(--admin-soft); border: 1px solid var(--admin-line); border-radius: var(--radius);
              color: #5c3a06; font-size: 14px; }
.admin-note > .icon { width: 20px; height: 20px; margin-top: 2px; color: var(--admin); }
.admin-note p + p { margin-top: 6px; }
.copy-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.copy-line code, .share-row code { padding: 2px 8px; background: #fff; border: 1px solid var(--admin-line);
                                   border-radius: 6px; font-size: 13px; word-break: break-all; }

/* ---------------------------------------------------------------- 列表 */

.ws-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.ws-card { position: relative; display: grid; grid-template-columns: 78px minmax(0, 1fr) 200px; gap: 20px;
           align-items: center; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line);
           border-radius: var(--radius); box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s; }
.ws-card:hover { border-color: #c5d3e8; box-shadow: var(--shadow-hover); }
.ws-card:focus-within { border-color: var(--brand); }

.ws-date { display: flex; flex-direction: column; align-items: center; justify-content: center; align-self: stretch;
           padding: 10px 0; border-radius: 12px; background: var(--brand-soft); color: var(--brand-ink); line-height: 1.15; }
.d-month { font-size: 13px; font-weight: 600; }
.d-day { font-size: 30px; font-weight: 800; margin: 3px 0; letter-spacing: -.02em; }
.d-week { font-size: 12.5px; }
.is-ended .ws-date { background: var(--muted-soft); color: var(--muted); }

.ws-body { min-width: 0; }
.ws-title { font-size: 18px; font-weight: 700; }
.ws-title a { color: var(--ink); text-decoration: none; }
/* 整張卡片都可以點：讓標題連結撐滿整張卡片 */
.ws-title a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.ws-card:hover .ws-title a { color: var(--brand); }
.ws-title-en { margin-top: 2px; font-size: 13.5px; color: var(--ink-3); line-height: 1.45; }
.ws-meta { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 3px; font-size: 14px; color: var(--ink-2); }
.ws-meta li { display: flex; gap: 8px; align-items: flex-start; }
.ws-meta .icon { margin-top: .28em; color: var(--ink-3); }
.ws-meta strong { color: var(--ink); font-weight: 600; }

.ws-side { display: flex; flex-direction: column; gap: 8px; }
.ws-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.ws-count { font-size: 13.5px; color: var(--ink-2); }
.ws-count strong { font-size: 21px; font-weight: 800; color: var(--ink); }
.ws-cta { display: inline-flex; align-items: center; gap: 2px; font-size: 13.5px; font-weight: 600; color: var(--brand); }
.ws-admin { position: relative; z-index: 1; display: flex; gap: 6px; }

@media (max-width: 760px) {
  .ws-card { grid-template-columns: 58px minmax(0, 1fr); gap: 14px; padding: 16px; align-items: start; }
  .ws-date { align-self: start; padding: 8px 0; }
  .d-day { font-size: 23px; margin: 1px 0; }
  .d-month, .d-week { font-size: 12px; }
  .ws-title { font-size: 16.5px; }
  .ws-side { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px;
             padding-top: 12px; border-top: 1px dashed var(--line); }
  .ws-side .meter { order: 3; flex: 1 1 100%; }
  .ws-count { margin-left: auto; }
  .ws-cta, .ws-admin { order: 4; }
}

.past { margin-top: 36px; }
.past > summary { display: inline-flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer;
                  font-weight: 700; color: var(--ink-2); list-style: none; }
.past > summary::-webkit-details-marker { display: none; }
.past > summary::before { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 2px 2px 0;
                          transform: rotate(-45deg); transition: transform .15s; }
.past[open] > summary::before { transform: rotate(45deg); }
.past > .ws-list, .past > .table-wrap { margin-top: 12px; }

/* ---------------------------------------------------------------- 場次頁 */

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "head side" "body side";
          gap: 20px 28px; align-items: start; }
.detail-head { grid-area: head; }
.detail-side { grid-area: side; position: sticky; top: 20px; display: grid; gap: 16px; }
.detail-body { grid-area: body; }
.detail-head .ws-badges { margin-bottom: 10px; }
.detail-head h1 { font-size: 28px; }
.title-en { margin-top: 6px; color: var(--ink-3); font-size: 16px; line-height: 1.5; }
@media (max-width: 880px) {
  .detail { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "side" "body"; }
  .detail-side { position: static; }
  .detail-head h1 { font-size: 23px; }
}

.facts { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.facts > div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); }
.facts > div:first-child { border-top: 0; }
.facts dt { display: flex; align-items: flex-start; gap: 8px; color: var(--ink-3); font-size: 14px; line-height: 1.75; }
.facts dt .icon { margin-top: .3em; }
.facts dd { margin: 0; }
.speaker-title { display: block; color: var(--ink-2); font-size: 14px; }
@media (max-width: 520px) {
  .facts > div { grid-template-columns: 1fr; gap: 0; padding: 12px 16px; }
}

.section { margin-top: 20px; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.section h2 { display: flex; align-items: center; gap: 8px; font-size: 17px; margin-bottom: 10px; }
.section-note { background: #fffbf2; border-color: #f0e0bd; }
.section-note h2 { color: #7a4d04; }
.prose { color: #2a3342; }
.prose p { margin: 0 0 .7em; overflow-wrap: anywhere; }
.prose p:last-child { margin-bottom: 0; }
@media (max-width: 520px) {
  .section { padding: 16px; }
}

.reg-card { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.reg-heading { font-size: 14px; color: var(--ink-3); font-weight: 600; }
.reg-count { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 10px; }
.reg-count strong { font-size: 36px; font-weight: 800; line-height: 1; }
.reg-count span { color: var(--ink-3); }
.reg-left { margin-top: 8px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.reg-deadline { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 13px; color: var(--ink-3); }
.reg-action { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.reg-done { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--ok-soft); color: #0e5a36; }
.reg-done .icon { width: 22px; height: 22px; margin-top: 1px; }
.reg-done small { display: block; font-size: 12.5px; color: #3c7a58; }
.reg-as { font-size: 12.5px; color: var(--ink-3); text-align: center; overflow-wrap: anywhere; }
.reg-hint { font-size: 13.5px; color: var(--ink-2); }

.admin-panel { padding: 16px; background: var(--admin-soft); border: 1px solid var(--admin-line); border-radius: var(--radius); }
.admin-heading { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--admin); margin-bottom: 12px; }
.admin-actions { display: grid; gap: 8px; }
.admin-actions .btn { justify-content: flex-start; }
.admin-share { margin-top: 14px; font-size: 13px; color: #5c3a06; }
.share-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 6px; }
.share-row code { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- 新增／編輯 */

.form-card { padding: 4px 24px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.fs { padding: 20px 0 6px; border-top: 1px solid var(--line); }
.fs:first-of-type { border-top: 0; }
.fs-title { font-size: 16px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) {
  .form-card { padding: 4px 16px 20px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; min-width: 0; }
.field label { font-weight: 600; font-size: 14px; }
.req { color: var(--bad); margin-left: 3px; }
.field input, .field textarea { width: 100%; min-width: 0; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px;
                                background: #fff; color: var(--ink); font: inherit; font-size: 15px; transition: border-color .15s, box-shadow .15s; }
.field textarea { resize: vertical; line-height: 1.65; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 95, 196, .15); }
.field .hint, .check .hint { font-size: 12.5px; color: var(--ink-3); }
.field .err { font-size: 13px; color: var(--bad); font-weight: 600; }
.field.has-error input, .field.has-error textarea { border-color: var(--bad); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--brand); flex: none; }
.check .hint { display: block; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }

.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-top: 28px;
               padding: 18px 22px; background: var(--surface); border: 1px solid #f0c9c5; border-radius: var(--radius); }
.danger-zone h2 { font-size: 16px; color: var(--bad); }
.danger-zone p { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; max-width: 640px; }

/* ---------------------------------------------------------------- 報名名單 */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stats > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; background: var(--surface);
               border: 1px solid var(--line); border-radius: 12px; }
.stats span { font-size: 13px; color: var(--ink-3); }
.stats strong { font-size: 22px; font-weight: 800; line-height: 1.4; }
.stats small { font-size: 13px; color: var(--ink-3); font-weight: 500; }
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { background: #f8fafc; color: var(--ink-2); font-size: 13px; font-weight: 700; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table .num { width: 48px; text-align: right; color: var(--ink-3); }
.table .mono { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.table .actions { text-align: right; width: 1%; }
.table .duty { white-space: normal; min-width: 160px; }
.table .duty small { display: block; font-size: 12.5px; color: var(--ink-3); }
.print-only { display: none; }

/* 身分（由職稱判斷） */
.id-tag { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; line-height: 1.7; white-space: nowrap; }
.id-teacher  { background: #e8f0fd; color: #1a4f9f; }
.id-research { background: #e3f4ef; color: #11694f; }
.id-staff    { background: #fdf1dc; color: #8a5a00; }
.id-student  { background: #f1eafc; color: #6231a8; }
.id-other    { background: var(--muted-soft); color: var(--muted); }
.id-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: -4px 0 16px; font-size: 14px; }
.id-summary-label { color: var(--ink-3); font-size: 13px; }
.id-count { display: inline-flex; align-items: center; gap: 6px; }
.id-count strong { font-size: 16px; }

@media print {
  @page { margin: 14mm 12mm; }
  body { background: #fff; font-size: 11pt; }
  .site-header, .site-footer, .no-print, .notice { display: none !important; }
  .main { padding: 0; min-height: 0; }
  .wrap { max-width: none; padding: 0; }
  .page-head { margin-bottom: 10px; }
  .page-head h1 { font-size: 17pt; }
  .stats { display: flex; gap: 24px; margin-bottom: 10px; }
  .stats > div { flex-direction: row; align-items: baseline; gap: 8px; padding: 0; border: 0; }
  .stats strong { font-size: 13pt; }
  .table-wrap { border: 0; border-radius: 0; overflow: visible; }
  .table { font-size: 10.5pt; }
  .table th, .table td, .table tbody tr:last-child td { border: 1px solid #888; padding: 7px 8px; background: none !important; white-space: normal; }
  .table .mono { font-size: 9pt; word-break: break-all; }
  .id-tag { padding: 0; background: none !important; color: inherit !important; font-weight: 600; }
  .id-summary { margin: 0 0 10px; }
  .table tr { break-inside: avoid; }
  th.print-only, td.print-only { display: table-cell; }
  .table .sign { width: 32%; }
}
