/* 設計基調：乾淨、信任感、深藍主色。所有顏色集中在變數，改品牌色只動這裡。 */
:root {
	--brand: #14508c;
	--brand-dark: #0e3a66;
	--brand-light: #eaf1f8;
	--ink: #1a2733;
	--muted: #5b6b7a;
	--faint: #8b9aa8;
	--line: #dfe6ec;
	--bg: #f2f5f8;
	--card: #ffffff;
	--danger: #b3261e;
	--ok: #1c7c43;
	--alert-bg: #fdecea;
	--radius: 12px;
	--shadow: 0 1px 3px rgba(16, 42, 67, 0.08), 0 4px 16px rgba(16, 42, 67, 0.06);
	color-scheme: light;
}

/* 深色主題：手動選深色，或跟隨系統偏好（未手動選淺色時） */
[data-theme="dark"] {
	--brand: #5b9bd9;
	--brand-dark: #7ab0e2;
	--brand-light: #1c2a3a;
	--ink: #e7edf4;
	--muted: #a7b5c2;
	--faint: #7a8998;
	--line: #2b3644;
	--bg: #0f151c;
	--card: #171f2a;
	--danger: #f07168;
	--ok: #57c584;
	--alert-bg: #3a2220;
	--shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35);
	color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--brand: #5b9bd9;
		--brand-dark: #7ab0e2;
		--brand-light: #1c2a3a;
		--ink: #e7edf4;
		--muted: #a7b5c2;
		--faint: #7a8998;
		--line: #2b3644;
		--bg: #0f151c;
		--card: #171f2a;
		--danger: #f07168;
		--ok: #57c584;
		--alert-bg: #3a2220;
		--shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35);
		color-scheme: dark;
	}
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
	font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
	background: var(--bg);
	color: var(--ink);
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	line-height: 1.6;
}

/* ---- 頂欄 ---- */
.topbar {
	background: var(--card);
	border-bottom: 1px solid var(--line);
	padding: 12px 24px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	position: sticky;
	top: 0;
	z-index: 10;
}
.brand {
	font-weight: 700;
	font-size: 1.15rem;
	color: var(--brand);
	text-decoration: none;
	display: flex;
	align-items: center;
	gap: 8px;
}
.brand::before {
	content: "咻";
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 8px;
	background: var(--brand);
	color: #ffffff;
	font-size: 0.95rem;
	font-weight: 700;
}
.topbar nav { display: flex; align-items: center; gap: 4px; }
.topbar nav a {
	color: var(--muted);
	text-decoration: none;
	padding: 6px 10px;
	border-radius: 8px;
	font-size: 0.92rem;
	transition: background 0.15s, color 0.15s;
}
.topbar nav a:hover { background: var(--brand-light); color: var(--brand); }
.theme-toggle {
	margin-left: 8px;
	padding: 5px 12px;
	border: 1.5px solid var(--line);
	background: transparent;
	color: var(--muted);
	border-radius: 8px;
	cursor: pointer;
	font-family: inherit;
	font-size: 0.84rem;
	transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }

/* ---- 主卡片 ---- */
.container {
	width: 100%;
	max-width: 660px;
	margin: 32px auto;
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 32px;
	box-shadow: var(--shadow);
	flex: 0 0 auto;
}
.container.narrow { max-width: 440px; }
.container.wide { max-width: 960px; overflow-x: auto; }
h1 { font-size: 1.35rem; margin-bottom: 6px; letter-spacing: 0.01em; }
.subtitle { color: var(--muted); margin-bottom: 22px; font-size: 0.94rem; }

/* ---- 首頁 hero ---- */
.hero { text-align: center; margin: 40px 16px 8px; }
.hero h1 { font-size: 1.9rem; line-height: 1.35; }
.hero p { color: var(--muted); margin-top: 8px; font-size: 1rem; }
.hero .accent { color: var(--brand); }

