:root {
  --primary: #3a9a9a;
  --secondary: #98c48f;
  --ink: #1f2d2d;
  --muted: #5d6f6f;
  --bg: #ffffff;
  --soft: #f3f8f6;
  --line: #dde8e5;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; color: var(--ink); background: var(--bg); line-height: 1.65; }
img { max-width: 100%; }
a { color: var(--primary); }
.wrap { width: min(1100px, 92%); margin: 0 auto; }
.muted { color: var(--muted); }

/* header */
.site-header { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.95); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.1rem; }
.logo-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: #fff; font-size: .85rem; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: .95rem; }
nav a:hover, nav a.active { background: var(--soft); color: var(--primary); }
nav a.btn-link { background: var(--primary); color: #fff; }
nav a.btn-link:hover { opacity: .9; color: #fff; }
nav select { margin-left: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 1.2rem; padding: 4px 10px; cursor: pointer; }

/* hero */
.hero { padding: 88px 0 72px; background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 14%, #fff), color-mix(in srgb, var(--secondary) 22%, #fff)); }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); line-height: 1.2; margin: 0 0 16px; max-width: 18em; }
.hero p { font-size: 1.1rem; max-width: 38em; color: var(--muted); margin: 0 0 28px; }
.page-head { padding: 56px 0 28px; background: var(--soft); }
.page-head h1 { margin: 0 0 8px; }
.page-head p { margin: 0; color: var(--muted); }

/* sections */
section.block { padding: 64px 0; }
section.alt { background: var(--soft); }
h2 { font-size: 1.7rem; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 32px; max-width: 40em; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card h3 { margin: 0 0 8px; font-size: 1.1rem; }
.card p { margin: 0; color: var(--muted); }
.card .icon { width: 40px; height: 40px; border-radius: 10px; margin-bottom: 14px; background: linear-gradient(135deg, var(--primary), var(--secondary)); }

/* buttons */
.btn { display: inline-block; padding: 12px 22px; border: 0; border-radius: 10px; background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { opacity: .9; }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* forms */
form .field { margin-bottom: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
textarea { min-height: 120px; resize: vertical; }
.msg { margin-top: 12px; font-size: .95rem; min-height: 1.4em; }
.msg.ok { color: #1e7a4f; }
.msg.err { color: #b3261e; }
.narrow { max-width: 520px; }

/* portal */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stat .n { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat .l { color: var(--muted); font-size: .9rem; }
ul.rows { list-style: none; padding: 0; margin: 0; }
ul.rows li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--soft); font-size: .88rem; color: var(--muted); }
.tag { padding: 3px 10px; border-radius: 999px; font-size: .82rem; font-weight: 600; }
.tag.normal { background: #e3f4e8; color: #1e7a4f; }
.tag.watch { background: #fff3d6; color: #8a6200; }
.tag.follow { background: #fde2df; color: #b3261e; }
.table-wrap { overflow-x: auto; }

/* portal tabs */
.tabs { background: #fff; border-bottom: 1px solid var(--line); }
.tabs .wrap { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 0; }
.tabs a { white-space: nowrap; padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--ink); font-size: .92rem; }
.tabs a:hover { background: var(--soft); }
.tabs a.active { background: var(--primary); color: #fff; }

/* check-in */
.field.card { margin-bottom: 16px; }
.moods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.moods button { display: grid; gap: 2px; justify-items: center; padding: 10px 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font: inherit; cursor: pointer; }
.moods button b { font-size: 1.4rem; font-weight: 400; }
.moods button span { font-size: .78rem; color: var(--muted); }
.moods button[aria-pressed="true"] { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, #fff); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font: inherit; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, #fff); color: var(--primary); font-weight: 600; }
input[type="range"] { padding: 0; accent-color: var(--primary); }

/* progress / bars */
.progress { display: flex; gap: 8px; margin: 10px 0; }
.progress i { flex: 1; height: 10px; border-radius: 999px; background: var(--line); }
.progress i.filled { background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.bar-row { display: grid; grid-template-columns: 7em 1fr 2em; gap: 10px; align-items: center; padding: 6px 0; }
.bar-row div { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-row i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.bar-row b { text-align: right; }

/* actions / rewards / vouchers */
.action .num { display: inline-block; margin-bottom: 8px; color: var(--primary); font-weight: 700; }
.action button { margin-top: 12px; }
.balance-strip { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.balance-strip strong { font-size: 1.4rem; color: var(--primary); }
.reward .art { display: grid; place-items: center; height: 96px; margin-bottom: 12px; border-radius: 12px; font-size: 2.4rem; background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 16%, #fff), color-mix(in srgb, var(--secondary) 26%, #fff)); }
.reward .small { font-size: .8rem; }
.reward-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.reward button:disabled, .action button:disabled { opacity: .5; cursor: not-allowed; }
.voucher .code { margin-top: 12px; padding: 12px; border: 1px dashed var(--primary); border-radius: 10px; background: var(--soft); }
.voucher .code small { display: block; color: var(--muted); }
.voucher .code code { font-size: 1.05rem; letter-spacing: .06em; }
.gain { color: #1e7a4f; }
.spend { color: #b3261e; }

/* footer */
.site-footer { padding: 32px 0; border-top: 1px solid var(--line); background: var(--soft); font-size: .9rem; }
.site-footer p { margin: 4px 0; }

@media (max-width: 800px) {
  .g2, .g3, .stats { grid-template-columns: 1fr; }
  .menu-btn { display: block; }
  #nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch; background: #fff; padding: 12px 4%; border-bottom: 1px solid var(--line); }
  #nav.open { display: flex; }
  #nav select { margin: 8px 0 0; }
}

/* 補充：蜜罐、連結列、行內表單、危險按鈕 */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.links { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 16px; }
.inline-form { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; margin-bottom: 16px; }
.inline-form button { grid-column: 1 / -1; justify-self: start; }
.btn.danger { background: #b3261e; }
small.muted { display: block; margin-top: 4px; }
[hidden] { display: none !important; }

/* 修正：空訊息不佔位、語言選單寬度、滑桿樣式 */
.msg:empty { display: none; }
#flash { margin: 16px 0 0; }
nav select { width: auto; }
input[type="range"] { border: 0; background: transparent; padding: 0; accent-color: var(--primary); }
@media (max-width: 800px) { #nav select { width: 100%; } }

/* 滑桿：各瀏覽器一致的外觀 */
input[type="range"] { appearance: none; -webkit-appearance: none; height: 6px; border-radius: 999px; background: var(--line); outline-offset: 6px; }
input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--primary); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--primary); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--primary); cursor: pointer; }

/* ===== 協議簽署視窗與管理頁 ===== */
body.modal-open { overflow: hidden; }
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(20, 35, 35, .6); overflow-y: auto; padding: 4vh 12px; }
.modal { background: #fff; max-width: 680px; margin: 0 auto; border-radius: var(--radius); padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { margin: 0 0 8px; font-size: 1.3rem; }
.modal .notice { padding: 10px 12px; border-radius: 10px; background: #fff3d6; color: #6b4e00; }
.ag-body { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 38vh; overflow-y: auto; padding: 14px; margin: 12px 0 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); line-height: 1.7; }
.ag-body.full { max-height: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; margin: 12px 0; }
.check input { width: auto; margin-top: 4px; }
.sigpad { display: block; width: 100%; height: auto; aspect-ratio: 16 / 5; border: 2px dashed var(--primary); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.modal-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.small { font-size: .85rem; }
textarea.tall { min-height: 280px; }
.kvs { margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: 9em 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv .k { color: var(--muted); font-size: .9rem; }
.kv .v { overflow-wrap: anywhere; }
.sig-img { display: block; max-width: 100%; width: 420px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
@media (max-width: 800px) { .kv { grid-template-columns: 1fr; gap: 0; } }
@media print {
  .site-header, .tabs, .site-footer, .no-print, #flash { display: none !important; }
  .page-head { display: none !important; }
  .card { border: 0; padding: 0; }
  body { background: #fff; }
}

.build { font-size: .75rem; opacity: .7; }
