/* 绿色主题与布局样式 */
:root {
    --green-50: #ecfdf3;
    --green-100: #d1fae5;
    --green-200: #a7f3d0;
    --green-300: #6ee7b7;
    --green-400: #34d399;
    --green-500: #10b981;
    --green-600: #059669;
    --green-700: #047857;
    --green-800: #065f46;
    --green-900: #064e3b;

    --brand: #12b76a; /* 主品牌色（默认，运行时会被主题覆盖） */
    /* 由品牌色推导的通用变量 */
    --brand-ink: color-mix(in srgb, var(--brand) 36%, black);
    --ring: color-mix(in srgb, var(--brand) 35%, transparent);
    --brand-500: var(--brand);
    --brand-600: color-mix(in srgb, var(--brand) 85%, black);

    /* 中性色：用少量品牌色进行轻微着色，避免固定浅绿色 */
    --bg: color-mix(in srgb, var(--brand) 6%, #ffffff);
    --card: #ffffff;
    --text: #111418;
    --muted: #667085;
    --shadow: 0 10px 25px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.05);
    /* 固定页脚的预留高度（含安全区），避免需要滚动才能看到） */
    --footer-height: 120px;

}

/* 删除自适应视口变量 */

/* 已移除本地字体文件依赖，统一使用系统字体栈 */

.theme-dark {
    /* 提亮深色模式整体氛围 */
    --bg: color-mix(in srgb, var(--brand) 18%, #0b1512);
    --card: color-mix(in srgb, var(--brand) 8%, #101d18);
    --text: #dbf5ea;
    --muted: #9cc7bb;
    --ring: color-mix(in srgb, var(--brand) 60%, transparent);
    --shadow: 0 20px 40px rgba(0,0,0,0.32), 0 6px 12px rgba(0,0,0,0.22);
}

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	/* Windows: DengXian; iOS: default system; Android: Roboto; others fallback */
	font-family: "DengXian", -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Roboto", "Noto Sans CJK SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Helvetica, Arial, sans-serif;
	overflow-x: hidden; /* 防止小屏横向抖动 */
    /* 防止某些浏览器缩放后出现 0.5px 级别的右侧位移 */
    position: relative;
}

/* Windows 下标题、小标题优先使用加粗微软雅黑（其他平台自动回退） */
h1, h2, h3, h4, h5, h6,
.brand__title,
.card__header,
.weui-cells__title,
.sheet__header {
	font-family: "Microsoft YaHei", "DengXian", -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Roboto", "Noto Sans CJK SC", "PingFang SC", "Hiragino Sans GB", Helvetica, Arial, sans-serif;
	font-weight: 700;
}

/* 移动端左右对称：所有主要容器按安全区域留白（避免只左侧留空） */
.app__header,
.app__main,
.app__footer {
    padding-left: calc(var(--page-padding-x, 16px) + max(env(safe-area-inset-left, 0px), 0px));
    padding-right: calc(var(--page-padding-x, 16px) + max(env(safe-area-inset-right, 0px), 0px));
}

/* 初始隐藏主体，显示加载层 */
.hidden-onload { visibility: hidden; }
.loader {
	position: fixed; inset: 0; display: grid; place-items: center; gap: 14px;
	background: var(--bg); color: var(--brand-ink); z-index: 999999999;
}
.loader__spinner {
    width: 36px; height: 36px; border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--brand) 25%, transparent);
    border-top-color: var(--brand);
    animation: spin 1s linear infinite;
}
.loader__text { font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 增加加载进度与文件名显示 */
.loader__progress { width: min(520px, 86vw); display: grid; gap: 6px; }
.loader__bar { width: 100%; height: 8px; background: color-mix(in srgb, var(--brand) 14%, transparent); border-radius: 999px; overflow: hidden; }
.loader__bar-inner { height: 100%; background: var(--brand); border-radius: 999px; width: 0%; transition: width .2s ease; }
.loader__meta { display: flex; justify-content: space-between; color: var(--muted); font-weight: 600; }

/* 选中文本的背景色设为绿色系 */
::selection { background: color-mix(in srgb, var(--brand) 35%, transparent); color: var(--brand-ink); }
::-moz-selection { background: color-mix(in srgb, var(--brand) 35%, transparent); color: var(--brand-ink); }

.app {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.app__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-top: 16px;
	padding-bottom: 16px;
	position: sticky;
	top: 0;
	background: linear-gradient(180deg, var(--card), rgba(255,255,255,0.6));
	backdrop-filter: saturate(140%) blur(6px);
	box-shadow: 0 1px 0 rgba(0,0,0,0.06);
	z-index: 50; /* 提升层级，避免被内容覆盖 */
}

.app__brand {
	display: flex;
	align-items: center;
	gap: 10px;
}

.brand__logo {
	font-size: 22px;
}

.brand__title {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: .5px;
}

.brand__profile { margin-left: 10px; }
.profile__label { margin-right: 6px; font-weight: 600; color: var(--brand-ink); }
.weui-select_in-header { all: revert; }

/* 恢复浏览器原生 Select 样式 */
select.weui-select { all: revert; }

/* 新版设置按钮：图标+文本，始终在页眉内对齐且不溢出 */
.settings-btn {
    appearance: none;
    border: 2px solid var(--brand);
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 8%, transparent), color-mix(in srgb, var(--brand) 2%, transparent)), var(--card);
    color: var(--brand);
    border-radius: 12px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    line-height: 1;
    box-shadow: 0 2px 0 color-mix(in srgb, var(--brand-ink) 6%, transparent), inset 0 1px 0 rgba(255,255,255,0.6);
    font-size: 14px;
    min-height: 38px;
}
.settings-btn__icon { width: 20px; height: 20px; display: inline-block; color: var(--brand); }
.settings-btn__text { font-weight: 600; }

