/* ============================================================
   Boardroom — 深色会议室质感
   ============================================================ */

:root {
  --bg:        #0a0b0e;
  --bg-glow:   #14161f;
  --panel:     #121419;
  --panel-2:   #171a21;
  --line:      rgba(255, 255, 255, 0.075);
  --line-2:    rgba(255, 255, 255, 0.13);
  --text:      #e8e6e2;
  --text-dim:  #b4b2ae;
  --muted:     #7e828c;
  --gold:      #c9a961;

  --cfo:       #6f9fd8;
  --investor:  #e2764f;
  --therapist: #63bd9d;
  --friend:    #a78fd6;
  --chair:     #c9a961;

  --ok:        #63bd9d;
  --warn:      #d9a441;
  --bad:       #e2635c;
  --info:      #6f9fd8;

  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --r: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -12px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }

/* 作者样式表里的 display 会盖过浏览器默认的 [hidden]{display:none}，
   .modal-backdrop / .followup 都显式设了 display，必须在这里兜底。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(201,169,97,.07), transparent 60%),
    radial-gradient(90% 50% at 50% 0%, var(--bg-glow), transparent 70%);
  z-index: 0;
}

button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
code { font-family: var(--mono); font-size: .88em; }

/* ---------------------------------------------- 顶栏 */

/* 安全区快捷变量。
   页面声明了 viewport-fit=cover + apple-mobile-web-app-capable，
   装成 PWA 后内容会一路顶到屏幕物理边缘 —— iPhone 上那就是灵动岛
   底下和底部手势条上。这几个值在桌面浏览器里恒为 0，写了不影响电脑端。 */
:root {
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
  --sal: env(safe-area-inset-left);
  --sar: env(safe-area-inset-right);
  --topbar-h: 62px;
}

/* 顶栏是 sticky 的，scrollIntoView 会把目标顶到视口最上沿 —— 也就是顶栏底下。
   开完会滚到新一轮、滚到辩论区、滚到主席卡片时，标题都会被压住看不见。
   给这些滚动目标留出等于顶栏高度（含安全区）的外边距。 */
.round, .debate, .seat, .followup { scroll-margin-top: calc(var(--topbar-h) + var(--sat) + 10px); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  /* 顶部让开灵动岛；左右让开横屏时的刘海 */
  padding: calc(12px + var(--sat)) calc(24px + var(--sar)) 12px calc(24px + var(--sal));
  background: rgba(10, 11, 14, .78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand-seal {
  flex: none;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 17px;
  color: var(--gold);
  border: 1px solid rgba(201,169,97,.4);
  border-radius: 8px;
  background: rgba(201,169,97,.07);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-family: var(--serif); font-size: 16px; letter-spacing: .06em; font-weight: 600; }
.brand-text em {
  font-style: normal; font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.chip {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  max-width: 190px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.chip:hover { color: var(--text-dim); border-color: var(--line-2); }

.btn-ghost {
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 13.5px;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,.045); border-color: var(--line-2); color: var(--text); }
.btn-ghost.sm { padding: 5px 11px; font-size: 12.5px; flex: none; }

.btn-primary {
  padding: 10px 22px;
  border-radius: 10px;
  background: linear-gradient(180deg, #d8bb76, #bd9a4f);
  color: #22190a;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .02em;
  box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 6px 18px -8px rgba(201,169,97,.6);
  transition: filter .15s, transform .1s;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }

/* 顶部横幅：连不上服务等状态提示 */
.banner {
  position: relative;
  z-index: 30;
  padding: 11px 16px;
  background: color-mix(in srgb, var(--bad) 14%, var(--panel));
  border-bottom: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
  color: #f0b5b1;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}
.banner.clickable { cursor: pointer; }
.banner.clickable:hover { background: color-mix(in srgb, var(--bad) 20%, var(--panel)); }

/* 安装按钮：只有 beforeinstallprompt 触发（即真的可安装）时才显示 */
.btn-install {
  padding: 6px 14px;
  border: 1px solid rgba(201,169,97,.55);
  border-radius: 9px;
  background: rgba(201,169,97,.12);
  color: var(--gold);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn-install:hover { background: rgba(201,169,97,.2); border-color: var(--gold); }

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}
.icon-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }

/* ---------------------------------------------- 布局 */

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px 24px 120px;
}

/* ---------------------------------------------- 议题录入 */

.compose-head { text-align: center; margin-bottom: 24px; }

.compose-head h1 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: .04em;
  margin: 0;
}

/* ---------------------------------------------- 成员名册（小方块） */

.roster {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 0 0 26px;
}

.roster-chip,
.roster-add {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 15px 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  text-align: left;
  overflow: hidden;
  transition: border-color .16s, background .16s, transform .12s;
}

.roster-chip::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  opacity: .9;
}

.roster-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
  background: var(--panel-2);
  transform: translateY(-1px);
}

