/* ============================================================
   台北永續發展扶輪社・永續勳章
   設計 tokens：苔紙底、深松面板、黃銅勳章、苗綠數據色
   ============================================================ */
:root {
  --ink: #22301f;
  --ink-2: #55614f;
  --ink-3: #8a927f;
  --paper: #eef1e6;
  --card: #fbfaf5;
  --card-edge: #e3e6d8;
  --pine: #29513c;
  --pine-deep: #1f4030;
  --pine-soft: #dfe8dd;
  --data-green: #337e52;
  --brass: #b98a2f;
  --brass-deep: #8f6a24;
  --gold: #e7c36a;
  --alert: #b4463c;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(34, 48, 31, 0.06), 0 6px 20px rgba(34, 48, 31, 0.07);
  --font-display: 'Noto Serif TC', 'PingFang TC', serif;
  --font-body: 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* App shell：整頁不捲動，捲動發生在 main 內，
   底部分頁列是版面固定底欄，不受手機瀏覽器工具列遮擋 */
html { color-scheme: light; height: 100%; }

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--pine); }

:focus-visible {
  outline: 2px solid var(--data-green);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- 版面 ---------- */
.shell {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(238, 241, 230, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-edge);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .club-mark { flex: none; }

.topbar .titles { min-width: 0; }

.topbar .club-name {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-2);
}

.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  line-height: 1.3;
}

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px 28px;
}

/* ---------- 底部分頁列 ---------- */
.tabbar {
  flex: none;
  background: var(--card);
  border-top: 1px solid var(--card-edge);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar-inner {
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.tab-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 8px 2px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: var(--font-body);
  font-size: 10.5px;
  color: var(--ink-3);
  cursor: pointer;
}

.tab-btn svg { width: 22px; height: 22px; }

.tab-btn[aria-selected='true'] {
  color: var(--pine);
  font-weight: 600;
}

.tab-panel[hidden] { display: none; }

/* ---------- 卡片與區塊 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
}

.card .sub {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.greeting {
  margin: 4px 0 14px;
}

.greeting .hello {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.45;
}

.greeting .hello .num {
  color: var(--brass-deep);
  font-size: 26px;
  padding: 0 2px;
}

.greeting .meta {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 2px;
}

/* ---------- 獎章櫃（signature） ---------- */
.medal-case {
  position: relative;
  border-radius: var(--radius);
  padding: 20px 18px 16px;
  margin-bottom: 14px;
  color: #f2efe2;
  background:
    radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1.3px) 0 0 / 9px 9px,
    radial-gradient(rgba(0, 0, 0, 0.16) 1px, transparent 1.3px) 4.5px 4.5px / 9px 9px,
    linear-gradient(160deg, #2e5a43, var(--pine-deep));
  box-shadow:
    inset 0 0 0 1px rgba(231, 195, 106, 0.28),
    inset 0 0 26px rgba(0, 0, 0, 0.28),
    var(--shadow);
}

.medal-case .case-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.medal-case .case-title h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.18em;
  color: #efe6c8;
}

.medal-case .case-title .case-sub {
  font-size: 11px;
  color: rgba(242, 239, 226, 0.65);
}

.medal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 12px 8px;
  justify-items: center;
}

.medal-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 56px;
}

.medal-slot .medal { width: 46px; height: 46px; display: block; }

.medal-slot .medal-date {
  font-size: 10px;
  color: rgba(242, 239, 226, 0.75);
  letter-spacing: 0.02em;
}

.medal-slot.is-empty .medal-date { color: rgba(242, 239, 226, 0.5); }

/* 例會專屬勳章圖：黃銅框＋米色琺瑯面 */
.medal-art {
  position: relative;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fdf8ec, #efe4c8 72%);
  box-shadow:
    inset 0 0 0 2.5px #c99a3b,
    inset 0 0 0 3.5px #8f6a24,
    inset 0 2px 6px rgba(143, 106, 36, 0.35),
    0 1px 3px rgba(0, 0, 0, 0.22);
}

