/* ===== NexusMind · 10秒核心记忆库 ===== */
/* 毛玻璃 · 蓝紫渐变 · 极简未来感 */

:root {
  --bg-start: #0f0c29;
  --bg-mid: #1a1542;
  --bg-end: #2d1b4e;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.7);
  --accent: #7c5cff;
  --accent-soft: rgba(124, 92, 255, 0.35);
  --accent-cyan: #5ce1e6;
  --radius: 16px;
  --radius-sm: 10px;
  --font-sans: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: linear-gradient(160deg, var(--bg-start) 0%, var(--bg-mid) 45%, var(--bg-end) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* 背景装饰（可选光晕） */
.bg-gradient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124, 92, 255, 0.2), transparent),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(92, 124, 255, 0.12), transparent),
    radial-gradient(ellipse 50% 30% at 0% 80%, rgba(92, 200, 255, 0.08), transparent);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 24px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== 右上角：登录 / 用户状态 ===== */
.top-bar {
  position: absolute;
  top: clamp(16px, 4vw, 24px);
  right: clamp(16px, 4vw, 24px);
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.btn-login {
  padding: 8px 16px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s, border-color 0.2s;
}

.btn-login:hover {
  opacity: 0.95;
  border-color: var(--accent);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-name {
  font-size: 0.9rem;
  color: var(--accent-cyan);
}

.btn-logout {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s;
}

.btn-logout:hover {
  opacity: 0.9;
}

.auth-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  margin: 0;
  padding: 0;
  min-width: 280px;
  max-width: 90vw;
  border-radius: var(--radius);
  overflow: hidden;
}

.auth-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 0;
  margin-bottom: 8px;
}

.auth-panel-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s, color 0.2s;
}

.auth-panel-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.auth-panel .auth-tabs {
  display: flex;
  gap: 0;
  padding: 0;
  margin: 0;
  flex: 1;
}

.auth-panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 16px 4px;
}

.auth-panel-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0 16px 12px;
  line-height: 1.4;
}

.auth-panel-body {
  min-height: 152px;
  padding: 0 16px 8px;
  position: relative;
}

.auth-panel .auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  left: 16px;
  right: 16px;
  top: 0;
  transition: opacity 0.2s ease;
}

.auth-panel .auth-form.auth-form--active {
  opacity: 1;
  pointer-events: auto;
  position: relative;
  left: 0;
  right: 0;
}

.auth-panel .auth-form input,
.auth-panel .auth-form .btn {
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
}

.auth-panel .auth-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0 16px 16px;
  padding: 0;
  line-height: 1.4;
}

/* 未登录时上传区：引导登录 */
.upload-login-prompt {
  text-align: center;
  padding: 28px 20px;
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.upload-login-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.upload-login-prompt .btn-primary {
  margin: 0;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.auth-tabs {
  display: flex;
  gap: 0;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}

.auth-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--accent), #5c7cff);
  color: #fff;
}

.auth-tab.active:hover {
  opacity: 0.95;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
}

.auth-form input::placeholder {
  color: var(--text-secondary);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-block {
  width: 100%;
  margin-top: 4px;
}

.auth-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 12px;
  margin-bottom: 0;
}

/* ===== 毛玻璃卡片 ===== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
}

/* ===== Header ===== */
.header {
  text-align: center;
  padding: clamp(24px, 5vw, 40px) 0;
  padding-top: 52px;
}

.logo {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.tagline {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ===== Main ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--glass-border);
}

/* ===== Chat 区域 ===== */
.chat-section {
  padding: 20px;
}

.chat-messages {
  min-height: 120px;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.chat-welcome {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.chat-welcome p + p {
  margin-top: 8px;
}

.chat-msg {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.chat-msg.user {
  background: var(--accent-soft);
  margin-left: 0;
  margin-right: 24px;
}

.chat-msg.ai {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  margin-left: 24px;
  margin-right: 0;
}

.chat-input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.8;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #5c7cff);
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}

.btn-send:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px var(--accent-soft);
}

.btn-send:active {
  transform: scale(0.98);
}

/* ===== Upload 区域 ===== */
.upload-section {
  padding: 20px;
}

.memory-section {
  padding: 20px;
}

.memory-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.memory-tab {
  padding: 8px 16px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}

.memory-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.memory-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.memory-list-wrap {
  margin-top: 0;
}

.memory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-list-empty {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
  padding: 12px 0;
}

.memory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.memory-item-name {
  font-size: 0.9rem;
  color: var(--text-primary);
  word-break: break-all;
  flex: 1;
  min-width: 0;
}

.btn-memory-delete {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 100, 100, 0.2);
  border: 1px solid rgba(255, 100, 100, 0.4);
  color: #ff9999;
  cursor: pointer;
  font-family: inherit;
}

.btn-memory-delete:hover {
  background: rgba(255, 100, 100, 0.3);
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.upload-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 20px;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.upload-icon {
  font-size: 1.75rem;
  color: var(--accent-cyan);
  opacity: 0.9;
}

.upload-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* 分类选择 */
.form-step {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.category-card {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.category-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.category-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.category-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.category-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.input-tags {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 14px;
  font-size: 0.9rem;
  font-family: inherit;
}

.input-tags:focus {
  outline: none;
  border-color: var(--accent);
}

.md-preview {
  width: 100%;
  min-height: 100px;
  max-height: 200px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 0.8rem;
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
  color: var(--accent-cyan);
  white-space: pre-wrap;
  word-break: break-word;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
}

.btn:hover {
  opacity: 0.95;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5c7cff);
  border: none;
  color: #fff;
}

.btn-primary:hover {
  box-shadow: 0 4px 16px var(--accent-soft);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

/* Footer */
.footer {
  padding: 20px 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* 移动端 */
@media (max-width: 600px) {
  .category-grid {
    grid-template-columns: 1fr;
  }

  .chat-msg.user {
    margin-right: 12px;
  }

  .chat-msg.ai {
    margin-left: 12px;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}