/* 出厂四位固定成员：静态展示块，无点击反馈 */
.roster-chip.is-locked { cursor: default; }
.roster-chip.is-locked:hover {
  border-color: var(--line);
  background: var(--panel);
  transform: none;
}

.rc-seal {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 50%;
}

.rc-meta { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.rc-meta strong {
  font-family: var(--serif);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.rc-meta em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.rc-edit {
  position: absolute;
  right: 6px; top: 5px;
  font-size: 10px;
  color: var(--muted);
  opacity: 0;
  transition: opacity .16s;
}
.roster-chip:hover .rc-edit { opacity: .8; }

.roster-add {
  border-style: dashed;
  border-color: var(--line-2);
  color: var(--muted);
  padding: 9px 15px;
}
.roster-add:hover {
  color: var(--gold);
  border-color: rgba(201,169,97,.5);
  background: rgba(201,169,97,.06);
  transform: translateY(-1px);
}
.roster-add span { font-size: 17px; line-height: 1; }
.roster-add em { font-style: normal; font-size: 12.5px; }

.profile {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  margin-bottom: 14px;
  overflow: hidden;
}

.profile > summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 18px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 13.5px;
  color: var(--text-dim);
  user-select: none;
}
.profile > summary::-webkit-details-marker { display: none; }
.profile > summary::before {
  content: "＋";
  color: var(--muted);
  font-size: 13px;
  transition: transform .2s;
}
.profile[open] > summary::before { content: "－"; }
.profile > summary small { color: var(--muted); font-size: 12px; }
.profile > summary:hover { background: rgba(255,255,255,.02); }

.profile textarea {
  display: block;
  width: 100%;
  padding: 0 18px 16px;
  background: transparent;
  border: none;
  resize: vertical;
  outline: none;
  color: var(--text);
  line-height: 1.75;
}

.ask {
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: border-color .18s;
}
.ask:focus-within { border-color: rgba(201,169,97,.45); }

.ask textarea {
  display: block;
  width: 100%;
  padding: 18px 20px 8px;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-size: 16.5px;
  line-height: 1.7;
  min-height: 78px;
}
.ask textarea::placeholder { color: #5b5f68; }

.ask-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px 12px 18px;
  flex-wrap: wrap;
}

.examples { display: flex; gap: 7px; flex-wrap: wrap; }
.examples button {
  font-size: 12.5px;
  color: var(--muted);
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: all .15s;
}
.examples button:hover { color: var(--text); border-color: var(--line-2); background: rgba(255,255,255,.04); }

/* ---------------------------------------------- 会议轮次 */

.rounds { margin-top: 40px; }

.round { margin-bottom: 52px; }
.round + .round { border-top: 1px solid var(--line); padding-top: 40px; }

.round-q {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 24px;
}
.round-q .idx {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold);
  border: 1px solid rgba(201,169,97,.32);
  border-radius: 6px;
  padding: 2px 7px;
  margin-top: 4px;
  letter-spacing: .06em;
}
.round-q .txt {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.6;
  letter-spacing: .02em;
}

.seat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* ---------------------------------------------- 席位卡片 */

.seat {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  padding: 18px 20px 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.seat::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 72%);
  opacity: .85;
}

.seat.is-chair {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, rgba(201,169,97,.05), transparent 130px), var(--panel);
  border-color: rgba(201,169,97,.24);
}

.seat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 14px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.seal {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border-radius: 50%;
}

.seat-id { flex: 1; min-width: 0; line-height: 1.3; }
.seat-id strong {
  display: block;
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: .04em;
}
.seat-id span { font-size: 11.5px; color: var(--muted); }

