/*
 * 模块价值：用紧凑、稳定的外壳把主要空间留给访谈、Copilot 和独立画布。
 * 职责：拥有页头、项目条、页面标题、目录弹窗、单窗口阻断提示和断点重排；保留既有品牌与导航顺序。
 * 输入：页面语义类名、浏览器全屏画布及弹窗状态；输出：桌面到 320px、长项目名、放大文字及阻断状态的外壳布局。
 * 依赖：tokens.css 的语义颜色和四像素间距；无业务、网络或存储副作用。
 * 限制：窄屏按原 DOM 顺序换行，不用隐藏溢出来掩盖内容；画布内部二维空间由画布模块处理。
 */
.workbench { min-height: 100dvh; display: flex; flex-direction: column; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 50; padding: 12px; background: var(--surface); }
.skip-link:focus { top: 12px; }
.app-header { min-height: 60px; display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 16px; align-items: center; padding: 8px var(--page-gutter); background: var(--surface); border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 1.12rem; color: var(--ink); text-decoration: none; }
.brand > span:last-child { overflow-wrap: anywhere; }
.brand strong { font-size: .86rem; color: var(--muted); font-weight: 550; margin-left: 6px; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; flex: none; color: #14212b; background: transparent; }
[data-theme="dark"] .brand-mark { color: #f5f3ee; }
.brand-mark svg { display: block; width: 100%; height: 100%; }
.core-nav { display: flex; gap: 4px; min-width: 0; }
.core-nav a { min-height: 44px; display: flex; align-items: center; justify-content: center; padding: 8px 16px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .96rem; text-align: center; line-height: 1.5; }
.core-nav a:hover { background: var(--paper); color: var(--ink); }
/* 当前页同时使用字重和下划线；移除色彩后仍能识别导航状态。 */
.core-nav a[aria-current=page] { background: var(--soft); color: var(--accent); font-weight: 650; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
.header-options { display: flex; align-items: center; gap: 2px; justify-content: flex-end; flex-wrap: wrap; min-width: 0; }
/* 双选项保持小巧：背景内衬与真实点击区分离，触屏增大目标时不把胶囊拉高。
   选中态仍有字重和下划线；不裁切原生按钮焦点，也不改变偏好命令。 */
.ui-preferences { display: flex; align-items: center; gap: 4px; }
.preference-switch { display: flex; position: relative; padding: 0; border: 0; background: transparent; }
.preference-switch::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 32px; transform: translateY(-50%); border: 1px solid var(--line); border-radius: 7px; background: var(--paper); pointer-events: none; }
.preference-switch button { position: relative; isolation: isolate; min-width: 32px; min-height: 32px; padding: 0 4px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: .75rem; line-height: 1.25; white-space: nowrap; }
.preference-switch button::before { content: ""; position: absolute; z-index: -1; top: 50%; left: 2px; right: 2px; height: 28px; transform: translateY(-50%); border-radius: 5px; pointer-events: none; }
.preference-switch button:hover { color: var(--ink); background: transparent; }
.preference-switch button:hover::before { background: var(--surface); }
.preference-switch button[aria-pressed=true] { color: var(--accent); background: transparent; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.preference-switch button[aria-pressed=true]::before { background: var(--soft); }
/* 粗指针与窄屏保留44px真实目标；可见胶囊仍高32px，不把顶部做成大按钮。 */
@media (pointer:coarse), (max-width:720px) {
  .preference-switch button { min-width: 44px; min-height: 44px; padding-inline: 6px; }
}
.project-strip { padding: 6px var(--page-gutter); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 12px; font-size: .83rem; background: var(--surface); }
.project-strip > span:first-child { flex: 1 1 18rem; min-width: 0; overflow-wrap: anywhere; line-height: 1.6; }
.project-strip strong { font-weight: 600; }
.project-description { color: var(--muted); margin-left: 12px; }
.prototype-label { color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
.workspace { flex: 1; min-width: 0; }
.workspace:focus { outline: none; }
.app-footer { padding: 8px var(--page-gutter); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; background: var(--surface); font-size: .76rem; color: var(--muted); flex: none; }
.app-footer > span { min-width: 0; overflow-wrap: anywhere; }
.page-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.page-heading p { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.interview-page,.copilot-page { padding: 16px var(--page-gutter) 24px; max-width: 1700px; margin: auto; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: min(560px,calc(100vw - 30px)); padding: 12px 18px; border-radius: 10px; color: var(--surface); background: var(--ink); font-size: .87rem; line-height: 1.7; z-index: 30; box-shadow: 0 9px 24px #10241922; overflow-wrap: anywhere; }
.loading-copy { padding: 24px; color: var(--muted); }
/* 门禁提示追加在body末尾，必须独立覆盖视口，不能被整屏工作台推到屏幕下方。
 * 上下自动外边距在有空间时居中；矮屏或放大文字时归零，内容仍可从顶部滚动读取。
 * 实色背景隔离已冻结的加载外壳；输入阻断、Web Lock及显式重试仍由单窗口模块负责。 */
#fde-single-window-notice {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  overflow: auto;
  margin: 0;
  padding: 32px 24px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
}
#fde-single-window-notice > h2 {
  flex: none;
  max-width: 32rem;
  margin: auto 0 0;
  font-size: 1.3rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
#fde-single-window-notice > p {
  flex: none;
  max-width: 32rem;
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}
#fde-single-window-notice > .button {
  flex: none;
  min-width: 112px;
  margin: 8px 0 auto;
}
.changes { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 20px; padding: 16px var(--page-gutter); background: var(--soft); border-bottom: 1px solid var(--line); }
.changes h2 { font-size: 1.08rem; margin-bottom: 8px; }
.changes h3 { margin-bottom: 6px; }
.changes p,.changes li { font-size: .82rem; line-height: 1.8; }
.changes ul { margin: 0; padding-left: 18px; }
.changes-footer { display: flex; justify-content: flex-end; gap: 6px; padding: 0 var(--page-gutter) 12px; background: var(--soft); }
.canvas-fullscreen .project-strip,.canvas-fullscreen .app-footer,.canvas-fullscreen .header-options,.canvas-fullscreen .brand { display: none; }
.canvas-fullscreen .app-header { min-height: 54px; padding: 4px 20px; display: flex; justify-content: center; }
@media (max-width:1100px) {
  .app-header { gap: 8px; grid-template-columns: auto 1fr auto; }
  .core-nav { justify-content: center; }
  .core-nav a { padding: 8px 12px; }
  .implementation-link { display: none; }
  .project-description { display: none; }
}
/* 两排导航让窄屏和放大文字自然换行，固定高度不会裁掉中文、项目名或操作。 */
@media (max-width:720px) {
  .app-header { display: flex; flex-wrap: wrap; padding: 6px 16px 0; gap: 4px 8px; }
  .brand { font-size: 1rem; flex: 1 1 auto; }
  .brand-mark { width: 30px; height: 30px; font-size: 1.4rem; }
  .header-options { margin-left: auto; }
  .ui-preferences { gap: 4px; }
  .preference-switch button { padding-inline: 6px; }
  .header-options .quiet-button { font-size: .8rem; padding: 6px 8px; }
  .core-nav { width: 100%; order: 3; justify-content: stretch; border-top: 1px solid var(--line); padding: 4px 0; gap: 4px; }
  .core-nav a { flex: 1; min-width: 0; font-size: .9rem; padding: 8px 6px; overflow-wrap: anywhere; }
  .project-strip { padding: 6px 16px; font-size: .8rem; }
  .project-strip > span:first-child { flex-basis: 12rem; }
  .prototype-label { font-size: .75rem; text-align: left; }
  .interview-page,.copilot-page { padding-top: 12px; }
  .page-heading { margin-bottom: 12px; }
  .page-heading p { font-size: .87rem; }
  .app-footer > span:last-child { display: none; }
  .changes { grid-template-columns: 1fr; gap: 12px; }
  .canvas-fullscreen .app-header { display: flex; }
  .canvas-fullscreen .core-nav { border-top: 0; padding: 0; }
  /* 原型的偏好与导航各占一行，说明入口共用导航行，不额外堆一排空白。
     生产页另有账号/保存控件，继续自然换行，避免把这些操作塞到重叠插槽。 */
  .app-header:not(:has(#product-account)) { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)) repeat(2,minmax(0,1.2fr)); gap: 4px; }
  .app-header:not(:has(#product-account)) .brand { grid-column: 1 / 3; grid-row: 1; }
  .app-header:not(:has(#product-account)) .header-options { display: contents; }
  .app-header:not(:has(#product-account)) .ui-preferences { grid-column: 3 / 5; grid-row: 1; justify-self: end; }
  .app-header:not(:has(#product-account)) .core-nav { display: contents; }
  .app-header:not(:has(#product-account)) .core-nav a { grid-row: 2; padding-inline: 4px; white-space: nowrap; }
  .app-header:not(:has(#product-account)) .core-nav [data-page=interview] { grid-column: 1; }
  .app-header:not(:has(#product-account)) .core-nav [data-page=copilot] { grid-column: 2; }
  .app-header:not(:has(#product-account)) .core-nav [data-page=canvas] { grid-column: 3; }
  .app-header:not(:has(#product-account)) [data-action=toggle-changes] { grid-column: 4; grid-row: 2; max-width: 94px; }
  .canvas-fullscreen .app-header:not(:has(#product-account)) { display: flex; }
  .canvas-fullscreen .app-header:not(:has(#product-account)) .header-options { display: none; }
  .canvas-fullscreen .app-header:not(:has(#product-account)) .core-nav { display: flex; width: 100%; }
}

/* 真实项目目录按需打开；弹窗保留焦点留白，长标题和项目名换行后仍可触达。 */
.project-directory { width: min(620px,calc(100vw - 28px)); max-height: 85dvh; overflow: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--control-line); border-radius: 12px; padding: 20px; }
.project-directory::backdrop { background: #142c2466; }
.project-options { display: grid; gap: 8px; margin: 12px 0; }
.project-option { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; text-align: left; }
.project-option strong,.project-option span { min-width: 0; overflow-wrap: anywhere; }
.project-option span { font-size: .8rem; color: var(--muted); }
.project-create { display: grid; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.project-create label { font-size: .86rem; }
.project-create .button { justify-self: start; margin-top: 4px; }
.project-directory #project-error { background: var(--warning-soft); color: var(--warning); padding: 12px; line-height: 1.8; font-size: .86rem; }
.branch-exits { display: flex; flex-wrap: wrap; gap: 6px; }
.branch-exits [aria-pressed=true] { background: var(--soft); color: var(--accent); font-weight: 650; text-decoration: underline; text-underline-offset: 4px; }
