:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #d9e0ea;
  --brand: #315f3d;
  --brand-2: #f2c94c;
  --danger: #a33b31;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #263238;
  color: #fff;
  border-bottom: 3px solid var(--brand-2);
}

.brand { font-weight: 700; letter-spacing: 0; }
.topbar nav { display: flex; gap: 18px; align-items: center; }
.topbar a { color: #fff; text-decoration: none; font-size: 14px; }

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px;
}

.hero, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.hero h1, .panel h1 {
  margin: 0 0 12px;
  font-size: 26px;
}

.hero p, .hint {
  color: var(--muted);
  line-height: 1.7;
}

.studio-public-card {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.studio-public-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}
.studio-audit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  flex-wrap: wrap;
}
.studio-audit.pass { border-color: #9ac7a8; background: #edf8f0; color: #215c37; }
.studio-audit.fail { border-color: #e3b0aa; background: #fff1f0; color: #8d2f27; }
.studio-audit.limited { border-color: #e0c572; background: #fff9e8; color: #775400; }
.studio-brief {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 18px;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}
.studio-brief h2 {
  margin: 0 0 8px;
  font-size: 22px;
}
.studio-brief p {
  margin: 0;
  line-height: 1.8;
}
.studio-brief ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.7;
}
.studio-protocol {
  margin: 14px 0;
  border: 1px solid #e6ddca;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fffdf7;
}
.studio-protocol summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand);
}
.studio-protocol p {
  margin: 9px 0;
  line-height: 1.7;
}
.studio-protocol ol {
  margin: 8px 0 0;
  padding-left: 24px;
  line-height: 1.7;
}
.studio-errors {
  margin: 0 0 18px;
  padding: 12px 18px 12px 32px;
  border: 1px solid #e3b0aa;
  border-radius: 8px;
  background: #fff7f6;
  color: #8d2f27;
}
.studio-report-card {
  margin-top: 18px;
}
.studio-report-card h2,
.studio-report-card h3,
.studio-report-card h4 {
  letter-spacing: 0;
}
.studio-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.studio-level {
  display: inline-flex;
  min-width: 86px;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
}
.studio-level.pass { background: #e7f6ec; color: #21613a; }
.studio-level.limited { background: #fff4d6; color: #805a00; }
.studio-level.fail { background: #ffe3df; color: #8d2f27; }
.result-ribbon {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.result-ribbon div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcf8;
}
.result-ribbon span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}
.result-ribbon strong {
  font-size: 22px;
  color: var(--brand);
}
.studio-standard {
  display: grid;
  gap: 14px;
}
.standard-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}
.standard-block h3 {
  margin: 0 0 8px;
  font-size: 17px;
}
.standard-block h4 {
  margin: 14px 0 8px;
  font-size: 15px;
}
.standard-block p {
  margin: 7px 0;
  line-height: 1.7;
}
.algo-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.algo-row {
  display: grid;
  gap: 4px;
  border: 1px solid #e6ddca;
  border-radius: 8px;
  padding: 9px;
  background: #fcfaf5;
  min-width: 0;
}
.algo-row span,
.algo-row small,
.tiny {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.legend-peaks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.legend-peaks p,
.market-box,
.pool-box {
  border: 1px solid #e6ddca;
  border-radius: 8px;
  padding: 10px;
  background: #fcfaf5;
}
.legend-peaks strong {
  display: block;
  margin-bottom: 4px;
  color: var(--brand);
}
.market-box {
  margin: 8px 0;
}
.market-head,
.dir-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.market-head {
  justify-content: space-between;
  margin-bottom: 8px;
}
.dir-count,
.score-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 13px;
  font-weight: 700;
}
.dir-count.win { background: #e7f6ec; color: #21613a; }
.dir-count.draw { background: #fff4d6; color: #805a00; }
.dir-count.lose { background: #ffe8e2; color: #8d2f27; }
.score-tag {
  margin: 2px 5px 2px 0;
  background: #eef3ee;
  color: #20302d;
}
.boundary-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.boundary-strip span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #e6ddca;
  border-radius: 8px;
  padding: 8px;
  background: #fbfcf8;
}
.pool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.pool-box h4 {
  margin: 0 0 8px;
}
.pool-top {
  margin: 10px 0 0;
  padding-left: 22px;
}
.pool-top li {
  margin: 6px 0;
  line-height: 1.45;
}
.pool-top li span {
  margin-left: 8px;
  color: var(--muted);
}
.pool-top li em {
  margin-left: 8px;
  color: #7a6a4a;
  font-style: normal;
}
.decision-pools p {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.empty {
  color: var(--muted);
}
.studio-final {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.studio-final h3 {
  margin: 0 0 8px;
}
.studio-final p {
  margin: 7px 0;
  line-height: 1.7;
}

.studio-highlight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px;
  margin: 12px 0 18px;
}

.studio-hi {
  min-height: 86px;
  border: 1px solid rgba(101, 240, 214, 0.2);
  border-radius: 10px;
  background: rgba(5, 12, 18, 0.9);
  padding: 12px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.studio-hi b {
  color: #8ca7ac;
  font-size: 13px;
}

.studio-hi strong {
  color: #fff;
  font-size: 16px;
  line-height: 1.55;
  font-weight: 800;
}

.studio-hi.primary {
  border-color: rgba(240, 163, 58, 0.85);
  box-shadow: 0 0 0 1px rgba(240, 163, 58, 0.16), 0 14px 34px rgba(240, 163, 58, 0.08);
}

.studio-hi.primary strong {
  color: #ffd18a;
  font-size: 18px;
}

.studio-hi.market {
  border-color: rgba(101, 240, 214, 0.34);
}

.studio-hi.poolhi {
  border-color: rgba(120, 180, 255, 0.35);
}

.studio-hi.legend {
  border-color: rgba(240, 163, 58, 0.45);
}
.studio-limitations {
  margin: 10px 0 0;
  padding-left: 22px;
  color: #775400;
  line-height: 1.7;
}

.narrow { max-width: 460px; margin: 0 auto; }
.wide { max-width: 100%; }
.actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.searchbox {
  display: grid;
  gap: 6px;
  width: min(360px, 100%);
  font-size: 14px;
  color: var(--muted);
}
.small { font-size: 13px; margin: 0; }

.linkbtn, button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
.linkbtn { display: inline-flex; align-items: center; text-decoration: none; }
.primary {
  background: var(--brand);
  color: #fff;
}
.secondary {
  background: #fff;
  color: var(--brand);
  border-color: var(--brand);
}

.form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.hp-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.form label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}
input, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}
.slider-captcha {
  position: relative;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc, #edf2f7);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.slider-captcha-track {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.slider-captcha-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #d9f5e3, #8ee1aa);
}
.slider-captcha-gap {
  position: absolute;
  top: 9px;
  width: 38px;
  height: 34px;
  border: 2px dashed #ad7a22;
  border-radius: 6px;
  background: rgba(255, 247, 223, .95);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.6);
}
.slider-captcha-text {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-weight: 600;
  padding-left: 50px;
  pointer-events: none;
}
.slider-captcha-thumb {
  position: absolute;
  left: 4px;
  top: 6px;
  z-index: 3;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid rgba(45, 70, 48, .35);
  border-radius: 7px;
  background: linear-gradient(180deg, #ffffff, #dcefe3);
  color: #315f3d;
  font-weight: 800;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .16);
}
.slider-captcha-thumb:active {
  cursor: grabbing;
}
.slider-captcha.verified {
  border-color: #42a66a;
}
.slider-captcha.verified .slider-captcha-text {
  color: #1f6a3a;
}
.slider-captcha.failed {
  border-color: #b45309;
}
textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  resize: vertical;
}

.site-announcement {
  padding: 8px 20px;
  background: #fff7df;
  color: #5f3f00;
  border-bottom: 1px solid #ead590;
  line-height: 1.35;
}
.site-announcement-inner {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  width: min(760px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 34px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-announcement-inner span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.announcement-close {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 1px solid rgba(95, 63, 0, .35);
  border-radius: 50%;
  background: rgba(255,255,255,.5);
  color: inherit;
  font-size: 17px;
  line-height: 1;
  padding: 0;
}
.site-announcement.update { background: #e8f1ff; color: #1d4b7a; border-color: #bdd4f0; }
.site-announcement.rest { background: #eef3ee; color: #315f3d; border-color: #cddccb; }
.site-announcement.promo { background: #fff0eb; color: #87412b; border-color: #f0c9b8; }
.admin-notice-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  flex-wrap: wrap;
}
.admin-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}
.admin-pager button {
  width: auto;
  min-height: 34px;
}

.status {
  display: inline-flex;
  margin: 10px 0 16px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
}
.status.ok { background: #e7f6ec; color: #21613a; }
.status.warn { background: #fff4d6; color: #805a00; }

.meta {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px 16px;
}
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; }

code {
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

@media (max-width: 720px) {
  .topbar { padding: 0 14px; }
  .topbar nav { gap: 10px; }
  .page { padding: 18px 12px; }
  .hero, .panel { padding: 18px; }
  .site-announcement-inner { justify-content: flex-start; text-align: left; overflow-x: auto; text-overflow: clip; }
  .slider-captcha { min-height: 42px; }
  .studio-brief { grid-template-columns: 1fr; }
  .studio-card-head { flex-direction: column; }
  .result-ribbon,
  .algo-list,
  .legend-peaks,
  .pool-grid,
  .boundary-strip { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Day/Night theme switch */
.theme-toggle {
  position: fixed;
  top: 72px;
  right: 18px;
  z-index: 1000;
  min-width: 58px;
  height: 32px;
  border: 1px solid rgba(242, 201, 76, 0.72);
  border-radius: 999px;
  background: linear-gradient(135deg, #315f3d, #d99117);
  color: #fff;
  font: 700 13px/1 "Microsoft YaHei", Arial, sans-serif;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}
.theme-toggle:active { transform: translateY(1px); }
:root[data-theme="dark"] {
  --bg: #071018;
  --panel: #0f1b25;
  --ink: #eef7f4;
  --muted: #9fb0bc;
  --line: rgba(101, 240, 214, 0.18);
  --brand: #65f0d6;
  --brand-2: #f0a33a;
  --danger: #ff806f;
}
:root[data-theme="dark"] body {
  background: linear-gradient(180deg, #071018 0%, #020508 100%);
}
:root[data-theme="dark"] .topbar {
  background: #101d25;
}
:root[data-theme="dark"] .hero,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .studio-brief,
:root[data-theme="dark"] .studio-protocol,
:root[data-theme="dark"] .studio-audit,
:root[data-theme="dark"] table,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background-color: var(--panel);
  color: var(--ink);
}
:root[data-theme="dark"] th {
  background: rgba(255,255,255,0.06);
}
:root[data-theme="dark"] .hint,
:root[data-theme="dark"] .hero p {
  color: var(--muted);
}

/* Public/admin page polish */
body { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.topbar nav a { border-radius: 999px; padding: 7px 10px; transition: background .16s ease, color .16s ease; }
.topbar nav a:hover { background: rgba(255,255,255,.12); }
.hero, .panel { box-shadow: 0 18px 42px rgba(25, 48, 66, 0.08); }
.linkbtn, button, input, select, textarea { border-radius: 8px; }
:root[data-theme="dark"] .hero, :root[data-theme="dark"] .panel { box-shadow: 0 18px 44px rgba(0,0,0,.34), 0 0 0 1px rgba(101, 240, 214, 0.08) inset; }
:root[data-theme="dark"] .topbar nav a:hover { background: rgba(101, 240, 214, 0.1); }
:root[data-theme="dark"] .linkbtn.primary, :root[data-theme="dark"] button.primary { background: linear-gradient(135deg, #315f3d, #0e8f7c); }

/* Dark theme readability fix for forms, captcha, tables and admin pages */
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .hero {
  background: linear-gradient(180deg, rgba(16, 28, 38, 0.98), rgba(10, 18, 26, 0.98));
  color: #eef7f4;
  border-color: rgba(101, 240, 214, 0.22);
}
:root[data-theme="dark"] .form label,
:root[data-theme="dark"] .form label span,
:root[data-theme="dark"] .searchbox,
:root[data-theme="dark"] .searchbox span,
:root[data-theme="dark"] td,
:root[data-theme="dark"] th,
:root[data-theme="dark"] p,
:root[data-theme="dark"] li,
:root[data-theme="dark"] summary {
  color: #eef7f4;
}
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: #f8fbff;
  color: #111827;
  border: 1px solid rgba(101, 240, 214, 0.45);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 0 0 1px rgba(101,240,214,0.08);
}
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
  color: #667085;
}
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] select:focus,
:root[data-theme="dark"] textarea:focus {
  outline: none;
  border-color: #65f0d6;
  box-shadow: 0 0 0 3px rgba(101, 240, 214, 0.18);
}
:root[data-theme="dark"] .slider-captcha {
  background: #f8fbff;
  color: #111827;
  border: 1px solid rgba(101, 240, 214, 0.45);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 0 0 1px rgba(101,240,214,0.08);
}
:root[data-theme="dark"] .slider-captcha-text { color: #334155; }
:root[data-theme="dark"] .slider-captcha.verified .slider-captcha-text { color: #14532d; }
:root[data-theme="dark"] .hint,
:root[data-theme="dark"] .small,
:root[data-theme="dark"] .meta,
:root[data-theme="dark"] .tiny {
  color: #b9c8d2;
}
:root[data-theme="dark"] table {
  background: rgba(11, 20, 29, 0.98);
  color: #eef7f4;
}
:root[data-theme="dark"] th {
  background: rgba(101, 240, 214, 0.1);
  color: #f8fffd;
}
:root[data-theme="dark"] td {
  border-color: rgba(101, 240, 214, 0.16);
}
:root[data-theme="dark"] tr:nth-child(even) td {
  background: rgba(255,255,255,0.025);
}
:root[data-theme="dark"] code {
  background: #f8fbff;
  color: #111827;
  border-color: rgba(101, 240, 214, 0.35);
}
:root[data-theme="dark"] .status.ok { background: #dff7e7; color: #14532d; }
:root[data-theme="dark"] .status.warn { background: #fff2bd; color: #713f12; }
:root[data-theme="dark"] .status.fail { background: #ffe1dd; color: #7f1d1d; }
:root[data-theme="dark"] .studio-audit.pass { background: rgba(34, 197, 94, 0.16); color: #dff7e7; border-color: rgba(74, 222, 128, 0.42); }
:root[data-theme="dark"] .studio-audit.fail { background: rgba(239, 68, 68, 0.14); color: #ffe1dd; border-color: rgba(248, 113, 113, 0.42); }
:root[data-theme="dark"] .studio-audit.limited { background: rgba(245, 158, 11, 0.14); color: #fff2bd; border-color: rgba(245, 158, 11, 0.44); }
