/* ========== 螃友备忘录 V3 - 专业版 ========== */
:root {
  --bg-primary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-success: #059669;
  --accent-success-bg: #d1fae5;
  --accent-warning: #d97706;
  --accent-warning-bg: #fef3c7;
  --accent-danger: #dc2626;
  --accent-danger-bg: #fee2e2;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== 登录页 ========== */
#loginOverlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 40%, #334155 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}
#loginOverlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

#loginBox {
  position: relative;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.2);
}
#loginBox h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
#loginBox p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}
#loginBox input[type="password"] {
  width: 100%;
  padding: 14px 18px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 16px;
  outline: none;
  background: var(--bg-surface);
  transition: var(--transition);
  font-family: var(--font-sans);
}
#loginBox input[type="password"]:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
#loginBox .remember-row {
  display: flex;
  align-items: center;
  margin: 20px 0;
  gap: 10px;
  font-size: 14px;
  color: var(--text-secondary);
}
#loginBox .remember-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}
#loginBox button {
  width: 100%;
  padding: 14px;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
#loginBox button:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
#loginBox .error {
  color: var(--accent-danger);
  font-size: 13px;
  margin-top: 16px;
  display: none;
  font-weight: 500;
}

/* ========== 头部 ========== */
.header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 20px 24px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}
.header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.header .date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ========== 工具栏 ========== */
.toolbar {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}
.toolbar button, .toolbar a {
  padding: 8px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  transition: var(--transition);
}
.toolbar button:hover, .toolbar a:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(37,99,235,0.04);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn-add {
  background: var(--accent-primary) !important;
  color: #fff !important;
  border-color: var(--accent-primary) !important;
}
.btn-add:hover {
  background: var(--accent-primary-hover) !important;
  color: #fff !important;
}

/* ========== 搜索栏 ========== */
.search-wrap {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
.search-input {
  flex: 1;
  min-width: 200px;
  padding: 9px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  background: var(--bg-surface);
  transition: var(--transition);
  font-family: var(--font-sans);
  color: var(--text-primary);
}
.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}
.search-input::placeholder {
  color: var(--text-muted);
}
#sortSelect {
  padding: 9px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
#sortSelect:focus {
  border-color: var(--accent-primary);
}

/* ========== 容器 ========== */
.container {
  max-width: 800px;
  margin: 24px auto;
  padding: 0 20px;
}

