/* ==========================================================================
   北棱改文站 · 应用外壳
   左侧 248px 纸墨侧栏（品牌 / 导航 / 生成记录）+ 主工作区
   改写台 = 侧栏 + 中栏输入编辑台 + 右栏流式输出区
   ========================================================================== */

body.page-rewrite {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(980px 520px at 100% -12%, rgba(255, 251, 242, .92), rgba(255, 251, 242, 0) 62%),
    #f4efe5;
}
body.page-rewrite .app-shell { height: 100vh; height: 100dvh; }

/* 隐藏的 SVG symbol 容器：默认 inline 会在 body 流里撑出行盒，把整页顶下 ~26px */
.brand-symbols {
  position: absolute;
  display: block;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ------------------------------------------------------------------ 侧栏 */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  overflow-y: auto;
  background: linear-gradient(180deg, #f9f4eb 0%, #f2ebde 100%);
  border-right: 1px solid var(--line);
  z-index: 30;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 8px 22px;
  color: var(--ink);
  text-decoration: none;
}
.side-brand .seal { flex: 0 0 32px; width: 32px; height: 32px; font-size: 18px; border-radius: 8px; }
.side-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.side-brand-text strong {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .10em;
}
.side-brand-text small {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .12em;
  color: var(--faint);
}

.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: background .15s, color .15s;
}
.side-link svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .82;
}
.side-link:hover { background: rgba(255, 255, 255, .58); color: var(--ink); }
.side-link.is-active {
  background: rgba(178, 58, 43, .085);
  color: var(--accent-deep);
  font-weight: 600;
}
.side-link.is-active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 9px;
  bottom: 9px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.side-group { margin-top: 22px; }
.side-label {
  padding: 0 10px;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .14em;
  color: var(--faint);
  text-transform: uppercase;
}
.side-spacer { flex: 1; min-height: 20px; }
.side-records-group + .side-spacer { flex: 0 0 12px; min-height: 12px; }

.side-note-card {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .44);
}
.side-note-card .side-label { padding: 0; margin-bottom: 6px; }
.side-note {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--muted);
}
.side-version {
  margin: 7px 0 0;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .06em;
  color: var(--faint);
}

.side-legal {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 0;
  font-size: 10.5px;
  color: var(--faint);
}
.side-legal a { color: var(--faint); text-decoration: none; }
.side-legal a:hover { color: var(--accent); }

.side-user {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.side-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fffaf2;
  font-family: var(--serif);
  font-size: 12px;
}
.side-user-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--ink-2);
}
.side-logout {
  border: 0;
  padding: 3px 4px;
  background: none;
  color: var(--faint);
  font-size: 10.5px;
  cursor: pointer;
  border-radius: 5px;
  text-decoration: none;
}
.side-logout:hover { color: var(--accent); background: rgba(178, 58, 43, .06); }

/* ------------------------------------------------------------------ 生成记录（侧栏） */

.side-records-group { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-records-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  margin-bottom: 8px;
}
.side-records-head .side-label { padding: 0; margin: 0; }
.side-records-count {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .5);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.4;
}
.side-records-count:empty { display: none; }

.history-empty {
  display: none;
  padding: 9px 10px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.6;
}
.history-empty.is-visible { display: block; }

.side-records {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  padding-right: 2px;
}

.side-records .history-item {
  position: relative;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 9px;
  margin: 0;
  min-width: 0;
  transition: background .15s, border-color .15s;
}
.side-records .history-item:hover { background: rgba(255, 255, 255, .58); border-color: var(--line); }
.side-records .history-item.is-current {
  background: rgba(178, 58, 43, .085);
  border-color: #ecd4c9;
}
.side-records .history-title {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-records .history-title:hover { color: var(--accent); }
.side-records .history-item.is-current .history-title { color: var(--accent-deep); font-weight: 600; }
.side-records .history-meta {
  margin-top: 2px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-records .history-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-top: 5px;
  opacity: 0;
  transition: opacity .15s;
}
.side-records .history-item:hover .history-actions,
.side-records .history-item.is-current .history-actions { opacity: 1; }
.side-records .history-actions .btn {
  height: auto;
  padding: 1px 6px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0;
}
.side-records .history-actions .btn:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, .85);
}
@media (hover: none) {
  .side-records .history-actions { opacity: 1; }
}

