/* ==========================================================================
 * 大白课堂 · 移动端 APP 化（< 1024px）。桌面端只隐藏新增元件，其他不变。
 * ========================================================================== */

.m-tabbar,
.m-sheet {
	display: none;
}

@media (max-width: 1023px) {
	:root {
		--m-hdr-h: 52px;
		--m-tab-h: 56px;
		--m-gut: 14px;
		--m-safe-b: env(safe-area-inset-bottom, 0px);
		--m-safe-t: env(safe-area-inset-top, 0px);
		--m-bottom: calc(var(--m-tab-h) + var(--m-safe-b));
	}

	html,
	body {
		overflow-x: clip;
		-webkit-tap-highlight-color: transparent;
	}

	body {
		padding-bottom: var(--m-bottom);
	}

	.container {
		padding-left: var(--m-gut);
		padding-right: var(--m-gut);
	}

	/* ---------- 顶栏：52px 吸顶 ---------- */
	.site-header {
		position: sticky;
		top: 0;
		z-index: 60;
		padding-top: var(--m-safe-t);
		background: rgba(255, 255, 255, 0.94);
		-webkit-backdrop-filter: saturate(180%) blur(14px);
		backdrop-filter: saturate(180%) blur(14px);
		border-bottom: 1px solid rgba(15, 23, 42, 0.08);
	}

	.site-header .header-inner {
		height: var(--m-hdr-h);
		min-height: var(--m-hdr-h);
		padding-top: 0;
		padding-bottom: 0;
	}

	.site-header .brand-logo {
		width: 28px;
		height: 28px;
	}

	.site-header .brand-name {
		font-size: 16px;
		white-space: nowrap;
	}

	.site-header .icon-btn {
		width: 38px;
		height: 38px;
	}

	body.menu-open .primary-nav {
		top: calc(var(--m-hdr-h) + var(--m-safe-t));
		bottom: var(--m-bottom);
	}

	html[data-theme="dark"] .site-header {
		background: rgba(15, 23, 42, 0.94);
		border-bottom-color: rgba(148, 163, 184, 0.16);
	}

	/* ---------- 底部导航栏 ---------- */
	.m-tabbar {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 95;
		display: grid;
		grid-template-columns: repeat(5, 1fr);
		height: var(--m-bottom);
		padding: 0 4px var(--m-safe-b);
		background: rgba(255, 255, 255, 0.97);
		-webkit-backdrop-filter: saturate(180%) blur(18px);
		backdrop-filter: saturate(180%) blur(18px);
		border-top: 1px solid rgba(15, 23, 42, 0.09);
	}

	.m-tabbar.is-n3 {
		grid-template-columns: repeat(3, 1fr);
	}

	.m-tab {
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 3px;
		height: var(--m-tab-h);
		color: #64748b;
		text-decoration: none !important;
		font-size: 11px;
		font-weight: 500;
		line-height: 1.2;
		user-select: none;
	}

	.m-tab:active {
		opacity: 0.6;
	}

	.m-tab-ic {
		position: relative;
		display: inline-flex;
		width: 24px;
		height: 24px;
	}

	.m-tab-ic svg {
		width: 24px;
		height: 24px;
	}

	.m-tab-live {
		position: absolute;
		top: -1px;
		right: -3px;
		width: 7px;
		height: 7px;
		border-radius: 50%;
		background: #ef4444;
		box-shadow: 0 0 0 2px #fff;
	}

	.m-tab.is-active {
		color: var(--db-accent-hover, #2563eb);
		font-weight: 700;
	}

	.m-tab.is-active .m-tab-ic svg {
		stroke-width: 2.3;
	}

	html[data-theme="dark"] .m-tabbar {
		background: rgba(15, 23, 42, 0.97);
		border-top-color: rgba(148, 163, 184, 0.16);
	}

	html[data-theme="dark"] .m-tab {
		color: #94a3b8;
	}

	html[data-theme="dark"] .m-tab.is-active {
		color: #38bdf8;
	}

	html[data-theme="dark"] .m-tab-live {
		box-shadow: 0 0 0 2px #0f172a;
	}

	/* K 线全屏时让出整个屏幕 */
	body.kline-is-max .m-tabbar,
	body.kline-is-max .site-header {
		display: none !important;
	}

	body.kline-is-max {
		padding-bottom: 0 !important;
	}

	/* 其他固定在底部的浮层整体抬到导航栏上方 */
	.mk-float-back {
		bottom: calc(var(--m-bottom) + 12px) !important;
	}

	.exr-pk-bar {
		bottom: calc(var(--m-bottom) + 10px) !important;
	}

	.v2-preview-dock {
		bottom: calc(var(--m-bottom) + 8px) !important;
	}

	.tm-box > .tm-cl-bar {
		bottom: calc(var(--m-bottom) + 10px) !important;
	}

	.tm.is-max .tm-box > .tm-cl-bar {
		bottom: calc(12px + var(--m-safe-b)) !important;
	}

	.site-footer {
		padding-bottom: 20px !important;
	}

	/* ---------- 首页 / 列表页：只做文章信息流 ---------- */
	body.m-app-home .market-ticker,
	body.m-app-home .quick-links,
	body.m-app-home .v2-quick-grid,
	body.m-app-home .v2-pulse-grid,
	body.m-app-home .fl-home,
	body.m-app-home .v2-steps-box,
	body.m-app-home .layout > .sidebar,
	body.m-app-feed .layout > .sidebar {
		display: none !important;
	}

	/* H1 保留给搜索引擎和读屏，视觉上不占首屏 */
	body.m-app-home .hero {
		position: absolute !important;
		width: 1px !important;
		height: 1px !important;
		padding: 0 !important;
		margin: -1px !important;
		overflow: hidden !important;
		clip: rect(0, 0, 0, 0) !important;
		white-space: nowrap !important;
		border: 0 !important;
	}

	body.m-app-home .layout {
		padding-bottom: 16px;
	}

	body.m-app-home .site-main {
		padding-top: 0 !important;
	}

	/* 标题行 + 分类条吸顶 */
	body.m-app-feed .section-head {
		position: sticky;
		top: calc(var(--m-hdr-h) + var(--m-safe-t));
		z-index: 40;
		gap: 0;
		margin: 0 calc(var(--m-gut) * -1) 4px;
		padding: 10px var(--m-gut) 0;
		background: var(--db-bg, #fff);
		border-bottom: 1px solid var(--db-divider, rgba(15, 23, 42, 0.08));
	}

	body.m-app-feed .v2-section-title-group {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: nowrap;
		gap: 8px;
	}

	body.m-app-feed .section-head .section-title {
		margin: 0;
		font-size: 18px;
		line-height: 28px;
		white-space: nowrap;
	}

	body.m-app-feed .v2-feed-btn {
		padding: 4px 11px;
		font-size: 12.5px;
	}

	body.m-app-feed .section-head .filter-tabs {
		flex-wrap: nowrap;
		gap: 18px;
		padding: 6px 0 0;
		overflow-x: auto;
	}

	body.m-app-feed .section-head .filter-tabs a {
		position: relative;
		height: 36px;
		padding: 0;
		border-radius: 0;
		background: transparent !important;
		color: var(--db-muted, #64748b);
		font-size: 14.5px;
	}

	body.m-app-feed .section-head .filter-tabs a[aria-current="page"] {
		color: var(--db-text, #0f172a);
		font-weight: 700;
	}

	body.m-app-feed .section-head .filter-tabs a[aria-current="page"]::after {
		content: "";
		position: absolute;
		left: 20%;
		right: 20%;
		bottom: 0;
		height: 3px;
		border-radius: 3px;
		background: var(--db-accent-hover, #2563eb);
	}

	body.m-app-feed .post-item {
		padding: 14px 0;
	}

	body.m-app-feed .load-more {
		height: 46px;
		margin: 12px 0 4px;
		font-size: 15px;
	}

	/* 繁中首页：不放快讯，教学文章排最前，其次退佣卡片和数据 */
	body.m-app-home .tw-home-main {
		display: flex;
		flex-direction: column;
	}

	body.m-app-home .tw-home-main > .tw-sec:last-of-type {
		order: -1;
	}

	body.m-app-home .tw-home-main {
		padding-top: 12px !important;
	}

	/* ---------- 快讯页 ---------- */
	body.m-app-flash .layout > .sidebar,
	body.m-app-flash .fl-page .breadcrumbs,
	body.m-app-flash .fl-sub {
		display: none !important;
	}

	body.m-app-flash .site-main {
		padding-top: 0 !important;
	}

	body.m-app-flash .fl-page {
		margin: 0;
		padding: 0;
	}

	body.m-app-flash .fl-page-hd {
		margin: 0;
		padding: 12px 0 2px;
	}

	body.m-app-flash .fl-page-hd .entry-title {
		margin: 0;
		font-size: 19px;
		line-height: 28px;
	}

	body.m-app-flash .fl-full {
		margin-top: 0;
	}

	body.m-app-flash .fl-bar {
		position: sticky;
		top: calc(var(--m-hdr-h) + var(--m-safe-t));
		z-index: 40;
		flex-wrap: nowrap;
		margin: 0 calc(var(--m-gut) * -1) 4px;
		padding: 8px var(--m-gut);
		background: var(--db-bg, #fff);
		border-bottom: 1px solid var(--db-divider, rgba(15, 23, 42, 0.08));
	}

	body.m-app-flash .fl-stat {
		white-space: nowrap;
	}

	body.m-app-flash .fl-newbar {
		position: sticky;
		top: calc(var(--m-hdr-h) + var(--m-safe-t) + 52px);
		z-index: 39;
	}

	body.m-app-flash .fl-full .fl-item {
		grid-template-columns: 44px minmax(0, 1fr);
		gap: 8px;
		padding: 12px 0;
		cursor: pointer;
	}

	body.m-app-flash .fl-full .fl-item:active {
		background: var(--db-surface, #f8fafc);
	}

	body.m-app-flash .fl-full .fl-h {
		font-size: 15.5px;
		line-height: 1.55;
	}

	body.m-app-flash .fl-full .fl-b {
		display: -webkit-box;
		-webkit-line-clamp: 3;
		-webkit-box-orient: vertical;
		overflow: hidden;
		font-size: 14px;
		line-height: 1.65;
	}

	/* 列表里来源只显示名字，点整条进站内详情，原文链接放在详情里 */
	body.m-app-flash .fl-full .fl-src {
		pointer-events: none;
	}

	body.m-app-flash .fl-more {
		height: 46px;
		padding: 0;
	}

	/* 快讯详情层：盖住顶栏，停在底栏上方，底栏始终可点 */
	.m-sheet {
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		bottom: var(--m-bottom);
		z-index: 94;
		flex-direction: column;
		background: var(--db-bg, #fff);
		transform: translateX(100%);
		transition: transform 0.22s ease;
	}

	.m-sheet.is-on {
		display: flex;
	}

	.m-sheet.is-in {
		transform: none;
	}

	.m-sheet-hd {
		flex: none;
		display: grid;
		grid-template-columns: 64px 1fr 64px;
		align-items: center;
		height: calc(var(--m-hdr-h) + var(--m-safe-t));
		padding: var(--m-safe-t) 4px 0;
		border-bottom: 1px solid var(--db-divider, rgba(15, 23, 42, 0.08));
	}

	.m-sheet-back {
		display: inline-flex;
		align-items: center;
		gap: 2px;
		height: 40px;
		padding: 0 8px;
		border: 0;
		background: none;
		color: var(--db-text, #0f172a);
		font: inherit;
		font-size: 15px;
		cursor: pointer;
	}

	.m-sheet-back svg {
		width: 22px;
		height: 22px;
	}

	.m-sheet-title {
		text-align: center;
		font-size: 16px;
		font-weight: 700;
		color: var(--db-text, #0f172a);
	}

	.m-sheet-bd {
		flex: 1;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
		padding: 18px var(--m-gut) 28px;
	}

	.m-sheet-time {
		font-size: 13px;
		color: var(--db-muted, #64748b);
		font-variant-numeric: tabular-nums;
	}

	.m-sheet-h {
		margin: 8px 0 0;
		font-size: 20px;
		line-height: 1.5;
		font-weight: 700;
		color: var(--db-text, #0f172a);
		word-break: break-word;
	}

	.m-sheet.is-imp .m-sheet-h {
		color: #dc2626;
	}

	.m-sheet-b {
		margin: 14px 0 0;
		font-size: 16px;
		line-height: 1.85;
		color: var(--db-text, #0f172a);
		word-break: break-word;
	}

	.m-sheet-meta {
		display: flex;
		align-items: center;
		gap: 8px;
		margin-top: 16px;
		font-size: 12.5px;
		color: var(--db-muted, #64748b);
	}

	.m-sheet-src {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 44px;
		margin-top: 22px;
		border: 1px solid var(--db-border, #e2e8f0);
		border-radius: 10px;
		color: var(--db-accent-hover, #2563eb) !important;
		font-size: 14.5px;
		font-weight: 600;
		text-decoration: none !important;
	}

	.m-sheet-note {
		margin: 14px 0 0;
		font-size: 12px;
		line-height: 1.7;
		color: var(--db-muted, #64748b);
	}

	body.m-sheet-open {
		overflow: hidden;
	}

	/* ---------- K 线页：主图一屏放下，不压底栏 ---------- */
	body.m-app-kline .site-main {
		padding-top: 0 !important;
		padding-bottom: 8px !important;
	}

	body.m-app-kline .tm-main {
		height: clamp(360px, calc(100dvh - 285px), 560px) !important;
		min-height: 360px;
	}

	body.m-app-kline .tm.is-max .tm-main {
		height: auto !important;
		max-height: none !important;
	}

	/* ---------- 通用防溢出 ---------- */
	.entry-content {
		overflow-wrap: anywhere;
	}

	.entry-content img,
	.entry-content iframe,
	.entry-content video {
		max-width: 100% !important;
		height: auto;
	}

	.entry-content table {
		display: block;
		max-width: 100%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.entry-content pre {
		max-width: 100%;
		overflow-x: auto;
	}
}

/* ==========================================================================
 * 手机端细节：点击区域、输入框字号、文章页侧栏去重、抽屉里的语言切换
 * ========================================================================== */
.m-drawer-lang {
	display: none;
}

@media (max-width: 1023px) {
	/* iOS 输入框字号小于 16px 时聚焦会自动放大页面 */
	input[type="text"],
	input[type="search"],
	input[type="email"],
	input[type="url"],
	input[type="tel"],
	input[type="number"],
	input[type="password"],
	input:not([type]),
	select,
	textarea {
		font-size: 16px !important;
	}

	/* 锚点跳转不被吸顶顶栏挡住 */
	.entry-content [id],
	.entry-content h2,
	.entry-content h3 {
		scroll-margin-top: calc(var(--m-hdr-h) + var(--m-safe-t) + 12px);
	}

	/* 文章里已有目录时，侧栏目录卡重复，手机上不再显示 */
	body:has(.entry-content .wp-block-yoast-seo-table-of-contents) .v2-article-sidebar .v2-toc-card {
		display: none !important;
	}

	.entry-content .wp-block-yoast-seo-table-of-contents li {
		margin-top: 0;
		margin-bottom: 0;
	}

	.entry-content .wp-block-yoast-seo-table-of-contents a {
		display: block;
		padding: 6px 0;
	}

	/* 行情、交易所入口底栏已有，侧栏同类卡片手机上不重复 */
	.layout > .sidebar .sb-mkt-card,
	.layout > .sidebar .sb-exr-card {
		display: none !important;
	}

	/* ---------- 点击区域：带底色的按钮直接加高，纯文字链接只扩大可点范围不改排版 ---------- */
	.fl-tab {
		min-height: 32px;
	}

	.v2-copy-chip,
	.v2-tool-chip,
	.mk-lang,
	.mk-rebate-calc,
	.exr-lang-btn,
	.exr-vbtn,
	.exr-jump-pill {
		min-height: 32px;
	}

	.exr-code-btn,
	.exr-pk-toggle,
	.exr-detail-toggle {
		min-height: 36px;
	}

	.tm-seg button,
	.tm-qi,
	.tm-ax,
	.tm-auto,
	.tm-fav-cur,
	.tm-tips-fold {
		min-height: 32px;
	}

	.tm-btn {
		min-width: 32px;
	}

	.tm-lh button {
		min-height: 32px;
	}

	.v2-author-chip,
	.author-box-name,
	.author-box-links a,
	.tw-sec-more,
	.sb-hd-more,
	.mk-more-link,
	.exr-mini-link {
		padding-top: 6px;
		padding-bottom: 6px;
		margin-top: -6px;
		margin-bottom: -6px;
	}

	.exr-faq-item > summary {
		padding-top: 6px;
		padding-bottom: 6px;
	}

	.post-cat,
	.exr-por-link {
		position: relative;
	}

	.post-cat::before,
	.exr-por-link::before {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		top: -5px;
		bottom: -5px;
	}

	/* 抽屉菜单顶部的语言切换（顶栏放不下时） */
	.primary-nav .m-drawer-lang {
		display: flex;
		gap: 8px;
		padding: 10px 0 12px;
		border-bottom: 1px solid var(--db-divider, rgba(15, 23, 42, 0.08));
	}

	.primary-nav .m-drawer-lang .hdr-lang-item {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-width: 56px;
		min-height: 36px;
		padding: 0 14px;
		border: 1px solid var(--db-border, #e2e8f0);
		border-radius: 999px;
		color: var(--db-text, #0f172a);
		font-size: 14px;
		font-weight: 600;
		text-decoration: none;
	}

	.primary-nav .m-drawer-lang .hdr-lang-item.is-active {
		border-color: var(--db-accent-hover, #2563eb);
		background: var(--db-accent-soft, #eff6ff);
		color: var(--db-accent-hover, #2563eb);
	}
}

@media (min-width: 421px) {
	.primary-nav .m-drawer-lang {
		display: none;
	}
}
@media (max-width: 1023px) and (prefers-reduced-motion: reduce) {
	.m-sheet {
		transition: none;
	}
}