/* ========== 卡片 ========== */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to right, var(--bg-surface), #fafbfc);
}
.card-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.count {
  background: var(--accent-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.count.done {
  background: var(--accent-success);
}

/* ========== 列表 ========== */
.list { list-style: none }
.list li {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
  flex-wrap: wrap;
  transition: var(--transition);
  position: relative;
}
.list li:last-child { border-bottom: none }
.list li:hover {
  background: #f8fafc;
}
.list li.done .item-text {
  text-decoration: line-through;
  color: var(--text-muted);
}
.list li.pinned {
  background: linear-gradient(to right, #fffbeb, #fff);
  border-left: 3px solid var(--accent-warning);
}
.list li.pinned:hover {
  background: linear-gradient(to right, #fef3c7, #fffbeb);
}

.checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  cursor: pointer;
}
.checkbox:hover {
  border-color: var(--accent-success);
}
.list li.done .checkbox {
  background: var(--accent-success);
  border-color: var(--accent-success);
}
.list li.done .checkbox:after {
  content: "✓";
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.item-text {
  font-size: 15px;
  line-height: 1.6;
  flex: 1;
  white-space: pre-wrap;
  min-width: 200px;
  color: var(--text-primary);
}
.item-id {
  color: var(--text-muted);
  font-size: 11px;
  min-width: 28px;
  font-weight: 600;
  margin-top: 3px;
  font-family: var(--font-mono);
}
.pin-btn {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  opacity: 0.3;
  cursor: pointer;
  transition: var(--transition);
  padding: 2px 4px;
  border-radius: 4px;
}
.pin-btn:hover {
  opacity: 0.8;
  background: var(--accent-warning-bg);
}
.pin-btn.pinned {
  opacity: 1;
  color: var(--accent-warning);
}

.attach-indicator {
  background: var(--accent-warning-bg);
  color: var(--accent-warning);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  letter-spacing: 0.3px;
}

.plabel {
  padding: 10px 24px;
  font-size: 12px;
  color: var(--accent-warning);
  font-weight: 700;
  background: linear-gradient(to right, #fffbeb, #fff);
  border-bottom: 1px solid #fde68a;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.plabel.normal {
  background: var(--bg-primary);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

/* 置顶标签 */
.pin-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-warning);
  background: var(--accent-warning-bg);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state-text {
  font-size: 15px;
  font-weight: 500;
}

/* ========== 底部 ========== */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ========== 消息提示 ========== */
.msg {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--text-primary);
  color: #fff;
  padding: 10px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  letter-spacing: 0.3px;
}
.msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== 附件 ========== */
.attachments {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  width: 100%;
  border: 1px solid var(--border-light);
}
.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}
.attachment-item:last-child { border-bottom: none }
.attachment-item img {
  max-width: 48px;
  max-height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-light);
}
.attachment-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-weight: 500;
}
.attachment-size {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.attachment-delete {
  color: var(--accent-danger);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.attachment-delete:hover {
  background: var(--accent-danger-bg);
}
.attach-input-wrap {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex }
.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.modal textarea {
  width: 100%;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 15px;
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: var(--transition);
  line-height: 1.6;
}
.modal textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}
.modal textarea::placeholder {
  color: var(--text-muted);
}
.modal-btns {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}
.modal-btns button {
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-sans);
}
.modal-btns .btn-cancel {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.modal-btns .btn-cancel:hover {
  background: var(--border-light);
  color: var(--text-primary);
}
.modal-btns .btn-confirm {
  background: var(--accent-primary);
  color: #fff;
}
.modal-btns .btn-confirm:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ========== 预览弹窗 ========== */
.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 20000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.preview-modal.show { display: flex }
.preview-modal img {
  max-width: 92%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}
.preview-modal .close-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(4px);
  transition: var(--transition);
}
.preview-modal .close-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.1);
}
.preview-filename {
  color: rgba(255,255,255,0.8);
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ========== 语音 ========== */
.voice-btn {
  padding: 8px 16px;
  background: var(--accent-danger-bg);
  color: var(--accent-danger);
  border: 1.5px solid var(--accent-danger-bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  font-family: var(--font-sans);
}
.voice-btn:hover {
  background: var(--accent-danger);
  color: #fff;
  border-color: var(--accent-danger);
}
.voice-btn.recording {
  background: var(--accent-danger);
  color: #fff;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  50% { opacity: 0.85; box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}
.voice-tip {
  font-size: 12px;
  color: var(--accent-danger);
  margin-top: 8px;
  display: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.voice-tip.show { display: flex }
.voice-tip::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent-danger);
  border-radius: 50%;
  animation: blink 1s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1 } 50% { opacity: 0.3 } }

.pin-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-sans);
}
.pin-toggle-btn:hover {
  border-color: var(--accent-warning);
  color: var(--accent-warning);
}
.pin-toggle-btn.pinned {
  background: var(--accent-warning-bg);
  color: var(--accent-warning);
  border-color: #fcd34d;
}

/* ========== 其他 ========== */
#fileInput { display: none }
.main-content { display: none }

/* ========== 响应式 ========== */
@media (max-width: 640px) {
  .header { padding: 16px }
  .header h1 { font-size: 20px }
  .container { margin: 16px auto; padding: 0 12px }
  .card-header { padding: 12px 16px }
  .list li { padding: 12px 16px }
  .toolbar button, .toolbar a { padding: 7px 14px; font-size: 12px }
  .modal { padding: 20px; border-radius: var(--radius-lg) }
  #loginBox { padding: 36px 28px }
}

/* ========== 滚动条美化 ========== */
::-webkit-scrollbar { width: 6px; height: 6px }
::-webkit-scrollbar-track { background: transparent }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 999px }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted) }