/* 布局：让按钮参与页眉 Flex 布局，始终与标题垂直居中且对齐右侧 */
.app__settings-btn { margin-left: auto; z-index: 1; }
@media (max-width: 640px) {
    .settings-btn { padding: 8px; gap: 0; min-height: 40px; border-radius: 12px; }
    .settings-btn__icon { width: 22px; height: 22px; }
    .settings-btn__text { display: none; } /* 小屏仅图标，避免溢出 */
}

/* 顶部横幅（居中，不占满；出现/隐藏不影响布局） */

.banner {
	position: fixed;
	top: 0; /* 由 JS 动态设置到页眉下方 */
	left: 50%;
	transform: translate(-50%, -140%);
	width: auto;
	max-width: min(920px, calc(100vw - 24px));
	z-index: 99999999;
	margin: 0;
	padding: 10px 14px;
	background: #E6F2FF; /* 默认非透明浅蓝 */
    color: var(--text);
	border-left: 4px solid #1d4ed8;
	border-radius: 0;
	box-shadow: 0 4px 22px rgba(0,0,0,0.12);
	opacity: 0;
	transition: transform .28s ease, opacity .28s ease;
	will-change: transform, opacity;
	pointer-events: none; /* 不遮挡下层点击，尤其是小屏 */
	display: inline-block;
	box-sizing: border-box;
}
.banner__inner { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.banner__text { display: block; font-weight: 700; white-space: normal; word-break: break-word; }
.banner--kaiti .banner__text { font-family: KaiTi, STKaiti, "Kaiti SC", "DFKai-SB", serif; }
.banner--slow { transition: transform .62s ease, opacity .62s ease; }
.banner__close {
	pointer-events: auto; /* 允许点击关闭按钮 */
	appearance: none; border: 0; background: transparent; color: currentColor; font-size: 18px; line-height: 1; width: 28px; height: 28px; cursor: pointer;
}
.banner__close:hover { opacity: .9; }
.banner.is-show { transform: translate(-50%, 0); opacity: 1; }
.banner--blue { background: #E6F2FF; border-left-color: #0078D4; }
.banner--red { background: #FFE8EA; border-left-color: #dc2626; color: #7f1d1d; }
.theme-dark .banner--blue { background: #143A66; border-left-color: #93c5fd; color: #dbeafe; }
.theme-dark .banner--red { background: #4C1416; border-left-color: #fecaca; color: #fee2e2; }



.app__main {
	flex: 1; /* 主体占满，底部信息置底 */
	padding: 16px;
	/* 为固定页脚预留空间，避免遮挡诗句或按钮 */
	padding-bottom: calc(16px + var(--footer-height));
	max-width: 700px;
	width: 100%;
	margin-left: auto;
	margin-right: auto;
	display: grid;
	gap: 16px;
	align-content: start;
}

/* 缩小整体外框视觉宽度 */
.app .card--panel { max-width: 700px; margin: 0 auto; }

.card {
	background: var(--card);
	border-radius: 14px;
	box-shadow: var(--shadow);
	padding: 16px;
}

.card--panel { border: 2px solid color-mix(in srgb, var(--brand) 12%, transparent); }

.card__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 8px;
	font-weight: 600;
}

.range-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 12px;
}

.range-item {
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 16%, transparent), color-mix(in srgb, var(--brand) 6%, transparent));
    border: 2px solid color-mix(in srgb, var(--brand) 45%, transparent);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 6px 14px color-mix(in srgb, var(--brand) 12%, transparent);
}


.weui-input, .weui-textarea {
    /* 统一为更显眼的输入视觉（与 rc-input 一致） */
    border: 2px solid color-mix(in srgb, var(--brand-ink) 70%, transparent);
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 8%, transparent), color-mix(in srgb, var(--brand) 2%, transparent)), #fff;
    border-radius: 10px;
    padding: 8px 10px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;
    box-shadow: 0 2px 0 color-mix(in srgb, var(--brand-ink) 6%, transparent), inset 0 1px 0 rgba(255,255,255,0.6);
    line-height: 1.4;
}

