/* ===================================
   ScholarFlow 科研助手 - Design System
   深蓝侧边栏 + 暖白内容区 + 古铜点缀
   =================================== */

:root {
  --primary-blue: #2c3b5a;
  --sidebar-bg: #1a1f2e;
  --sidebar-hover: rgba(255,255,255,0.06);
  --text-sidebar: rgba(255,255,255,0.7);
  --text-muted: #888;
  --bg-warm: #f7f6f3;
  --bg-card: #fff;
  --accent-bronze: #8b6f47;
  --accent-gold: #c9a96e;
  --success: #4caf84;
  --border-light: #e5e2dc;
  --danger: #c0392b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-warm);
  color: #333;
  line-height: 1.6;
  font-size: 1.05rem;
}

/* ===================================
   Layout
   =================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  max-width: 1660px;
  margin: 0 auto;
}

/* ===================================
   Sidebar
   =================================== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-brand {
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand h1 {
  font-family: Georgia, 'Noto Serif SC', serif;
  font-size: 1.08rem;
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
}
.sidebar-brand .subtitle {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
  letter-spacing: 2px;
  margin-top: 2px;
}

#project-selector { display: none; }

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar-section-title {
  padding: 14px 20px 6px;
  font-size: 0.767rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.3);
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 20px;
  margin: 1px 8px;
  border-radius: 6px;
  font-size: 0.979rem;
  color: var(--text-sidebar);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-link.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-weight: 600;
}

.step-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.25);
  color: var(--text-sidebar);
  background: transparent;
  transition: all 0.2s;
}
.sidebar-link.active .step-num {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}

.step-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===================================
   Sidebar Project List
   =================================== */
#project-list {
  margin: 0 0 4px 0;
}
.project-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 20px;
  border-radius: 6px;
  margin: 1px 8px;
  font-size: 0.968rem;
  color: var(--text-sidebar);
  text-decoration: none;
  transition: background 0.15s;
  cursor: pointer;
}
.project-link:hover {
  background: rgba(255,255,255,0.06);
}
.project-link.active {
  background: rgba(255,255,255,0.1);
  font-weight: 600;
}

.project-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-step {
  flex-shrink: 0;
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.74rem;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
}

.proj-status {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.767rem;
  border-radius: 50%;
}
.proj-status.in-progress { color: #f0c060; }
.proj-status.completed { color: #4caf84; font-weight: 700; }

.step-info {
  flex-shrink: 0;
  font-size: 0.802rem;
  color: rgba(255,255,255,0.35);
  font-weight: 400;
}

.sidebar-link-new {
  border: 1px dashed rgba(255,255,255,0.15);
  margin: 4px 8px;
}
.sidebar-link-new:hover {
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.04);
}

/* New Project Popup (right of sidebar) */
.new-proj-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
}
.new-proj-overlay.hidden { display: none; }

.new-proj-popup {
  position: fixed;
  z-index: 100;
  left: 268px;
  width: 260px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  padding: 6px 0;
  animation: popupIn 0.18s ease;
}
.new-proj-popup.hidden { display: none; }

.new-proj-body {
  padding: 12px 16px;
}
.new-proj-body input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1.038rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  outline: none;
  font-family: inherit;
  margin-bottom: 12px;
}
.new-proj-body input:focus {
  border-color: var(--accent-bronze);
}

