/* ===== CSS Variables ===== */
:root {
  --bg-primary: #0f0e17;
  --bg-sidebar: #14131a;
  --bg-chat: #1a1a24;
  --gold: #d4a853;
  --gold-light: #f0d68a;
  --gold-dim: #8b6914;
  --text-primary: #e8e6e3;
  --text-secondary: #9d9b98;
  --border: #2a2833;
  --surface: #1e1d28;
  --input-bg: #252330;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* ===== 侧边栏 ===== */
.sidebar {
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  width: 260px;
  min-width: 0;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  transition: width 0.35s ease, border-right-width 0.35s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  border-right-width: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  font-weight: 600;
  font-size: 16px;
  color: var(--gold-light);
  letter-spacing: 1px;
}

.sidebar-new-project {
  padding: 12px 16px;
  flex-shrink: 0;
}

.btn-new-project {
  width: 100%;
  padding: 10px 0;
  border: 1px dashed var(--gold-dim);
  border-radius: 8px;
  background: transparent;
  color: var(--gold-light);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}

.btn-new-project:hover {
  background: rgba(212, 168, 83, 0.08);
}

.sidebar-project-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.sidebar-project-list.switching .project-item {
  pointer-events: none;
  opacity: 0.5;
}

.sidebar-section-title {
  padding: 8px 8px 6px;
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background 0.15s;
}

.project-item:hover {
  background: rgba(212, 168, 83, 0.06);
}

.project-item.active {
  background: rgba(212, 168, 83, 0.08);
}

.project-item .project-icon { font-size: 20px; flex-shrink: 0; }

.project-item .project-info {
  flex: 1;
  min-width: 0;
}

.project-item .project-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-item .project-time {
  font-size: 11px;
  color: var(--text-secondary);
}

.project-item .project-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 99px;
}

.project-status.active-status {
  background: rgba(212, 168, 83, 0.2);
  color: var(--gold-light);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--gold-dim);
  color: var(--gold-light);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.avatar:hover {
  transform: scale(1.1);
}

.sidebar-username {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* ===== 退出登录按钮 ===== */
.btn-logout {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.btn-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* ===== 侧边栏切换按钮 ===== */
.sidebar-toggle {
  position: fixed;
  z-index: 100;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.35s ease, opacity 0.2s;
}

.sidebar-toggle:hover {
  color: var(--text-primary);
  border-color: var(--gold-dim);
}

/* ===== 聊天区 ===== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-chat);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chat-messages > * {
  max-width: 720px;
  width: 100%;
}

.chat-welcome {
  text-align: center;
  padding: 60px 0 40px;
}

.chat-welcome h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: 1px;
  color: var(--gold-light);
}

.chat-welcome p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== 消息气泡 ===== */
.message {
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  text-align: right;
}

.message.user .bubble {
  background: var(--gold-dim);
  display: inline-block;
  padding: 10px 16px;
  border-radius: 16px 16px 4px 16px;
  font-size: 14px;
  max-width: 80%;
  text-align: left;
}

.message.nexus .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 16px 16px 16px 4px;
  font-size: 14px;
  line-height: 1.6;
  max-width: 100%;
}

.message.nexus .bubble p { margin-bottom: 8px; }
.message.nexus .bubble p:last-child { margin-bottom: 0; }
.message.nexus .bubble code {
  background: var(--input-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.message.nexus .bubble pre {
  background: #0f0e17;
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.5;
}

/* ===== 快捷入口 ===== */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.quick-action-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.quick-action-card:hover {
  border-color: var(--gold-dim);
  background: rgba(212, 168, 83, 0.06);
}

.qa-icon { font-size: 22px; flex-shrink: 0; }
.qa-title { font-size: 13px; font-weight: 500; }
.qa-desc { font-size: 11px; color: var(--text-secondary); }

/* ===== 输入区 ===== */
.chat-input-area {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.chat-input-area > * {
  max-width: 720px;
  width: 100%;
}

.chat-input-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--input-bg);
  transition: border-color 0.15s;
}

.chat-input-box:focus-within {
  border-color: var(--gold-dim);
}

.chat-input-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
}

.chat-input-box input::placeholder {
  color: var(--text-secondary);
}

.btn-send {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-dim);
  color: #fff;
  font-size: 16px;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.btn-send:hover {
  background: var(--gold);
}

.btn-send:active {
  transform: scale(0.95);
}

.chat-footer-text {
  text-align: center;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* ===== 设置面板 ===== */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
}

.settings-overlay.hidden {
  display: none;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.settings-panel {
  position: absolute;
  left: 276px;
  bottom: 20px;
  width: 380px;
  max-height: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: left 0.35s ease;
}

.settings-menu {
  padding: 6px;
  border-bottom: 1px solid var(--border);
}

.settings-tab {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s, color 0.15s;
}

.settings-tab:hover {
  background: rgba(212, 168, 83, 0.08);
  color: var(--text-primary);
}

.settings-tab.active {
  background: rgba(212, 168, 83, 0.12);
  color: var(--gold-light);
}

.tab-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
}

.settings-content h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--gold-light);
  margin: 0 0 16px;
}

