:root {
  --fg: #222; --muted: #777; --bg: #fafafa; --line: #e5e5e5;
  --accent: #06c755; --ok: #067a37; --danger: #d93025;
}
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", sans-serif;
}
[hidden] { display: none !important; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
main.wide { max-width: 1100px; }
h1 { font-size: 1.4rem; }
.brand { color: var(--muted); font-size: .85rem; margin: 0 0 -8px; }
.muted { color: var(--muted); font-size: .9rem; }
.pre { white-space: pre-wrap; }
.danger { color: var(--danger); }
.ok { color: var(--ok); }

.banner { padding: 10px 12px; border-radius: 8px; background: #eef1ff; font-weight: 600; }
.banner.open { background: #e6f9ee; color: var(--ok); }
.banner.ended { background: #eee; color: #666; }

.item { display: flex; align-items: center; flex-wrap: wrap;
        padding: 12px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.item-body { flex: 1; min-width: 0; }
.item-desc { margin-top: 4px; font-size: .9rem; color: #555; white-space: pre-wrap; overflow-wrap: anywhere; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; cursor: zoom-in;
         flex: none; background: #eee; }
.thumb.zoom { width: 100%; height: auto; max-height: 60vh; object-fit: contain; cursor: zoom-out; }
.stepper { flex: none; }
.item.sold-out { opacity: .5; }
.item-name { font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 38px; height: 38px; font-size: 1.2rem; border-radius: 50%;
                  border: 1px solid #ccc; background: #fff; }

label { display: block; margin: 12px 0 4px; }
input, textarea, select { width: 100%; box-sizing: border-box; padding: 10px; font-size: 1rem;
                  border: 1px solid #ccc; border-radius: 6px; }
label input[type=checkbox] { width: auto; margin-right: 6px; }
.terms ul { padding-left: 20px; font-size: .85rem; color: #555; }
.total { font-size: 1.1rem; font-weight: 700; }

button { cursor: pointer; }
#submit, .primary { width: 100%; padding: 14px; font-size: 1.1rem; font-weight: 700;
                    color: #fff; background: var(--accent); border: 0;
                    border-radius: 8px; margin-top: 12px; }
button:disabled { background: #bbb; color: #fff; cursor: not-allowed; }

.result { padding: 14px; border-radius: 8px; margin-top: 16px; font-weight: 700; }
.result.success { background: #e6f9ee; color: var(--ok); }
.result.fail { background: #fdecea; color: var(--danger); }

.card { background: #fff; border: 1px solid var(--line); border-radius: 10px;
        padding: 12px 16px; margin: 12px 0; }
.tag { font-size: .8rem; padding: 2px 8px; border-radius: 10px; background: #eee; }
.tag.open { background: #e6f9ee; color: var(--ok); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; vertical-align: top; }
tr.cancelled { opacity: .45; text-decoration: line-through; }
#item-rows input { padding: 6px; }

.invite-box { background: #f6f7ff; border: 1px dashed #99a; border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
code { background: #f0f0f0; padding: 1px 5px; border-radius: 4px; font-size: .85em; }
.right { text-align: right; }

/* 頁籤 */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 14px 0 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px;
               padding: 10px 16px; font-size: 1rem; color: var(--muted); white-space: nowrap; }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--fg); font-weight: 700; border-bottom-color: var(--accent); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* 品項編輯卡片 */
.item-edit { border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px 12px; margin: 10px 0; background: #fcfcfc; }
.item-edit-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 0 10px; }
@media (max-width: 560px) { .item-edit-grid { grid-template-columns: 1fr 1fr; } }
.image-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.image-row .preview { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.file-btn { display: inline-block; margin: 0; padding: 8px 12px; border: 1px solid #ccc; border-radius: 6px;
            background: #fff; cursor: pointer; }
.file-btn input { display: none; }
.event-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 5px; vertical-align: middle; margin-right: 6px; }
.item-note { color: var(--muted); font-size: .85rem; }

/* 活動範本 */
.tpl-box { margin: 0 0 18px; padding: 6px 14px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fcfcfc; }
.tpl-box h3 { margin: 8px 0 4px; }
.tpl-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
           padding: 10px 0; border-bottom: 1px solid var(--line); }
.tpl-row:last-child { border-bottom: 0; }
.tpl-main { flex: 1; min-width: 200px; }
.tpl-name { font-weight: 600; overflow-wrap: anywhere; }
.tpl-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tpl-actions button.apply { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 6px 14px; font-weight: 600; }