/* ------------------------------------------------------------------ 主工作区 / 顶栏 */

.app-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.page-rewrite .app-main { height: 100vh; height: 100dvh; }

.app-topbar {
  flex: 0 0 62px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 25;
  border-bottom: 1px solid rgba(227, 216, 199, .86);
  background: rgba(249, 245, 237, .82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-mobile-brand { display: none; text-decoration: none; }
.topbar-mobile-brand .seal { width: 28px; height: 28px; font-size: 15px; border-radius: 7px; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--faint);
  white-space: nowrap;
  min-width: 0;
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumb-sep { color: var(--line-2); }
.crumb-current { color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-user {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--muted);
}
.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .46);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}
.topbar-status.is-warn { color: var(--warn); }

.live-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(63, 107, 88, .12);
  display: inline-block;
}
.live-dot.is-warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(135, 90, 34, .12); }

.app-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 28px 26px;
  overflow-x: hidden;
  overflow-y: auto;   /* 兜底：极窄/极矮窗口下页面仍可滚动，不裁切 */
}
body.page-keys .app-content,
body.page-tutorial .app-content { overflow-y: auto; }
body.page-tutorial .app-content > * {
  width: 100%;
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
}
/* 隐私弹层打开时抬升主内容层：全屏遮罩要盖住侧栏 / 顶栏，而不是只盖正文区 */
body.page-keys:has(#consentGate) .app-content { z-index: 200; }

/* 密钥页：只收窄单列内容；全屏弹层（consent-gate）和 dialog 不能被这条宽高规则影响 */
body.page-keys .app-content > .keys-wrap,
body.page-keys .app-content > .page-foot {
  width: 100%;
  max-width: 1020px;
  margin-left: auto;
  margin-right: auto;
}

/* ------------------------------------------------------------------ 改写台 */

.ws-workspace { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.ws-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}
.ws-heading { min-width: 0; }
.ws-heading h1 {
  margin: 4px 0 6px;
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink);
}
.ws-sub {
  margin: 0;
  max-width: 720px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}
.ws-controls { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; padding-bottom: 3px; }

.model-picker { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.model-picker > span { font-size: 11px; color: var(--faint); white-space: nowrap; }
.model-picker select {
  height: 34px;
  max-width: 220px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 253, 248, .72);
  color: var(--ink-2);
  font: 12px/1 var(--sans);
  cursor: pointer;
  text-overflow: ellipsis;
}
.model-picker select:hover:not(:disabled) { border-color: var(--accent); }
.model-picker select:disabled { opacity: .55; cursor: default; }

.ws-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .46);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ws-status::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border-radius: 50%;
  background: var(--line-2);
}
.ws-status.is-active { color: var(--accent-deep); border-color: #ecd4c9; background: var(--accent-soft); }
.ws-status.is-active::before { background: var(--accent); animation: ws-pulse 1.35s ease-in-out infinite; }
.ws-status.is-error { color: var(--danger); border-color: #e6c6b9; background: var(--danger-soft); }
.ws-status.is-error::before { background: var(--danger); }

.ws-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr);
  gap: 16px;
}

.ws-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 252, 246, .94), rgba(249, 244, 234, .9));
  box-shadow: 0 18px 44px -36px rgba(60, 45, 28, .48);
}
.ws-editor { transition: border-color .2s, box-shadow .2s; }
.ws-editor:focus-within {
  border-color: #c9b49d;
  box-shadow: 0 0 0 3px rgba(178, 58, 43, .07), 0 18px 44px -36px rgba(60, 45, 28, .48);
}

.ws-panel-head {
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px dashed var(--line);
  background: rgba(252, 248, 241, .62);
}
.ws-panel-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--ink);
}
.ws-index {
  padding: 2px 5px;
  border: 1px solid #ecd4c9;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .08em;
}
.ws-panel-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  white-space: nowrap;
}
.ws-output-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}
.meta-sep { margin: 0 3px; color: var(--line-2); }
.char-count.is-over { color: var(--danger); font-weight: 600; }

.ws-panel-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }

