/* ============================================================
   一稿 · Workspace
   ============================================================ */

body.app-body {
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: 56px 1fr;
}

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 30;
  position: relative;
}

.tb-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 620;
  font-size: 15px;
  letter-spacing: -0.025em;
  flex: none;
}
.tb-logo .logo-mark { width: 26px; height: 26px; border-radius: 8px; }
.tb-logo .logo-mark svg { width: 15px; height: 15px; }

.tb-sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  flex: none;
}

/* model picker trigger */
.model-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 550;
  max-width: 340px;
  transition: border-color 0.2s, background 0.2s;
}
.model-trigger:hover { border-color: var(--faint); background: var(--surface-2); }
.model-trigger .dots { display: flex; gap: -4px; }
.model-trigger .mstack {
  display: flex;
  margin-right: 2px;
}
.model-trigger .mstack i {
  width: 18px; height: 18px;
  border-radius: 6px;
  background: var(--acc-soft);
  color: var(--acc-deep);
  border: 1.5px solid var(--surface);
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700; font-style: normal;
  margin-left: -5px;
}
.model-trigger .mstack i:first-child { margin-left: 0; }
.model-trigger .mtxt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-trigger .chev { width: 14px; height: 14px; color: var(--faint); flex: none; }

.tb-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--muted);
  transition: background 0.18s, color 0.18s;
  position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

.tb-upgrade {
  height: 32px;
  padding: 0 13px;
  font-size: 12.5px;
  border-radius: 99px;
  background: var(--acc);
  color: #fff;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.2s, transform 0.15s;
}
.tb-upgrade:hover { background: var(--acc-deep); }
.tb-upgrade:active { transform: scale(0.97); }

/* ---------------- Work area ---------------- */
.work {
  display: grid;
  grid-template-columns: 296px 1fr;
  min-height: 0;
}

/* ---------------- Rail ---------------- */
.rail {
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rail-tabs {
  display: flex;
  padding: 10px 10px 0;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.rail-tab {
  flex: 1;
  height: 32px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--muted);
  border-radius: 7px 7px 0 0;
  position: relative;
  transition: color 0.2s;
}
.rail-tab:hover { color: var(--ink); }
.rail-tab.on { color: var(--ink); }
.rail-tab.on::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  background: var(--acc);
  border-radius: 2px 2px 0 0;
}

.rail-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.rail-pane { display: none; padding: 12px; }
.rail-pane.on { display: block; }

.search-box {
  position: relative;
  margin-bottom: 10px;
}
.search-box svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--faint);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 31px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.search-box input:focus { border-color: var(--acc-line); background: var(--surface); }

.cat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-bottom: 9px;
  margin-bottom: 4px;
}
.cat-chip {
  flex: none;
  height: 25px;
  padding: 0 10px;
  font-size: 11.5px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: all 0.18s;
  white-space: nowrap;
}
.cat-chip:hover { color: var(--ink); border-color: var(--line-strong); }
.cat-chip.on {
  background: var(--acc-soft);
  border-color: var(--acc-line);
  color: var(--acc-deep);
  font-weight: 600;
}

.p-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 11px;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: background 0.16s, border-color 0.16s;
  margin-bottom: 2px;
}
.p-item:hover { background: var(--surface-2); border-color: var(--line); }
.p-item .pt {
  font-size: 13.2px;
  font-weight: 560;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}
