:root {
  --primary: #0b78b6;
  --primary-dark: #075985;
  --primary-soft: #e0f2fe;
  --accent: #2563eb;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f7fb;
  --card: rgba(255,255,255,.92);
  --danger: #dc2626;
  --success: #059669;
  --shadow: 0 18px 45px rgba(15,23,42,.10);
  --shadow-sm: 0 10px 25px rgba(15,23,42,.07);
  --radius: 22px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', 'Microsoft JhengHei', Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(14,165,233,.14), transparent 32rem),
    radial-gradient(circle at top right, rgba(37,99,235,.10), transparent 28rem),
    var(--bg);
  color: var(--ink);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 18px; }
.main { padding: 34px 0 64px; }

/* Public header */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.90);
  color: var(--ink);
  padding: 14px 0;
  border-bottom: 1px solid rgba(226,232,240,.9);
  box-shadow: 0 8px 25px rgba(15,23,42,.06);
  backdrop-filter: blur(14px);
}
.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.brand-logo { display: inline-flex; align-items: center; transition: transform .22s ease; }
.brand-logo:hover { transform: translateY(-2px); }
.brand-logo img { display: block; max-height: 78px; max-width: min(440px, 66vw); }
.nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(37,99,235,.18);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.nav a:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(37,99,235,.26); filter: brightness(1.03); }