.ws-textarea {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 0;
  padding: 20px 22px 22px 24px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.95;
  caret-color: var(--accent);
}
.ws-textarea::placeholder { color: #b3a591; }

.ws-panel-foot {
  flex: 0 0 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  background: rgba(248, 242, 232, .6);
  flex-wrap: wrap;
}
.ws-foot-left,
.ws-foot-right { display: flex; align-items: center; gap: 10px; }
.ws-foot-note { font-size: 10.5px; color: var(--faint); }
.ws-panel-foot .btn { height: 34px; padding: 0 15px; font-size: 12.5px; }
.ws-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.ws-check input { width: 13px; height: 13px; accent-color: var(--accent); cursor: pointer; }

.kbd {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, .4);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  white-space: nowrap;
}

/* 输出区 */

.output-scroll {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  padding: 18px 20px 22px;
}

.output-empty {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--faint);
}
.output-empty p { margin: 0; font-size: 12.5px; line-height: 1.8; }
.output-empty .muted { color: var(--faint); }
.ws-empty-seal {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #c14a37, #9a2d20);
  color: #fff8ef;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1;
  transform: rotate(-3deg);
  opacity: .86;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .22),
    0 10px 22px -14px rgba(120, 30, 20, .8);
}
.ws-empty-seal .brand-mark { width: 68%; height: 68%; display: block; }

.reasoning-block {
  margin: 0 0 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 3px solid #cdbfa9;
  border-radius: 10px;
  background: #f7f3ea;
}
.reasoning-head {
  padding: 7px 13px;
  border-bottom: 1px dashed var(--line);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.reasoning-body {
  max-height: 38vh;
  overflow-y: auto;
  padding: 12px 14px;
  color: #8d877c;
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}

.content-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.content-head {
  padding: 8px 14px;
  border-bottom: 1px dashed var(--line);
  color: var(--accent-deep);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: rgba(242, 224, 216, .32);
  border-radius: 12px 12px 0 0;
}
.content-body {
  padding: 18px 20px 22px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.95;
  white-space: pre-wrap;
  word-break: break-word;
}
.content-body:empty::before {
  content: "正文即将出现…";
  color: var(--faint);
  font-family: var(--sans);
  font-size: 12.5px;
}

.ws-privacy-hint { margin: 10px 0 0; flex: 0 0 auto; }
.ws-workspace > .notice-warn { flex: 0 0 auto; margin: 10px 0 0; }

/* ------------------------------------------------------------------ 密钥页 */

/* 单列流式布局：一屏一条主线，避免左右双栏互相抢注意力 */
.keys-wrap { max-width: 1020px; margin: 0 auto; }

.api-hero { margin-bottom: 22px; flex: 0 0 auto; }
.api-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.api-hero h1 {
  margin: 0;
  font-size: clamp(34px, 3.8vw, 44px);
  letter-spacing: .01em;
}
.api-hero .hero-sub {
  max-width: 760px;
  margin: 10px 0 0;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--muted);
}

.flow-card { padding: 22px 24px 20px; margin-bottom: 16px; }

.flow-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}
.flow-num {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--paper-2);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--accent-deep);
}
.flow-head-text { flex: 1 1 auto; min-width: 0; }
.flow-head-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.flow-head-row h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: .04em;
}
.flow-head-text > p {
  max-width: 640px;
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.8;
  color: var(--faint);
}

/* 两个按键切换接入方式 */
.seg-tabs {
  display: inline-flex;
  gap: 3px;
  margin-bottom: 18px;
  padding: 3px;
  border: 1px solid rgba(178, 58, 43, .24);
  border-radius: 10px;
  background: var(--accent-soft);
}
.seg-tab {
  height: 33px;
  padding: 0 20px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--accent-deep);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.seg-tab:hover { color: var(--accent-deep); background: rgba(178, 58, 43, .10); }
.seg-tab.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(146, 44, 31, .35), 0 8px 16px -12px rgba(146, 44, 31, .9);
}
.seg-tab.is-active:hover { color: var(--accent-ink); background: var(--accent); }
.seg-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tab-pane { animation: keys-fade .18s ease-out; }
@keyframes keys-fade {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.sub-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 2px 0 8px;
}
.sub-head h3 {
  margin: 0;
  font-size: 16.5px;
  letter-spacing: .04em;
}
.sub-head-note {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--faint);
}