.p-item .pd {
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 2px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-item .badge {
  font-size: 10px;
  font-weight: 500;
  color: var(--acc-deep);
  background: var(--acc-soft);
  border-radius: 4px;
  padding: 0 5px;
  flex: none;
}

.empty-tip {
  font-size: 12.5px;
  color: var(--faint);
  text-align: center;
  padding: 26px 12px;
  line-height: 1.7;
}

/* docs pane */
.drop-zone {
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  padding: 22px 14px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  background: var(--surface-2);
}
.drop-zone:hover, .drop-zone.over {
  border-color: var(--acc);
  background: var(--acc-soft);
}
.drop-zone svg {
  width: 22px; height: 22px;
  margin: 0 auto 8px;
  color: var(--acc-deep);
}
.drop-zone b { font-size: 13px; font-weight: 600; display: block; }
.drop-zone span { font-size: 11.5px; color: var(--faint); display: block; margin-top: 3px; }

.doc-list { margin-top: 12px; display: grid; gap: 6px; }
.doc-item {
  display: grid;
  grid-template-columns: 26px 1fr 22px;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  transition: border-color 0.18s;
}
.doc-item:hover { border-color: var(--line-strong); }
.doc-item .di {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--acc-soft);
  color: var(--acc-deep);
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700;
  font-family: var(--mono);
  text-transform: uppercase;
}
.doc-item .dn {
  font-size: 12.2px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-item .dm { font-size: 10.5px; color: var(--faint); margin-top: 1px; }
.doc-item .dx {
  width: 22px; height: 22px;
  border-radius: 5px;
  display: grid; place-items: center;
  color: var(--faint);
  font-size: 15px;
  line-height: 1;
}
.doc-item .dx:hover { background: var(--bg-alt); color: var(--danger); }

/* history */
.h-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 11px;
  border-radius: 9px;
  transition: background 0.16s;
  border: 1px solid transparent;
}
.h-item:hover { background: var(--surface-2); border-color: var(--line); }
.h-item .ht {
  font-size: 12.8px;
  font-weight: 540;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.h-item .hm {
  font-size: 10.8px;
  color: var(--faint);
  margin-top: 3px;
  display: flex;
  gap: 8px;
}

/* ---------------- Stage ---------------- */
.stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(800px 380px at 85% -10%, var(--acc-soft), transparent 62%),
    var(--bg);
}

.stage-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 22px 8px;
  overscroll-behavior: contain;
}

/* empty state */
.welcome {
  max-width: 760px;
  margin: 40px auto 0;
  animation: rise 0.55s var(--ease);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.welcome h2 {
  font-size: 26px;
  letter-spacing: -0.035em;
  line-height: 1.24;
}
.welcome h2 span { color: var(--acc-deep); }
.welcome .lede {
  margin-top: 9px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-top: 24px;
}
.quick {
  text-align: left;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  transition: all 0.22s var(--ease);
  display: flex;
  gap: 11px;
  align-items: flex-start;
}
.quick:hover {
  border-color: var(--acc-line);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.quick .qi {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--acc-soft);
  color: var(--acc-deep);
  display: grid; place-items: center;
  flex: none;
}
.quick .qi svg { width: 15px; height: 15px; }
.quick b { font-size: 13.2px; font-weight: 580; display: block; letter-spacing: -0.01em; }
.quick span { font-size: 11.8px; color: var(--faint); display: block; margin-top: 2px; line-height: 1.45; }

.welcome .privacy-note {
  margin-top: 26px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 12.2px;
  color: var(--faint);
  line-height: 1.6;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.welcome .privacy-note svg { width: 15px; height: 15px; color: var(--acc); flex: none; margin-top: 1px; }
.welcome .privacy-note b { color: var(--ink-2); }

/* ---------------- Result grid ---------------- */
.ask-echo {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
  animation: rise 0.4s var(--ease);
}
.ask-echo .ring {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--muted);
  display: grid; place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  flex: none;
  font-family: var(--mono);
}
.ask-echo .txt {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 96px;
  overflow: hidden;
  position: relative;
}
.ask-echo .txt.open { max-height: none; }
.ask-echo .more {
  font-size: 11.5px;
  color: var(--acc-deep);
  margin-top: 4px;
}

.cols {
  display: grid;
  gap: 12px;
  align-items: start;
}
.cols[data-n="1"] { grid-template-columns: 1fr; }
.cols[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols[data-n="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.rcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  animation: rise 0.45s var(--ease);
  overflow: hidden;
}
.rcard.err { border-color: rgba(214, 69, 69, 0.4); }

.rc-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  flex: none;
}
.rc-badge {
  width: 19px; height: 19px;
  border-radius: 5px;
  background: var(--acc-soft);
  color: var(--acc-deep);
  display: grid; place-items: center;
  font-size: 9.5px; font-weight: 700;
  flex: none;
}
.rc-name {
  font-size: 12.2px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rc-meta {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--faint);
  font-family: var(--mono);
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
}
.rc-meta .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--faint);
}
.rc-meta.live .dot { background: var(--acc); animation: pulse 1.1s infinite; }
.rc-meta.done .dot { background: var(--acc); }
.rc-meta.bad .dot { background: var(--danger); }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.rc-body {
  padding: 13px 14px 6px;
  font-size: 13.4px;
  line-height: 1.72;
  color: var(--ink-2);
  overflow-wrap: break-word;
  word-break: break-word;
  flex: 1;
}
.rc-body.streaming::after {
  content: "";
  display: inline-block;
  width: 7px; height: 14px;
  background: var(--acc);
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

.rc-foot {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 7px 8px;
  border-top: 1px solid var(--line);
  flex: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.rcard:hover .rc-foot, .rcard.pin .rc-foot { opacity: 1; }
@media (hover: none) { .rc-foot { opacity: 1; } }
.rc-act {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--muted);
  transition: background 0.16s, color 0.16s;
}
.rc-act:hover { background: var(--bg-alt); color: var(--ink); }
.rc-act svg { width: 13px; height: 13px; }
.rc-act.ok { color: var(--acc-deep); }

/* error box */
.err-box {
  padding: 12px 14px;
  font-size: 12.8px;
  line-height: 1.62;
}
.err-box .et {
  color: var(--danger);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.err-box .et svg { width: 14px; height: 14px; flex: none; }
.err-box .eh {
  color: var(--muted);
  background: var(--bg-alt);
  border-radius: 7px;
  padding: 7px 9px;
  margin-top: 7px;
  font-size: 12px;
}
.err-box .eact { margin-top: 9px; }

/* skeleton */
.skel {
  padding: 13px 14px;
  display: grid;
  gap: 7px;
}
.skel i {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--line) 0%, var(--bg-alt) 50%, var(--line) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
.skel i:nth-child(2) { width: 88%; }
.skel i:nth-child(3) { width: 72%; }
.skel i:nth-child(4) { width: 92%; }
.skel i:nth-child(5) { width: 54%; }
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------------- Markdown inside rc-body ---------------- */
.rc-body h2, .rc-body h3, .rc-body h4, .rc-body h5, .rc-body h6 {
  font-size: 14.2px;
  font-weight: 650;
  margin: 13px 0 6px;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.4;
}
.rc-body h2:first-child, .rc-body h3:first-child { margin-top: 0; }
.rc-body p { margin: 0 0 8px; }
.rc-body p:last-child { margin-bottom: 0; }
.rc-body ul, .rc-body ol { margin: 0 0 9px; padding-left: 19px; }
.rc-body li { margin-bottom: 3px; }
.rc-body li::marker { color: var(--faint); }
.rc-body strong { color: var(--ink); font-weight: 640; }
.rc-body code {
  font-family: var(--mono);
  font-size: 11.8px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
  color: var(--ink);
}
.rc-body .md-pre {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 0 0 10px;
  position: relative;
}
.rc-body .md-pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 11.7px;
  line-height: 1.6;
  white-space: pre;
  color: var(--ink-2);
}
.rc-body blockquote {
  margin: 0 0 9px;
  padding-left: 11px;
  border-left: 2px solid var(--acc-line);
  color: var(--muted);
}
.rc-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 13px 0;
}
.rc-body a { color: var(--acc-deep); text-decoration: underline; text-underline-offset: 2px; }
.md-table-wrap { overflow-x: auto; margin: 0 0 10px; }
.rc-body table {
  border-collapse: collapse;
  font-size: 12.2px;
  width: 100%;
  min-width: 240px;
}
.rc-body th, .rc-body td {
  border: 1px solid var(--line);
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
}
.rc-body th {
  background: var(--bg-alt);
  font-weight: 620;
  color: var(--ink);
  white-space: nowrap;
}

