:root {
  --bg: #050316;
  --bg-soft: rgba(15, 23, 42, 0.86);
  --bg-soft-alt: rgba(15, 23, 42, 0.96);
  --border-subtle: rgba(148, 163, 184, 0.4);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --accent: #f97316;
  --accent-alt: #a855f7;
  --accent-soft: rgba(248, 250, 252, 0.08);
  --note-paper: #111827;
  --note-paper-edge: rgba(249, 250, 251, 0.08);
  --radius-lg: 18px;
  --shadow-soft: 0 24px 60px rgba(15, 23, 42, 0.85);
}

:root.light {
  --bg: #f8fafc;
  --bg-soft: rgba(255, 255, 255, 0.9);
  --bg-soft-alt: rgba(255, 255, 255, 0.9);
  --border-subtle: rgba(148, 163, 184, 0.3);
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent: #7c3aed;
  --accent-alt: #ec4899;
  --accent-soft: rgba(129, 140, 248, 0.08);
  --note-paper: #f9fafb;
  --note-paper-edge: rgba(15, 23, 42, 0.06);
  --shadow-soft: 0 22px 50px rgba(15, 23, 42, 0.16);
}

/* 全局 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.18) 0, transparent 55%),
    radial-gradient(circle at 100% 0%, rgba(236, 72, 153, 0.22) 0, transparent 60%),
    radial-gradient(circle at 50% 100%, rgba(30, 64, 175, 0.7) 0, var(--bg) 60%);
  color: var(--text-main);
}

/* 星空层 */
.stars {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(248, 250, 252, 0.6), transparent),
    radial-gradient(1px 1px at 80% 10%, rgba(248, 250, 252, 0.4), transparent),
    radial-gradient(2px 2px at 30% 70%, rgba(129, 140, 248, 0.5), transparent),
    radial-gradient(1px 1px at 60% 40%, rgba(248, 250, 252, 0.6), transparent),
    radial-gradient(1px 1px at 90% 80%, rgba(248, 250, 252, 0.5), transparent);
  opacity: 0.9;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 22px 16px 32px;
}

/* Header */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.3), transparent 55%),
    rgba(15, 23, 42, 0.92);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.8);
}

:root.light .logo {
  background: radial-gradient(circle at top left, rgba(129, 140, 248, 0.3), transparent 55%),
    rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
}

.logo-glyph {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(248, 250, 252, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.logo-sub {
  font-size: 11px;
  color: rgba(226, 232, 240, 0.8);
}

:root.light .logo-sub {
  color: #6b7280;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-box {
  min-width: 220px;
  flex: 1;
}

.search-box input {
  width: 100%;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

:root.light .search-box input {
  background: rgba(255, 255, 255, 0.96);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  border-color: rgba(129, 140, 248, 0.7);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.6);
}

.btn-ghost {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  font-size: 13px;
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
  cursor: pointer;
  backdrop-filter: blur(10px);
}

:root.light .btn-ghost {
  background: rgba(255, 255, 255, 0.9);
}

.btn-ghost:hover {
  background: var(--accent-soft);
}

.btn-primary {
  border-radius: 999px;
  border: none;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  color: #f9fafb;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.8);
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.9);
}
/* Tag bar */

.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.tag-chip {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text-muted);
  cursor: pointer;
}

:root.light .tag-chip {
  background: rgba(255, 255, 255, 0.9);
}

.tag-chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  border-color: transparent;
  color: #f9fafb;
}

/* Main */

.main {
  border-radius: var(--radius-lg);
  background: var(--bg-soft-alt);
  border: 1px solid rgba(148, 163, 184, 0.5);
  box-shadow: var(--shadow-soft);
  padding: 12px 12px 16px;
}

:root.light .main {
  background: var(--bg-soft);
}

.notes-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

/* Note card */