/* ---- 分頁 ---- */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; background: var(--bg); padding: 5px; border-radius: 10px; }
.tab {
	flex: 1;
	padding: 9px 0;
	border: none;
	background: transparent;
	border-radius: 8px;
	cursor: pointer;
	font-size: 0.98rem;
	color: var(--muted);
	font-family: inherit;
	transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.tab:hover { color: var(--brand); }
.tab.active { background: var(--card); color: var(--brand); font-weight: 700; box-shadow: 0 1px 3px rgba(16, 42, 67, 0.12); }

/* ---- 表單 ---- */
.panel { margin-bottom: 16px; }
.hidden { display: none; }
label { display: block; font-size: 0.9rem; color: var(--ink); margin-bottom: 12px; font-weight: 500; }
input[type="url"], input[type="text"], input[type="password"], select, textarea {
	width: 100%;
	margin-top: 6px;
	padding: 11px 12px;
	border: 1.5px solid var(--line);
	border-radius: 9px;
	font-size: 1rem;
	font-family: inherit;
	background: var(--card);
	color: var(--ink);
	transition: border-color 0.15s, box-shadow 0.15s;
	font-weight: 400;
}
textarea { resize: vertical; font-family: inherit; }
.desc-label { grid-column: 1 / -1; }
input:focus, select:focus, textarea:focus {
	outline: none;
	border-color: var(--brand);
	box-shadow: 0 0 0 3px rgba(20, 80, 140, 0.12);
}
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 20px; }

/* ---- 拖拉上傳區 ---- */
.dropzone {
	margin-top: 6px;
	border: 2px dashed var(--line);
	border-radius: 10px;
	padding: 26px 16px;
	text-align: center;
	color: var(--muted);
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s;
	font-weight: 400;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand); background: var(--brand-light); color: var(--brand); }
.dropzone input[type="file"] { display: none; }
.dropzone .dz-hint { font-size: 0.82rem; color: var(--faint); margin-top: 4px; }
.dropzone.dragover .dz-hint { color: var(--brand); }

/* 選好的檔案清單 */
.file-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.file-item {
	display: flex;
	align-items: center;
	gap: 10px;
	background: var(--bg);
	border-radius: 9px;
	padding: 8px 12px;
	font-size: 0.88rem;
}
.file-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.file-item .fi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .fi-size { color: var(--faint); flex: 0 0 auto; }
.file-item .fi-bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 5px; }
.file-item .fi-bar-fill { height: 100%; width: 0; background: var(--brand); border-radius: 2px; transition: width 0.2s; }
.file-item .fi-main { flex: 1; min-width: 0; }
.file-item .fi-done { color: var(--ok); flex: 0 0 auto; font-size: 0.82rem; }

/* ---- 按鈕 ---- */
button.primary, a.primary {
	width: 100%;
	padding: 13px;
	background: var(--brand);
	color: #ffffff;
	border: none;
	border-radius: 10px;
	font-size: 1.05rem;
	font-weight: 700;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s, transform 0.05s;
}
button.primary:hover, a.primary:hover { background: var(--brand-dark); }
button.primary:active { transform: scale(0.99); }
button.primary:disabled { background: var(--faint); cursor: default; }

#progress { margin-top: 16px; color: var(--muted); font-size: 0.92rem; }