/* ---------------- Composer ---------------- */
.composer-wrap {
  flex: none;
  padding: 8px 22px 16px;
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}

.composer {
  max-width: 1080px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 30px -18px rgba(20, 23, 26, 0.28);
  transition: border-color 0.22s, box-shadow 0.22s;
}
.composer:focus-within {
  border-color: var(--acc-line);
  box-shadow: 0 8px 34px -18px var(--acc), 0 0 0 3px var(--acc-soft);
}
.composer.drag { border-color: var(--acc); background: var(--acc-soft); }

.att-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px 10px 0;
}
.att-row:empty { display: none; }
.att {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 6px 0 8px;
  border-radius: 7px;
  background: var(--acc-soft);
  border: 1px solid var(--acc-line);
  font-size: 11.5px;
  color: var(--acc-deep);
  font-weight: 550;
  max-width: 220px;
}
.att span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.att b { font-weight: 500; color: var(--faint); font-size: 10.5px; flex: none; }
.att button {
  width: 15px; height: 15px;
  border-radius: 4px;
  display: grid; place-items: center;
  color: var(--acc-deep);
  font-size: 13px;
  line-height: 1;
  flex: none;
  opacity: 0.6;
}
.att button:hover { opacity: 1; background: var(--acc-line); }

.composer textarea {
  display: block;
  width: 100%;
  border: none;
  background: none;
  outline: none;
  resize: none;
  padding: 12px 14px 6px;
  font-size: 14px;
  line-height: 1.62;
  max-height: 176px;
  min-height: 58px;
  color: var(--ink);
}
.composer textarea::placeholder { color: var(--faint); }