.settings-content label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.settings-content input[type="text"],
.settings-content input[type="password"],
.settings-content textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}

.settings-content input:focus,
.settings-content textarea:focus {
  border-color: var(--gold-dim);
}

.settings-content textarea {
  resize: vertical;
  min-height: 60px;
}

.radio-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.radio-card {
  flex: 1;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.radio-card:hover {
  border-color: var(--gold-dim);
}

.radio-card.selected {
  border-color: var(--gold-dim);
  color: var(--gold-light);
  background: rgba(212, 168, 83, 0.08);
}

.radio-icon {
  font-size: 18px;
  display: block;
  margin-bottom: 4px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.toggle-label {
  font-size: 13px;
  color: var(--text-primary);
}

.toggle-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.toggle-switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #3a3548;
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #6b6578;
  transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--gold-dim);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: var(--gold-light);
}

.btn-save {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-radius: 8px;
  background: var(--gold-dim);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}

.btn-save:hover {
  background: var(--gold);
}

.about-version {
  font-size: 40px;
  font-weight: 700;
  color: var(--gold-light);
  text-align: center;
  margin: 24px 0 8px;
}

.about-desc {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
}

/* ===== 加载动画 ===== */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-dim);
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1.2); }
}

/* ===== 登录/注册界面 ===== */
.hidden { display: none !important; }

.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.auth-container {
  width: 380px;
  text-align: center;
}

.auth-logo {
  font-size: 42px;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.auth-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  text-align: left;
}

.auth-form h2 {
  text-align: center;
  font-size: 18px;
  color: var(--text-primary);
  margin: 0 0 20px;
}

.auth-form label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  margin-top: 12px;
}

.auth-form label:first-of-type { margin-top: 0; }

.auth-form input[type="text"],
.auth-form input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.auth-form input:focus {
  border-color: var(--gold-dim);
}

.auth-error {
  color: #ef4444;
  font-size: 12px;
  margin: 8px 0 0;
}

.auth-submit-btn {
  width: 100%;
  padding: 12px 0;
  border: none;
  border-radius: 8px;
  background: var(--gold-dim);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.15s;
}

.auth-submit-btn:hover {
  background: var(--gold);
}

.auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-switch {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 16px;
}