/* 自定义名单输入框放大 + 科技感字体 */
#textareaRoster.weui-textarea {
	font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	font-size: 16px;
	line-height: 1.6;
	min-height: 280px; /* 默认更高 */
	padding: 12px 12px; /* 内边距更舒适 */
	letter-spacing: 0.2px;
}

/* number 输入统一外观：去除浏览器自带微调按钮 */
input.weui-input[type="number"]::-webkit-outer-spin-button,
input.weui-input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.weui-input[type="number"] { -moz-appearance: textfield; }


.weui-input:focus, .weui-textarea:focus { box-shadow: 0 0 0 3px var(--ring), 0 2px 0 color-mix(in srgb, var(--brand-ink) 6%, transparent); border-color: var(--brand); background: #fff; }

/* 输入框未键入也要明显 */
.weui-input::placeholder, .weui-textarea::placeholder { color: color-mix(in srgb, var(--brand-ink) 65%, transparent); }
/* 占位符状态也保持与常态一致，避免样式不统一 */
.weui-input:placeholder-shown, .weui-textarea:placeholder-shown {
    border-color: color-mix(in srgb, var(--brand-ink) 70%, transparent);
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 8%, transparent), color-mix(in srgb, var(--brand) 2%, transparent)), #fff;
}

/* 深色模式：输入框与下拉统一深色背景与绿色边框 */
.theme-dark .weui-input,
.theme-dark .weui-textarea,
.theme-dark select.weui-select {
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, transparent), color-mix(in srgb, var(--brand) 2%, transparent)), #0e1915;
    border-color: color-mix(in srgb, var(--brand) 55%, transparent);
    color: var(--text);
}
.theme-dark .weui-input::placeholder,
.theme-dark .weui-textarea::placeholder { color: color-mix(in srgb, var(--text) 65%, transparent); }
.theme-dark .weui-input:focus,
.theme-dark .weui-textarea:focus,
.theme-dark select.weui-select:focus {
    border-color: var(--brand);
    background: #0e1915;
    box-shadow: 0 0 0 3px var(--ring), 0 2px 0 color-mix(in srgb, var(--brand-ink) 6%, transparent);
}

.controls {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 12px;
	margin-top: 12px;
}

.controls__primary {
	position: relative;
	width: 100%;
	display: grid;
	grid-template-columns: 1fr;
	grid-template-rows: 1fr;
}
.controls__primary > .weui-btn { grid-area: 1 / 1; }
.controls__primary > .hidden { display: none; }

/* 底部第二组按钮 */
.controls--bottom { margin-top: 12px; grid-template-columns: 1fr; justify-items: center; gap: 10px; }

.weui-btn_primary { background-color: var(--brand); border-color: var(--brand); }
.weui-btn_primary:not(.weui-btn_disabled):active { background-color: var(--brand-600); }