.keys-wrap p code,
.keys-wrap li code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent-deep);
}

.key-note {
  margin: 14px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--line-2);
  border-radius: 8px;
  background: rgba(246, 240, 229, .72);
  font-size: 12px;
  line-height: 1.85;
  color: var(--muted);
}

.cloud-key-form { margin-top: 6px; }

.pane-divider {
  height: 1px;
  margin: 20px 0 16px;
  background: var(--line);
}

.self-steps {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  counter-reset: self-step;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.self-steps li {
  position: relative;
  padding-left: 32px;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-2);
}
.self-steps li::before {
  counter-increment: self-step;
  content: counter(self-step, decimal-leading-zero);
  position: absolute;
  top: 3px;
  left: 0;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
}
.self-steps a {
  color: var(--accent-deep);
  text-decoration: none;
  border-bottom: 1px solid rgba(178, 58, 43, .3);
}
.self-steps a:hover { border-bottom-color: var(--accent); }

/* ---------------------------------------------- 密钥页：接入地址 / 裸 URL 提示词 */

.url-pair {
  display: grid;
  gap: 12px;
}
.url-item {
  padding: 12px 14px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
}
.url-item-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.url-item-head strong {
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink);
}
.url-badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--paper);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
}
.url-badge-accent {
  border-color: rgba(178, 58, 43, .35);
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.url-badge-core {
  border-color: rgba(135, 90, 34, .32);
  background: var(--warn-soft);
  color: var(--warn);
}
.url-item .kv-row { padding: 0; border-bottom: 0; }
.url-item .hint { margin: 8px 0 0; }

.core-note {
  margin-top: 12px;
  padding: 13px 16px 12px;
  border: 1px solid rgba(135, 90, 34, .30);
  border-left: 3px solid #c99a3f;
  border-radius: 10px;
  background: linear-gradient(180deg, #fcf4e1 0%, #f7ecd3 100%);
}
.core-note-title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--warn);
}
.core-note-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.9;
  color: var(--ink-2);
}
.core-note-list li + li { margin-top: 2px; }
.core-note strong { color: var(--warn); }
.core-note code {
  padding: 1px 5px;
  border: 1px solid #e6d6b2;
  border-radius: 4px;
  background: #fffaf0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--warn);
}

.raw-prompt { margin-top: 18px; }
.raw-callout {
  padding: 13px 16px 12px;
  border: 1px solid rgba(178, 58, 43, .38);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: linear-gradient(180deg, #fcefe9 0%, #f7e5dd 100%);
}
.raw-callout-title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--accent-deep);
}
.raw-callout p:last-child {
  margin: 0;
  font-size: 12px;
  line-height: 1.85;
  color: var(--ink-2);
}
.raw-callout strong { color: var(--accent-deep); }
.raw-callout code,
.raw-steps code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent-deep);
}
.raw-steps {
  margin: 12px 0 0;
  padding-left: 20px;
  font-size: 12.5px;
  line-height: 1.95;
  color: var(--ink-2);
}
.raw-steps li + li { margin-top: 2px; }
.raw-example {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  overflow: hidden;
}
.raw-example-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.6;
}
.raw-example pre,
.raw-instr pre {
  margin: 0;
  padding: 12px 14px;
  max-height: 300px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.95;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.raw-instr {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
  overflow: hidden;
}
.raw-instr summary {
  padding: 10px 14px;
  cursor: pointer;
  color: var(--accent-deep);
  font-size: 12.5px;
  letter-spacing: .02em;
}
.raw-instr summary::marker { color: var(--accent); }
.raw-instr pre {
  border-top: 1px solid var(--line);
  background: var(--paper);
  max-height: 340px;
}
.raw-instr .btn { margin: 0 14px 14px; }

@media (max-width: 640px) {
  .raw-example-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .raw-example-head .btn { width: 100%; }
  .raw-callout { padding: 11px 13px 10px; }
}

.page-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: .03em;
  color: var(--faint);
}
.page-foot p { margin: 0; }