.new-proj-actions {
  display: flex;
  gap: 10px;
}
.np-btn {
  flex: 1;
  padding: 8px 0;
  font-size: 0.968rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
}
.np-btn-confirm {
  background: var(--primary-blue);
  color: #fff;
}
.np-btn-confirm:hover { background: #3d506e; }
.np-btn-cancel {
  background: #f5f4f1;
  color: #888;
}
.np-btn-cancel:hover { background: #e8e6e0; }

/* ===================================
   Step Popup Panel
   =================================== */
.step-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
}
.step-popup-overlay.hidden { display: none; }

.step-popup {
  position: fixed;
  z-index: 100;
  left: 268px;
  width: 220px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  padding: 6px 0;
  animation: popupIn 0.18s ease;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.step-popup.hidden { display: none; }

@keyframes popupIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.step-popup-arrow {
  position: absolute;
  left: -8px;
  top: 14px;
  width: 16px;
  height: 16px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: -2px 2px 6px rgba(0,0,0,0.08);
}

.step-popup-header {
  padding: 8px 16px 6px;
  font-size: 0.826rem;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #f0eee9;
  margin-bottom: 4px;
}

.step-popup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.968rem;
  color: #333;
  transition: background 0.12s;
}
.step-popup-item:hover {
  background: #f5f4f1;
}
.step-popup-item.locked {
  color: #c5c0b8;
  cursor: not-allowed;
}
.step-popup-item.locked:hover {
  background: transparent;
}

.sp-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.826rem;
  font-weight: 600;
  flex-shrink: 0;
  background: #eee;
  color: #999;
}
.step-popup-item.done .sp-icon {
  background: #4caf84;
  color: #fff;
}
.step-popup-item.locked .sp-icon {
  background: #f0f0f0;
  color: #ccc;
}

.sp-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===================================
   Sidebar Footer
   =================================== */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-login-link {
  color: var(--accent-gold);
  font-size: 0.944rem;
  text-decoration: none;
}
.sidebar-login-link:hover { color: #fff; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-bronze);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.885rem;
  font-weight: 600;
}
.sidebar-user-name {
  color: var(--text-sidebar);
  font-size: 0.944rem;
}
.sidebar-user-logout {
  color: rgba(255,255,255,0.35);
  font-size: 0.826rem;
  cursor: pointer;
  margin-left: auto;
}
.sidebar-user-logout:hover { color: #fff; }

/* ===================================
   Main Content
   =================================== */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px 40px;
  max-width: 1400px;
  width: 100%;
}

.top-bar {
  margin-bottom: 24px;
}
.page-title {
  font-family: Georgia, 'Noto Serif SC', serif;
  font-size: 1.888rem;
  font-weight: 700;
  color: var(--primary-blue);
}
.project-info {
  font-size: 1.003rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===================================
   Progress Bar (Horizontal Step Tracker)
   =================================== */
.progress-bar-v2 {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.progress-project {
  font-family: Georgia, 'Noto Serif SC', serif;
  font-size: 1.121rem;
  font-weight: 700;
  color: var(--primary-blue);
}
.progress-step-label {
  font-size: 0.92rem;
  color: var(--accent-bronze);
  font-weight: 600;
  background: #faf6f0;
  padding: 3px 12px;
  border-radius: 100px;
}
.progress-track {
  display: flex;
  align-items: center;
  gap: 0;
}
.progress-seg {
  flex: 1;
  height: 4px;
  background: #e8e5df;
  position: relative;
  transition: background 0.3s;
}
.progress-seg:first-child {
  border-radius: 2px 0 0 2px;
}
.progress-seg:last-child {
  border-radius: 0 2px 2px 0;
}
.progress-seg.done {
  background: var(--success);
}
.progress-seg.current {
  background: var(--primary-blue);
  box-shadow: 0 0 8px rgba(44,59,90,0.3);
}
.seg-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #e8e5df;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.767rem;
  font-weight: 700;
  color: #999;
  transition: all 0.3s;
}
.progress-seg.done .seg-dot {
  background: var(--success);
  color: #fff;
}
.progress-seg.current .seg-dot {
  background: var(--primary-blue);
  color: #fff;
  width: 28px; height: 28px;
  box-shadow: 0 0 0 4px rgba(44,59,90,0.15);
}
.seg-label {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: #bbb;
  white-space: nowrap;
  transition: color 0.3s;
}
.progress-seg.done .seg-label {
  color: #999;
}
.progress-seg.current .seg-label {
  color: var(--primary-blue);
  font-weight: 600;
}

/* ===================================
   Step Panels
   =================================== */
.step-panel { display: none; }
.step-panel.active { display: block; }

/* ===================================
   Hero / Home
   =================================== */
.hero-section {
  text-align: center;
  padding: 60px 40px;
}
.hero-topline {
  width: 48px; height: 3px;
  background: var(--accent-bronze);
  margin: 0 auto 20px;
}
.hero-eyebrow {
  display: inline-block;
  font-size: 0.802rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent-bronze);
  font-weight: 600;
  margin-bottom: 24px;
  position: relative;
}
.hero-eyebrow::before,
.hero-eyebrow::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  background: var(--accent-bronze);
  vertical-align: middle;
  margin: 0 10px;
  opacity: 0.4;
}
.hero-title {
  font-family: Georgia, 'Noto Serif SC', serif;
  font-size: 4.248rem;
  font-weight: 700;
  color: var(--primary-blue);
  line-height: 1.15;
  letter-spacing: -0.5px;
}
.hero-title-sub {
  font-weight: 300;
  font-size: 3.068rem;
  display: block;
  color: var(--accent-bronze);
}
.hero-desc {
  font-size: 1.239rem;
  color: var(--text-muted);
  margin: 20px 0 48px;
  font-weight: 400;
}