.display { 
	margin-top: 14px;
	text-align: center;
	padding: 24px 12px 14px;
	border-radius: 12px;
	position: relative;
	background: var(--card);
    border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
	box-shadow: var(--shadow);
	overflow: hidden; /* 避免内容溢出引发滚动抖动 */
	contain: content; /* 更强隔离，减少小屏抖动 */
	min-height: 200px; /* 小屏兜底高度，避免内容推挤抖动 */
	max-height: none;
	/* 让中间数字始终几何居中 */
	display: grid;
	grid-template-rows: auto 1fr auto; /* label / number / name */
	align-items: center;
}

/* 结果操作栏：答对/答错/跳过（停止后缓缓显现） */
#resultActions.result-actions { display:flex; gap:10px; align-items:center; justify-content:center; opacity:0; transform: translateY(-6px); transition: opacity .24s ease, transform .24s ease; }
#resultActions.result-actions.is-show { opacity:1; transform: translateY(0); }
#resultActions .weui-btn { min-width: 92px; }

/* 智慧统计弹窗标题行：左右对齐显示提示文案 */
.stats-title { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.stats-title .stats-hint { font-size: 12px; color: var(--muted); font-weight: 500; }

/* 智慧统计蓝色提示：缓慢淡隐/淡现 */
.js-hint-disable-no-repeat { transition: opacity .4s ease; }
.js-hint-disable-no-repeat.is-hidden-soft { opacity: 0; }
/* 当需要隐藏整行（weui-cell）以避免残留分割线时 */
.weui-cell.js-hint-row { transition: opacity .4s ease; }
.weui-cell.js-hint-row.is-hidden-soft { opacity: 0; }

.display__label {
	font-size: 13px;
	color: var(--brand-ink);
	margin-bottom: 6px;
	font-weight: 600;
}

.display__number {
	font-size: 168px;
	font-weight: 900;
	letter-spacing: 1.5px;
	color: var(--brand-ink);
    text-shadow: 0 12px 28px color-mix(in srgb, var(--brand) 30%, transparent);
	min-height: 1em;
	line-height: 1.05;
	white-space: nowrap;
	will-change: transform, filter; /* 启用合成层，减少重排 */
	backface-visibility: hidden;
	/* 使用继承字体（保持以前的字体效果） */
	display: inline-block; /* 允许设置稳定最小宽度 */
	min-width: var(--number-min-width, auto); /* JS 可设置为 Nch，避免不同位数跳动 */
	margin: 0 auto; /* 视觉水平居中 */
}

/* 占位提示样式：小字号、可换行、不投影 */
/* 占位样式已拆分到 assets/css/display.css */

.display__name {
	margin-top: 4px;
	font-size: 18px;
	color: var(--text);
	opacity: .85;
}

/* 数字滚动时隐藏姓名但保留占位，避免垂直抖动 */
.display__name.hidden { display: block; visibility: hidden; }

/* 自动抽人读秒覆盖层 */
.display__countdown {
	position: absolute;
	inset: 0;
	display: flex;
	justify-content: center;
	align-items: center;
	font-weight: 900;
    font-size: clamp(48px, 12vw, 96px);
    color: var(--brand);
    text-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 25%, transparent);
	background: rgba(0,0,0,0.02);
	border-radius: 16px;
}

/* 原历史区域隐藏，页面更紧凑 */
/* 历史 UI 已移除 */

.history .weui-cell { align-items: center; }
.history__num {
    font-weight: 700;
    color: var(--brand-ink);
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    padding: 4px 10px;
    border-radius: 999px;
    margin-right: 10px;
}

.app__footer { 
    padding: 6px 10px; 
    display: grid;
    grid-template-columns: auto 1fr; 
    align-items: center; 
    gap: 12px;
    color: var(--muted);
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, color-mix(in srgb, var(--card) 86%, transparent), color-mix(in srgb, var(--card) 60%, transparent));
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    box-shadow: 0 -1px 0 rgba(0,0,0,0.06);
    z-index: 10;
}

.app__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.footer__profile { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.footer__profile .profile__label { font-weight: 600; color: var(--brand-ink); }
.footer-select { 
    all: revert; 
    appearance: none;
    padding: 4px 10px; 
    border: 2px solid color-mix(in srgb, var(--brand-ink) 70%, transparent);
    border-radius: 999px; 
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 8%, transparent), color-mix(in srgb, var(--brand) 2%, transparent)), #fff;
    color: var(--text);
    font-size: 14px; 
    box-shadow: 0 2px 0 color-mix(in srgb, var(--brand-ink) 6%, transparent), inset 0 1px 0 rgba(255,255,255,0.6);
}
.footer-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring), 0 2px 0 color-mix(in srgb, var(--brand-ink) 6%, transparent); background: #fff; }
.theme-dark .footer-select { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, transparent), color-mix(in srgb, var(--brand) 2%, transparent)), #0e1915; border-color: color-mix(in srgb, var(--brand) 40%, transparent); color: var(--text); }

