/* ============ AlgoBeat Dark Mode v1.7.2 ============ */

html[data-theme="dark"] { background: #1a1a1a; color-scheme: dark; }
html[data-theme="dark"] body { background: #1a1a1a !important; color: #d0d0d0; }

/* ---- TopBar ---- */
html[data-theme="dark"] .ab-topbar {
  background: #242424; border-bottom: 1px solid #3a3a3a;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
html[data-theme="dark"] .ab-topbar-toggle { color: #bbb; }
html[data-theme="dark"] .ab-topbar-toggle:hover { background: #333; color: #fff; }
html[data-theme="dark"] .ab-topbar-brand-name { color: #e0e0e0; }
html[data-theme="dark"] .ab-topbar-icon { color: #bbb !important; }
html[data-theme="dark"] .ab-topbar-icon:hover { background: #333; color: #fff !important; }
html[data-theme="dark"] .ab-topbar-user-dropdown { color: #ddd; }
html[data-theme="dark"] .ab-topbar-user-dropdown:hover { background: #333; }
html[data-theme="dark"] .ab-topbar-user-dropdown .menu {
  background: #2a2a2a !important; border: 1px solid #3a3a3a !important;
  box-shadow: 0 4px 12px rgba(0,0,0,.4) !important;
}
html[data-theme="dark"] .ab-topbar-user-dropdown .menu .item { color: rgba(255,255,255,.85) !important; }
html[data-theme="dark"] .ab-topbar-user-dropdown .menu .item:hover { background: #383838 !important; color: #fff !important; }
html[data-theme="dark"] .ab-topbar-user-dropdown .menu .divider { border-top-color: #3a3a3a !important; }
html[data-theme="dark"] .ab-topbar-contest-back {
  background: #3a2e10; border-color: #806010; color: #ffc107 !important;
}
html[data-theme="dark"] .ab-topbar-contest-back:hover { background: #4a3a14; }

/* ---- Sidebar ---- */
html[data-theme="dark"] .ab-sidebar { background: #242424; border-right: 1px solid #3a3a3a; }
html[data-theme="dark"] .ab-sidebar-header { border-bottom: 1px solid #333; }
html[data-theme="dark"] .ab-sidebar-header:hover { background: #2c2c2c; }
html[data-theme="dark"] .ab-sidebar-item { color: #bbb !important; }
html[data-theme="dark"] .ab-sidebar-item:hover { background: #2e2e2e; color: #fff !important; }
html[data-theme="dark"] .ab-sidebar-item.active {
  background: #0d3a5c; color: #4ba8e0 !important; border-left-color: #4ba8e0;
}

/* ---- Semantic UI 通用覆盖 ---- */
html[data-theme="dark"] .ui.segment {
  background: #242424 !important; color: rgba(255,255,255,.87) !important;
  border-color: #3a3a3a !important; box-shadow: 0 1px 2px rgba(0,0,0,.3) !important;
}
html[data-theme="dark"] .ui.basic.segment { background: transparent !important; box-shadow: none !important; }
html[data-theme="dark"] .ui.placeholder.segment { background: #2a2a2a !important; color: #999 !important; }
html[data-theme="dark"] .ui.header { color: #e8e8e8 !important; }
html[data-theme="dark"] .ui.divider:not(.vertical):not(.horizontal) {
  border-top-color: #3a3a3a !important; border-bottom-color: #3a3a3a !important;
}

/* table */
html[data-theme="dark"] .ui.table {
  background: #242424 !important; color: #d0d0d0 !important; border-color: #3a3a3a !important;
}
html[data-theme="dark"] .ui.table thead th {
  background: #2c2c2c !important; color: #e0e0e0 !important; border-color: #3a3a3a !important;
}
html[data-theme="dark"] .ui.table tbody tr { background: transparent !important; }
html[data-theme="dark"] .ui.table tbody tr td { border-color: #333 !important; color: #d0d0d0 !important; }
html[data-theme="dark"] .ui.celled.table tr td,
html[data-theme="dark"] .ui.celled.table tr th { border-color: #3a3a3a !important; }
html[data-theme="dark"] .ui.basic.table tbody tr { border-bottom-color: #333 !important; }
html[data-theme="dark"] .ui.very.basic.table tbody tr:hover { background: #2a2a2a !important; }

/* menu */
html[data-theme="dark"] .ui.menu {
  background: #242424 !important; border-color: #3a3a3a !important; box-shadow: none !important;
}
html[data-theme="dark"] .ui.menu .item { color: rgba(255,255,255,.7) !important; }
html[data-theme="dark"] .ui.menu .item.active { color: #fff !important; background: #2c2c2c !important; }
html[data-theme="dark"] .ui.pointing.menu .item:hover { background: #2c2c2c !important; color: #fff !important; }
html[data-theme="dark"] .ui.pointing.menu .active.item:after {
  background: #2c2c2c !important; border-color: #3a3a3a !important;
}

/* dropdown menu */
html[data-theme="dark"] .ui.dropdown,
html[data-theme="dark"] .ui.dropdown > .text { color: #ccc !important; }
html[data-theme="dark"] .ui.dropdown .menu {
  background: #2a2a2a !important; border: 1px solid #3a3a3a !important;
}
html[data-theme="dark"] .ui.dropdown .menu > .item {
  color: rgba(255,255,255,.85) !important; border-top-color: #3a3a3a !important;
}
html[data-theme="dark"] .ui.dropdown .menu > .item:hover { background: #383838 !important; }
html[data-theme="dark"] .ui.dropdown .menu > .divider { border-top-color: #3a3a3a !important; }

/* form / input */
html[data-theme="dark"] .ui.form input[type=text],
html[data-theme="dark"] .ui.form input[type=password],
html[data-theme="dark"] .ui.form input[type=email],
html[data-theme="dark"] .ui.form input[type=number],
html[data-theme="dark"] .ui.form textarea,
html[data-theme="dark"] .ui.input input,
html[data-theme="dark"] input[type=password],
html[data-theme="dark"] input[type=email],
html[data-theme="dark"] textarea {
  background: #2a2a2a !important; color: #e0e0e0 !important; border-color: #444 !important;
}
html[data-theme="dark"] .ui.form input:focus,
html[data-theme="dark"] .ui.input input:focus,
html[data-theme="dark"] textarea:focus {
  background: #303030 !important; border-color: #2185d0 !important;
}
html[data-theme="dark"] .ui.form label,
html[data-theme="dark"] .ui.form .field > label { color: #c0c0c0 !important; }
html[data-theme="dark"] .ui.checkbox label { color: #ccc !important; }
html[data-theme="dark"] .ui.search > .results { background: #2a2a2a !important; border-color: #3a3a3a !important; }
html[data-theme="dark"] .ui.search > .results .result { border-bottom-color: #333 !important; color: #d0d0d0 !important; }
html[data-theme="dark"] .ui.search > .results .result:hover { background: #333 !important; }

/* basic button */
html[data-theme="dark"] .ui.basic.button:not(.green):not(.red):not(.blue):not(.yellow):not(.orange):not(.violet):not(.teal):not(.olive):not(.pink):not(.purple) {
  background: transparent !important; color: #ccc !important; box-shadow: 0 0 0 1px #555 inset !important;
}
html[data-theme="dark"] .ui.basic.button:hover {
  background: #2a2a2a !important; color: #fff !important; box-shadow: 0 0 0 1px #777 inset !important;
}

/* basic label */
html[data-theme="dark"] .ui.basic.label {
  background: transparent !important; color: #ccc !important; border-color: #555 !important;
}

/* message */
html[data-theme="dark"] .ui.message {
  background: #2a2a2a !important; color: #d0d0d0 !important; box-shadow: 0 0 0 1px #3a3a3a inset !important;
}
html[data-theme="dark"] .ui.info.message { background: #0d2a3e !important; color: #6ecbff !important; }
html[data-theme="dark"] .ui.warning.message { background: #3d2f0a !important; color: #ffd966 !important; }
html[data-theme="dark"] .ui.negative.message,
html[data-theme="dark"] .ui.error.message { background: #3a1414 !important; color: #ff8e8e !important; }
html[data-theme="dark"] .ui.positive.message { background: #0f2a14 !important; color: #6dd084 !important; }

/* card */
html[data-theme="dark"] .ui.card,
html[data-theme="dark"] .ui.cards > .card {
  background: #242424 !important; color: #d0d0d0 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.3) !important;
}
html[data-theme="dark"] .ui.card > .content,
html[data-theme="dark"] .ui.cards > .card > .content { border-top-color: #3a3a3a !important; }
html[data-theme="dark"] .ui.card .header,
html[data-theme="dark"] .ui.cards > .card .header { color: #e8e8e8 !important; }
html[data-theme="dark"] .ui.card .meta,
html[data-theme="dark"] .ui.cards > .card .meta { color: #999 !important; }

/* modal */
html[data-theme="dark"] .ui.modal { background: #2a2a2a !important; color: #e0e0e0 !important; }
html[data-theme="dark"] .ui.modal > .header { background: #242424 !important; color: #e8e8e8 !important; border-color: #3a3a3a !important; }
html[data-theme="dark"] .ui.modal > .content { background: #2a2a2a !important; color: #d0d0d0 !important; }
html[data-theme="dark"] .ui.modal > .actions { background: #242424 !important; border-color: #3a3a3a !important; }

/* pagination */
html[data-theme="dark"] .ui.pagination.menu { background: #242424 !important; }
html[data-theme="dark"] .ui.pagination.menu .item { color: #ccc !important; }
html[data-theme="dark"] .ui.pagination.menu .item:hover { background: #2c2c2c !important; }
html[data-theme="dark"] .ui.pagination.menu .active.item { background: #2185d0 !important; color: #fff !important; }

/* statistics */
html[data-theme="dark"] .ui.statistic > .value,
html[data-theme="dark"] .ui.statistics .statistic > .value { color: #e8e8e8 !important; }
html[data-theme="dark"] .ui.statistic > .label,
html[data-theme="dark"] .ui.statistics .statistic > .label { color: #aaa !important; }

/* AlgoBeat 自定义组件 */
html[data-theme="dark"] .ab-banner-wrap { background: #2a2a2a; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
html[data-theme="dark"] .ab-banner-empty { color: #888; }
html[data-theme="dark"] .ab-contest-card { background: #2a2a2a; border: 1px solid #3a3a3a; }
html[data-theme="dark"] .ab-contest-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.4); }
html[data-theme="dark"] .ab-contest-card-title { color: #e8e8e8; }
html[data-theme="dark"] .ab-contest-card-footer { color: #999; border-top-color: #3a3a3a; }
html[data-theme="dark"] .ab-contest-card-time { color: #888; }
html[data-theme="dark"] .ab-contest-mini { border-bottom: 1px solid #333; }
html[data-theme="dark"] .ab-contest-mini:hover { background: #2c2c2c; }
html[data-theme="dark"] .ab-contest-mini-title { color: #e0e0e0; }
html[data-theme="dark"] .ab-contest-mini-time { color: #888; }

/* username tier 微调 */
html[data-theme="dark"] .username-tier-default { color: #bbb; }
html[data-theme="dark"] .username-tier-default:hover { text-decoration: underline; }

/* 题面里的代码块: 保持浅底深字, atom-one-light 兼容 */
html[data-theme="dark"] pre, html[data-theme="dark"] pre code {
  background: #f8f8f8 !important; color: #333 !important; border: 1px solid #444 !important;
}
html[data-theme="dark"] :not(pre) > code {
  background: #2a2a2a !important; color: #ffb4b4 !important;
  border: 1px solid #3a3a3a !important; padding: 1px 5px; border-radius: 3px;
}

/* markdown 题面其它元素 */
html[data-theme="dark"] table:not(.ui) { border-color: #3a3a3a !important; }
html[data-theme="dark"] table:not(.ui) th,
html[data-theme="dark"] table:not(.ui) td { border-color: #3a3a3a !important; color: #d0d0d0; }
html[data-theme="dark"] blockquote {
  border-left-color: #555 !important; background: #2a2a2a; color: #c0c0c0; padding: 8px 12px;
}
html[data-theme="dark"] hr { border-color: #3a3a3a !important; }

/* 默认链接 */
html[data-theme="dark"] .ui.main.container a:not([class*="ui"]):not([class*="ab-"]):not([class*="item"]):not([class*="username-tier"]):not(.user-name-tag) {
  color: #6db8ee;
}
html[data-theme="dark"] .ui.main.container a:not([class*="ui"]):not([class*="ab-"]):not([class*="item"]):not([class*="username-tier"]):not(.user-name-tag):hover {
  color: #93cdf3;
}

/* footer */
html[data-theme="dark"] .ui.vertical.footer.segment {
  background: #242424 !important; border-top: 1px solid #3a3a3a !important;
}

/* main container 默认文字色 */
html[data-theme="dark"] .ui.main.container { color: #d0d0d0; }

/* 切换按钮过渡更平滑 */
html[data-theme="dark"] body, html[data-theme="dark"] .ab-topbar,
html[data-theme="dark"] .ab-sidebar, html[data-theme="dark"] .ui.segment {
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

/* ============ v1.7.3 补丁: attached header + inline style 反转 ============ */

/* attached header / segment (Semantic UI 卡片头部) */
html[data-theme="dark"] .ui.top.attached.header,
html[data-theme="dark"] .ui.attached.header,
html[data-theme="dark"] .ui.bottom.attached.header {
  background: #2c2c2c !important;
  color: #e0e0e0 !important;
  border-color: #3a3a3a !important;
}
html[data-theme="dark"] .ui.attached.segment {
  background: #242424 !important;
  color: rgba(255,255,255,.87) !important;
  border-color: #3a3a3a !important;
}

/* ---- 反转 inline style 写死的浅色文字 ---- */
html[data-theme="dark"] [style*="color: #333"],
html[data-theme="dark"] [style*="color:#333"] { color: #e0e0e0 !important; }
html[data-theme="dark"] [style*="color: #444"],
html[data-theme="dark"] [style*="color:#444"] { color: #d0d0d0 !important; }
html[data-theme="dark"] [style*="color: #555"],
html[data-theme="dark"] [style*="color:#555"] { color: #c0c0c0 !important; }
html[data-theme="dark"] [style*="color: #666"],
html[data-theme="dark"] [style*="color:#666"] { color: #bbb !important; }
html[data-theme="dark"] [style*="color: #777"],
html[data-theme="dark"] [style*="color:#777"] { color: #aaa !important; }
html[data-theme="dark"] [style*="color: #888"],
html[data-theme="dark"] [style*="color:#888"] { color: #aaa !important; }
html[data-theme="dark"] [style*="color: #999"],
html[data-theme="dark"] [style*="color:#999"] { color: #999 !important; }
html[data-theme="dark"] [style*="color: #aaa"],
html[data-theme="dark"] [style*="color:#aaa"] { color: #888 !important; }
html[data-theme="dark"] [style*="color: #bbb"],
html[data-theme="dark"] [style*="color:#bbb"] { color: #888 !important; }
html[data-theme="dark"] [style*="color: #ccc"],
html[data-theme="dark"] [style*="color:#ccc"] { color: #666 !important; }
html[data-theme="dark"] [style*="color: #ddd"],
html[data-theme="dark"] [style*="color:#ddd"] { color: #555 !important; }
html[data-theme="dark"] [style*="color: rgba(0,0,0"] { color: rgba(255,255,255,.85) !important; }

/* ---- 反转 inline style 写死的浅色背景 ---- */
html[data-theme="dark"] [style*="background: #fff"]:not(.ab-banner-slide):not(.ab-banner-slide *),
html[data-theme="dark"] [style*="background:#fff"]:not(.ab-banner-slide),
html[data-theme="dark"] [style*="background-color: #fff"],
html[data-theme="dark"] [style*="background-color:#fff"] {
  background: #242424 !important;
}
html[data-theme="dark"] [style*="background: #fafafa"],
html[data-theme="dark"] [style*="background:#fafafa"],
html[data-theme="dark"] [style*="background-color: #fafafa"] {
  background: #1a1a1a !important;
}
html[data-theme="dark"] [style*="background: #f8"],
html[data-theme="dark"] [style*="background: #f9"],
html[data-theme="dark"] [style*="background: #f5"],
html[data-theme="dark"] [style*="background: #f0"],
html[data-theme="dark"] [style*="background:#f8"],
html[data-theme="dark"] [style*="background:#f9"],
html[data-theme="dark"] [style*="background:#f5"],
html[data-theme="dark"] [style*="background:#f0"] {
  background: #2a2a2a !important;
}
html[data-theme="dark"] [style*="background-color: #f8"],
html[data-theme="dark"] [style*="background-color: #f9"],
html[data-theme="dark"] [style*="background-color: #f5"],
html[data-theme="dark"] [style*="background-color: #f0"] {
  background-color: #2a2a2a !important;
}

/* ---- 反转 inline style 写死的浅色边框 ---- */
html[data-theme="dark"] [style*="border-color: #e"],
html[data-theme="dark"] [style*="border-color: #f"],
html[data-theme="dark"] [style*="border-color:#e"],
html[data-theme="dark"] [style*="border-color:#f"],
html[data-theme="dark"] [style*="border: 1px solid #e"],
html[data-theme="dark"] [style*="border: 1px solid #f"],
html[data-theme="dark"] [style*="border-top: 1px solid #f"],
html[data-theme="dark"] [style*="border-top: 1px solid #e"],
html[data-theme="dark"] [style*="border-bottom: 1px solid #f"],
html[data-theme="dark"] [style*="border-bottom: 1px solid #e"],
html[data-theme="dark"] [style*="border-left: 1px solid #f"],
html[data-theme="dark"] [style*="border-right: 1px solid #f"] {
  border-color: #3a3a3a !important;
}
