/* ============================================================
 * ApiSimul —— The Switchboard（总机交换台）
 * 浅色宽幅 · 插孔点阵 · 线红 / 接通绿 / 占线琥珀
 * ============================================================ */

:root {
  --paper: #f4f1ea;            /* 稻草纸底 */
  --panel: #fffdf8;            /* 面板米白 */
  --panel-2: #efece3;
  --ink: #221c14;              /* 墨黑 */
  --ink-soft: #57503f;
  --ink-faint: #9b937f;

  --red: #c03d2e;              /* 线红 */
  --red-deep: #9c2d20;
  --red-soft: rgba(192, 61, 46, .08);
  --green: #2e6b4f;            /* 接通绿 */
  --green-soft: rgba(46, 107, 79, .09);
  --amber: #a8700a;            /* 占线琥珀 */
  --amber-soft: rgba(168, 112, 10, .1);

  --line: #ddd7c8;
  --line-2: #c7bfa9;

  --m-get: #2e6b4f;
  --m-post: #1f5f8b;
  --m-put: #a8700a;
  --m-delete: #c03d2e;
  --m-patch: #7d5ba6;
  --m-head: #57503f;
  --m-options: #57503f;

  --max-width: 1560px;
  --mono: "Fira Code", "SF Mono", Consolas, monospace;
  --sans: "Be Vietnam Pro", "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  --display: "Familjen Grotesk", var(--sans);

  --shadow-sm: 0 1px 2px rgba(34, 28, 20, .05), 0 4px 12px rgba(34, 28, 20, .05);
  --shadow-md: 0 2px 6px rgba(34, 28, 20, .06), 0 18px 44px rgba(34, 28, 20, .1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 插孔点阵背景 */
body {
  background-image: radial-gradient(rgba(34, 28, 20, .055) 1px, transparent 1px);
  background-size: 26px 26px;
}

a { color: var(--red-deep); text-decoration: none; }
a:hover { color: var(--red); }

::selection { background: var(--red); color: #fff; }

/* ============ 头部 ============ */
.site-head {
  background: var(--panel);
  border-bottom: 2px solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 50;
}
.head-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand-icon { width: 38px; height: 38px; display: block; }
.brand-text { font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: .01em; }
.brand-text em { font-style: normal; font-weight: 500; font-size: 13px; color: var(--ink-faint); margin-left: 6px; }

.head-nav { margin-left: auto; display: flex; gap: 22px; }
.head-nav a {
  color: var(--ink-soft); font-size: 14px; font-weight: 500;
  padding: 4px 2px; border-bottom: 2px solid transparent;
}
.head-nav a:hover { color: var(--red); border-bottom-color: var(--red); }

.menu-btn { display: none; }

/* ============ 主区容器 ============ */
.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 28px; }

/* ============ Hero（一行，点开即见工具） ============ */
.hero { padding: 30px 0 22px; display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.hero-no {
  font-family: var(--mono); font-size: 13px; color: var(--red);
  border: 1.5px solid var(--red); padding: 2px 8px; white-space: nowrap;
}
.hero h1 { font-family: var(--display); font-size: clamp(26px, 3.4vw, 42px); font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.hero h1 .accent { color: var(--ink-faint); font-weight: 500; }

/* ============ 交换台工作区 ============ */
.desk {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 400px;
  gap: 18px;
  align-items: start;
  padding-bottom: 26px;
}

.panel {
  background: var(--panel);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--panel-2);
  border-bottom: 1.5px solid var(--ink);
}
.panel-head .p-tag {
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  color: var(--ink-soft); letter-spacing: .08em; text-transform: uppercase;
}
.panel-head .p-tag b { color: var(--red); font-weight: 600; margin-right: 6px; }
.panel-head .p-side { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.p-count { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

/* ---------- 左栏：操作员总开关 + 规则列表 ---------- */
.operator {
  padding: 16px;
  background: var(--panel-2);
  border-bottom: 1.5px solid var(--line-2);
}
.op-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.op-lamp {
  width: 12px; height: 12px; border-radius: 50%;
  background: #c9c2ae; border: 2px solid var(--ink-soft); flex: none;
}
.op-lamp.on { background: var(--green); border-color: var(--green); animation: lampPulse 2.2s infinite; }
.op-lamp.warn { background: var(--amber); border-color: var(--amber); }
@keyframes lampPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 107, 79, .45); }
  50% { box-shadow: 0 0 0 6px rgba(46, 107, 79, 0); }
}
.sw-state { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); line-height: 1.45; }
.sw-state.on { color: var(--green); }
.sw-state.warn { color: var(--amber); }
.sw-state.off { color: var(--ink-faint); }

.btn-operator {
  width: 100%;
  font-family: var(--display); font-weight: 700; font-size: 15px;
  letter-spacing: .04em; text-transform: uppercase;
  padding: 13px 14px; cursor: pointer;
  background: var(--ink); color: var(--paper);
  border: 2px solid var(--ink); border-radius: 6px;
  transition: transform .12s ease, box-shadow .12s ease, background .15s;
}
.btn-operator:hover { background: var(--red); border-color: var(--red); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-operator.on { background: var(--red); border-color: var(--red-deep); }
.btn-operator.busy { opacity: .7; cursor: wait; }
.btn-operator:active { transform: translateY(0); }

.rule-tools { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1.5px solid var(--line-2); flex-wrap: wrap; }
.mini-btn {
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  padding: 7px 10px; cursor: pointer;
  background: var(--panel); color: var(--ink-soft);
  border: 1.5px solid var(--line-2); border-radius: 5px;
  transition: border-color .15s, color .15s;
}
.mini-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.mini-btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.mini-btn.primary:hover { background: var(--red); border-color: var(--red); }

.rule-list { max-height: 560px; overflow-y: auto; }
.rule-empty {
  padding: 34px 20px; text-align: center;
  font-family: var(--mono); font-size: 13px; color: var(--ink-faint);
}
.rule-empty b { display: block; font-size: 30px; margin-bottom: 8px; color: var(--line-2); }

.rule-card {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid var(--line-2);
  transition: background .15s;
}
.rule-card:hover { background: var(--red-soft); }
.rule-card.off { opacity: .5; border-left-color: var(--line); }
.rule-card.editing { background: var(--amber-soft); border-left-color: var(--amber); }
.rc-main { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.rc-path {
  font-family: var(--mono); font-size: 12.5px; font-weight: 500;
  color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rc-status, .rc-delay {
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint); white-space: nowrap;
}
.rc-side { display: flex; align-items: center; gap: 6px; }
.rc-btn {
  width: 26px; height: 26px; cursor: pointer;
  background: none; border: 1.5px solid var(--line-2); border-radius: 5px;
  color: var(--ink-soft); font-size: 13px; line-height: 1;
  transition: border-color .15s, color .15s;
}
.rc-btn:hover { border-color: var(--red); color: var(--red); }
.rc-btn.danger:hover { border-color: var(--m-delete); color: var(--m-delete); }

/* 方法徽章 */
.m-badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .04em; color: #fff;
  padding: 2px 7px; border-radius: 4px; flex: none;
}
.m-get { background: var(--m-get); }
.m-post { background: var(--m-post); }
.m-put { background: var(--m-put); }
.m-delete { background: var(--m-delete); }
.m-patch { background: var(--m-patch); }
.m-head, .m-options { background: var(--m-head); }

/* 开关 */
.switch { position: relative; display: inline-block; width: 34px; height: 19px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: var(--line-2); border-radius: 19px;
  transition: background .18s;
}
.switch .slider::before {
  content: ""; position: absolute; left: 2.5px; top: 2.5px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--panel); box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .18s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(15px); }

/* ---------- 中栏：规则表单 ---------- */
.rule-form { display: none; }
.rule-form.open { display: block; }

.rf-body { padding: 16px; }
.rf-grid { display: grid; grid-template-columns: 130px minmax(0, 1fr) 110px; gap: 12px; margin-bottom: 12px; }
.rf-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.rf-field label {
  display: block; font-family: var(--mono); font-size: 11px; font-weight: 500;
  color: var(--ink-soft); letter-spacing: .06em; text-transform: uppercase;
  margin-bottom: 5px;
}
.rf-field input, .rf-field select, .rf-field textarea {
  width: 100%;
  font-family: var(--mono); font-size: 13px; color: var(--ink);
  background: var(--panel); border: 1.5px solid var(--line-2); border-radius: 5px;
  padding: 9px 10px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.rf-field input:focus, .rf-field select:focus, .rf-field textarea:focus {
  border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft);
}
.rf-field textarea { resize: vertical; line-height: 1.55; }
#fBody { min-height: 240px; }
#fHeaders { min-height: 64px; }

.delay-row { display: flex; align-items: center; gap: 10px; }
.delay-row input[type=range] { flex: 1; accent-color: var(--red); padding: 0; }
.delay-val { font-family: var(--mono); font-size: 12px; color: var(--red); white-space: nowrap; min-width: 58px; text-align: right; }

.rf-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-soft); }
.rf-check input { width: 16px; height: 16px; accent-color: var(--green); }

