/* =====================================================
   Summit 2026 Portal — 參加者/管理後台樣式
   配色與字體沿用官網 summit.fourh.org.tw 的 design token，
   但版面是「表單導向的工具」而非行銷頁：更緊湊、更多留白在垂直方向、
   觸控目標一律 >= 44px。行動優先，桌機再加寬。
   ===================================================== */

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

:root {
  /* ── 沿用官網 token ── */
  --ink:        #0F1A14;
  --ink-soft:   #2A3A30;
  --ink-mute:   #667A6E;
  --paper:      #F6F4EC;
  --paper-2:    #EFEBDD;
  --cream:      #FAF7EE;
  --line:       #D7D2C2;
  --line-soft:  rgba(15, 26, 20, 0.08);
  --leaf:       #2D7D46;
  --leaf-deep:  #1F5C34;
  --leaf-pale:  #E8F5E9;
  --accent:     #E9532B;
  --accent-pale:#FDEDE8;

  /* ── 後台專用的狀態色 ── */
  --ok:      #2D7D46;
  --ok-pale: #E8F5E9;
  --warn:      #B8860B;
  --warn-pale: #FBF3DF;
  --danger:      #C0392B;
  --danger-pale: #FBEAE7;
  --info:      #2C6E8F;
  --info-pale: #E6F1F6;

  --shadow:      0 24px 64px -28px rgba(15, 26, 20, 0.32);
  --shadow-soft: 0 6px 24px -10px rgba(15, 26, 20, 0.18);
  --radius:    14px;
  --radius-sm: 10px;

  --serif: "Fraunces", "Noto Serif TC", "Source Han Serif TC", Georgia, serif;
  --sans:  "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
           "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --header-h: 60px;
}

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; display: block; }
a   { color: var(--leaf-deep); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.5rem); }
h3 { font-size: 1.05rem; }

/* 鍵盤操作一定看得見焦點——這是無障礙的底線，不要為了美觀拿掉 */
:focus-visible {
  outline: 3px solid var(--leaf);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--ink); color: var(--paper); padding: .75rem 1rem;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ---------- 版面骨架 ---------- */
.wrap {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 1rem;
}
.wrap--wide { max-width: 1240px; }

main { padding: 1.25rem 0 4rem; }

/* ---------- 頁首 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
}
.site-header__bar {
  display: flex; align-items: center; gap: .75rem;
  min-height: var(--header-h);
}
.site-header__brand {
  display: flex; align-items: center; gap: .6rem;
  text-decoration: none; color: inherit;
  margin-right: auto; min-width: 0;
}
.site-header__logo { width: auto; height: 34px; flex: none; }
.site-header__text { display: flex; flex-direction: column; min-width: 0; }
.site-header__text b {
  font-family: var(--serif); font-size: .95rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-header__text > span {
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 窄螢幕：標誌留著（它才是辨識度來源），日期那行讓位 */
@media (max-width: 420px) {
  .site-header__text > span { display: none; }
  .site-header__text b { font-size: .85rem; white-space: normal; line-height: 1.2; }
}

