/* CTF Crypto Lab - 视觉样式（浅色为主，可切换深色） */
:root {
  /* 与主站（静笺）保持同一套暖纸配色 */
  --bg: #f6f4ef;
  --surface: #fffdf9;
  --surface-2: #faf8f3;
  --surface-3: #f2efe7;
  --border: #e2ddd0;
  --border-strong: #cfc7b4;
  --text: #211f1a;
  --text-2: #514c42;
  --muted: #8b8478;
  --accent: #2c3f63;
  --accent-2: #1e2c47;
  --accent-soft: #e9edf5;
  --accent-border: #c3cddd;
  --teal: #2f6b4f;
  --teal-soft: #eaf2ed;
  --amber: #9a6b1f;
  --amber-soft: #f8efdd;
  --red: #9d3b32;
  --code-bg: #f7f4ee;
  --shadow: 0 1px 2px rgba(38, 33, 22, .05), 0 8px 24px -12px rgba(38, 33, 22, .22);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}
[data-theme="dark"] {
  --bg: #111827;
  --surface: #182234;
  --surface-2: #1d293c;
  --surface-3: #22304a;
  --border: #2b3a52;
  --border-strong: #3c4d69;
  --text: #e8eef8;
  --text-2: #b6c2d6;
  --muted: #8696ae;
  --accent: #8b8cf9;
  --accent-2: #a5a6ff;
  --accent-soft: #262b52;
  --accent-border: #43498a;
  --teal: #4fd1c5;
  --teal-soft: #183b3c;
  --amber: #f0b357;
  --amber-soft: #3b2e1c;
  --red: #f08a80;
  --code-bg: #131c2c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 8px 24px rgba(0, 0, 0, .18);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
::selection { background: var(--accent-soft); }

/* ---------------- 顶部工具条 ---------------- */
.side-logo {
  width: 22px; height: 22px; flex: none; border-radius: 7px;
  object-fit: cover; object-position: 50% 38%; border: 1px solid var(--border);
}
.top-search {
  flex: 0 1 190px; min-width: 120px; position: relative;
}
.top-search input {
  width: 100%; height: 30px; padding: 0 10px 0 28px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); outline: none; font-size: 12px;
}
.top-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.top-search .icon { position: absolute; left: 9px; top: 8px; color: var(--muted); pointer-events: none; }

/* ---------------- 布局 ---------------- */
.layout { display: grid; grid-template-columns: 224px minmax(0, 1fr); max-width: 1520px; margin: 0 auto; }
.sidebar {
  position: sticky; top: 58px; align-self: start; height: calc(100vh - 58px);
  overflow-y: auto; padding: 22px 14px 40px;
  border-right: 1px solid var(--border);
}
.nav-group { margin-bottom: 18px; }
.nav-title {
  font-size: 10px; font-weight: 700; letter-spacing: 1.4px; color: var(--muted);
  text-transform: uppercase; padding: 0 10px; margin-bottom: 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2); text-align: left;
  font-size: 12.5px; transition: .15s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-num { font: 600 10px var(--mono); color: var(--muted); min-width: 17px; }
.nav-item.active .nav-num { color: var(--accent); }
.sidebar-note {
  margin: 18px 8px 0; padding: 11px; border-radius: 10px;
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  font-size: 11px; color: var(--muted); line-height: 1.7;
}
main { padding: 18px 30px 90px; min-width: 0; }

/* ---------------- 通用组件 ---------------- */
.hero {
  background: linear-gradient(120deg, var(--surface) 0%, var(--surface) 55%, var(--accent-soft) 100%);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 26px 28px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 8px; font-size: 25px; letter-spacing: -.4px; }