/* Hero CTA Hint */
.hero-cta-hint {
  margin-top: 40px;
  padding: 18px 32px;
  background: #fff;
  border: 1.5px dashed var(--accent-bronze);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.062rem;
  color: var(--primary-blue);
  animation: hintPulse 3s ease-in-out infinite;
}
.hero-cta-hint .cta-arrow {
  font-size: 1.652rem;
  color: var(--accent-bronze);
  animation: arrowBounce 1.5s ease-in-out infinite;
}
@keyframes arrowBounce {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-6px); }
}
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139,111,71,0.1); }
  50% { box-shadow: 0 0 0 8px rgba(139,111,71,0); }
}

/* ===================================
   Cards
   =================================== */
.card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  border: 1px solid var(--border-light);
}
.card-header {
  margin-bottom: 16px;
}
.card-title {
  font-family: Georgia, 'Noto Serif SC', serif;
  font-size: 1.298rem;
  font-weight: 700;
  color: var(--primary-blue);
}

/* ===================================
   Forms
   =================================== */
.panel-section { margin-bottom: 14px; }
.panel-section label {
  display: block;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.panel-section input,
.panel-section select,
.panel-section textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 1.038rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: #fafaf8;
  font-family: inherit;
  transition: border-color 0.2s;
}
.panel-section input:focus,
.panel-section select:focus,
.panel-section textarea:focus {
  outline: none;
  border-color: var(--accent-bronze);
  background: #fff;
}
.panel-section textarea {
  min-height: 120px;
  resize: vertical;
}

/* ===================================
   Buttons
   =================================== */