.auth-switch a {
  color: var(--gold-light);
  text-decoration: none;
  cursor: pointer;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ===== 向导多页表单 ===== */
.wizard-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.wizard-overlay.hidden { display: none; }

.wizard-container {
  width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.wizard-header {
  padding: 24px 32px 0;
}

.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.wizard-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  background: var(--input-bg);
  color: var(--text-secondary);
  border: 2px solid var(--border);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.wizard-dot.active {
  background: var(--gold-dim);
  border-color: var(--gold-dim);
  color: #fff;
}

.wizard-dot.done {
  background: var(--gold-dim);
  border-color: var(--gold-dim);
  color: #fff;
  opacity: 0.7;
}

.wizard-line {
  width: 60px;
  height: 2px;
  background: var(--border);
  transition: background 0.3s ease;
  flex-shrink: 0;
}

.wizard-line.done {
  background: var(--gold-dim);
}

.wizard-body {
  padding: 32px 32px 24px;
  min-height: 260px;
}

.wizard-body h2 {
  font-size: 20px;
  color: var(--text-primary);
  margin: 0 0 8px;
}

.wizard-body .wizard-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.wizard-body label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  margin-top: 14px;
}

.wizard-body label:first-of-type { margin-top: 0; }

.wizard-body input[type="text"],
.wizard-body input[type="password"],
.wizard-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.wizard-body input:focus,
.wizard-body textarea:focus {
  border-color: var(--gold-dim);
}

.wizard-body .wizard-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

.wizard-footer {
  padding: 16px 32px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.wizard-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.wizard-btn-primary {
  background: var(--gold-dim);
  color: #fff;
}

.wizard-btn-primary:hover {
  background: var(--gold);
}

.wizard-btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.wizard-btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.wizard-skip {
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  text-decoration: underline;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.wizard-skip:hover {
  opacity: 1;
}

/* ===== 权限确认弹窗 ===== */
.perm-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.perm-overlay.hidden { display: none; }

.perm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.perm-dialog {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 420px;
  max-width: 90vw;
  padding: 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.perm-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gold-light);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.perm-icon { font-size: 20px; }

.perm-body {
  margin-bottom: 20px;
}

.perm-tool-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.perm-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}

.perm-details {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
}
.perm-key {
  color: var(--gold-dim);
  font-weight: 500;
}

.perm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.perm-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s;
}

.perm-btn-deny {
  background: transparent;
  color: var(--text-secondary);
}
.perm-btn-deny:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
  color: #ef4444;
}

.perm-btn-allow-once {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--gold-dim);
}
.perm-btn-allow-once:hover {
  background: rgba(212, 168, 83, 0.12);
  border-color: var(--gold);
}

.perm-btn-allow-always {
  background: var(--gold-dim);
  color: #fff;
  border-color: var(--gold-dim);
}
.perm-btn-allow-always:hover {
  background: var(--gold);
  border-color: var(--gold);
}

/* ========== HTML 原型预览面板 ========== */

/* --- 原型模式：三栏布局切换 --- */
.html-prototype-mode #nx-sidebar {
  width: 0;
  overflow: hidden;
  transition: width 0.3s ease;
}

.html-prototype-mode .chat-area {
  width: 38%;
  transition: width 0.3s ease;
  min-width: 280px;
}

.html-prototype-mode #html-preview-panel {
  width: 62%;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
}

/* --- 预览面板默认隐藏 --- */
#html-preview-panel {
  width: 0;
  overflow: hidden;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
}

#html-preview-panel.hidden {
  display: none;
}

/* --- 预览工具栏 --- */
.preview-toolbar {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.preview-toolbar .preview-title {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.preview-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.preview-toolbar button {
  background: var(--gold-dim);
  color: var(--bg-primary);
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s;
}

.preview-toolbar button:hover {
  background: var(--gold-light);
}

#btn-save-preview {
  background: var(--gold-primary);
  color: white;
  padding: 5px 16px;
  font-weight: 600;
  position: relative;
}

#btn-save-preview:hover {
  background: var(--gold-light);
  color: var(--bg-primary);
}

/* ── 未提交改动红点 ── */
.proto-dirty-dot {
  display: none;
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  border: 1px solid #fff;
  box-shadow: 0 0 0 1px #ef4444;
}

/* --- 预览 iframe --- */
#html-preview-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: white;
}