.comp-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 9px;
}
.comp-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  transition: background 0.16s, color 0.16s;
  white-space: nowrap;
}
.comp-btn:hover { background: var(--bg-alt); color: var(--ink); }
.comp-btn svg { width: 15px; height: 15px; }
.comp-btn.on { color: var(--acc-deep); background: var(--acc-soft); }

.comp-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hint-key {
  font-size: 11px;
  color: var(--faint);
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 3px;
}
.hint-key kbd {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 10px;
  font-family: var(--mono);
}

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--acc);
  color: #fff;
  display: grid;
  place-items: center;
  transition: background 0.18s, transform 0.14s, opacity 0.18s;
}
.send-btn:hover { background: var(--acc-deep); }
.send-btn:active { transform: scale(0.94); }
.send-btn svg { width: 17px; height: 17px; }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.send-btn.stop { background: var(--danger); }

/* ---------------- Popover / Model picker ---------------- */
.pop {
  position: fixed;
  z-index: 102;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  min-width: 300px;
  max-height: 70vh;
  overflow-y: auto;
  animation: popIn 0.18s var(--ease);
  transform-origin: top left;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.97) translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.pop-head .ph-t { font-size: 12px; font-weight: 600; color: var(--ink); }
.pop-head .ph-s { font-size: 11px; color: var(--faint); }

