/* ===== 全局变量 ===== */
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1c2128;
  --bg-card: #161b22;
  --bg-input: #0d1117;
  --border-color: #30363d;
  --border-hover: #484f58;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-blue: #58a6ff;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --accent-yellow: #d29922;
  --accent-purple: #bc8cff;
  --shadow-glow: 0 0 20px rgba(88, 166, 255, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 64px;
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* ===== 顶部导航 ===== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #58a6ff 0%, #bc8cff 100%);
  border-radius: 8px;
  font-weight: 800; font-size: 13px; color: #fff;
}
.logo-text { display: flex; flex-direction: column; }
.logo-title { font-size: 15px; font-weight: 700; }
.logo-sub { font-size: 11px; color: var(--text-secondary); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.status-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--border-color);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-ok { color: var(--accent-green); border-color: rgba(63,185,80,0.3); }
.status-ok .status-dot { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.status-warn { color: var(--accent-yellow); border-color: rgba(210,153,34,0.3); }
.status-warn .status-dot { background: var(--accent-yellow); }
.status-unknown { color: var(--text-muted); }
.status-unknown .status-dot { background: var(--text-muted); }

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-icon:hover { color: var(--text-primary); border-color: var(--border-hover); background: var(--bg-tertiary); }

/* ===== 三栏布局 ===== */
.workspace {
  display: grid;
  grid-template-columns: 300px 1fr 260px;
  gap: 0;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.col-left, .col-right {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}
.col-right {
  background: var(--bg-secondary);
  border-right: none;
  border-left: 1px solid var(--border-color);
}

.col-center {
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.col-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
}
.col-header h2 { font-size: 14px; font-weight: 600; }

.col-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

/* ===== 左栏 ===== */
.input-textarea {
  flex: 1;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  resize: none;
  line-height: 1.6;
}
.input-textarea:focus { outline: none; border-color: var(--accent-blue); }
.input-textarea::placeholder { color: var(--text-muted); }

.col-actions {
  padding-top: 12px;
}

.btn-primary {
  width: 100%;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #58a6ff 0%, #bc8cff 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 中栏 ===== */
.gen-status {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--bg-tertiary);
}

.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.5;
}
.editor-empty svg { opacity: 0.3; margin-bottom: 12px; }
.editor-empty p { font-size: 13px; }

.editor-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.loading-dots { display: flex; gap: 6px; margin-bottom: 12px; }
.loading-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-blue);
  animation: dot 1.4s infinite ease-in-out;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

.editor-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
}

.editor-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.editor-title-row {
  display: flex;
  flex-direction: column;
}

.editor-body-row {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.editor-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  resize: none;
  transition: border-color 0.2s;
}
.editor-input:focus { outline: none; border-color: var(--accent-blue); }
.editor-input::placeholder { color: var(--text-muted); }

.editor-input-title {
  padding: 10px 12px;
  font-weight: 600;
  font-size: 15px;
}

.editor-input-body {
  padding: 10px 12px;
  flex: 1;
  line-height: 1.6;
  min-height: 150px;
}

.editor-body-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
}
.word-count {
  font-size: 12px;
  color: var(--text-muted);
}
.editor-body-actions {
  display: flex;
  gap: 6px;
}

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-sm:hover { color: var(--text-primary); border-color: var(--border-hover); }
.btn-sm.copied { color: var(--accent-green); border-color: rgba(63,185,80,0.4); }
.btn-sm-primary {
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent-blue);
  border-color: rgba(88, 166, 255, 0.3);
}
.btn-sm-primary:hover { background: rgba(88, 166, 255, 0.25); }

/* ===== 右栏 ===== */
.platform-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding: 0 4px;
}

.platform-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  overflow-y: auto;
}

.platform-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s;
  font-size: 13px;
}
.platform-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-tertiary);
  transform: translateX(2px);
}
.platform-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  flex-shrink: 0;
}
.platform-info { flex: 1; min-width: 0; }
.platform-name { font-size: 13px; font-weight: 600; }
.platform-url { font-size: 10px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.platform-arrow { color: var(--text-muted); font-size: 12px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 10px 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  z-index: 9999;
  transition: transform 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { color: var(--accent-green); border-color: rgba(63,185,80,0.3); }
.toast.error { color: var(--accent-red); border-color: rgba(248,81,73,0.3); }

/* ===== 配置弹窗 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 420px;
  max-width: 90vw;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.btn-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 18px; cursor: pointer;
  border-radius: 6px;
}
.btn-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.form-group input {
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
}
.form-group input:focus { outline: none; border-color: var(--accent-blue); }
.form-hint { font-size: 11px; color: var(--text-muted); }
.btn-save {
  padding: 10px;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.btn-save:hover { opacity: 0.9; }

/* ===== 记事本 / 历史面板 ===== */
.notepad-panel {
  position: fixed;
  top: 0; right: -400px;
  width: 380px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  z-index: 150;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
}
.notepad-panel.open { right: 0; }
.notepad-panel .notepad-body { display: flex; flex-direction: column; height: 100%; }
.notepad-panel .notepad-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}
.notepad-panel .notepad-header h3 { font-size: 14px; font-weight: 600; }
.notepad-header-actions { display: flex; gap: 6px; }
.notepad-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: -1;
}
.notepad-panel.open .notepad-overlay { opacity: 1; pointer-events: auto; }
.notes-container { flex: 1; overflow-y: auto; padding: 10px; }
.notes-loading, .notes-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 13px;
  padding: 20px;
}
.notes-empty p { color: var(--text-muted); }

/* ===== 历史记录项 ===== */
.notes-empty-text { padding: 12px; color: var(--text-muted); font-size: 13px; }
.history-item {
  padding: 10px;
  margin-bottom: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s;
}
.history-item:hover { border-color: var(--border-hover); }
.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}
.history-item-title {
  font-size: 12px;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.history-item-time {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 6px;
}
.history-item-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.platform-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent-blue);
}
.btn-delete-history {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  background: transparent;
  border: none;
  color: var(--accent-red);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s;
}
.btn-delete-history:hover { opacity: 1; background: rgba(248, 81, 73, 0.15); }

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: 280px 1fr 230px;
  }
}
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: auto;
  }
  .col-left {
    height: 280px;
    border-bottom: 1px solid var(--border-color);
    border-right: none;
  }
  .col-right {
    height: auto;
    max-height: 300px;
    border-top: 1px solid var(--border-color);
    border-left: none;
  }
  .col-center { min-height: 500px; }
  .platform-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
}
@media (max-width: 600px) {
  .logo-text { display: none; }
  .topbar { padding: 0 12px; }
  .platform-list { grid-template-columns: 1fr 1fr; }
  .editor-body-actions { flex-wrap: wrap; }
}