/* --- HTML 预览消息气泡 --- */
.html-preview-message .bubble {
  background: rgba(212, 168, 83, 0.08);
  border: 1px solid var(--gold-dim);
}

.html-preview-info {
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.html-preview-path {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-family: monospace;
  word-break: break-all;
}

.btn-preview {
  background: var(--gold-dim);
  color: var(--bg-primary);
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}

/* ── 右边缘沙盘 toggle ── */
.proto-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 60px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 6px 0 0 6px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.proto-toggle:hover,
.proto-toggle.visible {
  opacity: 1;
}

/* 鼠标靠近右边缘 → 浮现 toggle */
@media (hover: hover) {
  body:hover .proto-toggle {
    opacity: 0;
  }
  .proto-toggle:hover {
    opacity: 1;
  }
}

.btn-preview:hover {
  background: var(--gold-light);
}

/* --- Toast 提示 --- */
.nx-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold-dim);
  color: var(--bg-primary);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 9999;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== 项目侧边栏 ===== */

.project-item {
  margin-bottom: 2px;
  border-radius: 6px;
}

.project-item.active .project-item-header {
  background: rgba(196, 82, 37, 0.15);
}

.project-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}

.project-item-header:hover {
  background: rgba(196, 82, 37, 0.1);
}

.project-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.project-name {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-active-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-primary);
  margin-left: auto;
  flex-shrink: 0;
}

/* ===== 文件树 ===== */

.project-item {
  display: block;
  padding: 0;
  cursor: default;
}

.project-files {
  display: none;
  padding: 0 0 4px 0;
}

.project-files.expanded {
  display: block;
}

.file-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 12px 3px 24px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  transition: background 0.1s;
}

.file-node:hover {
  background: rgba(212, 168, 83, 0.06);
}

.file-node .file-arrow {
  font-size: 8px;
  flex-shrink: 0;
  width: 10px;
  text-align: center;
  color: var(--text-secondary);
  transition: transform 0.12s;
}

.file-node .file-icon {
  font-size: 12px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.file-node .file-name {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-node.directory .file-name {
  color: var(--text-primary);
}

.file-node.directory.expanded > .file-arrow {
  transform: rotate(90deg);
}

.file-children {
  display: none;
}

.file-children.expanded {
  display: block;
}

/* ===== 三点菜单按钮 ===== */

.project-menu-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  letter-spacing: 1px;
}

.project-item-header:hover .project-menu-btn {
  display: flex;
}

.project-menu-btn:hover {
  color: var(--text-primary);
  background: rgba(212, 168, 83, 0.1);
}

/* ===== 三点下拉菜单 ===== */

.project-menu-dropdown {
  position: absolute;
  right: 4px;
  top: calc(100% + 2px);
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 110px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  display: none;
}

.project-menu-item {
  display: block;
  width: 100%;
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.1s;
}

.project-menu-item:hover {
  background: rgba(212, 168, 83, 0.08);
}

.project-menu-item.danger {
  color: #e05555;
}

.project-menu-item.danger:hover {
  background: rgba(224, 85, 85, 0.1);
}

/* ===== 编辑标题 + 删除确认 弹窗公用 ===== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
}

.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  min-width: 300px;
}

.modal-dialog h3 {
  font-size: 15px;
  margin-bottom: 16px;
}

.modal-dialog input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

.modal-dialog input:focus {
  border-color: var(--gold-dim);
}

.modal-dialog .modal-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-btn-cancel {
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.modal-btn-cancel:hover {
  background: rgba(255,255,255,0.05);
}

.modal-btn-confirm {
  padding: 6px 16px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.modal-btn-confirm.gold {
  background: var(--gold-dim);
  color: #fff;
}

.modal-btn-confirm.gold:hover {
  background: var(--gold);
}

.modal-btn-confirm.danger {
  background: #e05555;
  color: #fff;
}

.modal-btn-confirm.danger:hover {
  background: #c94444;
}