/* ---- 結果卡 ---- */
#result { margin-top: 20px; background: var(--brand-light); border-radius: 10px; padding: 16px; }
#result > p { font-size: 0.88rem; color: var(--muted); margin-bottom: 6px; }
.result-row { display: flex; gap: 8px; }
.result-row input { flex: 1; background: var(--card); margin: 0; font-weight: 500; }
.result-row button {
	padding: 0 18px;
	border: 1.5px solid var(--brand);
	background: var(--card);
	color: var(--brand);
	border-radius: 9px;
	cursor: pointer;
	font-family: inherit;
	font-size: 0.95rem;
	font-weight: 500;
	transition: background 0.15s, color 0.15s;
	white-space: nowrap;
}
.result-row button:hover { background: var(--brand); color: #ffffff; }
.result-row button.copied { background: var(--ok); border-color: var(--ok); color: #ffffff; }
.result-title { font-size: 1.2rem; margin-bottom: 14px; color: var(--ok); }
.result-actions { display: flex; gap: 10px; margin-top: 16px; }
.result-actions .line-btn {
	flex: 1;
	text-align: center;
	padding: 11px;
	background: #06c755;
	color: #ffffff;
	border-radius: 9px;
	text-decoration: none;
	font-weight: 500;
}
.result-actions .line-btn:hover { background: #05a648; }
#again {
	flex: 1;
	padding: 11px;
	border: 1.5px solid var(--brand);
	background: transparent;
	color: var(--brand);
	border-radius: 9px;
	cursor: pointer;
	font-family: inherit;
	font-size: 0.98rem;
}
#again:hover { background: var(--brand-light); }

.result-qr { margin-top: 14px; text-align: center; }
.result-qr img { width: 150px; height: 150px; border: 1px solid var(--line); border-radius: 10px; background: #ffffff; padding: 6px; }

.error { color: var(--danger); margin-top: 14px; font-size: 0.92rem; }
/* 遮罩輸入：顯示成圓點但保留中文輸入法（真正的密碼框會被瀏覽器擋掉輸入法） */
input.masked { -webkit-text-security: disc; }

.utm-box { margin-top: 4px; }
.utm-box summary { font-size: 0.85rem; color: var(--faint); cursor: pointer; }
.utm-box summary:hover { color: var(--brand); }
.utm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.utm-grid label { font-size: 0.82rem; color: var(--muted); margin: 0; }

.adult-check { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--muted); margin-bottom: 16px; font-weight: 400; }
.tag-adult { display: inline-block; margin-left: 6px; padding: 1px 7px; font-size: 0.74rem; background: var(--alert-bg); color: var(--danger); border-radius: 5px; }

.qr-colors { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 8px; font-size: 0.82rem; color: var(--muted); }
.qr-color { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.share-desc { color: var(--muted); font-size: 0.95rem; line-height: 1.7; margin-bottom: 14px; white-space: pre-wrap; word-break: break-word; }

/* ---- 首頁下方：特色與比較 ---- */
.below { max-width: 960px; margin: 8px auto 0; padding: 0 16px; width: 100%; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 28px 0; }
.feature {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 20px;
}
.feature h3 { font-size: 1rem; margin-bottom: 6px; color: var(--brand); }
.feature p { font-size: 0.88rem; color: var(--muted); }

.below h2 { font-size: 1.15rem; text-align: center; margin-bottom: 16px; }
.steps { margin: 36px 0; }
.step-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.step {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 18px;
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 0.92rem;
	color: var(--muted);
}
.step-num {
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--brand);
	color: #ffffff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
}
.scenarios { margin: 36px 0; }
.home-faq { max-width: 660px; margin: 36px auto; }
.home-faq details {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 14px 18px;
	margin-bottom: 10px;
}
.home-faq summary { cursor: pointer; font-weight: 500; color: var(--ink); }
.home-faq summary:hover { color: var(--brand); }
.home-faq details p { margin-top: 8px; font-size: 0.9rem; color: var(--muted); }
.home-faq details a { color: var(--brand); }

/* ---- 觀看頁 ---- */
.gallery { display: flex; flex-direction: column; gap: 16px; }
.gallery img, .gallery video { width: 100%; border-radius: 10px; display: block; }
.gallery audio { width: 100%; }
.footnote { margin-top: 20px; text-align: center; font-size: 0.9rem; color: var(--muted); }
.footnote a { color: var(--brand); }

/* ---- 頁尾 ---- */
.footer { text-align: center; color: var(--faint); font-size: 0.84rem; padding: 28px 16px; margin-top: auto; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--brand); }

/* ---- 條文頁 ---- */
.prose { font-size: 0.95rem; line-height: 1.75; color: var(--ink); }
.prose h2 { font-size: 1.02rem; margin: 20px 0 8px; }
.prose p { margin-bottom: 10px; }
.prose ul { margin: 0 0 10px 20px; }
.prose a { color: var(--brand); }

/* ---- 列表頁（我的分享 / 後台） ---- */
.mine-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.mine-table th { color: var(--muted); font-weight: 500; font-size: 0.84rem; }
.mine-table th, .mine-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.mine-table tbody tr { transition: background 0.1s; }
.mine-table tbody tr:hover { background: var(--bg); }
.mine-table a { color: var(--brand); }
.mine-table .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mine-table .actions form { display: flex; gap: 4px; margin: 0; }
.mine-table .actions select { width: auto; margin: 0; padding: 4px 6px; font-size: 0.86rem; }
.mine-table .actions button {
	padding: 4px 12px;
	border-radius: 7px;
	border: 1.5px solid var(--brand);
	background: var(--card);
	color: var(--brand);
	cursor: pointer;
	font-family: inherit;
	font-size: 0.86rem;
	transition: background 0.15s, color 0.15s;
}
.mine-table .actions button:hover { background: var(--brand); color: #ffffff; }
.mine-table .actions button.danger { border-color: var(--danger); color: var(--danger); }
.mine-table .actions button.danger:hover { background: var(--danger); color: #ffffff; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 7px; font-size: 0.74rem; background: var(--brand-light); color: var(--brand); border-radius: 5px; }
.dimmed, .dimmed a { color: var(--faint); }

/* ---- 登入頁 ---- */
.login-buttons { display: flex; flex-direction: column; gap: 10px; }
a.primary.go-button { display: block; text-align: center; text-decoration: none; }
a.primary.line-button { background: #06c755; }
a.primary.line-button:hover { background: #05a648; }

/* ---- 轉址等待頁 ---- */
.redirect-target { word-break: break-all; background: var(--bg); border-radius: 9px; padding: 12px; margin: 12px 0; font-size: 0.94rem; }
.ad-slot { margin: 16px 0; min-height: 90px; }

/* ---- 管理後台 ---- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0 8px; }
.stat { background: var(--bg); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-size: 1.45rem; font-weight: 700; color: var(--ink); }
.stat-label { font-size: 0.8rem; color: var(--muted); }
.section-title { font-size: 1.02rem; margin: 26px 0 10px; }
.bar-chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.bar-track { flex: 1; width: 70%; display: flex; flex-direction: column; justify-content: flex-end; }
.bar-fill { min-height: 2px; background: var(--brand); border-radius: 4px 4px 0 0; }
.bar-day { font-size: 0.66rem; color: var(--faint); margin-top: 4px; border-top: 1px solid var(--line); width: 100%; text-align: center; padding-top: 3px; }
.filter-row { display: flex; gap: 8px; margin: 12px 0 16px; }
.filter-row select, .filter-row input { width: auto; flex: 0 0 auto; margin: 0; }
.filter-row input[type="text"] { flex: 1; }
.filter-row button {
	padding: 8px 18px;
	border: none;
	background: var(--brand);
	color: #ffffff;
	border-radius: 9px;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.15s;
}
.filter-row button:hover { background: var(--brand-dark); }
.target-url { font-size: 0.76rem; color: var(--faint); word-break: break-all; max-width: 260px; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; display: block; }
a.stat { text-decoration: none; transition: background 0.15s; }
a.stat:hover { background: var(--brand-light); }
.stat-alert { background: var(--alert-bg); }
.stat-alert .stat-num { color: var(--danger); }
.gender-set { border: none; margin-bottom: 16px; }
.gender-set legend { font-size: 0.9rem; font-weight: 500; margin-bottom: 8px; }
.radio-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 9px; margin-bottom: 8px; cursor: pointer; font-weight: 400; }
.radio-row:hover { border-color: var(--brand); }
.pager { display: flex; gap: 16px; justify-content: center; margin-top: 16px; color: var(--muted); }
.pager a { color: var(--brand); }

/* ---- 手機 ---- */
@media (max-width: 700px) {
	.stat-grid { grid-template-columns: repeat(2, 1fr); }
	.feature-grid, .step-row, .utm-grid { grid-template-columns: 1fr; }
	.container { margin: 14px; padding: 20px; width: auto; }
	.options { grid-template-columns: 1fr; }
	.hero { margin: 24px 12px 4px; }
	.hero h1 { font-size: 1.45rem; }
	.topbar { padding: 10px 12px; flex-wrap: wrap; gap: 6px; }
	.topbar nav { flex-wrap: wrap; }
	.topbar nav a { padding: 6px 7px; font-size: 0.86rem; }
	.mine-table { min-width: 560px; } /* 表格窄不下去就讓它在卡片內橫向捲動 */
	.filter-row { flex-wrap: wrap; }
	.filter-row input[type="text"] { min-width: 160px; }
	.result-row { flex-direction: column; }
	.result-row button { padding: 10px; }
}