.app__meta { display: flex; gap: 8px; align-items: center; font-size: 12px; text-align: center; }
.app__meta .dot { opacity: .6; }

.app__tip { font-size: 12px; }

/* 深色模式视觉优化 */
.theme-dark { --brand-ink: color-mix(in srgb, var(--brand) 72%, white); }
.theme-dark .app__header {
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 4%, rgba(16,24,20,0.96)), color-mix(in srgb, var(--brand) 2%, rgba(16,24,20,0.66)));
    box-shadow: 0 1px 0 rgba(255,255,255,0.04);
}
.theme-dark .app__footer {
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, rgba(16,24,20,0.90)), color-mix(in srgb, var(--brand) 4%, rgba(16,24,20,0.70)));
    box-shadow: 0 -1px 0 rgba(255,255,255,0.04);
}
.theme-dark .card--panel { border-color: color-mix(in srgb, var(--brand) 22%, transparent); }
.theme-dark .range-item {
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 8%, transparent), color-mix(in srgb, var(--brand) 3%, transparent));
    border-color: color-mix(in srgb, var(--brand) 45%, transparent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 6px 14px rgba(0,0,0,0.24);
}
.theme-dark .display { background: var(--card); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent); box-shadow: var(--shadow); }
.theme-dark .display__label { color: var(--text); }
.theme-dark .display__number { text-shadow: 0 0 10px color-mix(in srgb, var(--brand) 55%, transparent); }

/* 底部信息横向分布与响应式 */
.app__meta { justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 640px) {
	.app__footer { grid-template-columns: 1fr; justify-items: center; row-gap: 6px; }
	.app__meta { justify-content: center; gap: 6px 10px; }
}

.sheet {
	position: fixed;
	left: 50%;
	bottom: 0;
	transform: translateX(-50%);
	width: min(680px, 96%);
	background: var(--card);
	border-radius: 16px 16px 0 0;
	box-shadow: var(--shadow);
	max-height: 80vh;
	border: 1px solid rgba(0,0,0,0.06);
	display: grid;
	grid-template-rows: auto 1fr auto;
	overflow: hidden;
}
.sheet__header { position: sticky; top: 0; z-index: 2; font-weight: 700; padding: 14px 16px; background: var(--card); border-bottom: 1px solid rgba(0,0,0,0.06); }
/* 统一所有分页面关闭按钮为“主设置页”风格，并加入红色交互反馈 */
.sheet__close {
    position: absolute;
    right: 10px;
    top: 8px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease, color .15s ease, opacity .15s ease;
}
.sheet__close:hover,
.sheet__close:active { background: #ef4444; color: #fff; }
.theme-dark .sheet__close:hover,
.theme-dark .sheet__close:active { background: #dc2626; color: #fff; }
.sheet__content { padding: 0 12px 12px; overflow: auto; }
.sheet__footer { padding: 12px; display: grid; gap: 10px; grid-template-columns: 1fr 1fr; position: sticky; bottom: 0; background: var(--card); border-top: 1px solid rgba(0,0,0,0.06); }
.sheet__footer .weui-btn {
	width: 100%;
	height: 44px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	margin: 0 !important; /* 去除 WeUI 默认上下外边距，确保三按钮齐平 */
	box-sizing: border-box;
	line-height: 1; /* 避免行高差异导致视觉不齐 */
}
/* 名单弹窗：三按钮同一行 */
#rosterSheet .sheet__footer { grid-template-columns: 1fr 1fr 1fr; }

.weui-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .28s ease; }
.weui-mask.is-open { opacity: 1; }

.hidden { display: none; }

/* 设置弹窗动画 */
/* 通用：所有 weui-mask 下的 sheet 滑入动画（适配新功能弹窗等） */
.weui-mask .sheet {
	opacity: 0;
	transform: translate(-50%, 100%);
	transition: transform .32s ease, opacity .32s ease;
}
.weui-mask.is-open .sheet { opacity: 1; transform: translate(-50%, 0); }
#settingsSheet .sheet {
	opacity: 0;
	/* 从底部完全滑入 */
	transform: translate(-50%, 100%);
	transition: transform .32s ease, opacity .32s ease;
}
#settingsSheet.is-open { opacity: 1; }
#settingsSheet.is-open .sheet { opacity: 1; transform: translate(-50%, 0); }