.rf-error { font-family: var(--mono); font-size: 12px; color: var(--red); min-height: 18px; margin: 4px 0; }

.rf-actions { display: flex; gap: 10px; align-items: center; }
.btn-save {
  font-family: var(--display); font-weight: 700; font-size: 14px;
  letter-spacing: .03em; text-transform: uppercase;
  padding: 10px 22px; cursor: pointer;
  background: var(--red); color: #fff;
  border: 2px solid var(--red); border-radius: 6px;
  transition: background .15s, transform .12s;
}
.btn-save:hover { background: var(--red-deep); border-color: var(--red-deep); transform: translateY(-1px); }
.btn-cancel {
  font-family: var(--mono); font-size: 13px;
  padding: 10px 16px; cursor: pointer;
  background: none; color: var(--ink-soft);
  border: 1.5px solid var(--line-2); border-radius: 6px;
}
.btn-cancel:hover { border-color: var(--ink); color: var(--ink); }

/* 占位符 chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.chip {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  color: var(--ink-soft); cursor: pointer;
  background: var(--panel-2); border: 1px dashed var(--line-2); border-radius: 4px;
  padding: 3px 8px;
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); border-style: solid; }

/* ---------- 右栏：测试呼叫 + 通话日志 ---------- */
.test-pad { padding: 14px 16px; border-bottom: 1.5px solid var(--line-2); }
.test-row { display: flex; gap: 8px; }
.test-row select {
  font-family: var(--mono); font-size: 12.5px; font-weight: 600;
  color: var(--ink); background: var(--panel);
  border: 1.5px solid var(--line-2); border-radius: 5px;
  padding: 8px 6px; outline: none; cursor: pointer;
}
.test-row input {
  flex: 1; min-width: 0;
  font-family: var(--mono); font-size: 12.5px;
  background: var(--panel); color: var(--ink);
  border: 1.5px solid var(--line-2); border-radius: 5px;
  padding: 8px 10px; outline: none;
}
.test-row input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.btn-send {
  font-family: var(--display); font-weight: 700; font-size: 12.5px;
  letter-spacing: .05em; text-transform: uppercase; cursor: pointer;
  padding: 8px 14px;
  background: var(--ink); color: var(--paper);
  border: 2px solid var(--ink); border-radius: 5px;
  transition: background .15s, border-color .15s;
}
.btn-send:hover { background: var(--green); border-color: var(--green); }