.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang-switch a {
  padding: .35rem .7rem; font-size: .8rem; text-decoration: none;
  color: var(--ink-mute); background: transparent; line-height: 1.4;
}
.lang-switch a[aria-current="true"] { background: var(--leaf); color: #fff; font-weight: 600; }

.nav-toggle {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: ''; display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px;
  transition: transform .18s ease, opacity .18s ease;
}
.nav-toggle span::before { transform: translateY(-6px); }
.nav-toggle span::after  { transform: translateY(4px); }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span::before { transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span::after  { transform: rotate(-45deg) translateY(-1px); }

/* ---------- 導覽 ---------- */
.site-nav { display: none; border-top: 1px solid var(--line); padding: .5rem 0 .75rem; }
.site-nav[data-open="true"] { display: block; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.site-nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem .75rem; min-height: 44px;
  text-decoration: none; color: var(--ink-soft);
  border-radius: var(--radius-sm);
}
.site-nav a:hover { background: var(--paper-2); }
.site-nav a[aria-current="page"] { background: var(--leaf-pale); color: var(--leaf-deep); font-weight: 600; }
.site-nav .nav-status { margin-left: auto; }

@media (min-width: 860px) {
  .nav-toggle { display: none; }
  .site-nav { display: block; border-top: 0; padding: 0; }
  .site-nav ul { flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .site-nav a { padding: .45rem .8rem; min-height: 38px; font-size: .92rem; }
  .site-nav .nav-status { display: none; }
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head {
  display: flex; align-items: flex-start; gap: .75rem; flex-wrap: wrap;
  margin-bottom: .9rem;
}
.card__head h2, .card__head h3 { margin-right: auto; }
.card__note { color: var(--ink-mute); font-size: .9rem; margin: .35rem 0 0; }

/* ---------- 頁面標題區 ---------- */
.page-head { margin: .5rem 0 1.25rem; }
.page-head p { color: var(--ink-mute); margin: .4rem 0 0; max-width: 62ch; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; line-height: 1.5;
  white-space: nowrap;
}
.badge--ok     { background: var(--ok-pale);     color: var(--ok); }
.badge--warn   { background: var(--warn-pale);   color: var(--warn); }
.badge--danger { background: var(--danger-pale); color: var(--danger); }
.badge--info   { background: var(--info-pale);   color: var(--info); }
.badge--mute   { background: var(--paper-2);     color: var(--ink-mute); }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 46px; padding: .6rem 1.2rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 600; text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--leaf); color: #fff; }
.btn--primary:hover { background: var(--leaf-deep); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn--ghost:hover { background: var(--paper-2); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-pale); }
.btn--sm { min-height: 38px; padding: .35rem .8rem; font-size: .86rem; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.btn-row--end { justify-content: flex-end; }

/* ---------- 表單 ---------- */
.field { margin-bottom: 1rem; }
.field > label, .field__label {
  display: block; margin-bottom: .3rem;
  font-size: .88rem; font-weight: 600; color: var(--ink-soft);
}
.field__req  { color: var(--accent); margin-left: .15rem; }
.field__hint { display: block; margin-top: .3rem; font-size: .82rem; color: var(--ink-mute); }
.field__error { display: block; margin-top: .3rem; font-size: .82rem; color: var(--danger); font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: .6rem .75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
}
.textarea { min-height: 100px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--leaf); }
.input[readonly], .input:disabled, .select:disabled, .textarea:disabled {
  background: var(--paper-2); color: var(--ink-mute); cursor: not-allowed;
}
/* iOS 在 font-size < 16px 的輸入框會自動放大整頁，所以這裡不縮字 */
.input, .select, .textarea { font-size: 16px; }

.field-grid { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 620px) {
  .field-grid--2 { grid-template-columns: 1fr 1fr; }
  .field-grid--3 { grid-template-columns: repeat(3, 1fr); }
  .field--full { grid-column: 1 / -1; }
}

.check {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .7rem .8rem; min-height: 46px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer;
}
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--leaf); flex: none; }
.check span  { font-size: .93rem; }
.check--on { border-color: var(--leaf); background: var(--leaf-pale); }

fieldset { border: 0; margin: 0 0 1.5rem; padding: 0; }
legend {
  font-family: var(--serif); font-size: 1.05rem; font-weight: 600;
  padding: 0 0 .6rem; margin-bottom: .4rem; width: 100%;
  border-bottom: 1px solid var(--line-soft);
}

/* ---------- 提示訊息 ---------- */
.alert {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .85rem 1rem; margin-bottom: 1rem;
  border: 1px solid; border-radius: var(--radius-sm);
  font-size: .93rem;
}
.alert__icon { flex: none; font-size: 1.05rem; line-height: 1.5; }
.alert p:first-child { margin-top: 0; }
.alert p:last-child  { margin-bottom: 0; }
.alert--ok     { background: var(--ok-pale);     border-color: #BFDFC7; color: #1E5B33; }
.alert--warn   { background: var(--warn-pale);   border-color: #E8D9A8; color: #7A5B08; }
.alert--danger { background: var(--danger-pale); border-color: #EEC2BB; color: #8E2A1F; }
.alert--info   { background: var(--info-pale);   border-color: #BBD7E4; color: #1F5064; }

/* ---------- 待辦清單 ---------- */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li + li { border-top: 1px solid var(--line-soft); }
.checklist a {
  display: flex; align-items: center; gap: .85rem;
  padding: .95rem .25rem; min-height: 56px;
  text-decoration: none; color: inherit;
}
.checklist a:hover { background: var(--paper-2); }
.checklist__mark {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 700;
  border: 2px solid var(--line);
  color: var(--ink-mute); background: #fff;
}
.checklist__mark--done { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist__mark--part { background: var(--warn-pale); border-color: var(--warn); color: var(--warn); }
.checklist__body { min-width: 0; margin-right: auto; }
.checklist__body b { display: block; font-weight: 600; }
.checklist__body small { color: var(--ink-mute); }
.checklist__arrow { flex: none; color: var(--ink-mute); }

/* ---------- 進度條 ---------- */
.progress {
  height: 8px; border-radius: 999px; background: var(--paper-2); overflow: hidden;
}
.progress__bar { height: 100%; background: var(--leaf); border-radius: 999px; transition: width .4s ease; }

/* ---------- 資料檢視（key/value）---------- */
.dl { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.dl > div {
  display: flex; flex-wrap: wrap; gap: .25rem 1rem;
  padding: .6rem 0; border-bottom: 1px solid var(--line-soft);
}
.dl dt { flex: 0 0 100%; font-size: .82rem; color: var(--ink-mute); margin: 0; }
.dl dd { flex: 1; margin: 0; font-weight: 500; word-break: break-word; }
@media (min-width: 620px) {
  .dl dt { flex: 0 0 190px; font-size: .9rem; }
}
.dl .is-empty { color: var(--ink-mute); font-weight: 400; font-style: italic; }

/* ---------- 表格（桌機用；手機自動轉卡片）---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: .65rem .7rem; text-align: left; vertical-align: middle; }
table.data thead th {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-mute); border-bottom: 2px solid var(--line); white-space: nowrap;
}
table.data tbody tr + tr td { border-top: 1px solid var(--line-soft); }
table.data tbody tr:hover { background: var(--paper-2); }

/* ---------- 參加者編號 ---------- */
.pid {
  font-family: var(--mono); font-size: .85rem; font-weight: 500;
  letter-spacing: .02em; color: var(--leaf-deep);
  background: var(--leaf-pale); padding: .15rem .5rem; border-radius: 6px;
  white-space: nowrap;
}

/* ---------- 登入頁 ---------- */
.auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 1.5rem 1rem;
  background:
    radial-gradient(120% 80% at 50% -10%, #E9EDE3 0%, transparent 60%),
    var(--paper);
}
.auth__box { width: 100%; max-width: 420px; }
.auth__brand { text-align: center; margin-bottom: 1.5rem; }
.auth__brand img { width: 96px; height: auto; margin: 0 auto .75rem; }
.auth__brand b {
  display: block; font-family: var(--serif); font-size: 1.35rem; font-weight: 600;
}
.auth__brand span {
  display: block; margin-top: .3rem;
  font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-mute);
}
.auth__foot { text-align: center; margin-top: 1.25rem; font-size: .88rem; color: var(--ink-mute); }
.auth__foot a { display: inline-block; padding: .35rem; }

/* ---------- 頁尾 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2.5rem;
  font-size: .86rem; color: var(--ink-mute);
}
.site-footer a { color: var(--ink-soft); }

/* ---------- 工具類 ---------- */
.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;
}
.stack > * + * { margin-top: 1rem; }
.muted  { color: var(--ink-mute); }
.small  { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.mono   { font-family: var(--mono); }
.tar    { text-align: right; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