.badge {
  flex: none;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s;
}
.badge.show { opacity: 1; }
.badge[data-v="支持"]      { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 45%, transparent);   background: color-mix(in srgb, var(--ok) 11%, transparent); }
.badge[data-v="反对"]      { color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 45%, transparent);  background: color-mix(in srgb, var(--bad) 11%, transparent); }
.badge[data-v="有条件支持"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 11%, transparent); }
.badge[data-v="另有方案"]   { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); background: color-mix(in srgb, var(--info) 11%, transparent); }

.seat-body {
  font-size: 14.2px;
  line-height: 1.82;
  color: var(--text-dim);
  min-height: 42px;
  word-break: break-word;
}

.seat-body p { margin: 0 0 .75em; }
.seat-body p:last-child { margin-bottom: 0; }
.seat-body strong { color: var(--text); font-weight: 600; }
.seat-body ul, .seat-body ol { margin: .5em 0 .8em; padding-left: 1.35em; }
.seat-body li { margin: .3em 0; }
.seat-body h3 {
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: .05em;
  margin: 1.5em 0 .6em;
  padding-bottom: .4em;
  border-bottom: 1px solid var(--line);
}
.seat-body h3:first-child { margin-top: 0; }
.seat-body code { background: rgba(255,255,255,.07); padding: 1px 5px; border-radius: 4px; }
.seat-body hr { border: none; border-top: 1px solid var(--line); margin: 1.2em 0; }

.seat.is-chair .seat-body { font-size: 14.8px; color: var(--text); }

