/* ===== 暗夜铜色 · Neo-Noir Theme ===== */

/* --- 变量 --- */
:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-2: #1e1e1e;
  --surface-3: #242424;
  --border: #2a2a2a;
  --border-light: #333;
  --accent: #c4843c;
  --accent-hover: #d4944c;
  --accent-glow: rgba(196, 132, 60, 0.15);
  --accent-dim: rgba(196, 132, 60, 0.08);
  --text: #e8e6e3;
  --text-2: #8a8a8a;
  --text-3: #5a5a5a;
  --danger: #ef4444;
  --high: #c4843c;
  --medium: #6b7280;
  --low: #4ade80;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --radius: 10px;
  --radius-sm: 6px;
  --font-display: 'Noto Serif SC', 'Source Han Serif SC', 'Noto Serif CJK SC', serif;
  --font-body: 'Noto Sans SC', 'Source Han Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* --- 噪点纹理 --- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  opacity: 0.025;
}
.grain::after {
  content: '';
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  animation: grainShift 8s steps(8) infinite;
}
@keyframes grainShift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-5%, -3%); }
  50% { transform: translate(3%, -7%); }
  75% { transform: translate(-2%, 5%); }
  100% { transform: translate(0, 0); }
}

/* --- 布局 --- */
.app {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* --- 侧边栏 --- */
.sidebar {
  width: 220px;
  padding: 16px 0 16px 16px;
  flex-shrink: 0;
  position: relative;
}
.sidebar::before {
  content: '';
  position: absolute;
  right: 8px;
  top: 16px;
  bottom: 16px;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--border) 20%, var(--border) 80%, transparent);
}
.sidebar-inner {
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

/* Logo */
.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  color: #0f0f0f;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
}
.logo-text {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.logo-dot {
  width: 4px; height: 4px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.6;
}

/* 侧栏区块 */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 分隔线 */
.sidebar-divider {
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}
.section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 2px;
}
.section-label span:first-child {
  font-family: var(--font-body);
}
.btn-ghost {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 16px;
  cursor: pointer;
  width: 24px; height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-ghost:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

/* 快速筛选 */
.quick-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 2px;
}
.filter-list {
  display: flex;
  gap: 2px;
}
.filter-item {
  flex: 1;
  padding: 4px 2px;
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.filter-item:hover {
  background: var(--surface-3);
  color: var(--text-2);
}
.filter-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.prio-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.prio-indicator.high { background: var(--high); }
.prio-indicator.medium { background: var(--medium); }
.prio-indicator.low { background: var(--low); }

/* 分类条目 */
.category-item {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  color: var(--text-2);
  position: relative;
}
.category-item:hover {
  background: var(--surface-3);
  color: var(--text);
}
.category-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}
.category-item.active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}
.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 标签云 */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  background: var(--surface-3);
  color: var(--text-2);
}
.tag-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}
.tag-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* 底部统计 */
.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.stats-line {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stats-line span:first-child {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  font-size: 14px;
}
.stat-label {
  color: var(--text-3);
  font-size: 11px;
}

/* --- 主内容区 --- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 36px;
  overflow-y: auto;
  min-width: 0;
}
/* 自定义滚动条 */
.main::-webkit-scrollbar { width: 4px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.main::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* 顶部栏 */
.main-top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

/* 搜索框 */
.search-wrap {
  flex: 1;
  max-width: 360px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  color: var(--text-3);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  padding: 9px 32px 9px 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: all var(--transition);
}
.search-wrap input::placeholder { color: var(--text-3); }
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-clear {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.search-clear:hover { color: var(--text); background: var(--surface-3); }
.search-wrap input:not(:placeholder-shown) ~ .search-clear { display: flex; }

/* 按钮 */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-icon-plus {
  font-size: 14px;
  font-weight: 700;
}

.btn-secondary {
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover {
  border-color: var(--text-3);
  color: var(--text);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 16px;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-close:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* 事项计数 */
.todo-count {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 12px;
}
.todo-count span {
  color: var(--text-2);
}

/* --- 代办卡片 --- */
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 40px;
}

.todo-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  animation: cardIn 0.35s ease both;
}
.todo-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}
.todo-card.prio-high::before { background: var(--high); }
.todo-card.prio-medium::before { background: var(--medium); }
.todo-card.prio-low::before { background: var(--low); }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.todo-card:nth-child(1) { animation-delay: 0s; }
.todo-card:nth-child(2) { animation-delay: 0.03s; }
.todo-card:nth-child(3) { animation-delay: 0.06s; }
.todo-card:nth-child(4) { animation-delay: 0.09s; }
.todo-card:nth-child(5) { animation-delay: 0.12s; }

.todo-card:hover {
  border-color: var(--border-light);
  background: var(--surface-2);
  transform: translateX(3px);
}

.todo-card.completed {
  opacity: 0.4;
}
.todo-card.completed:hover {
  opacity: 0.55;
}
.todo-card.completed .todo-title {
  text-decoration: line-through;
  color: var(--text-3);
}

.todo-checkbox {
  appearance: none;
  width: 18px; height: 18px;
  border: 2px solid var(--border-light);
  border-radius: 50%;
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: all var(--transition);
}
.todo-checkbox:hover { border-color: var(--accent); }
.todo-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.todo-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4.5px; top: 2px;
  width: 5px; height: 9px;
  border: solid #0f0f0f;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.todo-content {
  flex: 1;
  min-width: 0;
}

.todo-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.todo-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
}