.pv-group { margin-bottom: 4px; }
.pv-group-t {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 6px 8px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pv-group-t .nokey {
  font-size: 9.5px;
  color: var(--warn);
  background: rgba(217, 119, 6, 0.1);
  border-radius: 3px;
  padding: 0 4px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}

.mopt {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  border-radius: 8px;
  text-align: left;
  transition: background 0.14s;
}
.mopt:hover { background: var(--surface-2); }
.mopt .box {
  width: 16px; height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  display: grid; place-items: center;
  flex: none;
  transition: all 0.16s;
}
.mopt .box svg { width: 10px; height: 10px; opacity: 0; color: #fff; }
.mopt.on .box { background: var(--acc); border-color: var(--acc); }
.mopt.on .box svg { opacity: 1; }
.mopt .mn { font-size: 13px; font-weight: 540; }
.mopt .mt {
  font-size: 10.5px;
  color: var(--faint);
  background: var(--bg-alt);
  border-radius: 4px;
  padding: 0 5px;
  margin-left: auto;
  flex: none;
}
.mopt .mid { font-size: 10.5px; color: var(--faint); font-family: var(--mono); }

/* ---------------- Drawer ---------------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 13, 0.42);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}
.scrim.on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 520px;
  max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.34s var(--ease);
  box-shadow: -20px 0 60px -30px rgba(0, 0, 0, 0.4);
}
.drawer.on { transform: none; }

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.drawer-head h3 { font-size: 15.5px; letter-spacing: -0.02em; }
.drawer-head .x {
  margin-left: auto;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--muted);
}
.drawer-head .x:hover { background: var(--bg-alt); color: var(--ink); }
.drawer-head .x svg { width: 16px; height: 16px; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 30px;
}

.dsec { margin-bottom: 26px; }
.dsec-t {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.dsec-t::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.dsec-t .opt { font-size: 10px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--faint); }

.kv {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
.kv:hover { border-color: var(--line-strong); }
.kv-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}
.kv-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--line-strong);
}
.kv-dot.set { background: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.kv-name { font-size: 12.8px; font-weight: 600; }
.kv-note {
  font-size: 10.8px;
  color: var(--faint);
  margin-left: auto;
  text-align: right;
  max-width: 58%;
  line-height: 1.4;
}
.kv-row { display: flex; gap: 6px; }
.kv input[type="text"],
.kv input[type="password"] {
  flex: 1;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 12.5px;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}
.kv input:focus { border-color: var(--acc-line); background: var(--surface); }
.kv-btn {
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 550;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  white-space: nowrap;
  transition: all 0.18s;
  flex: none;
}
.kv-btn:hover { color: var(--ink); border-color: var(--faint); }
.kv-btn.go { background: var(--acc-soft); border-color: var(--acc-line); color: var(--acc-deep); }
.kv-btn.testing { opacity: 0.6; pointer-events: none; }
.kv-tip { font-size: 11px; color: var(--faint); margin-top: 6px; line-height: 1.5; }
.kv-tip a { color: var(--acc-deep); text-decoration: underline; text-underline-offset: 2px; }
.kv-tip.ok { color: var(--acc-deep); }
.kv-tip.bad { color: var(--danger); }

.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  margin-bottom: 6px;
  color: var(--ink-2);
}
.field .fh { font-weight: 400; color: var(--faint); font-size: 11.5px; margin-left: 4px; }
.field input[type="text"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.field textarea { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--acc-line); background: var(--surface); }

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.range-row input[type="range"] {
  flex: 1;
  accent-color: var(--acc);
  height: 4px;
}
.range-val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  min-width: 34px;
  text-align: right;
}

.act-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.act-grid .btn { width: 100%; height: 38px; font-size: 12.5px; }
.btn-danger {
  border-color: rgba(214, 69, 69, 0.35);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(214, 69, 69, 0.07); }

/* ---------------- Toast ---------------- */
.toast-host {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: #14171a;
  color: #f2f5f3;
  font-size: 12.8px;
  padding: 9px 16px;
  border-radius: 99px;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(-10px) scale(0.96);
  transition: all 0.3s var(--ease);
  max-width: 82vw;
  text-align: center;
}
[data-theme="dark"] .toast { background: #f2f5f3; color: #14171a; }
.toast.on { opacity: 1; transform: none; }
.toast.err { background: #a83232; color: #fff; }

/* ---------------- Modal (授权) ---------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
  padding: 20px;
}
.modal.on { display: grid; }
.modal .scrim-in {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 13, 0.5);
  backdrop-filter: blur(3px);
}
.modal-box {
  position: relative;
  width: min(464px, calc(100vw - 28px));
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.25s var(--ease);
  text-align: center;
}
.modal-box h3 { font-size: 17px; margin-bottom: 6px; }
.modal-box p { font-size: 13px; color: var(--muted); line-height: 1.6; }
.modal-box .qr {
  width: 176px; height: 176px;
  margin: 18px auto 12px;
  border-radius: 12px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  color: var(--faint);
  text-align: center;
  padding: 16px;
  line-height: 1.6;
}
.modal-box .qr img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }
.modal-box .qr.has-img {
  border-style: solid;
  border-color: var(--line);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.modal-box .price-line {
  font-size: 22px;
  font-weight: 660;
  letter-spacing: -0.03em;
  margin: 4px 0 2px;
}
.modal-box .price-line s { font-size: 13px; color: var(--faint); font-weight: 400; margin-left: 6px; }
.modal-box .field { text-align: left; margin-top: 14px; }
.modal-box .acts { display: flex; gap: 8px; margin-top: 14px; }
.modal-box .acts .btn { flex: 1; }
.modal-box .fine { font-size: 11px; color: var(--faint); margin-top: 12px; line-height: 1.5; }

/* ---------------- Mobile ---------------- */
.rail-toggle { display: none; }

@media (max-width: 1080px) {
  .cols[data-n="3"], .cols[data-n="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .work { grid-template-columns: 1fr; }
  .rail {
    position: fixed;
    top: 56px; bottom: 0; left: 0;
    width: 300px;
    z-index: 100;
    transform: translateX(-102%);
    transition: transform 0.3s var(--ease);
    box-shadow: 10px 0 40px -20px rgba(0, 0, 0, 0.3);
    border-right: 1px solid var(--line);
  }
  .rail.on { transform: none; }
  .rail-toggle { display: grid; }
  .tb-logo small { display: none; }
  .tb-logo span.lg-txt { display: none; }
  .model-trigger { max-width: 160px; }
  .model-trigger .mtxt { max-width: 92px; }
  .tb-upgrade { display: none; }
  .cols[data-n="2"], .cols[data-n="3"], .cols[data-n="4"] { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .stage-scroll { padding: 16px 14px 6px; }
  .composer-wrap { padding: 6px 12px 12px; }
  .drawer { width: 100%; }
  .welcome { margin-top: 18px; }
  .welcome h2 { font-size: 22px; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .tb-sep { display: none; }
  .model-trigger { max-width: 168px; padding: 0 9px; }
  .model-trigger .mtxt { max-width: 96px; font-size: 12px; }
  .hint-key { display: none; }
  .quick { padding: 12px 13px; }
  .welcome h2 { font-size: 21px; }
  .welcome .lede { font-size: 13px; }
}

/* ---------------- 空状态：最近记录 ---------------- */
#recentWrap { margin-top: 26px; }
.recent-t {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 9px;
}
.recent-row { display: grid; gap: 6px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.2s, transform 0.25s var(--ease), background 0.2s;
}
.recent-item:hover {
  border-color: var(--acc-line);
  background: var(--surface-2);
  transform: translateX(3px);
}
.recent-item .ri-t {
  font-size: 12.6px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.recent-item .ri-m {
  font-size: 10.8px;
  color: var(--faint);
  font-family: var(--mono);
  flex: none;
}

/* 侧栏条目轻位移 */
.p-item { transition: background 0.16s, border-color 0.16s, transform 0.24s var(--ease); }
.p-item:hover { transform: translateX(3px); }

/* ---------------- 收款码 ---------------- */
.pay-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 12px;
}
.pay-item { margin: 0; min-width: 0; }
.modal-box .pay-row .qr {
  width: 100%;
  min-width: 0;
  height: auto;
  aspect-ratio: 1 / 1;
  margin: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-style: solid;
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  cursor: zoom-in;
  transition: border-color 0.2s, transform 0.26s var(--ease), box-shadow 0.26s;
}
.modal-box .pay-row .qr:hover {
  border-color: var(--acc-line);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -12px rgba(20, 23, 26, 0.3);
}
.modal-box .pay-row .qr img {
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
}
.pay-item figcaption {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.pdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}
.pdot.wx { background: #1aad19; }
.pdot.ali { background: #1677ff; }
.pay-tip {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 4px;
}
.pay-tip b { color: var(--ink-2); font-weight: 600; }

/* ---------------- 大图查看 ---------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: none;
  place-items: center;
  padding: 26px;
  background: rgba(8, 11, 10, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: zoom-out;
  animation: lbIn 0.24s var(--ease);
}
.lightbox.on { display: grid; }
@keyframes lbIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.lightbox img {
  width: min(76vw, 76vh);
  height: auto;
  max-width: 100%;
  border-radius: 16px;
  background: #fff;
  padding: 16px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.7);
  animation: lbZoom 0.28s var(--ease);
}
@keyframes lbZoom {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (max-width: 560px) {
  .modal { padding: 14px; }
  .modal-box { padding: 22px 18px; }
  .pay-row { gap: 10px; }
}

/* ---------------- 付款后联系 ---------------- */
.contact-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 13px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  margin-top: 4px;
  text-align: left;
}
.modal-box .contact-card .qr.mini {
  width: 78px;
  height: 78px;
  flex: none;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  display: grid;
  place-items: center;
  cursor: zoom-in;
  transition: border-color 0.2s, transform 0.24s var(--ease);
}
.modal-box .contact-card .qr.mini:hover {
  border-color: var(--acc-line);
  transform: scale(1.04);
}
.contact-card .qr.mini img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.contact-txt { min-width: 0; }
.contact-txt b {
  display: block;
  font-size: 12.8px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  margin-bottom: 3px;
}
.contact-txt b span { font-weight: 500; color: var(--muted); }
.contact-txt > span {
  display: block;
  font-size: 11.6px;
  color: var(--muted);
  line-height: 1.55;
}

/* 弹窗内容可能超屏，允许内部滚动 */
.modal-box {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ---------------- 免费额度提示 ---------------- */
.quota-tip {
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 0 2px;
}
.quota-tip.low { color: var(--warn); font-weight: 550; }
.quota-tip.out { color: var(--danger); font-weight: 600; }
.quota-tip.pro { color: var(--acc-deep); font-weight: 600; }

/* ---------------- 反馈入口 ---------------- */
.fb-card {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  transition: border-color 0.2s, background 0.2s, transform 0.24s var(--ease);
}
.fb-card:hover {
  border-color: var(--acc-line);
  background: var(--acc-soft);
  transform: translateY(-1px);
}
.fb-ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--acc-soft);
  color: var(--acc-deep);
  display: grid;
  place-items: center;
  flex: none;
}
.fb-ico svg { width: 16px; height: 16px; }
.fb-txt { flex: 1; min-width: 0; }
.fb-txt b { display: block; font-size: 12.8px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.fb-txt span { display: block; font-size: 11.4px; color: var(--faint); margin-top: 2px; }
.fb-arrow { width: 15px; height: 15px; color: var(--faint); flex: none; transition: transform 0.2s; }
.fb-card:hover .fb-arrow { transform: translateX(2px); color: var(--acc-deep); }

@media (max-width: 560px) {
  .quota-tip { font-size: 10.5px; }
}