.btn {
  padding: 8px 20px;
  font-size: 1.003rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary-blue);
  color: #fff;
}
.btn-primary:hover { background: #3d506e; }
.btn-accent {
  background: var(--accent-bronze);
  color: #fff;
}
.btn-accent:hover { background: #7a5e3d; }
.btn-outline {
  background: #fff;
  border-color: var(--border-light);
  color: var(--primary-blue);
}
.btn-outline:hover { border-color: var(--primary-blue); }
.btn-full {
  width: 100%;
  padding: 12px;
  background: var(--primary-blue);
  color: #fff;
  font-size: 1.062rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* ===================================
   AI Output
   =================================== */
.ai-output {
  background: #fafbfc;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 16px;
  min-height: 120px;
  font-size: 1.038rem;
  line-height: 1.7;
}
.ai-output.empty {
  color: #bbb;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===================================
   Two Column
   =================================== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.col-header {
  font-size: 0.885rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* ===================================
   Tables
   =================================== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.038rem;
}
thead tr {
  text-align: left;
  border-bottom: 2px solid var(--border-light);
}
th { padding: 10px 12px; font-weight: 600; color: var(--text-muted); }
td { padding: 12px; }

/* ===================================
   Tags
   =================================== */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.85rem;
  background: #eef0f4;
  color: var(--primary-blue);
  margin: 2px;
}
.tag-list { margin: 8px 0; }

/* ===================================
   Modal
   =================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  width: 420px;
  max-width: 90vw;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  font-size: 1.77rem;
  cursor: pointer;
  color: #999;
}

.modal-tabs {
  display: flex;
  gap: 0;
  margin: 16px 0;
  border-bottom: 2px solid var(--border-light);
}
.modal-tab {
  padding: 8px 20px;
  cursor: pointer;
  font-size: 1.003rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.modal-tab.active {
  color: var(--primary-blue);
  border-bottom-color: var(--primary-blue);
  font-weight: 600;
}

.modal-form { display: none; }
.modal-form.active { display: block; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.field input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1.062rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
}
.field input:focus {
  outline: none;
  border-color: var(--primary-blue);
}

.alt-action {
  text-align: center;
  font-size: 0.944rem;
  color: var(--text-muted);
  margin-top: 12px;
}
.alt-action a {
  color: var(--primary-blue);
  cursor: pointer;
  font-weight: 600;
}

.social-login {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.social-btn {
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 1.038rem;
  text-align: center;
}
.social-btn.wechat { background: #f0f9eb; border-color: #c8e6c8; }
.social-btn.google { background: #fafafa; }

/* ===================================
   Toast
   =================================== */
.toast {
  position: fixed;
  bottom: 30px;
  left: calc(260px + (100vw - 260px) / 2);
  transform: translateX(-50%);
  background: var(--primary-blue);
  color: #fff;
  padding: 10px 28px;
  border-radius: 8px;
  font-size: 1.003rem;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
}

/* ===================================
   Edit Panel
   =================================== */
.edit-panel textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  font-size: 1.038rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  resize: vertical;
  font-family: inherit;
}

/* ===================================
   Icon Grid (Home page)
   =================================== */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 40px;
}
.icon-card {
  text-align: center;
  padding: 24px 16px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border-light);
}
.icon-card svg { width: 40px; height: 40px; margin-bottom: 8px; }
.icon-card h3 { font-size: 1.062rem; color: var(--primary-blue); margin-bottom: 4px; font-family: Georgia, serif; }
.icon-card p { font-size: 0.885rem; color: var(--text-muted); }

/* ===================================
   Version Panel
   =================================== */
.version-panel {
  background: #fff;
  margin-top: 16px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
}
.version-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}
.version-panel-badge {
  font-size: 0.85rem;
  background: #eef0f4;
  color: var(--primary-blue);
  padding: 2px 10px;
  border-radius: 100px;
  font-weight: 500;
}
.version-panel-badge.full {
  background: #fef9e7;
  color: var(--accent-bronze);
  border: 1px solid #f0e8d0;
}
.version-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f5f4f1;
  font-size: 0.944rem;
  transition: background 0.12s;
}
.version-item:last-child {
  border-bottom: none;
}
.version-item:hover {
  background: #fafbfc;
}
.version-item.selected {
  background: #f0f4f8;
  border-left: 3px solid #2c3b5a;
}
.version-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1cdc5;
  flex-shrink: 0;
  transition: background 0.2s;
}
.version-item.selected .version-dot {
  background: #2c3b5a;
  box-shadow: 0 0 0 3px rgba(44,59,90,0.15);
}
.version-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: #2c3b5a;
  min-width: 28px;
  flex-shrink: 0;
}
.version-time {
  font-size: 0.826rem;
  color: #999;
  flex-shrink: 0;
  min-width: 78px;
}
.version-preview {
  font-size: 0.897rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.version-action {
  font-size: 0.85rem;
  color: #8b6f47;
  font-weight: 500;
  flex-shrink: 0;
}
.version-empty {
  padding: 24px 16px;
  text-align: center;
  color: #bbb;
  font-size: 0.944rem;
}

.hidden { display: none !important; }