/* 优先级标签改为色条 + 文字 */
.prio-label {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.prio-high .prio-label { background: rgba(196, 132, 60, 0.15); color: var(--high); }
.prio-medium .prio-label { background: rgba(107, 114, 128, 0.15); color: var(--medium); }
.prio-low .prio-label { background: rgba(74, 222, 128, 0.12); color: var(--low); }

.todo-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-3);
  flex-wrap: wrap;
}
.todo-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.todo-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.todo-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}
.todo-card:hover .todo-actions {
  opacity: 1;
}
.todo-action-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  width: 28px; height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.todo-action-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.todo-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

/* --- 空状态 --- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-3);
}
.empty-state-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.4;
}
.empty-state p {
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text-2);
}
.empty-state .sub {
  font-size: 12px;
  color: var(--text-3);
}

/* --- 弹窗 --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: overlayIn 0.2s ease;
}
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

/* 表单 */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}
.required { color: var(--danger); }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: all var(--transition);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field textarea { resize: vertical; min-height: 70px; }
.field select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6' fill='none' stroke='%238a8a8a' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.field select option { background: var(--surface); }

.field-row {
  display: flex;
  gap: 12px;
}
.field-row .field {
  flex: 1;
}

/* 优先级选择器（弹窗内） */
.prio-selector {
  display: flex;
  gap: 4px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.prio-opt {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-3);
  transition: all var(--transition);
}
.prio-opt:hover { color: var(--text); }
.prio-opt.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.prio-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

/* 标签选择器（弹窗内） */
.tag-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag-option {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  background: var(--surface-3);
  color: var(--text-2);
}
.tag-option:hover {
  border-color: var(--text-3);
  color: var(--text);
}
.tag-option.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* 颜色选择器 */
.color-picker {
  display: flex;
  gap: 8px;
}
.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  background: var(--swatch);
  border: 3px solid transparent;
  transition: all var(--transition);
  position: relative;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--swatch);
}

/* 弹窗操作 */
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* --- 响应式 --- */
@media (max-width: 720px) {
  .sidebar {
    display: none;
  }
  .main {
    padding: 16px;
  }
  .main-top {
    flex-direction: column;
    align-items: stretch;
  }
  .search-wrap {
    max-width: none;
  }
  .field-row {
    flex-direction: column;
    gap: 0;
  }
  .modal {
    padding: 20px;
  }
}