.test-result {
  margin-top: 10px; border: 1px solid var(--line); border-radius: 5px;
  background: var(--paper);
  font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
  padding: 0; max-height: 260px; overflow: auto;
  display: none;
}
.test-result.loading, .test-result:not(:empty) { display: block; }
.test-result .tr-meta {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel);
}
.test-result pre { padding: 10px; white-space: pre-wrap; word-break: break-all; line-height: 1.5; color: var(--ink); }

.log-list { max-height: 520px; overflow-y: auto; }
.log-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px;
  animation: logIn .25s ease;
}
@keyframes logIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.log-row.mock { background: var(--green-soft); }
.log-row.pass { background: transparent; }
.lg-time { color: var(--ink-faint); flex: none; }
.lg-url {
  flex: 1; min-width: 0; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lg-status { font-weight: 600; color: var(--ink-soft); flex: none; }
.log-row.mock .lg-status { color: var(--green); }
.lg-tag { font-size: 10px; font-weight: 600; letter-spacing: .05em; flex: none; }
.log-row.mock .lg-tag { color: var(--green); }
.log-row.pass .lg-tag { color: var(--ink-faint); }
.log-empty { padding: 30px 16px; text-align: center; font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

/* ============ 说明区（工作台之下） ============ */
.doc { padding: 34px 0 20px; }
.doc-sec { margin-bottom: 44px; }
.doc-sec h2 {
  font-family: var(--display); font-size: clamp(20px, 2.4vw, 30px); font-weight: 700;
  display: flex; align-items: baseline; gap: 12px; line-height: 1.2;
}
.doc-sec h2 .sec-no {
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  color: var(--red); letter-spacing: .05em; flex: none;
}
.doc-rule {
  height: 3px; background: var(--ink); margin: 12px 0 18px;
  position: relative;
}
.doc-rule::after {
  content: ""; position: absolute; right: 0; top: 0;
  width: 64px; height: 3px; background: var(--red);
}
.lead { font-size: 16.5px; color: var(--ink-soft); max-width: 860px; margin-bottom: 20px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.info-card {
  background: var(--panel); border: 1.5px solid var(--line-2); border-radius: 7px;
  padding: 18px 20px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.info-card:hover { border-color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.ic-no {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--red); margin-bottom: 8px; letter-spacing: .08em;
}
.info-card h3 { font-family: var(--display); font-size: 16.5px; font-weight: 700; margin-bottom: 8px; }
.info-card p { font-size: 14px; color: var(--ink-soft); line-height: 1.65; }
.info-card code {
  font-family: var(--mono); font-size: 12.5px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; color: var(--red-deep);
}

/* 速查表 */
.cheat-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1.5px solid var(--ink); border-radius: 7px; overflow: hidden; font-size: 13.5px; }
.cheat-table th {
  font-family: var(--mono); font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  text-align: left; color: var(--paper); background: var(--ink);
  padding: 10px 14px; font-weight: 500;
}
.cheat-table td { padding: 9px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.cheat-table td:first-child { font-family: var(--mono); font-size: 12.5px; color: var(--red-deep); white-space: nowrap; }
.cheat-table td:last-child { color: var(--ink-soft); }
.table-scroll { overflow-x: auto; border-radius: 7px; }

/* FAQ */
details.faq {
  background: var(--panel); border: 1.5px solid var(--line-2); border-radius: 7px;
  margin-bottom: 10px; overflow: hidden;
}
details.faq summary {
  cursor: pointer; list-style: none;
  font-family: var(--display); font-weight: 600; font-size: 15.5px;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::before {
  content: "+"; font-family: var(--mono); color: var(--red); font-size: 17px; font-weight: 600;
  width: 22px; height: 22px; border: 1.5px solid var(--red); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
details.faq[open] summary::before { content: "–"; }
details.faq[open] summary { background: var(--panel-2); border-bottom: 1px solid var(--line); }
details.faq .faq-a { padding: 14px 18px 16px 52px; color: var(--ink-soft); font-size: 14.5px; line-height: 1.7; }

/* ============ 页脚 ============ */
.site-foot {
  margin-top: 40px;
  background: var(--ink); color: var(--paper);
  border-top: 4px solid var(--red);
}
.foot-inner {
  max-width: var(--max-width); margin: 0 auto;
  padding: 40px 28px 26px;
  display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); gap: 36px;
}
.foot-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.foot-brand img { width: 30px; height: 30px; }
.foot-brand span { font-family: var(--display); font-weight: 700; font-size: 18px; }
.foot-inner p { font-size: 13.5px; color: rgba(244, 241, 234, .6); line-height: 1.7; max-width: 460px; }
.foot-col h4 {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--red); margin-bottom: 12px;
}
.foot-col a { display: block; color: rgba(244, 241, 234, .75); font-size: 13.5px; padding: 4px 0; }
.foot-col a:hover { color: #fff; }
.foot-base {
  border-top: 1px solid rgba(244, 241, 234, .15);
  text-align: center; padding: 16px;
  font-family: var(--mono); font-size: 12px; color: rgba(244, 241, 234, .45);
}

/* ============ 响应式 ============ */
@media (max-width: 1200px) {
  .desk { grid-template-columns: 340px minmax(0, 1fr); }
  .desk .panel-log { grid-column: 1 / -1; }
}

@media (max-width: 880px) {
  .head-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--panel); border-bottom: 2px solid var(--ink);
    flex-direction: column; gap: 0; padding: 8px 20px 14px;
  }
  .head-nav.open { display: flex; }
  .head-nav a { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .menu-btn {
    display: flex; flex-direction: column; gap: 5px; justify-content: center;
    margin-left: auto; background: none; border: none; cursor: pointer;
    width: 44px; height: 44px; align-items: center;
  }
  .menu-btn span { display: block; width: 22px; height: 2.5px; background: var(--ink); }
}

@media (max-width: 760px) {
  .wrap, .head-inner, .foot-inner { padding-left: 16px; padding-right: 16px; }
  .desk { grid-template-columns: 1fr; }
  .desk .panel-log { grid-column: auto; }
  .hero { padding: 22px 0 16px; }
  .grid-3 { grid-template-columns: 1fr; }
  .rf-grid, .rf-grid2 { grid-template-columns: 1fr; }
  .rule-list, .log-list { max-height: 380px; }
  .foot-inner { grid-template-columns: 1fr; gap: 24px; }
  .btn-operator, .btn-save, .btn-send, .mini-btn, .rc-btn { min-height: 44px; min-width: 44px; }
  .btn-send { padding: 8px 16px; }
  .cheat-table td:first-child { white-space: normal; }

  /* 触屏设备：悬停态常显 */
  @media (hover: none) {
    .info-card:hover { transform: none; box-shadow: var(--shadow-sm); }
    .rule-card:hover { background: transparent; }
  }
}

/* 打印 */
@media print {
  .site-head, .site-foot, .desk, .hero { display: none; }
  body { background: #fff; }
}
