/* 全站共用主题。属性在首帧前设置，保持入口和静态文档一致。 */
html[data-ocp-theme] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: rgba(0,0,0,.12);
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #ea580c;
  --accent-2: #5b21b6;
  --accent-glow: rgba(234,88,12,.35);
  --success: #15803d;
  --danger: #b91c1c;
}

html[data-ocp-theme='dark'] {
  color-scheme: dark;
  --bg: #0d0f12;
  --surface: #15181d;
  --surface-2: #1b1f26;
  --border: #292e37;
  --text: #edeef0;
  --text-muted: #9ba3b1;
  --accent: #ff9454;
  --accent-2: #b6a0ed;
  --accent-glow: transparent;
  --success: #70d4ad;
  --danger: #ef9caa;
}

html[data-ocp-theme='light'] { color-scheme: light; }
:where(html[data-ocp-theme]) :where(*, ::before, ::after) { border-color: var(--border); }
html[data-ocp-theme] body { background: var(--bg); color: var(--text); }
html[data-ocp-theme] :where(input, textarea, select) {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
html[data-ocp-theme] :where(input, textarea)::placeholder { color: var(--text-muted); opacity: 1; }
html[data-ocp-theme] :where(button, a, input, textarea, select, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.site-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
}
.site-theme-toggle:hover { border-color: var(--accent); }

/* 兼容现有市场卡片、创建表单和共用交易视图中的固定浅色工具类。 */
html[data-ocp-theme='dark'] :is(.bg-white, .bg-white\/60, .bg-white\/70, .bg-white\/80) { background-color: var(--surface); }
html[data-ocp-theme='dark'] :is(.bg-slate-50, .bg-slate-50\/40, .bg-slate-100, .bg-gray-100) { background-color: var(--surface-2); }
html[data-ocp-theme='dark'] :is(.text-slate-900, .text-slate-800, .text-slate-700) { color: var(--text); }
html[data-ocp-theme='dark'] :is(.text-slate-600, .text-slate-500, .text-slate-400) { color: var(--text-muted); }
html[data-ocp-theme='dark'] :is(.border-slate-200, .border-slate-300, .border-orange-200) { border-color: var(--border); }
html[data-ocp-theme='dark'] :is(.text-orange-600, .text-orange-700, .text-amber-700) { color: var(--accent); }
html[data-ocp-theme='dark'] :is(.bg-orange-50, .bg-orange-100) { background-color: #252019; }
html[data-ocp-theme='dark'] .text-green-700 { color: var(--success); }
html[data-ocp-theme='dark'] :is(.text-red-600, .text-red-700) { color: var(--danger); }
html[data-ocp-theme='dark'] .bg-red-50 { background-color: #2a1d24; }
html[data-ocp-theme='dark'] .border-red-200 { border-color: #65404b; }
html[data-ocp-theme='dark'] :is(.bg-slate-900, .bg-orange-500) { background-color: var(--accent); color: #19120d; }
html[data-ocp-theme='dark'] :is(.hover\:border-orange-300:hover, .hover\:border-orange-200:hover) { border-color: var(--accent); }
html[data-ocp-theme='dark'] :is(.from-orange-50, .from-orange-50\/70) { --tw-gradient-from: #201a16 var(--tw-gradient-from-position); --tw-gradient-to: #201a1600 var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
html[data-ocp-theme='dark'] .via-white { --tw-gradient-to: #15181d00 var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), #15181d var(--tw-gradient-via-position), var(--tw-gradient-to); }
html[data-ocp-theme='dark'] .to-slate-50 { --tw-gradient-to: #15181d var(--tw-gradient-to-position); }
html[data-ocp-theme='dark'] nav { background-color: #0d0f12ed; }
html[data-ocp-theme='dark'] :is([stroke='#e2e8f0']) { stroke: var(--border); }
html[data-ocp-theme='dark'] :is([fill='#64748b']) { fill: var(--text-muted); }
html[data-ocp-theme='dark'] :is([stroke='#15803d']) { stroke: var(--success); }
html[data-ocp-theme='dark'] :is([fill='#15803d']) { fill: var(--success); }
html[data-ocp-theme='dark'] :is([stroke='#dc2626']) { stroke: var(--danger); }
html[data-ocp-theme='dark'] :is([fill='#dc2626']) { fill: var(--danger); }

html[data-ocp-theme='dark'] :is([class~="bg-white/40"], [class~="bg-white/45"], [class~="bg-white/85"], [class~="bg-white/90"]) { background-color: var(--surface); }
html[data-ocp-theme='dark'] :is([class~="bg-slate-50/50"], [class~="bg-slate-50/70"], [class~="bg-[#f8fafc]"]) { background-color: var(--bg); }
html[data-ocp-theme='dark'] :is(.text-slate-950,.text-gray-900,.text-gray-800) { color: var(--text); }
html[data-ocp-theme='dark'] :is(.border-slate-100,[class~="border-slate-200/70"],.border-orange-100) { border-color: var(--border); }
html[data-ocp-theme='dark'] :is(.text-orange-800,.text-orange-950,.text-amber-600,.text-amber-800,.text-yellow-600) { color: var(--accent); }
html[data-ocp-theme='dark'] :is([class~="bg-orange-50/40"],[class~="bg-orange-50/50"],.bg-amber-50,[class~="bg-amber-50/40"]) { background-color: #252019; }
html[data-ocp-theme='dark'] :is(.bg-green-50,[class~="bg-emerald-50/40"],[class~="bg-emerald-50/60"]) { background-color: #172822; }
html[data-ocp-theme='dark'] :is(.text-green-800,.text-emerald-600,.text-emerald-700) { color: var(--success); }
html[data-ocp-theme='dark'] :is(.text-red-800,.text-red-950) { color: var(--danger); }
html[data-ocp-theme='dark'] :is([class~="bg-blue-50/50"]) { background-color: #192330; }
html[data-ocp-theme='dark'] .text-blue-600 { color: #91baff; }
html[data-ocp-theme='dark'] .text-purple-600 { color: var(--accent-2); }
html[data-ocp-theme='dark'] :is(.border-amber-200,.border-emerald-100,.border-blue-100) { border-color: var(--border); }
html[data-ocp-theme='dark'] :is(.to-white,.to-white\/70) { --tw-gradient-to: var(--surface) var(--tw-gradient-to-position); }
html[data-ocp-theme='dark'] :is(.from-white,.from-slate-50) { --tw-gradient-from: var(--surface) var(--tw-gradient-from-position); --tw-gradient-to: #15181d00 var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from),var(--tw-gradient-to); }
html[data-ocp-theme='dark'] :is([class~="bg-[#0b0c11]/60"]) { background-color: var(--surface); }
html[data-ocp-theme] .document-theme-toggle { float: right; font-size: 18px; cursor: pointer; }
html[data-ocp-theme] .muted { color: var(--text-muted); }
html[data-ocp-theme] body > main a { color: var(--accent); }
html[data-ocp-theme] body > main :is(header,footer) { border-color: var(--border); }
html[data-ocp-theme='dark'] .draft { background: var(--surface-2); }
html[data-ocp-theme='dark'] .bg-yellow-50 { background-color: #292416; }
html[data-ocp-theme='dark'] :is(.text-yellow-700,.text-yellow-800,.text-yellow-900) { color: #edce7f; }
html[data-ocp-theme='dark'] .text-rose-600 { color: var(--danger); }
html[data-ocp-theme='dark'] [class~="from-emerald-50/80"] { --tw-gradient-from: #172822 var(--tw-gradient-from-position); --tw-gradient-to: #17282200 var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from),var(--tw-gradient-to); }
