:root {
  color-scheme: light;
  --bg: #eef0eb;
  --panel: #ffffff;
  --ink: #17211f;
  --muted: #6b7874;
  --line: #dde0da;
  --accent: #1c7c69;
  --accent-strong: #0e5346;
  --accent-soft: #d6ede6;
  --warn: #a46210;
  --speaker-a: #1c7c69;
  --speaker-b: #5b62b5;
  --speaker-c: #b45468;
  --speaker-d: #6b7c26;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(28, 124, 105, 0.07) 0%, transparent 70%),
    linear-gradient(180deg, #f5f7f2 0%, var(--bg) 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 0 14px;
  transition:
    transform 100ms ease,
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(28, 124, 105, 0.12);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

button:disabled {
  color: #a0aba8;
  cursor: not-allowed;
  opacity: 0.6;
}

input[type="color"] {
  width: 48px;
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.color-field {
  min-width: 104px;
}

button.primary {
  border-color: var(--accent-strong);
  background: linear-gradient(160deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(28, 124, 105, 0.28);
}

button.primary:hover:not(:disabled) {
  box-shadow: 0 4px 14px rgba(28, 124, 105, 0.36);
}

.shell {
  width: min(1680px, 100%);
  height: 100vh;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}



.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-size: 15px;
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.summary-text {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b8bdb9;
  transition: background 300ms;
  flex-shrink: 0;
}

.status.ready .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(28, 124, 105, 0.2);
  animation: pulse-dot 2.5s ease-in-out infinite;
}

.status.error .dot {
  background: #d94034;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(28, 124, 105, 0.2); }
  50%       { box-shadow: 0 0 0 5px rgba(28, 124, 105, 0.06); }
}


.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.9fr) minmax(0, 0.9fr);
  grid-auto-rows: 1fr;
  align-items: stretch;
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.is-hidden {
  display: none !important;
}

.auth-screen {
  display: grid;
  min-height: 100%;
  place-items: center;
  overflow: auto;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 14px rgba(23, 33, 31, 0.08);
}

.auth-header {
  display: grid;
  gap: 4px;
}

.auth-header h1 {
  font-size: 28px;
  line-height: 1.15;
}

.auth-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.room-lobby {
  display: grid;
  min-height: 100%;
  place-items: center;
  overflow: auto;
  padding: 24px;
}

.lobby-inner {
  width: min(980px, 100%);
  display: grid;
  gap: 18px;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.lobby-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.lobby-header h1 {
  font-size: 30px;
  line-height: 1.15;
}

.lobby-create {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(104px, auto) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(23, 33, 31, 0.06);
}

.lobby-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.room-card {
  display: grid;
  gap: 10px;
  min-height: 138px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  box-shadow: 0 2px 12px rgba(23, 33, 31, 0.05);
  position: relative;
}

.room-card:hover {
  border-color: var(--accent);
}

.room-card:hover .room-card-actions {
  opacity: 1;
  pointer-events: auto;
}

.room-card h2 {
  font-size: 17px;
  padding-right: 96px; /* leave room for 3 action buttons */
}

.room-card p,
.room-card small {
  color: var(--muted);
  font-size: 13px;
}

/* Action buttons overlaid top-right of card */
.room-card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.room-card-actions button {
  width: 28px;
  height: 28px;
  min-height: unset;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: var(--surface, #f5f5f5);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}

.room-card-actions button:hover {
  background: var(--accent);
  color: #fff;
  transform: none;
}

.room-card-actions button.danger:hover {
  background: #e53935;
  color: #fff;
  transform: none;
}

.room-card-rename {
  display: none;
  gap: 6px;
  align-items: center;
  padding-right: 96px;
}

.room-card-rename.active {
  display: flex;
}

.room-card-rename input {
  flex: 1;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.room-card-rename .btn-confirm {
  width: 28px;
  height: 28px;
  min-height: unset;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}
.room-card-rename .btn-confirm:hover {
  transform: none;
}

.room-card-rename .btn-cancel {
  width: 28px;
  height: 28px;
  min-height: unset;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.room-card-rename .btn-cancel:hover {
  transform: none;
}



.lobby-create input {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
}

.transcript-panel,
.chat-panel,
.settings-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(23, 33, 31, 0.06), 0 0 0 0 transparent;
  transition: box-shadow 200ms;
}

.panel-group {
  display: grid;
  gap: 12px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field select,
.field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.field input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.field input[type="color"] {
  width: 48px;
  padding: 3px;
}

.field input:disabled {
  background: #f3f5f1;
  color: #98a09d;
}

.file-field.is-active input {
  border-color: rgba(28, 124, 105, 0.45);
}

.meter {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8faf7;
}

.compact-meter {
  flex: 1 1 180px;
  min-width: 160px;
  max-width: 260px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f6f8f4;
  border: 1px solid var(--line);
}

#meterCanvas {
  width: 100%;
  height: 36px;
  display: block;
  border-radius: 4px;
}

.compact-meter #meterCanvas {
  height: 36px;
}

.meter-line {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.run-controls,
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.run-controls {
  display: flex;
  gap: 8px;
}

.run-controls button {
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

/* 设置齿轮图标按钮 */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  transition: color 120ms, border-color 120ms, background 120ms;
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: none;
}

.control-strip > input {
  display: none;
}

.settings-dialog {
  width: min(820px, calc(100vw - 32px));
  max-height: min(860px, calc(100vh - 32px));
  border: 0;
  padding: 0;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(23, 33, 31, 0.36);
  backdrop-filter: blur(4px);
}

.settings-card {
  display: grid;
  gap: 18px;
  max-height: min(860px, calc(100vh - 32px));
  overflow: auto;
  padding: 18px;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.settings-header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.settings-title-group {
  display: flex;
  flex-direction: column;
}

.settings-tabs {
  display: inline-flex;
  background: #f1f3f0;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--line);
  align-items: center;
}

.settings-tab-btn {
  border: 0 !important;
  background: transparent !important;
  color: var(--muted) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  padding: 6px 14px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  transition: all 120ms ease !important;
  min-height: 28px !important;
  line-height: 1 !important;
  box-shadow: none !important;
}

.settings-tab-btn:hover:not(:disabled) {
  border-color: transparent !important;
  transform: none !important;
  box-shadow: none !important;
  background: rgba(255, 255, 255, 0.45) !important;
  color: var(--ink) !important;
}

.settings-tab-btn:active:not(:disabled) {
  transform: none !important;
  box-shadow: none !important;
}

.settings-tab-btn.active {
  background: #fff !important;
  color: var(--accent) !important;
  box-shadow: 0 1px 3px rgba(23, 33, 31, 0.08) !important;
}

.settings-tab-btn.active:hover {
  background: #fff !important;
  color: var(--accent) !important;
}

.settings-tab-content {
  display: grid;
  gap: 18px;
}

.settings-tab-content[hidden] {
  display: none !important;
}

.settings-tab-content .agent-settings {
  border-top: none;
  padding-top: 0;
}

.settings-header button {
  min-width: 86px;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.utility-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.engine-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.engine-list div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
}

.engine-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.engine-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
}

.transcript-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.chat-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.chat-header-top {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.chat-header-top h2 {
  flex-shrink: 0;
}

.chat-header-top p {
  color: var(--muted);
  font-size: 13px;
}

/* 成员头像栏 */
.chat-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.member-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: default;
  border: 1.5px solid transparent;
  transition: opacity 120ms, border-color 120ms;
  user-select: none;
}

.member-tag:hover {
  opacity: 1;
}

.member-tag .agent-avatar {
  width: 22px;
  height: 22px;
  font-size: 11px;
}

.human-member {
  background: #f5f7f2;
  color: var(--ink);
}

.human-member .agent-avatar {
  background: #60726c;
}

/* Agent 圆形头像 */
.agent-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  color: #fff;
  line-height: 1;
}

.chat-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: none;
  padding: 16px 14px;
}

.chat-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

/* 气泡共有样式 */
.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  gap: 4px;
}

/* 真人消息：其他成员在左，自己在右 */
.chat-message.user {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-message.user.is-me {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message.user .chat-bubble {
  background: var(--accent);
  color: #fff;
  border-radius: 18px 18px 18px 4px;
}

.chat-message.user.is-me .chat-bubble {
  border-radius: 18px 18px 4px 18px;
}

.chat-message.user .chat-meta {
  color: var(--muted);
  font-size: 11px;
  padding-left: 4px;
}

.chat-message.user.is-me .chat-meta {
  padding-left: 0;
  padding-right: 4px;
}

.chat-message.user.is-me .chat-meta::after {
  content: " · 我";
  color: var(--accent-strong);
}

/* Agent 消息：左对齐，带头像 */
.chat-message.assistant {
  align-self: flex-start;
  align-items: flex-start;
  flex-direction: row;
  gap: 8px;
}

.chat-message.assistant .chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
}

.chat-message.assistant .chat-bubble {
  border-radius: 4px 18px 18px 18px;
  background: #f3f4f9;
}

.chat-message.assistant .chat-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding-left: 4px;
}

.chat-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* @补全弹层 */
.chat-composer-wrap {
  position: relative;
  border-top: 1px solid var(--line);
}

.at-mention-popup {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 14px;
  right: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(23, 33, 31, 0.12);
  overflow: hidden;
  z-index: 10;
}

.at-mention-popup[hidden] {
  display: none;
}

.at-mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 80ms;
}

.at-mention-item:hover,
.at-mention-item.active {
  background: var(--accent-soft);
}

.at-mention-item .agent-avatar {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

/* 输入区 */
.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
}

.chat-composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8faf7;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  transition: border-color 120ms;
  overflow-y: auto;
}

.chat-composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.chat-send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  transition: background 120ms, transform 120ms;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--accent-strong);
  transform: scale(1.08);
}