.note-card {
  position: relative;
  border-radius: 16px;
  padding: 10px 10px 9px;
  background:
    linear-gradient(to bottom, rgba(148, 163, 184, 0.1), transparent),
    radial-gradient(circle at top left, rgba(129, 140, 248, 0.25), transparent 55%),
    var(--note-paper);
  border: 1px solid var(--note-paper-edge);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.14s ease-out, box-shadow 0.14s ease-out,
    border-color 0.14s ease-out, background 0.14s ease-out;
}

.note-card::before {
  /* 侧边残页效果 */
  content: "";
  position: absolute;
  inset: 0 -60px auto auto;
  height: 16px;
  background: linear-gradient(
    to right,
    transparent,
    rgba(248, 250, 252, 0.25),
    transparent
  );
  opacity: 0.15;
  pointer-events: none;
}

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.8);
  border-color: rgba(248, 250, 252, 0.2);
}

.note-title {
  font-size: 14px;
  font-weight: 600;
}

.note-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.note-snippet {
  font-size: 12px;
  color: rgba(226, 232, 240, 0.92);
  line-height: 1.5;
  max-height: 3.1em;
  overflow: hidden;
}

:root.light .note-snippet {
  color: #4b5563;
}

.note-tags {
  margin-top: 2px;
  font-size: 11px;
  color: rgba(248, 250, 252, 0.8);
}

:root.light .note-tags {
  color: #6b7280;
}

/* Footer */

.footer {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Viewer */

.note-viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-viewer.hidden {
  display: none;
}

.note-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
}

.note-viewer-dialog {
  position: relative;
  z-index: 1;
  max-width: 700px;
  width: 100%;
  max-height: 88vh;
  border-radius: 20px;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.25), transparent 60%),
    radial-gradient(circle at bottom right, rgba(236, 72, 153, 0.22), transparent 65%),
    #020617;
  border: 1px solid rgba(148, 163, 184, 0.7);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.9);
  padding: 14px 16px 16px;
}

.note-viewer-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: rgba(15, 23, 42, 0.85);
  color: #e5e7eb;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
}

.note-viewer-scroll {
  max-height: 80vh;
  overflow: auto;
  padding-right: 4px;
}

.note-viewer-header {
  margin-bottom: 8px;
}

.nv-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.nv-meta {
  font-size: 12px;
  color: #9ca3af;
  display: flex;
  gap: 10px;
}

.nv-body {
  font-size: 14px;
  line-height: 1.7;
  color: #e5e7eb;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

.editor {
  border-radius: 16px;
  padding: 10px 10px 12px;
  margin-bottom: 10px;
  background:
    linear-gradient(to bottom, rgba(148, 163, 184, 0.18), transparent),
    var(--bg-soft);
  border: 1px solid rgba(148, 163, 184, 0.6);
}

:root.light .editor {
  background: rgba(255, 255, 255, 0.95);
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.editor-title {
  font-size: 14px;
  font-weight: 600;
}

.editor-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}

.editor-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.editor-row label {
  font-size: 12px;
  color: var(--text-muted);
}

.editor-row input,
.editor-row textarea {
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
  font-size: 13px;
  padding: 6px 8px;
  outline: none;
  resize: vertical;
}

:root.light .editor-row input,
:root.light .editor-row textarea {
  background: rgba(255, 255, 255, 0.96);
}

.editor-row input:focus,
.editor-row textarea:focus {
  border-color: rgba(129, 140, 248, 0.7);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.4);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.nv-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.nv-delete {
  font-size: 12px;
  padding: 4px 10px;
  border-color: rgba(239, 68, 68, 0.6);
  color: #fca5a5;
}

:root.light .nv-delete {
  color: #b91c1c;
}

.nv-delete:hover {
  background: rgba(239, 68, 68, 0.12);
}
/* Responsive */

@media (max-width: 900px) {
  .notes-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    width: 100%;
  }

  .notes-grid {
    grid-template-columns: 1fr;
  }

  .note-viewer-dialog {
    max-width: 94vw;
  }
}