/* 动画 */
@keyframes roll {
	0% { transform: translateY(0) scale(1); filter: blur(0); }
	50% { transform: translateY(-6px) scale(1.02); filter: blur(.2px); }
	100% { transform: translateY(0) scale(1); filter: blur(0); }
}
.rolling .display__number { animation: roll .26s ease-in-out infinite; }

/* 更丰富的停靠动效 */
@keyframes pop { 0% { transform: scale(0.96); opacity: .6; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
.pop { animation: pop .36s cubic-bezier(.2,.9,.2,1); }

/* 随机诗句加载与切换动效 */
#poemBar { user-select: none; }
#poemBar #poemText,
#poemBar #poemMeta { transition: opacity .28s ease, transform .28s ease; }
.poem-loading #poemText { animation: poemLoading 1.6s ease-in-out infinite; opacity: .85; }
@keyframes poemLoading { 0% { opacity: .45; } 50% { opacity: 1; } 100% { opacity: .45; } }
.poem-enter { animation: poemEnter .42s ease both; }
@keyframes poemEnter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* 随机诗句字体（楷体/仿宋，跨平台回退） */
#poemText {
	font-family: KaiTi, STKaiti, "Kaiti SC", "DFKai-SB", "AR PL KaitiM GB", "Kaiti TC", "Source Han Serif SC", "Noto Serif CJK SC", "Noto Serif SC", serif;
	font-size: clamp(18px, 2vw, 24px);
	line-height: 1.8;
}
#poemMeta {
	font-family: FangSong, FangSong_GB2312, STFangsong, "FZFangSong-Z02S", SimSun, "Source Han Serif SC", "Noto Serif CJK SC", "Noto Serif SC", serif;
	font-size: clamp(14px, 1.6vw, 18px);
	line-height: 1.6;
}

/* 遵循系统“减少动效”偏好 */
@media (prefers-reduced-motion: reduce) {
	.rolling .display__number { animation: none !important; }
	.pop { animation: none !important; }
	.weui-mask .sheet { transition: none !important; }
	.poem-loading #poemText { animation: none !important; }
}


/* 自适应 */
@media (max-width: 640px) {
	/* 某些移动端对 safe-area 处理不一致，统一改为固定对称内边距，避免整体向右偏移 */
	.app__header,
	.app__main,
	.app__footer {
		padding-left: 14px;
		padding-right: 14px;
	}
	/* 移动端：页脚不悬浮，避免遮挡底部按钮；同时考虑底部安全区 */
	.app__footer { position: static; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
	/* 移动端：主体不再为页脚预留额外空间 */
	.app__main { padding-bottom: 12px; }
	/* 小屏：随机诗句与出处分行显示 */
	#poemBar { display: grid; grid-template-columns: 1fr; justify-items: center; row-gap: 2px; }
	#poemBar #poemText, #poemBar #poemMeta { display: block; }
	#poemBar #poemMeta { margin-left: 0 !important; }
	.range-cells { grid-template-columns: 1fr !important; }
	/* 确保 WeUI 容器左右无额外外边距，避免视觉右偏 */
	.weui-cells { margin-left: 0 !important; margin-right: 0 !important; }
	/* 统一给顶部设置栏的每个块左右留出同等间距，避免视觉右贴边 */
    /* 顶部设置栏：统一左右间距完全一致 */
    #rangeBar { padding-left: 14px; padding-right: 14px; box-sizing: border-box; }
    #rangeBar .weui-cells { width: 100%; box-sizing: border-box; }
    #rangeBar .weui-cells { margin-left: 0 !important; margin-right: 0 !important; }
	.controls { grid-template-columns: 1fr; }
	.display { padding: 20px 10px 14px; border-radius: 14px; }
	/* 用 vmin 按较小边缩放，避免窗口越窄越显得更大 */
	.display__number { font-size: clamp(124px, 20vmin, 520px); min-height: 1.05em; }
	/* 小屏使用低幅动画，进一步减少视觉抖动 */
	@keyframes rollSm {
		0% { transform: translateY(0) scale(1); filter: blur(0); }
		50% { transform: translateY(-3px) scale(1.01); filter: blur(.2px); }
		100% { transform: translateY(0) scale(1); filter: blur(0); }
	}
	.rolling .display__number { animation: rollSm .26s ease-in-out infinite; }
	/* 头部与卡片在极小屏幕收紧，且两侧同宽并考虑安全区 */
	.app__header {
		padding-top: 12px;
		padding-bottom: 12px;
		padding-left: 14px;
		padding-right: 14px;
	}
	.card { padding: 12px; border-radius: 12px; }

	/* 移动端：弱化“框体”，与背景融为一体 */
	.card,
	.card--panel,
	.display {
		background: transparent !important;
		border: 0 !important;
		box-shadow: none !important;
	}
	.range-cells .weui-cells {
		background: transparent !important;
		border: 0 !important;
		box-shadow: none !important;
	}
	/* 但顶部设置栏保持白色卡片样式 */
	#rangeBar .weui-cells {
		background: var(--card) !important;
		border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent) !important;
		box-shadow: var(--shadow) !important;
		border-radius: 12px;
	}
}