.medal-art img {
  position: absolute;
  inset: 18%;
  width: 64%;
  height: 64%;
  object-fit: contain;
}

.big-medal.medal-art {
  box-shadow:
    inset 0 0 0 5px #c99a3b,
    inset 0 0 0 7px #8f6a24,
    inset 0 3px 10px rgba(143, 106, 36, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.22);
}

@media (prefers-reduced-motion: no-preference) {
  .medal-slot.pop-in { animation: medal-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
  @keyframes medal-pop {
    from { transform: scale(0.4); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }
}

/* 銅牌銘板：累積數 */
.case-plaque {
  margin: 16px auto 2px;
  width: fit-content;
  padding: 5px 18px;
  border-radius: 6px;
  background: linear-gradient(175deg, #d8ab4c, #a97f2a 60%, #c49838);
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 214, 0.7),
    inset 0 -1px 2px rgba(70, 48, 8, 0.55),
    0 2px 5px rgba(0, 0, 0, 0.35);
  color: #3d2c0a;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 0 rgba(255, 244, 214, 0.5);
}

.case-empty-note {
  text-align: center;
  font-size: 13px;
  color: rgba(242, 239, 226, 0.85);
  padding: 8px 0 4px;
}

/* ---------- 統計磚 ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-tile {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-sm);
  padding: 12px 8px 10px;
  text-align: center;
}

.stat-tile .label {
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.06em;
}

.stat-tile .value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  line-height: 1.25;
  color: var(--ink);
}

.stat-tile .unit {
  font-size: 12px;
  color: var(--ink-3);
  margin-left: 1px;
}

/* ---------- 進度（分段量表） ---------- */
.meter {
  display: flex;
  gap: 2px;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  margin: 10px 0 6px;
}

.meter .seg {
  flex: 1;
  background: var(--pine-soft);
}

.meter .seg.on { background: var(--data-green); }

.meter-bar {
  height: 14px;
  border-radius: 7px;
  background: var(--pine-soft);
  overflow: hidden;
  margin: 10px 0 6px;
}

.meter-bar .fill {
  height: 100%;
  border-radius: 7px;
  background: var(--data-green);
  min-width: 4px;
}

.meter-caption {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-2);
}

.meter-caption .strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- 名單 chips ---------- */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
}

.mini-medal {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold), var(--brass) 70%);
  box-shadow: inset 0 0 0 1px var(--brass-deep);
  flex: none;
  vertical-align: -2px;
}

.chip .count {
  color: var(--brass-deep);
  font-weight: 600;
  font-size: 12px;
}

.chip.is-zero .mini-medal {
  background: var(--pine-soft);
  box-shadow: inset 0 0 0 1px var(--card-edge);
}

/* ---------- 全社成果牆 ---------- */
.wall-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 12px 0 4px;
}

.wall-dots .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold), var(--brass) 72%);
  box-shadow: inset 0 0 0 1px rgba(143, 106, 36, 0.8);
}

.wall-dots .dot.more {
  width: auto;
  height: auto;
  border-radius: 999px;
  background: none;
  box-shadow: none;
  font-size: 11px;
  color: var(--ink-2);
  align-self: center;
  padding-left: 2px;
}

/* ---------- 列表卡（下次例會、最近獲得…） ---------- */
.info-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px dashed var(--card-edge);
  font-size: 14px;
}

.info-line:first-of-type { border-top: 0; }

.info-line .k { color: var(--ink-2); flex: none; }

.info-line .v { text-align: right; font-weight: 600; }

.info-line .v .light { font-weight: 400; color: var(--ink-2); }

/* ---------- 按鈕 ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease;
}

.btn:active { transform: scale(0.985); }

.btn-primary {
  background: var(--pine);
  color: #f5f2e4;
}

.btn-secondary {
  background: var(--card);
  color: var(--pine);
  border: 1.5px solid var(--pine);
}

.btn-quiet {
  background: none;
  color: var(--ink-2);
  text-decoration: underline;
  width: auto;
  padding: 8px;
  font-weight: 400;
  font-size: 13px;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- 綁定面板 ---------- */