/* 打字光标 */
.caret {
  display: inline-block;
  width: 7px; height: 1.05em;
  vertical-align: -.16em;
  margin-left: 2px;
  background: var(--accent);
  opacity: .8;
  animation: blink 1.05s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* 思考中 */
.thinking { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.thinking i { display: flex; gap: 4px; }
.thinking i b {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.3s ease-in-out infinite;
}
.thinking i b:nth-child(2) { animation-delay: .16s; }
.thinking i b:nth-child(3) { animation-delay: .32s; }
@keyframes bounce { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.seat-error {
  font-size: 13px;
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 28%, transparent);
  border-radius: 9px;
  padding: 9px 12px;
  word-break: break-word;
}

/* ---------------------------------------------- 辩论区（第 2、3 轮）
   独立于席位卡片，按对话线程展示，让"谁在质疑谁"看得见。 */

.debate {
  margin-top: 16px;
  border: 1px solid rgba(201,169,97,.28);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(201,169,97,.05), transparent 120px), var(--panel);
  overflow: hidden;
}

.debate-head { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.debate-head .dbg {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--gold);
  border: 1px solid rgba(201,169,97,.35);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 8px;
}
.debate-head .crux {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
}
.debate-head .players { margin-top: 6px; font-size: 11.5px; color: var(--muted); letter-spacing: .04em; }

.debate-round { padding: 4px 18px 14px; }
.debate-round .rl {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .1em;
  margin: 12px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px dashed var(--line);
}

.debate-turn {
  position: relative;
  border-left: 2px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: rgba(255,255,255,.022);
  padding: 10px 14px;
  margin-bottom: 9px;
}
.debate-turn.is-changed { background: color-mix(in srgb, var(--warn) 7%, transparent); }

.dt-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dt-seal {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 12px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 50%;
}
.dt-head strong { font-family: var(--serif); font-size: 13px; font-weight: 600; letter-spacing: .03em; }
.dt-tag {
  font-size: 10.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}

.dt-body { font-size: 13.8px; line-height: 1.78; color: var(--text-dim); }
.dt-body p { margin: 0 0 .6em; }
.dt-body p:last-child { margin-bottom: 0; }
.dt-body strong { color: var(--text); }

.dt-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dt-badge, .dt-shift {
  font-size: 11px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted);
}
.dt-badge[data-v="支持"]      { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.dt-badge[data-v="反对"]      { color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.dt-badge[data-v="有条件支持"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.dt-badge[data-v="另有方案"]   { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.dt-shift.changed { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.dt-shift.held    { color: var(--muted); }

.chair-wait {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 8px;
  letter-spacing: .05em;
}

/* ---------------------------------------------- 追问 */

.followup {
  position: sticky;
  bottom: 20px;
  display: flex;
  gap: 10px;
  padding: 10px;
  margin-top: 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: rgba(18, 20, 25, .92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.followup input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  padding: 6px 10px;
  font-size: 15px;
}
.followup input::placeholder { color: #5b5f68; }

/* ---------------------------------------------- 设置弹窗 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 6, 8, .68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0; } }

.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  max-height: 88dvh; /* 移动端浏览器工具栏收起/展开时不跳动 */
  overflow: auto;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
  animation: rise .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { transform: translateY(10px) scale(.99); opacity: 0; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: .06em; }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 20px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 12.5px; color: var(--text-dim); letter-spacing: .04em; }
.field small { font-size: 11.5px; color: var(--muted); line-height: 1.65; }
.field small code { background: rgba(255,255,255,.07); padding: 1px 5px; border-radius: 4px; }

.field input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  font-size: 13.5px;
  font-family: var(--mono);
  transition: border-color .15s;
}
.field input:focus { border-color: rgba(201,169,97,.5); }

.input-row { display: flex; gap: 8px; align-items: center; }

.port-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.port-row > code {
  font-size: 15px;
  color: var(--gold);
  border: 1px solid rgba(201,169,97,.3);
  border-radius: 7px;
  padding: 3px 12px;
}
.port-row small { flex: 1; min-width: 200px; }

.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.ok-text  { color: var(--ok) !important; }
.bad-text { color: var(--bad) !important; }

/* ---------------------------------------------- 成员编辑弹窗 */

.modal-wide { width: min(720px, 100%); }

.seat-modal-title { display: flex; align-items: center; gap: 11px; }

.seal-preview {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--accent, var(--gold));
  border: 1px solid color-mix(in srgb, var(--accent, #c9a961) 42%, transparent);
  background: color-mix(in srgb, var(--accent, #c9a961) 10%, transparent);
  border-radius: 50%;
}

.grid-3 { display: grid; grid-template-columns: 1fr 110px 150px; gap: 14px; }

#seatPrompt {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  resize: vertical;
  font-size: 13px;
  line-height: 1.75;
  font-family: var(--mono);
  transition: border-color .15s;
}
#seatPrompt:focus { border-color: rgba(201,169,97,.5); }

#seatColor {
  width: 40px;
  height: 34px;
  padding: 2px;
  flex: none;
  cursor: pointer;
  background: var(--bg);
}
#seatColor::-webkit-color-swatch-wrapper { padding: 2px; }
#seatColor::-webkit-color-swatch { border: none; border-radius: 5px; }

.seat-foot { align-items: center; }
.foot-gap { flex: 1; }
.btn-ghost.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.btn-ghost.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: var(--bad); color: var(--bad); }

/* ---------------------------------------------- 打印 / 导出 PDF */

.print-head { display: none; }

@media print {
  @page { size: A4; margin: 12mm 10mm; }

  /* 保留屏幕上的深色观感 */
  html, body {
    background: #0a0b0e !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  body::before { display: none !important; }

  /* 输入类 UI 不进 PDF */
  .topbar, .compose, .followup, .modal-backdrop, .caret, .thinking, .banner { display: none !important; }

  /* 辩论过程要进 PDF —— 它是这场会议最有价值的部分之一 */
  .debate { break-inside: auto; }
  .debate-turn { break-inside: avoid; page-break-inside: avoid; }
  .debate-head .crux { font-size: 13px; }
  .dt-body { font-size: 11px; line-height: 1.65; }

  .wrap { max-width: none; padding: 0; margin: 0; }
  .rounds { margin-top: 0; }

  .print-head {
    display: block !important;
    padding: 0 0 14px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(201,169,97,.35);
  }
  .print-head h1 {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: .08em;
    color: var(--gold);
    margin: 0 0 6px;
  }
  .print-head p { margin: 0; font-size: 11px; color: var(--muted); }
  .print-profile {
    margin-top: 12px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 9px;
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--text-dim);
    white-space: pre-wrap;
  }
  .print-profile b { display: block; color: var(--muted); font-size: 10.5px; margin-bottom: 4px; letter-spacing: .06em; }

  /* 分页：卡片不要被劈开 */
  .seat { break-inside: avoid; page-break-inside: avoid; }
  .round { break-inside: auto; }
  .round-q { break-after: avoid; page-break-after: avoid; }
  .round + .round { border-top: none; padding-top: 0; }
  .round { margin-bottom: 26px; }

  .seat-grid { gap: 12px; }
  .seat { padding: 14px 16px 16px; }
  .seat-body { font-size: 11.5px; line-height: 1.7; }
  .seat.is-chair .seat-body { font-size: 12px; }
  .round-q .txt { font-size: 16px; }
  .seat-id strong { font-size: 13px; }
}

/* 打印时隐藏输入焦点态残留 */
@media print {
  .ask, .profile, .roster, .compose-head { display: none !important; }
}

/* ---------------------------------------------- 响应式
   目标设备：Z Fold 8 展开（约 670–720px 宽，近方形）走两列；
   Z Fold 8 外屏（约 344px）与 iPhone Pro Max（430px）走单列 + 底部抽屉弹窗。 */

/* —— 中屏（Fold 展开 / 小平板）：保留两列，收紧留白 —— */
@media (max-width: 900px) {
  .wrap { padding: 28px 18px 110px; }
  .modal-wide { width: min(640px, 100%); }
  .seat-grid { gap: 12px; }
  .seat { padding: 16px 17px 18px; }
}

/* —— 窄屏公共调整（手机 + Fold 外屏）—— */
@media (max-width: 700px) {
  :root { --topbar-h: 64px; }  /* 窄屏顶栏高度变了，滚动避让要跟着变 */
  .topbar {
    padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 10px calc(12px + var(--sal));
    gap: 10px;
  }
  .topbar-actions { gap: 6px; }

  .btn-ghost, .btn-install { padding: 8px 12px; font-size: 13px; }
  .brand-text em { display: none; }
  .chip { max-width: 96px; padding: 6px 10px; }

  .compose-head h1 { font-size: 24px; }
  .grid-3 { grid-template-columns: 1fr; }
  .seat-foot { flex-wrap: wrap; row-gap: 8px; }
  .round-q .txt { font-size: 18px; }
  .round-q .idx { margin-top: 2px; }
}

/* —— 手机单列（iPhone Pro Max / Fold 外屏）—— */
@media (max-width: 600px) {
  .wrap {
    padding: 22px calc(14px + var(--sar)) calc(96px + var(--sab)) calc(14px + var(--sal));
  }

  /* 顶栏在 440px 上要塞 6 个元素，模型名会被截成「gpt-5.6-s…」，
     既占地方又没读全。点它只是打开设置，而「设置」按钮就在旁边，
     手机上直接收起来，把空间让给真正要点的按钮。 */
  .chip { display: none; }

  .seat-grid { grid-template-columns: 1fr; gap: 11px; }
  .seat-body { font-size: 14.5px; }
  .badge { max-width: 45%; overflow: hidden; text-overflow: ellipsis; }

  /* 名册：四个固定成员 2×2，「增加成员」独占一行 */
  .roster { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .roster-chip { width: 100%; padding: 9px 10px; }
  .rc-meta strong, .rc-meta em { overflow: hidden; text-overflow: ellipsis; }
  .roster-add { grid-column: 1 / -1; justify-content: center; min-height: 44px; }

  /* 提问区：示例横向滑动，不再挤成两行；主按钮整行好按 */
  .ask textarea { padding: 15px 16px 6px; min-height: 70px; }
  /* flex-wrap 必须显式关掉。基础规则是 row + wrap，这里只改成 column
     却留着 wrap，就变成了"按列换行排布"：子项按各自内容宽度排，
     既不会被拉伸也不会被收缩到容器宽度，下面 .examples 的 min-width:0 也就白设了。 */
  .ask-bar {
    flex-direction: column; flex-wrap: nowrap;
    align-items: stretch; gap: 10px; padding: 8px 12px 12px;
  }
  /* min-width: 0 是这里的关键，不能省。
     .examples 自己是 flex 项，默认 min-width:auto 会解析成"内容固有宽度"
     （四个 nowrap 按钮 ≈ 370px），于是它拒绝收缩到可用宽度，
     overflow-x: auto 根本没机会生效 —— 结果是整页能左右拖动。
     440px 的 Pro Max 恰好够宽看不出来，320/375/390 的机型全中招。 */
  .examples {
    flex-wrap: nowrap; overflow-x: auto; min-width: 0;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    margin: 0 -12px; padding: 0 12px;
  }
  .examples::-webkit-scrollbar { display: none; }
  .examples button { flex: none; white-space: nowrap; padding: 7px 13px; }
  .ask-bar .btn-primary { width: 100%; padding: 13px; font-size: 15px; }

  /* 辩论区：手机上收紧留白，避免整页过长 */
  .debate-head { padding: 12px 14px; }
  .debate-head .crux { font-size: 14.5px; }
  .debate-round { padding: 2px 12px 12px; }
  .debate-turn { padding: 9px 11px; margin-bottom: 8px; }
  .dt-body { font-size: 13.5px; }

  /* iOS：输入框字号 <16px 聚焦时会强制放大页面，这里统一抬到 16px */
  .ask textarea, .profile textarea, .followup input,
  .field input, #seatPrompt { font-size: 16px; }

  /* 追问条：贴底、避开 iPhone 底部手势条。
     --kb 由 app.js 通过 visualViewport 写入：iOS 上键盘弹出时不会缩小
     layout viewport，position:fixed 的元素会原地不动被键盘盖住 ——
     而这正是用户刚点开要打字的那个输入框。JS 把键盘高度写进 --kb 顶上去。 */
  .followup {
    position: fixed;
    left: calc(10px + var(--sal)); right: calc(10px + var(--sar));
    bottom: calc(10px + var(--sab) + var(--kb, 0px));
    margin: 0; padding: 8px; gap: 8px;
    transition: bottom .18s ease-out;
  }
  .followup .btn-primary { padding: 11px 16px; }

  /* 弹窗改为底部抽屉：手机上比居中对话框好用得多 */
  .modal-backdrop { display: flex; align-items: flex-end; padding: 0; }
  .modal {
    width: 100%;
    max-height: 92vh;
    /* 抽屉最高不能顶到灵动岛底下，所以再减一次顶部安全区 */
    max-height: min(92dvh, calc(100dvh - var(--sat) - 12px));
    /* 抽屉内滚到头之后不要把身后的页面也带着滚（iOS 上的滚动链） */
    overscroll-behavior: contain;
    border-radius: 18px 18px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    animation: sheetUp .26s cubic-bezier(.2, .8, .3, 1);
  }
  .modal::before {
    content: "";
    display: block;
    width: 40px; height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .18);
    margin: 8px auto 0;
  }
  .modal-head { position: sticky; top: 0; z-index: 2; background: var(--panel-2); }
  .modal-body { padding: 16px; gap: 16px; }
  .modal-foot {
    position: sticky; bottom: 0; z-index: 2; background: var(--panel-2);
    padding: 12px 16px calc(12px + var(--sab));
  }
  .modal-foot .btn-primary { padding: 12px 24px; }
  .modal-foot .btn-ghost { padding: 11px 16px; }
  #seatPrompt { min-height: 200px; }
  .port-row small { min-width: 0; }

  /* 颜色选择器：40×34 的色块在触屏上太小（低于 44px 最小点击区），
     而且 .input-row 一换行它就单独占一整行、和色值框断开。
     只对颜色行禁止换行 —— API Key 那行的「显示 / 清除」还得靠换行才排得下。 */
  .input-row { flex-wrap: wrap; }
  .input-row.color-row { flex-wrap: nowrap; }
  #seatColor { width: 52px; height: 44px; }
  #seatColorHex { min-width: 0; flex: 1; }
}

@keyframes sheetUp { from { transform: translateY(28px); opacity: .5; } }

/* —— 触屏设备（无 hover）——
   1) 悬停位移动画在触屏上只会闪一下，关掉；
   2) 自定义成员的「改」角标依赖 hover 才显示，触屏上常显，否则用户不知道能点。 */
@media (hover: none) {
  .roster-chip:hover, .roster-add:hover { transform: none; }
  .rc-edit { opacity: .75; }

  /* 触摸目标尺寸按「是不是手指操作」来判断，而不是按屏幕宽度 ——
     Fold 展开到 673px 依然是手指点，用 max-width 判断就漏掉了它。
     Apple HIG 的最小点击区是 44pt：顶栏按钮原本 36px、弹窗的 × 只有 38px，
     单看都不算离谱，但它们挤在屏幕最上沿、彼此只隔 6px，按偏的概率不低。
     这里只加高不加宽，横向排布完全不受影响。 */
  .btn-ghost, .btn-install {
    min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  }
  .icon-btn { width: 44px; height: 44px; }
  .field input { min-height: 44px; }
  .examples button { min-height: 40px; }
  .chip { min-height: 36px; }
}

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