/* 平板优化（横竖屏 iPad/Android 介于手机与桌面之间） */
@media (min-width: 641px) and (max-width: 1023px) {
	:root { --page-padding-x: 20px; }
	.app__main { max-width: 900px; gap: 18px; }
	/* 输入行三等分在平板上容易拥挤，改为两列 */
	.range-cells { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	/* 让显示区更高，数字不过大不溢出 */
	.display { min-height: clamp(260px, 36vh, 520px); }
	.display__number { font-size: clamp(132px, 20vmin, 560px); }
	.display__countdown { font-size: clamp(96px, 16vmin, 520px); }
	/* 底部操作按钮更集中 */
	.controls { grid-template-columns: 1fr; }
}

/* 极小高度（横屏或全面屏地址栏占位）时，进一步收紧字号与边距 */
@media (max-height: 520px) {
	.app__header { padding-top: 8px; padding-bottom: 8px; }
	.card { padding: 10px; }
	.display { padding: 16px 10px 10px; border-radius: 10px; }
	.display__number { font-size: clamp(64px, 16vmin, 420px); }
	.display__countdown { font-size: clamp(48px, 15vmin, 420px); }
}

/* 大屏优化与居中显示 */
@media (min-width: 1024px) {
	/* 让主内容在可视区域中居中呈现 */
	.app__main {
		display: flex;
		align-items: center;
		justify-content: center;
		min-height: 80vh;
		max-width: 1200px;
		width: 100%;
		padding: 24px;
	}
	/* 放大中间卡片与内容区域 */
	.app .card--panel { width: min(92vw, 1200px); max-width: 1200px; }
	/* 拉长显示区高度，便于放大数字 */
	.display { min-height: clamp(320px, 42vh, 720px); }
	/* 放大数字与读秒以适配远距离观看 */
	.display__number { font-size: clamp(160px, 26vmin, 1200px); }
	.display__countdown { font-size: clamp(110px, 20vmin, 1100px); }
}

/* WeUI 风格的自动时长滑条 */
input[type="range"]#inputAutoSeconds {
    appearance: none;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--brand) var(--_val,50%), color-mix(in srgb, var(--brand-ink) 20%, transparent) 0);
    border-radius: 999px;
}
input[type="range"]#inputAutoSeconds::-webkit-slider-thumb {
	appearance: none;
	width: 22px; height: 22px; border-radius: 50%;
	background: #fff; border: 2px solid var(--brand);
	box-shadow: 0 0 0 3px var(--ring);
}
input[type="range"]#inputAutoSeconds:active::-webkit-slider-thumb { border-color: var(--brand-600); }

/* 均衡强度滑条与自动时长滑条保持一致 */
input[type="range"]#inputBalancedBoost {
	appearance: none;
	width: 100%;
	height: 4px;
	background: linear-gradient(90deg, var(--brand) var(--_val,50%), color-mix(in srgb, var(--brand-ink) 20%, transparent) 0);
	border-radius: 999px;
}
input[type="range"]#inputBalancedBoost::-webkit-slider-thumb {
	appearance: none;
	width: 22px; height: 22px; border-radius: 50%;
	background: #fff; border: 2px solid var(--brand);
	box-shadow: 0 0 0 3px var(--ring);
}
input[type="range"]#inputBalancedBoost:active::-webkit-slider-thumb { border-color: var(--brand-600); }