.bind-panel .search {
  width: 100%;
  border: 1.5px solid var(--card-edge);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 15px;
  font-family: var(--font-body);
  background: var(--card);
  color: var(--ink);
  margin-bottom: 10px;
}

.bind-panel .search:focus {
  outline: none;
  border-color: var(--data-green);
}

.name-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 2px;
}

.name-item {
  appearance: none;
  border: 1.5px solid var(--card-edge);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 11px 8px;
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--ink);
  cursor: pointer;
}

.name-item[aria-pressed='true'] {
  border-color: var(--pine);
  background: var(--pine-soft);
  font-weight: 700;
}

.bind-confirm {
  margin-top: 12px;
}

.bind-confirm .confirm-text {
  text-align: center;
  font-size: 14px;
  margin-bottom: 10px;
}

.bind-confirm .confirm-text .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--pine);
}

/* ---------- 打卡頁 ---------- */
.checkin-stage {
  padding-top: 26px;
  text-align: center;
}

.checkin-stage .big-medal {
  width: 108px;
  height: 108px;
  margin: 0 auto 14px;
  display: block;
}

@media (prefers-reduced-motion: no-preference) {
  .checkin-stage.award .big-medal {
    animation: medal-drop 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
  }
  @keyframes medal-drop {
    0% { transform: translateY(-36px) scale(0.6); opacity: 0; }
    60% { transform: translateY(4px) scale(1.04); opacity: 1; }
    100% { transform: translateY(0) scale(1); }
  }
}

.checkin-stage .headline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  margin: 0 0 6px;
}

.checkin-stage .detail {
  color: var(--ink-2);
  font-size: 14px;
  margin: 0 0 18px;
}

.checkin-stage .counts {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 20px;
}

.checkin-stage .counts .c .n {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
}

.checkin-stage .counts .c .l {
  font-size: 11.5px;
  color: var(--ink-2);
}

/* ---------- 規則頁 ---------- */
.rule-steps { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: rule; }

.rule-steps li {
  counter-increment: rule;
  position: relative;
  padding: 10px 0 10px 40px;
  border-top: 1px dashed var(--card-edge);
}

.rule-steps li:first-child { border-top: 0; }

.rule-steps li::before {
  content: counter(rule);
  position: absolute;
  left: 0;
  top: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--pine-soft);
  color: var(--pine);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 內容頁（社員故事／榮譽與感謝／社務資源） ---------- */
.post-card h2 {
  margin: 4px 0 8px;
  font-size: 18px;
}

.post-card .eyebrow .mini-medal {
  width: 12px;
  height: 12px;
  margin-right: 4px;
}

.post-img {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
  margin: 4px 0 10px;
}

.post-body {
  font-size: 14.5px;
}

.post-body p { margin: 0 0 10px; }

.post-body p:last-child { margin-bottom: 0; }

a.link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.link-item .link-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.link-item .link-title {
  font-weight: 600;
  font-size: 15px;
}

.link-item .link-note {
  font-size: 12px;
  color: var(--ink-2);
}

.link-item .arrow { flex: none; color: var(--pine); }

/* ---------- 狀態 ---------- */
.notice {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}

.notice-info { background: var(--pine-soft); color: var(--pine-deep); }

.notice-error { background: #f6e4e2; color: #7c2f28; }

.dev-banner {
  background: #3d2c0a;
  color: var(--gold);
  font-size: 12px;
  text-align: center;
  padding: 4px 8px;
}

.dev-banner a { color: var(--gold); }

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--card) 40%, var(--pine-soft) 50%, var(--card) 60%);
  background-size: 200% 100%;
  min-height: 120px;
  margin-bottom: 14px;
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: shimmer 1.4s infinite linear; }
  @keyframes shimmer {
    from { background-position: 120% 0; }
    to { background-position: -80% 0; }
  }
}

.empty-hint {
  text-align: center;
  color: var(--ink-2);
  font-size: 13.5px;
  padding: 14px 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  max-width: 86vw;
  text-align: center;
  z-index: 50;
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

/* 頁尾 */
.page-foot {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 18px 0 8px;
}