.chat-send-btn:disabled {
  background: #c8d4cf;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  background: rgba(248, 250, 247, 0.6);
  border-radius: 12px 12px 0 0;
}

.toolbar-info p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}

.toolbar-controls .run-controls {
  flex-shrink: 0;
}

.agent-settings {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.settings-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.agent-list {
  display: grid;
  gap: 12px;
}

.agent-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8faf7;
}

.agent-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  resize: vertical;
}

.agent-prompt {
  grid-column: 1 / -2;
}

.agent-context {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.agent-context input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.timeline {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: none;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  flex: 1;
  color: var(--muted);
  text-align: center;
}

.wave-preview {
  width: min(420px, 80%);
  height: 96px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 0 9px, rgba(28, 124, 105, 0.24) 9px 11px, transparent 11px 20px),
    linear-gradient(180deg, #eef5f0, #fff);
  background-size: 20px 100%, 100% 100%;
  mask-image: radial-gradient(ellipse at center, #000 55%, transparent 74%);
}

.segment {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.segment[hidden] {
  display: none;
}

.scroll-sentinel {
  flex: 0 0 8px;
  min-height: 8px;
  overflow-anchor: none;
  pointer-events: none;
}

.stamp {
  display: grid;
  align-content: start;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
}

.stamp span:not(.speaker) {
  white-space: nowrap;
  overflow: visible;
}

.speaker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 52px;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.segment.speaker-1 .speaker {
  background: rgba(28, 124, 105, 0.14);
  color: var(--speaker-a);
}

.segment.speaker-2 .speaker {
  background: rgba(91, 98, 181, 0.14);
  color: var(--speaker-b);
}

.segment.speaker-3 .speaker {
  background: rgba(180, 84, 104, 0.14);
  color: var(--speaker-c);
}

.segment.speaker-4 .speaker {
  background: rgba(107, 124, 38, 0.14);
  color: var(--speaker-d);
}

.segment.speaker-unknown .speaker {
  background: #e2e6e4;
  color: var(--muted);
}

.content {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.original {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.48;
}

.translation {
  color: var(--accent-strong);
  font-size: 14px;
  line-height: 1.45;
}

.subtitle-lines {
  display: grid;
  gap: 4px;
}

.subtitle-lines span {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: #f8faf7;
}

.pill.warn {
  border-color: rgba(164, 98, 16, 0.28);
  background: rgba(164, 98, 16, 0.08);
  color: var(--warn);
}

@media (max-width: 1320px) {
  .workspace {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.9fr);
    grid-template-rows: minmax(0, 1fr) minmax(320px, 0.75fr);
  }

  .chat-panel {
    grid-column: 1 / -1;
    min-height: 320px;
  }
}

@media (max-width: 860px) {
  .shell {
    padding: 10px;
    height: auto;
    min-height: 100vh;
  }

  .workspace {
    grid-template-columns: 1fr;
    flex: none;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .toolbar-controls {
    flex-wrap: wrap;
  }

  .lobby-create {
    grid-template-columns: 1fr;
  }

  .notes-header,
  .notes-room-meta {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .notes-room-meta h2,
  .notes-room-meta .summary-text {
    flex-basis: 100%;
  }

  .chat-panel {
    max-height: 560px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .agent-card {
    grid-template-columns: 1fr;
  }

  .agent-prompt {
    grid-column: auto;
  }

  .segment {
    grid-template-columns: 1fr;
  }

  .stamp {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .run-controls,
  .utility-actions {
    flex-wrap: wrap;
  }
}

/* ===== Notes Panel ===== */

.notes-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(23, 33, 31, 0.06);
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.notes-room-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.notes-room-meta h2 {
  flex: 0 1 150px;
  min-width: 88px;
  overflow: hidden;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f8faf7;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-room-meta .status {
  flex-shrink: 0;
}

.notes-room-meta .summary-text {
  flex: 1 1 160px;
  min-width: 90px;
  max-width: none;
}

.notes-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 34px;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  width: max-content;
  white-space: nowrap;
}

.notes-container {
  position: relative;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.notes-editor {
  padding: 14px 20px 40px;
  min-height: 100%;
  counter-reset: note-num;
}

/* === Blocks === */

.note-block {
  position: relative;
  margin: 1px 0;
  transition: background 100ms ease;
}

.note-block.selected-block {
  background: rgba(28, 124, 105, 0.09) !important;
  border-radius: 4px;
}

.nb-content {
  outline: none;
  min-height: 1.65em;
  line-height: 1.65;
  font-size: 14px;
  color: var(--ink);
  word-break: break-word;
  white-space: pre-wrap;
  caret-color: var(--accent);
  border-radius: 4px;
  padding: 1px 4px;
  transition: background 80ms;
}

.nb-content:hover {
  background: rgba(0,0,0,0.025);
}

.nb-content:focus {
  background: rgba(28, 124, 105, 0.04);
}

/* Placeholder */
.nb-content:empty::before {
  content: attr(data-ph);
  color: #bcc5c2;
  pointer-events: none;
  font-style: normal;
}

/* Headings */
.nb-h1 .nb-content {
  font-size: 1.8em;
  font-weight: 800;
  line-height: 1.25;
  color: var(--ink);
  margin-top: 0.4em;
}

.nb-h2 .nb-content {
  font-size: 1.35em;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 0.3em;
}

.nb-h3 .nb-content {
  font-size: 1.1em;
  font-weight: 700;
  line-height: 1.4;
  margin-top: 0.2em;
}

/* Bullet */
.nb-bullet {
  padding-left: 20px;
}

.nb-bullet::before {
  content: '•';
  position: absolute;
  left: 5px;
  top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

/* Numbered */
.nb-numbered {
  padding-left: 26px;
  counter-increment: note-num;
}

.nb-numbered::before {
  content: counter(note-num) '.';
  position: absolute;
  left: 0;
  top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  min-width: 22px;
  text-align: right;
}

/* Todo */
.nb-todo {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.nb-todo .nb-content {
  flex: 1;
  min-width: 0;
}

.nb-todo-toggle {
  position: relative;
  width: 14px;
  height: 14px;
  min-height: unset;
  margin: 4px 0 0 2px;
  padding: 0;
  flex: 0 0 14px;
  border: 1.5px solid #b8c3bf;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, box-shadow 100ms ease;
}

.nb-todo-toggle:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(28, 124, 105, 0.08);
  transform: none;
}

.nb-todo.is-checked .nb-todo-toggle {
  background: var(--accent);
  border-color: var(--accent);
}

.nb-todo.is-checked .nb-todo-toggle::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.nb-todo.is-checked .nb-content {
  color: var(--muted);
  text-decoration: line-through;
}

/* === Agent Pad — 自主 Agent 输出区 === */

.agent-pad {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: #f9fbfa;
  display: flex;
  flex-direction: column;
  max-height: 450px;
}

.agent-pad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 4px;
  flex-shrink: 0;
}

.agent-pad-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  min-height: unset;
}

.agent-pad-toggle-btn:hover {
  background: rgba(28,124,105,0.05);
  border-radius: 5px;
  transform: none;
  box-shadow: none;
}

.agent-pad-chevron {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s ease;
  display: inline-block;
}

.agent-pad[data-open] .agent-pad-chevron {
  transform: rotate(90deg);
}

.agent-pad-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.agent-pad-actions {
  display: flex;
  gap: 4px;
}

.agent-pad-btn {
  width: 24px;
  height: 24px;
  min-height: unset;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.agent-pad-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: none;
}

.agent-pad-btn.running {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* 内联配置面板 */
.agent-pad-config {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  flex-shrink: 0;
}

.agent-pad-config .field {
  display: grid;
  gap: 4px;
}

.agent-pad-config .field span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.agent-pad-config input,
.agent-pad-config textarea {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

/* 输出区 */
.agent-pad-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.agent-pad-config[hidden],
.agent-pad-body[hidden] {
  display: none !important;
}

.agent-pad-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 0;
}

.agent-pad-outputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 每条输出 */
.agent-pad-entry {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.agent-pad-entry-time {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 4px;
}



/* Quote */
.nb-quote .nb-content {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--muted);
  font-style: italic;
  background: none !important;
}

/* Code */
.nb-code .nb-content {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85em;
  background: #f0f2ef !important;
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--accent-strong);
  white-space: pre;
  overflow-x: auto;
}

/* Divider */
.nb-divider .nb-content {
  height: 0;
  border-top: 2px solid var(--line);
  margin: 8px 0;
  pointer-events: none;
}

/* === Slash Menu === */

.slash-menu {
  position: absolute;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(23, 33, 31, 0.14);
  overflow: hidden;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
}

.slash-menu[hidden] {
  display: none;
}

.slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  transition: background 60ms;
}

.slash-item:hover,
.slash-item.active {
  background: var(--accent-soft);
}

.slash-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #f0f2ef;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  color: var(--ink);
  font-family: 'SF Mono', monospace;
}

.slash-label {
  flex: 1;
}

.slash-hint {
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
}

/* Responsive: hide notes panel on narrow screens */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(320px, 0.75fr);
  }
  .notes-panel {
    display: none;
  }
  .chat-panel {
    grid-column: auto;
  }
}

/* ===== Selection Popup ===== */

.selection-popup {
  position: fixed;
  z-index: 200;
  display: flex;
  gap: 3px;
  padding: 4px;
  background: #1a2422;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%);
  animation: sel-pop 120ms ease;
  pointer-events: auto;
}

.selection-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1a2422;
}

.selection-popup[hidden] {
  display: none;
}

@keyframes sel-pop {
  from { opacity: 0; transform: translateX(-50%) translateY(4px) scale(0.96); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.sel-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: unset;
  padding: 5px 11px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #e8efed;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 80ms;
  box-shadow: none;
}

.sel-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: none;
  box-shadow: none;
  border-color: transparent;
}

.sel-btn svg {
  flex-shrink: 0;
}

/* Auth Screen Tabs & Panels */
.auth-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.auth-tab-btn {
  flex: 1;
  min-height: 32px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
  padding: 0 8px;
}

.auth-tab-btn:hover {
  background: rgba(28, 124, 105, 0.05);
  color: var(--accent);
  transform: none;
  box-shadow: none;
  border-color: transparent;
}

.auth-tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.auth-tab-content.is-hidden {
  display: none !important;
}

/* Lobby Settings Row & Cards Layout */
.lobby-settings-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .lobby-settings-row {
    grid-template-columns: 1fr;
  }
}

.lobby-profile-card,
.lobby-room-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(23, 33, 31, 0.06);
}

.lobby-profile-card h2,
.lobby-room-card h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin: 0;
}

.profile-fields {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(80px, auto) minmax(140px, 1.2fr) minmax(140px, 1.2fr);
  gap: 12px;
  align-items: end;
}

@media (max-width: 600px) {
  .profile-fields {
    grid-template-columns: 1fr;
  }
  
  .lobby-profile-card .color-field {
    min-width: unset;
    width: 100%;
  }
}

.room-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: end;
}

.lobby-profile-card button,
.lobby-room-card button {
  align-self: flex-end;
  margin-top: auto;
}
