﻿:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #e5e1d8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 18px 50px rgba(31, 41, 51, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(245, 158, 11, 0.16), transparent 28rem),
    var(--bg);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.brand { display: flex; gap: 16px; align-items: center; margin-bottom: 26px; }
.brand-mark {
  width: 54px; height: 54px; border-radius: 18px;
  display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 24px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}
h1, h2, h3, p { margin: 0; }
.brand h1 { font-size: 28px; }
.brand p, .hint, .sidebar p, .eyebrow { color: var(--muted); }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 14px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  background: white;
}
.primary, .ghost, .link, .danger {
  border: 0;
  border-radius: 14px;
  padding: 11px 15px;
  font-weight: 700;
}
.primary { background: var(--primary); color: white; }
.primary:hover { background: var(--primary-dark); }
.ghost { background: #f3f4f6; color: var(--text); }
.ghost:hover { background: #e5e7eb; }
.link { width: 100%; margin-top: 14px; color: var(--primary); background: transparent; }
.danger { background: #fee2e2; color: var(--danger); }
.hint { margin-top: 12px; font-size: 13px; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px 1fr;
}
.sidebar {
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,.62);
  backdrop-filter: blur(20px);
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.system-categories {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.sidebar-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.sidebar-top h1 { font-size: 26px; }
.sidebar-actions { display: flex; gap: 8px; align-items: center; }
.category-header {
  margin: 22px 4px 10px 8px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.new-category-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--panel-strong);
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(31, 41, 51, 0.06);
}
.new-category-btn:hover { border-color: rgba(37, 99, 235, 0.35); background: #eff6ff; }

.category-header-actions { display: flex; align-items: center; gap: 8px; }

.manage-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(31, 41, 51, 0.06);
}
.manage-btn:hover { border-color: rgba(37, 99, 235, 0.35); background: #eff6ff; color: var(--primary); }
.manage-btn.active {
  border-color: rgba(37, 99, 235, 0.45);
  background: #eff6ff;
  color: var(--primary);
}
.category-list { display: grid; gap: 8px; }
.category {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 14px;
  padding: 11px 12px;
  color: var(--text);
  text-align: left;
}
/* 管理模式下行内更挤，左右内边距收一点，把宽度让给栏目名 */
.category-list.manage-mode .category { padding: 11px 8px; }
.category:hover { background: rgba(255,255,255,.7); }
.category.active {
  background: var(--panel-strong);
  border-color: var(--line);
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
}
.category span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category small {
  color: var(--muted);
  background: #f3f4f6;
  border-radius: 999px;
  padding: 2px 8px;
}
.tiny {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  padding: 0;
  color: var(--muted);
  background: transparent;
}
.tiny svg { width: 17px; height: 17px; stroke: currentColor; }
.tiny:hover { background: #f3f4f6; color: var(--text); }
.tiny.danger-icon:hover { background: #fee2e2; color: var(--danger); }

.content { padding: 28px; min-width: 0; }
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 22px;
}
.toolbar h2 { font-size: clamp(28px, 4vw, 42px); letter-spacing: -1px; }
.eyebrow { font-weight: 800; margin-bottom: 4px; }
.toolbar-actions { display: flex; gap: 12px; align-items: center; }
.toolbar-actions input { width: min(320px, 36vw); }
.message {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  background: #eff6ff;
}
.notes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.note-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  min-height: 170px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(31, 41, 51, .08);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .16s, box-shadow .16s;
  position: relative;
}
.note-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.note-card h3 { font-size: 20px; word-break: break-word; }
.note-remark {
  color: #4b5563;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  flex: 1;
}
.note-meta { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.pill {
  align-self: flex-start;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty {
  margin: 70px auto;
  text-align: center;
  color: var(--muted);
}
.empty div { font-size: 48px; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }

#profileDialog,
#categoryDialog,
#noteDialog {
  width: min(560px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0;
  box-shadow: var(--shadow);
}
#profileDialog::backdrop,
#categoryDialog::backdrop,
#noteDialog::backdrop { background: rgba(15, 23, 42, .38); backdrop-filter: blur(4px); }
.profile-form,
.category-dialog-form,
.note-form { padding: 22px; display: grid; gap: 14px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.icon { border: 0; background: transparent; font-size: 28px; line-height: 1; color: var(--muted); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .category-list, .sidebar { }
  .category-row { grid-template-columns: auto minmax(0, 1fr); }
  .category-list.manage-mode .category-row { grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions input { width: 100%; }
}

@media (max-width: 560px) {
  .auth-card, .content, .sidebar { padding: 18px; }
  .toolbar-actions { flex-direction: column; align-items: stretch; }
  .notes-list { grid-template-columns: 1fr; }
  .sidebar-top { align-items: center; }
  .category-header { flex-wrap: wrap; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .primary, .form-actions .ghost, .form-actions .danger { flex: 1; }
}


.admin-entry {
  margin-top: 18px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.55);
  font-weight: 800;
}

.note-card.completed {
  opacity: 0.6;
}

.note-card.completed h3 {
  text-decoration: line-through;
  color: var(--muted);
  text-align: center;
}

.note-card.archived {
  opacity: 0.7;
  border: 1px dashed var(--muted);
  background: rgba(243, 244, 246, 0.5);
}

.note-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  position: absolute;
  top: 18px;
  right: 18px;
}

.complete-btn, .tiny {
  border: 0;
  background: transparent;
  padding: 4px;
  cursor: pointer;
  color: var(--muted);
  transition: color .16s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.complete-btn {
  width: 28px;
  height: 28px;
  border: 2px solid #d1d5db;
  border-radius: 6px;
  background: white;
  padding: 0;
  cursor: pointer;
  transition: all .16s;
}

.complete-btn:hover {
  border-color: #9ca3af;
}

.complete-btn.completed {
  border-color: #10b981;
  background: white;
  color: #10b981;
}

.complete-btn svg, .tiny svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.complete-btn.completed svg {
  width: 18px;
  height: 18px;
}

.tiny:hover {
  color: var(--text);
}

.danger-icon {
  color: var(--danger);
}

.priority-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.priority-badge[data-priority="urgent-important"] {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

.priority-badge[data-priority="important"] {
  background: #fef3c7;
  color: #d97706;
  border: 1px solid #fcd34d;
}

.priority-badge[data-priority="urgent"] {
  background: #dbeafe;
  color: #2563eb;
  border: 1px solid #93c5fd;
}

.priority-badge[data-priority="neither"] {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #d1d5db;
}

/* 栏目名所在的轨道必须用 minmax(0, 1fr)：裸 1fr 的自动最小宽度是内容宽度，
   长栏目名会把整行撑宽、把右侧图标顶出侧边栏。minmax(0, …) 才允许收缩并触发省略号。 */
.category-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.category-list.manage-mode .category-row {
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 4px;
}

/* 管理模式下图标收小一点，给栏目名多留些宽度 */
.category-list.manage-mode .tiny {
  width: 30px;
  height: 30px;
}

.drag-handle {
  border: 0;
  background: transparent;
  padding: 4px;
  cursor: grab;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .16s;
}

.drag-handle:hover {
  color: var(--text);
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.category-row {
  transition: opacity .16s, background .16s, box-shadow .16s;
}

.category-row.dragging {
  opacity: 0.35;
  border-radius: 14px;
}

.category-row.dragging-active {
  box-shadow: 0 8px 30px rgba(37, 99, 235, 0.18);
  background: white;
  z-index: 100;
  border-radius: 14px;
}

.archive-block {
  margin-bottom: 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(31, 41, 51, .06);
}

.archive-block-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .3px;
}

#archivedNotesTitle { margin-top: 4px; }

.archived-category-list { display: grid; gap: 10px; }

.archived-category-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(243, 244, 246, .6);
}

.archived-category-card h3 {
  font-size: 17px;
  margin-bottom: 6px;
  color: var(--muted);
}

.archived-category-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 13px;
}

.archived-category-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.archived-category-actions button {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.archive-empty {
  color: var(--muted);
  font-size: 13px;
}

.drag-indicator {
  height: 3px;
  margin: -2px 8px;
  background: var(--primary);
  border-radius: 2px;
  transition: all .12s;
}

.quadrant-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 16px;
  min-height: 600px;
}

.quadrant {
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .16s, background .16s;
}

.quadrant.drag-over {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.quadrant-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.quadrant-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.quadrant-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.quadrant-notes {
  display: grid;
  gap: 10px;
  overflow-y: auto;
}

.note-card-mini {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: white;
  cursor: move;
  transition: transform .16s, box-shadow .16s;
}

.note-card-mini:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(31, 41, 51, .1);
}

.note-card-mini.dragging {
  opacity: 0.5;
}

.note-card-mini.completed {
  opacity: 0.5;
}

.note-card-mini h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.note-card-mini.completed h4 {
  text-decoration: line-through;
  color: var(--muted);
}

.note-card-mini p {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.quick-capture {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: stretch;
  margin: -6px 0 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(31, 41, 51, .06);
}
.quick-capture textarea {
  min-height: 54px;
  max-height: 130px;
  border: 0;
  background: transparent;
  box-shadow: none;
  resize: vertical;
  padding: 10px 8px;
  font-size: 17px;
}
.quick-capture textarea:focus { box-shadow: none; }
.quick-capture button { align-self: center; min-width: 86px; }
.users-view { min-width: 0; }
.user-create-card {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(31, 41, 51, .06);
}
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  white-space: nowrap;
}
.check-label input { width: auto; }
.users-list { display: grid; gap: 12px; }
.user-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}
.user-card h3 { font-size: 18px; margin-bottom: 6px; }
.user-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}
.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.user-actions button { padding: 9px 12px; border-radius: 12px; }
.admin-badge {
  display: inline-flex;
  margin-left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 860px) {
  .user-create-card { grid-template-columns: 1fr 1fr; }
  .user-card { grid-template-columns: 1fr; }
  .user-actions { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .quick-capture { grid-template-columns: 1fr; }
  .quick-capture button { width: 100%; }
  .user-create-card { grid-template-columns: 1fr; }
  .check-label { padding-bottom: 0; }
  .archived-category-card { grid-template-columns: 1fr; }
  .archived-category-actions button { flex: 1; }
}