/* Public hero and cards */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 30px;
  background: linear-gradient(135deg, #0b78b6 0%, #2563eb 52%, #4338ca 100%);
  color: #fff;
  padding: 38px;
  box-shadow: var(--shadow);
  margin-bottom: 26px;
}
.hero::after {
  content: '';
  position: absolute;
  width: 310px;
  height: 310px;
  right: -120px;
  top: -120px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
}
.hero h1 { margin: 0 0 10px; font-size: clamp(30px, 5vw, 48px); letter-spacing: .02em; }
.hero p { max-width: 720px; margin: 0; line-height: 1.8; color: rgba(255,255,255,.88); }
.section-title { margin: 0 0 18px; font-size: clamp(26px, 3vw, 38px); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.card {
  background: var(--card);
  border: 1px solid rgba(226,232,240,.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  animation: fadeUp .42s ease both;
}
.card h1, .card h2, .card h3 { margin-top: 0; line-height: 1.25; }
.activity-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 270px;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.activity-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.activity-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: rgba(14,116,144,.28); }
.activity-card .btn { margin-top: auto; align-self: flex-start; }
.meta { color: var(--muted); line-height: 1.85; font-size: 15px; }
.meta-row { display: flex; gap: 8px; align-items: flex-start; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  background: #dcfce7;
  color: #166534;
}
.badge::before { content: ''; width: 8px; height: 8px; border-radius: 999px; background: currentColor; box-shadow: 0 0 0 5px rgba(22,101,52,.10); }
.badge.closed { background: #fee2e2; color: #991b1b; }
.event-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 22px; align-items: start; }
.event-info { position: sticky; top: 126px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* Forms, buttons, tables */
.form { display: grid; gap: 16px; }
.form label { display: block; font-weight: 850; margin-bottom: 6px; }
.input, textarea, select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 12px 13px;
  font-size: 16px;
  background: rgba(255,255,255,.95);
  color: var(--ink);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
textarea { min-height: 130px; resize: vertical; }
.input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.13); }
.choice { display:block; margin:.45rem 0; font-weight:600; color: #334155; }
.choice input { margin-right: 7px; transform: translateY(1px); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 17px;
  min-height: 43px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(37,99,235,.18);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(37,99,235,.26); filter: brightness(1.03); }
.btn:active { transform: translateY(0); }
.btn.secondary { background: linear-gradient(135deg, #475569, #334155); }
.btn.danger { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.btn.light { background: #eef2f7; color: #0f172a; box-shadow: none; }
.notice { padding: 14px 16px; border-radius: 16px; margin-bottom: 18px; background: #ecfeff; border: 1px solid #a5f3fc; color: #155e75; }
.notice.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.notice.success { background:#ecfdf5; color:#065f46; border:1px solid #a7f3d0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 18px; overflow: hidden; }
th, td { padding: 13px 15px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; white-space: normal; }
th { background: #f1f5f9; font-size: 14px; color: #334155; }
tr:hover td { background: #f8fafc; }
.table-wrap textarea { min-height:72px; }
.table-wrap input.input, .table-wrap select, .table-wrap textarea { width:100%; min-width:150px; }

/* Countdown */
.countdown {
  display: inline-flex;
  align-items: center;
  font-weight: 900;
  color: #b91c1c;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 999px;
  padding: 5px 11px;
  animation: softPulse 1.6s ease-in-out infinite;
}
.countdown.expired { color: #475569; background: #f1f5f9; border-color: #cbd5e1; animation: none; }

/* Admin */
.admin-layout { display: grid; grid-template-columns: 246px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, #075985, #0b78b6 58%, #1d4ed8);
  color: #fff;
  padding: 24px 20px;
  box-shadow: 12px 0 35px rgba(15,23,42,.12);
  z-index: 30;
}
.sidebar h1 { font-size: 22px; margin: 0 0 24px; letter-spacing: .03em; }
.sidebar a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 11px 13px;
  border-radius: 14px;
  margin-bottom: 9px;
  background: rgba(255,255,255,.12);
  font-weight: 850;
  transition: background .18s ease, transform .18s ease;
}
.sidebar a:hover { background: rgba(255,255,255,.22); transform: translateX(4px); }
.admin-main { padding: 30px; min-width: 0; }
.admin-topbar { display: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: #fff; border-radius: 18px; padding: 20px; border: 1px solid #e5e7eb; box-shadow: var(--shadow-sm); }
.stat strong { font-size: 34px; display: block; color: var(--primary-dark); }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, rgba(14,165,233,.16), transparent 36rem), var(--bg);
}
.login-box { max-width: 430px; width: 100%; margin: 0 auto; }
.login-logo { display: block; max-height: 74px; margin: 0 auto 18px; }

/* Footer */
.site-footer {
  margin-top: 28px;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #e5e7eb;
  font-size: 14px;
  line-height: 1.7;
  padding: 20px 0;
}
.site-footer .container { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes softPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.15); } 50% { box-shadow: 0 0 0 7px rgba(220,38,38,0); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 980px) {
  .event-layout { grid-template-columns: 1fr; }
  .event-info { position: static; }
}
@media (max-width: 760px) {
  .container { padding: 0 14px; }
  .main { padding: 22px 0 48px; }
  .header { position: static; padding: 12px 0; }
  .header-inner { align-items: flex-start; flex-direction: column; }
  .brand-logo img { max-width: 100%; max-height: 70px; }
  .nav { width: 100%; }
  .nav a, .btn { width: 100%; }
  .hero { padding: 26px 20px; border-radius: 24px; }
  .grid { grid-template-columns: 1fr; }
  .card { padding: 20px; border-radius: 20px; }
  .site-footer .container { align-items: flex-start; flex-direction: column; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 40;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    color: #fff;
    background: linear-gradient(135deg, #075985, #2563eb);
    box-shadow: 0 8px 24px rgba(15,23,42,.15);
  }
  .menu-toggle { border: 0; color: #fff; background: rgba(255,255,255,.16); border-radius: 12px; padding: 9px 12px; font-weight: 900; }
  .sidebar { position: fixed; transform: translateX(-105%); transition: transform .22s ease; width: 250px; height: 100vh; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .admin-main { padding: 20px 14px 34px; }
  th, td { padding: 11px 12px; }
}
@media (max-width: 520px) {
  .meta { font-size: 14px; }
  .input, textarea, select { font-size: 16px; }
  .hero h1 { font-size: 30px; }
}
