* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #5b7cfa;
  --primary-dark: #4c6ef5;
  --danger-color: #ff6b6b;
  --success-color: #51cf66;
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --border-color: #e1e4e8;
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fb;
  --bg-light: #f8f9fa;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
    "Ubuntu", "Cantarell", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: var(--text-primary);
  overflow: hidden;
}

.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
  margin: 6px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* ====== 头部样式 ====== */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
}

.header-left h1.app-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.5px;
}

.header-left .app-subtitle {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 4px;
  font-weight: 400;
}

.header-stats {
  display: flex;
  gap: 24px;
  align-items: center;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.15);
  padding: 8px 14px;
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.stat-label {
  font-size: 12px;
  opacity: 0.9;
  font-weight: 500;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
}

.save-status {
  gap: 6px !important;
  background: rgba(81, 207, 102, 0.2) !important;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #51cf66;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.status-text {
  font-size: 12px;
  font-weight: 500;
}

/* ====== 工具栏样式 ====== */
.toolbar {
  display: flex;
  gap: 16px;
  padding: 16px 32px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
}

.toolbar-search {
  flex: 1;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s ease;
  background: var(--bg-light);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-primary);
  box-shadow: 0 0 0 4px rgba(91, 124, 250, 0.1);
}

.toolbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
}

.btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background: #ff5252;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-color);
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.btn-icon {
  font-size: 16px;
}

.btn-text {
  display: none;
}

@media (min-width: 1024px) {
  .btn-text {
    display: inline;
  }
}

/* ====== 主容器 ====== */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* ====== 侧边栏 ====== */
.sidebar {
  width: 300px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.note-item {
  padding: 14px;
  margin-bottom: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.note-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
  transform: translateX(4px);
}

.note-item.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.note-item.active .note-item-title,
.note-item.active .note-item-preview,
.note-item.active .note-item-date {
  color: white;
  opacity: 0.95;
}

.note-item-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-preview {
  font-size: 12px;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.note-item-date {
  font-size: 11px;
  opacity: 0.5;
}

/* ====== 编辑区 ====== */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

.empty-state {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: var(--text-secondary);
  padding: 40px;
  text-align: center;
}

.empty-icon {
  font-size: 80px;
  margin-bottom: 24px;
  opacity: 0.4;
}

.empty-state h2 {
  font-size: 22px;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 14px;
  opacity: 0.8;
  max-width: 300px;
}

.empty-state strong {
  color: var(--primary-color);
  font-weight: 600;
}

.editor-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  gap: 0;
}

/* ====== 编辑器标题栏 ====== */
.editor-title-bar {
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.note-title {
  width: 100%;
  font-size: 28px;
  font-weight: 700;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding: 0;
  letter-spacing: -0.5px;
}

.note-title::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

.title-bar-info {
  display: flex;
  gap: 24px;
}

.time-info {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ====== 编辑工具栏 ====== */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 32px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
}

.toolbar-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.tool-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  color: var(--text-primary);
}

.tool-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(91, 124, 250, 0.05);
}

.tool-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 4px;
}

.spacer {
  flex: 1;
}

/* ====== 编辑区 (文本框) ====== */
.note-content {
  flex: 1;
  padding: 32px;
  border: none;
  background: var(--bg-primary);
  font-size: 16px;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", "Courier New", monospace;
  resize: none;
  line-height: 1.8;
  color: var(--text-primary);
  overflow-y: auto;
  outline: none;
}

.note-content::placeholder {
  color: var(--text-secondary);
  opacity: 0.4;
}

/* ====== 编辑器底部栏 ====== */
.editor-footer {
  display: flex;
  gap: 24px;
  padding: 16px 32px;
  background: var(--bg-light);
  border-top: 1px solid var(--border-color);
  align-items: flex-start;
}

.footer-left {
  flex: 1;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tags-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tags-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.tags-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(91, 124, 250, 0.1);
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  background: var(--primary-color);
  color: white;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.tag:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.tag-remove {
  cursor: pointer;
  font-weight: 700;
  opacity: 0.8;
  margin-left: 4px;
}

.tag-remove:hover {
  opacity: 1;
}

.color-picker-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.color-picker {
  display: flex;
  gap: 8px;
}

.color-option {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  box-shadow: var(--shadow-sm);
}

.color-option:hover {
  transform: scale(1.15);
  border-color: var(--text-secondary);
}

.color-option.active {
  border-color: var(--primary-color);
  transform: scale(1.15);
  box-shadow: 0 0 0 3px rgba(91, 124, 250, 0.2);
}

/* ====== 消息提示 ====== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 16px 24px;
  background: var(--success-color);
  color: white;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  pointer-events: all;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast.success {
  background: var(--success-color);
}

.toast.error {
  background: var(--danger-color);
}

.toast.info {
  background: var(--primary-color);
}

/* ====== 滚动条美化 ====== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ====== 响应式设计 ====== */
@media (max-width: 1024px) {
  .sidebar {
    width: 280px;
  }

  .btn-text {
    display: none;
  }
}

@media (max-width: 768px) {
  .app-wrapper {
    margin: 0;
    border-radius: 0;
  }

  .header {
    padding: 16px;
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

  .header-stats {
    width: 100%;
    justify-content: space-between;
  }

  .toolbar {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }

  .toolbar-search {
    max-width: 100%;
  }

  .toolbar-actions {
    width: 100%;
  }

  .main-content {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .editor-title-bar,
  .editor-toolbar,
  .editor-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .note-content {
    padding: 16px;
  }

  .note-title {
    font-size: 22px;
  }
}