/* 智慧统计强度与下降强度滑条统一样式 */
input[type="range"]#inputSmartWrongAlpha,
input[type="range"]#inputSmartCorrectDecay {
	appearance: none;
	width: 100%;
	height: 4px;
	background: linear-gradient(90deg, var(--brand) var(--_val,50%), color-mix(in srgb, var(--brand-ink) 20%, transparent) 0);
	border-radius: 999px;
}
input[type="range"]#inputSmartWrongAlpha::-webkit-slider-thumb,
input[type="range"]#inputSmartCorrectDecay::-webkit-slider-thumb {
	appearance: none;
	width: 22px; height: 22px; border-radius: 50%;
	background: #fff; border: 2px solid var(--brand);
	box-shadow: 0 0 0 3px var(--ring);
}
input[type="range"]#inputSmartWrongAlpha:active::-webkit-slider-thumb,
input[type="range"]#inputSmartCorrectDecay:active::-webkit-slider-thumb { border-color: var(--brand-600); }

/* 自定义输入（权重设置页更显眼的输入框） */
.rc-input {
    border: 2px solid color-mix(in srgb, var(--brand-ink) 70%, transparent);
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 8%, transparent), color-mix(in srgb, var(--brand) 2%, transparent)), #fff;
    border-radius: 10px;
    padding: 8px 10px;
    box-shadow: 0 2px 0 color-mix(in srgb, var(--brand-ink) 6%, transparent), inset 0 1px 0 rgba(255,255,255,0.6);
    outline: none;
    transition: box-shadow .2s ease, border-color .2s ease, background-color .2s ease;
}
.rc-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--ring), 0 2px 0 color-mix(in srgb, var(--brand-ink) 6%, transparent);
    background: #fff;
}
.rc-input--small { width: 120px; }
.rc-input--percent { width: 96px; }

/* 权重设置行的可视布局 */
.weights-row { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.weights-row label { display:flex; align-items:center; gap:8px; font-weight:600; color: var(--text); }
.weights-row .unit { margin-left: 4px; color: var(--muted); font-weight: 500; }

/* 深色模式下的自定义输入 */
.theme-dark .rc-input {
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, transparent), color-mix(in srgb, var(--brand) 2%, transparent)), #0e1915;
    border-color: color-mix(in srgb, var(--brand) 40%, transparent);
    color: var(--text);
}
.theme-dark .rc-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }

.range-cells {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 12px;
	align-items: stretch;
}
/* 自动断行：每个项目至少 260px，不够则自动换到下一行 */
@media (min-width: 480px) {
	.range-cells { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
.range-cells .weui-cells_form .weui-cell_active { padding: 12px; }
.range-cells .weui-cells { margin-top: 0; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent); }
.range-cells .weui-cell { align-items: center; }
.range-cells .weui-label { width: 5.5em; color: var(--brand-ink); font-weight: 700; }

/* 小标题图标（设置弹窗等） */
.title-with-icon { display: inline-flex; align-items: center; gap: 6px; }
.title-with-icon img.icon { width: 18px; height: 18px; vertical-align: middle; filter: none; }


/* 打开按钮图标（明暗主题自动切换） */
.btn-icon { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-icon .open-icon { width: 16px; height: 16px; vertical-align: middle; display: inline-block; }
.btn-icon .open-icon--light { display: inline-block; }
.btn-icon .open-icon--dark { display: none; }
.theme-dark .btn-icon .open-icon--light { display: none; }
.theme-dark .btn-icon .open-icon--dark { display: inline-block; }

/* 主题色预设色块 */
.swatches { display: grid; grid-template-columns: repeat(8, 28px); gap: 10px; }
.swatch { width: 28px; height: 28px; border-radius: 6px; border: 2px solid rgba(0,0,0,.08); background: var(--c); cursor: pointer; }
.theme-dark .swatch { border-color: rgba(255,255,255,.12); }
/* 自定义色块右键删除提示（可选） */
.swatch[data-color]:hover { outline: 2px solid color-mix(in srgb, var(--brand) 50%, transparent); }