.hero p { margin: 0; color: var(--text-2); max-width: 780px; font-size: 13px; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pill {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.pill.accent { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.pill.teal { background: var(--teal-soft); border-color: color-mix(in srgb, var(--teal) 30%, transparent); color: var(--teal); }

.section-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 34px 0 16px; font-size: 12px; font-weight: 700;
  letter-spacing: 1.2px; color: var(--muted); text-transform: uppercase;
}
.section-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px 22px; margin-bottom: 18px; scroll-margin-top: 78px;
}
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.card-idx {
  font: 700 11px var(--mono); color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--accent-border); border-radius: 7px;
  padding: 2px 7px; margin-top: 3px; flex: none;
}
.card h2 { font-size: 16px; margin: 0; letter-spacing: -.2px; }
.card-head .spacer { flex: 1; }
.tag {
  font-size: 10.5px; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border); color: var(--muted); background: var(--surface-2);
}
.tag.src { color: var(--amber); background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.tag.ext { color: var(--teal); background: var(--teal-soft); border-color: color-mix(in srgb, var(--teal) 25%, transparent); }
.card-desc { margin: 0 0 16px 40px; color: var(--muted); font-size: 12px; }
.card-body { margin-left: 40px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1100px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .lbl { font-size: 11px; font-weight: 600; color: var(--text-2); letter-spacing: .3px; }
.field .hint, .hint { font-size: 11px; color: var(--muted); font-weight: 400; }
textarea, input[type="text"], input[type="number"], select {
  width: 100%; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; outline: none; transition: .15s;
}
textarea { resize: vertical; min-height: 78px; font: 12.5px/1.65 var(--mono); }
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { height: 36px; padding: 0 8px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.mono { font-family: var(--mono); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12px; font-weight: 600; transition: .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent-border); color: var(--accent); background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); color: #fff; }
.btn.sm { height: 27px; padding: 0 9px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.grid2.btn-row, .grid3.btn-row, .grid4.btn-row { display: grid; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 26px; padding: 0 7px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font: 600 11px var(--mono);
}
.chip:hover, .chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.output {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; min-height: 38px; font: 12.5px/1.7 var(--mono);
  white-space: pre-wrap; word-break: break-all; color: var(--text);
}
.output.empty { color: var(--muted); }
.output.accent-out { border-color: var(--accent-border); background: var(--accent-soft); }
.result-box { display: flex; flex-direction: column; gap: 6px; }
.result-head { display: flex; align-items: center; gap: 8px; }
.result-head .lbl { flex: 1; }
.err { color: var(--red); font-size: 12px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tab {
  border: 0; background: transparent; padding: 8px 12px; font-size: 12px;
  color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

details.fold { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); margin-top: 12px; }
details.fold > summary {
  cursor: pointer; padding: 9px 12px; font-size: 12px; font-weight: 600; color: var(--text-2);
  list-style: none; user-select: none;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: '▸'; margin-right: 8px; color: var(--accent); display: inline-block; transition: .15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
.fold-body { padding: 0 12px 12px; max-height: 320px; overflow-y: auto; }
.bf-row {
  display: flex; gap: 10px; padding: 4px 6px; border-bottom: 1px dashed var(--border);
  font: 11.5px/1.6 var(--mono); align-items: baseline;
}
.bf-row:last-child { border-bottom: 0; }
.bf-row .k { color: var(--accent); min-width: 46px; flex: none; }
.bf-row .v { word-break: break-all; color: var(--text); }

.formula {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 16px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 20px;
}
.formula div { font: 13px/1.9 var(--mono); color: var(--text); }
.formula small { display: block; font: 11px/1.5 var(--sans); color: var(--muted); }
sup, sub { font-size: .75em; }

/* ---------------- 表格 ---------------- */
.table-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.table-tools input { max-width: 260px; height: 30px; font-size: 12px; }
.table-wrap {
  border: 1px solid var(--border); border-radius: 10px; overflow: auto;
  max-height: 340px; background: var(--surface);
}
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-3); color: var(--text-2); font-weight: 700;
  font-size: 11px; letter-spacing: .3px;
}
td { font-family: var(--mono); color: var(--text); }
tbody tr:hover { background: var(--accent-soft); }
td.num { color: var(--muted); }
td.ch { color: var(--accent); font-weight: 700; }
.table-wrap.compact { max-height: 260px; }
.ref-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ref-block { border: 1px solid var(--border); border-radius: 11px; padding: 14px; background: var(--surface-2); min-width: 0; }
.ref-block h3 { margin: 0 0 4px; font-size: 13px; }
.ref-block p { margin: 0 0 10px; font-size: 11px; color: var(--muted); }
.ref-block .table-wrap { max-height: 250px; }
.ref-table td { white-space: normal; font-family: var(--sans); font-size: 11.5px; }
.ref-table td:first-child { font-family: var(--mono); color: var(--accent); white-space: nowrap; }

.callout {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 9px 9px 0; padding: 9px 13px; font-size: 11.5px;
  color: var(--text-2); margin: 12px 0;
}
.callout.teal { border-left-color: var(--teal); background: var(--teal-soft); }

.split-arrow { text-align: center; color: var(--muted); font-size: 11px; padding: 2px 0; }

/* ---------------- 杂项 ---------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 16px);
  background: var(--text); color: var(--surface); padding: 9px 16px; border-radius: 9px;
  font-size: 12px; opacity: 0; pointer-events: none; transition: .25s; z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }
.footer { text-align: center; color: var(--muted); font-size: 11px; margin-top: 30px; line-height: 1.9; }

/* ---------------- 单视图 / 可收起目录 ---------------- */
.view { display: none; }
.view.active { display: block; }
.section-divider { display: none; }
.layout.no-sidebar { grid-template-columns: minmax(0, 1fr); }
.layout.no-sidebar .sidebar { display: none; }
.icon-btn {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text-2);
}
.icon-btn:hover, .icon-btn.on { border-color: var(--accent-border); color: var(--accent); background: var(--accent-soft); }
.sidebar-top {
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px 10px; margin-bottom: 12px; border-bottom: 1px solid var(--border);
}
.sidebar-caption { flex: 1; font-size: 10px; font-weight: 700; letter-spacing: 1.4px; color: var(--muted); text-transform: uppercase; }
.hero.compact { padding: 16px 20px; margin-bottom: 14px; }
.hero.compact h1 { font-size: 19px; margin-bottom: 4px; }
.hero.compact p { font-size: 12px; }
.hero.compact .hero-tags { margin-top: 10px; }
.view-head {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 8px 10px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; box-shadow: var(--shadow);
}
.view-head select { width: auto; min-width: 210px; height: 32px; font-size: 12px; font-weight: 600; }
.view-hint { flex: 1; font-size: 11px; color: var(--muted); text-align: right; }
.search-results {
  position: absolute; top: 34px; left: 0; width: 330px; max-width: 70vw; z-index: 80;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(24, 39, 75, .15); padding: 5px;
  max-height: 320px; overflow-y: auto;
}
.sr-item { display: flex; align-items: baseline; gap: 8px; padding: 7px 9px; border-radius: 7px; cursor: pointer; }
.sr-item:hover { background: var(--accent-soft); }
.sr-num { font: 700 10px var(--mono); color: var(--accent); min-width: 26px; }
.sr-name { font-size: 12px; font-weight: 700; }
.sr-desc { font-size: 11px; color: var(--muted); }
.sr-empty { padding: 10px; font-size: 12px; color: var(--muted); }
.ov-group { margin-bottom: 16px; }
.ov-title { font-size: 10px; font-weight: 700; letter-spacing: 1.2px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 10px; }
.ov-card {
  text-align: left; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 10px; padding: 10px 12px; transition: .15s;
}
.ov-card:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.ov-card .n { font: 700 10px var(--mono); color: var(--accent); }
.ov-card .t { font-size: 12.5px; font-weight: 700; margin: 2px 0 3px; }
.ov-card .d { font-size: 11px; color: var(--muted); line-height: 1.5; }

@media (max-width: 900px) {
  .layout, .layout.no-sidebar { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px; }
  .nav-group { margin-bottom: 8px; }
  .nav-group .nav-item { display: inline-flex; width: auto; }
  .sidebar-note { display: none; }
  main { padding: 18px 16px 60px; }
  .grid2, .grid3, .grid4, .ref-grid { grid-template-columns: 1fr; }
  .card-body, .card-desc { margin-left: 0; }
  .brand { min-width: 0; }
  .view-hint { display: none; }
  .view-head { gap: 6px; padding: 7px 8px; }
  .view-head select { min-width: 0; flex: 1; }
  .top-search { flex: 1 1 100%; order: 9; }
  .ov-grid { grid-template-columns: 1fr; }
}

/* ---------------- 精简版：收掉非必要的说明文字 ---------------- */
.card-desc, .sidebar-note, .badge-live, .view-hint,
.callout:not(#p1ArgHint):not(#p2ArgHint),
.field > .hint, .btn-row > .hint, .card-body > .hint,
.ref-block > p { display: none !important; }
.hero.compact { padding: 13px 18px; }
.hero.compact h1 { font-size: 18px; }
.view-head { margin-bottom: 12px; }
#backOverview { margin-left: auto; }
.card-body { margin-top: 2px; }