/* ------------------------------------------------------------------ 移动端菜单 */

.topbar-menu,
.sidebar-close,
.mobile-overlay { display: none; }

.topbar-menu {
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .45);
  color: var(--ink-2);
  cursor: pointer;
  flex: 0 0 34px;
}
.topbar-menu svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

.sidebar-close {
  position: absolute;
  top: 12px;
  right: 10px;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, .5);
  color: var(--ink-2);
  cursor: pointer;
  z-index: 2;
}
.sidebar-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(33, 29, 23, .38);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}
body.menu-open { overflow: hidden; }

/* ------------------------------------------------------------------ 动画 */

@keyframes ws-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(178, 58, 43, .12); }
  50% { box-shadow: 0 0 0 5px rgba(178, 58, 43, .04); }
}
@keyframes ws-caret { 50% { opacity: 0; } }
@keyframes ws-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------ 响应式 */

@media (max-width: 1240px) {
  .app-shell { grid-template-columns: 232px minmax(0, 1fr); }
  .app-content { padding: 20px 22px 22px; }
  .ws-heading h1 { font-size: 27px; }
}

@media (max-width: 1080px) {
  .ws-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(300px, 1fr) minmax(300px, 1.1fr); }
  .ws-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .ws-controls { padding-bottom: 0; }
  .ws-workspace { overflow-y: auto; }
  body.page-rewrite { height: auto; overflow: auto; }
  body.page-rewrite .app-shell,
  body.page-rewrite .app-main { height: auto; min-height: 100dvh; }
  .app-content { overflow: visible; }
  .ws-workspace { min-height: calc(100dvh - 62px); }
  .ws-panel { min-height: 320px; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    display: flex;
    visibility: hidden;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 320px);
    height: 100dvh;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    transform: translateX(-100%);
    transition: transform .22s ease, visibility .22s;
    z-index: 70;
    box-shadow: 24px 0 48px -34px rgba(33, 29, 23, .55);
  }
  .sidebar.is-open { transform: translateX(0); transition: transform .22s ease; visibility: visible; }
  .sidebar .side-brand { padding-right: 36px; }
  .sidebar-close { display: grid; }
  .topbar-menu { display: inline-flex; }
  .mobile-overlay { display: block; }
  .crumbs { display: none; }
  .app-topbar { padding: 0 18px; }
  .topbar-mobile-brand { display: inline-flex; }
  .app-content { padding: 18px; }
  .ws-heading h1 { font-size: 25px; }
  .flow-card { padding: 20px 20px 18px; }
}

@media (max-width: 640px) {
  .app-content { padding: 14px; }
  .app-topbar { height: 56px; flex-basis: 56px; padding: 0 14px; }
  .topbar-user { display: none; }
  .topbar-status { display: none; }
  .ws-heading h1 { font-size: 23px; }
  .ws-sub { font-size: 12px; }
  .model-picker > span { display: none; }
  .model-picker select { max-width: 148px; height: 32px; font-size: 11.5px; }
  .ws-controls { width: 100%; justify-content: space-between; }
  .ws-panel-foot { flex-basis: auto; padding: 9px 13px; row-gap: 8px; }
  .ws-panel-foot .kbd { display: none; }
  .ws-panel-foot .btn { height: 34px; }
  .ws-panel-head { padding: 0 14px; }
  .ws-output-tools > span { display: none; }
  .ws-textarea { padding: 16px 16px 18px; font-size: 15.5px; }
  .output-scroll { padding: 14px 16px 18px; }
  .content-body { padding: 15px 16px 18px; font-size: 15.5px; }
  .ws-foot-note { display: none; }
  .flow-card { padding: 18px 16px 16px; }
  .flow-head { gap: 10px; }
  .flow-num { flex-basis: 26px; width: 26px; height: 26px; font-size: 12px; }
  .flow-head-row h2 { font-size: 18px; }
  .seg-tabs { display: flex; width: 100%; }
  .seg-tab { flex: 1 1 0; padding: 0 8px; }
  .kv-row .kv-label { flex-basis: 100%; }
  .kv-row .btn-sm { flex: 1 1 100%; }
  .api-hero h1 { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
  }
}
