:root {
  color-scheme: dark;
  --page: #0e1120;
  --surface: #171b2e;
  --surface-deep: #121629;
  --surface-hover: #212741;
  --line: #2b3148;
  --text: #f0effb;
  --muted: #a0a7c0;
  --fine: #8992b0;
  --accent: #bbb0fa;
  --accent-text: #e4defe;
  --accent-wash: #23203c;
  --cyan: #91e5d6;
  --warning: #ffc38f;
  --shadow: 0 20px 55px rgb(5 7 19 / 28%);
  --sans: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f3f2fb;
  --surface: #ffffff;
  --surface-deep: #f7f6fd;
  --surface-hover: #efedf9;
  --line: #dfdced;
  --text: #20223a;
  --muted: #5e6482;
  --fine: #636b89;
  --accent: #644abc;
  --accent-text: #4f379e;
  --accent-wash: #eee8fe;
  --cyan: #137365;
  --warning: #974909;
  --shadow: 0 20px 55px rgb(64 49 128 / 9%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 70% -170px, color-mix(in srgb, var(--accent-wash) 75%, transparent), transparent 46rem), var(--page);
  color: var(--text);
  font: 400 15px/1.6 var(--sans);
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.skip-link {
  position: fixed;
  z-index: 9;
  top: 12px;
  left: 12px;
  padding: 8px 16px;
  transform: translateY(-160%);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
}
.skip-link:focus { transform: translateY(0); }

.site-header, .site-main, .site-footer { width: min(1160px, calc(100% - 64px)); margin-inline: auto; }
.site-header {
  min-height: 78px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
}
.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 11px;
  font-weight: 760;
  letter-spacing: .035em;
  line-height: 1.12;
}
.brand-mark {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 12px;
  color: var(--accent);
  background: var(--accent-wash);
  font-size: 22px;
}
.site-nav, .header-tools { display: flex; align-items: center; gap: 7px; }
.site-nav a {
  padding: 5px 15px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.site-nav a:hover, .site-nav [aria-current] { background: var(--surface-hover); color: var(--text); }
.header-tools { justify-self: end; gap: 11px; }
.theme-control, .manage-link {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}
.theme-control { color: var(--muted); background: var(--surface-deep); }
.theme-control span { font-size: 15px; color: var(--accent); }
.theme-control select { border: 0; background: transparent; color: inherit; min-width: 0; padding: 5px 0; }
.theme-control option { color: var(--text); background: var(--surface); }
.manage-link {
  color: var(--accent-text);
  padding-inline: 12px;
  background: var(--accent-wash);
  font-weight: 700;
}
.manage-link:hover { border-color: var(--accent); }

.hero {
  isolation: isolate;
  position: relative;
  min-height: clamp(300px, 31vw, 390px);
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid #3a3b5e;
  background: #171832;
  box-shadow: var(--shadow);
  color: #f7f4ff;
}
.hero-image, .hero::after { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-image { z-index: -2; object-fit: cover; object-position: 67% 50%; }
.hero::after {
  content: "";
  z-index: -1;
  background: linear-gradient(90deg, rgb(14 14 34 / 40%), rgb(14 14 34 / 7%) 47%, transparent 70%);
  pointer-events: none;
}
.hero-content { position: relative; padding: 44px clamp(30px, 5.2vw, 66px); }
.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 15px;
  color: #c6bcf1;
  font: 650 11px/1.4 var(--mono);
  letter-spacing: .13em;
}
.hero-eyebrow span {
  width: 16px;
  height: 1px;
  background: #a99bea;
}
.hero h1 {
  margin: 0;
  font: 800 clamp(48px, 6.8vw, 83px)/1.12 "Noto Serif SC", "Songti SC", "SimSun", serif;
  letter-spacing: -.035em;
  text-shadow: 0 4px 20px #14152d;
}
.hero h1 span { color: #b9a6ff; }
.hero-description { margin: 13px 0 22px; font-size: clamp(13px, 1.6vw, 16px); color: #ddd8ef; }
.hero-button {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  padding: 8px 14px;
  border: 1px solid #c2adfb;
  border-radius: 8px;
  background: #c4b3fb;
  color: #221843;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 5px 20px rgb(118 90 229 / 25%);
}
.hero-button:hover { background: #d3c7ff; }
.hero-button span { font-size: 16px; line-height: 1; }

.archive { margin-top: 28px; scroll-margin-top: 18px; }
.archive-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 21px clamp(16px, 3vw, 32px);
  margin-bottom: 19px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: radial-gradient(ellipse at 12% 0, var(--accent-wash), transparent 75%), var(--surface);
}
.archive-title { display: flex; align-items: center; gap: 13px; }
.archive-mark { color: var(--accent); font-size: clamp(18px, 2vw, 24px); }
.archive-heading h1 { font: 760 clamp(27px, 4vw, 42px)/1.2 "Noto Serif SC", "Songti SC", "SimSun", serif; margin: 0; letter-spacing: -.03em; }
.archive-heading p { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; }
.archive-heading strong { color: var(--accent-text); font: 650 14px/1 var(--mono); }

.archive-layout { display: grid; grid-template-columns: minmax(185px, 232px) minmax(0, 1fr); gap: 17px; align-items: start; }
.archive-rail { display: grid; gap: 13px; min-width: 0; }
.collection-card, .sync-card, .library { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; }
.collection-card { padding: 15px 11px 11px; }
.collection-card h2 { margin: 0 9px 11px; font-size: 14px; }
.collection-card nav { display: grid; gap: 3px; }
.collection-button {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  text-align: left;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.collection-button:hover { background: var(--surface-hover); }
.collection-button[aria-current="true"] { color: var(--accent-text); background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.collection-glyph { font-size: 13px; text-align: center; font-weight: 800; color: var(--accent); }
.collection-count { font: 650 11px/1 var(--mono); color: var(--fine); }
.sync-card { padding: 13px 15px; color: var(--muted); font-size: 12px; }
.sync-heading { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text); }
.status-dot { height: 7px; width: 7px; border-radius: 50%; background: var(--fine); }
.status-dot[data-state="connected"] { background: var(--cyan); box-shadow: 0 0 9px color-mix(in srgb, var(--cyan) 65%, transparent); }
.sync-card p { margin: 5px 0 0; }
.sync-date span { color: var(--fine); }
.text-button { border: 0; background: transparent; color: var(--accent); padding: 0; margin-top: 7px; font-size: 12px; }
.text-button:hover { text-decoration: underline; }

.library { padding: 14px 16px 7px; overflow: clip; }
.toolbar { display: grid; grid-template-columns: minmax(140px, 1fr) auto auto; gap: 8px; }
.search-box, .toolbar select {
  min-height: 40px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-deep);
  color: var(--text);
}
.search-box { display: flex; padding: 0 6px 0 11px; align-items: center; }
.search-box:focus-within { border-color: var(--accent); }
.search-field { display: flex; flex: 1; min-inline-size: 0; align-items: center; gap: 10px; }
.search-icon {
  position: relative;
  flex: 0 0 11px;
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--fine);
  border-radius: 50%;
}
.search-icon::after {
  position: absolute;
  content: "";
  width: 5px;
  height: 1.5px;
  border-radius: 2px;
  background: var(--fine);
  top: 8px;
  left: 7px;
  transform: rotate(45deg);
}
.search-box input {
  border: 0;
  outline: 0;
  padding: 8px 0;
  width: 100%;
  min-width: 0;
  color: inherit;
  background: transparent;
  font-size: 13px;
}
.search-box input:focus-visible { outline: 0; }
.search-box input::placeholder { color: var(--fine); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear {
  flex: none;
  display: grid;
  place-items: center;
  inline-size: 32px;
  block-size: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: 600 20px/1 var(--sans);
}
.search-clear:is(:hover, :focus-visible) { background: var(--accent-wash); color: var(--accent-text); }
.toolbar select { padding: 4px 21px 4px 9px; max-width: 169px; font-size: 12px; }
.library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-top: 13px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.library-location { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 8px; min-width: 0; }
.location { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; color: var(--muted); min-width: 0; font-size: 12px; }
.result-count {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--accent-wash);
  color: var(--accent-text);
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
}
.location [aria-current] { color: var(--text); font-weight: 720; overflow-wrap: anywhere; }
.crumb-button {
  border: 0;
  background: transparent;
  padding: 1px 0;
  color: var(--accent);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.crumb-button:hover { text-decoration: underline; }
.view-switch {
  display: flex;
  flex-shrink: 0;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-deep);
}
.view-switch button {
  border: 0;
  border-radius: 5px;
  padding: 3px 8px;
  background: transparent;
  color: var(--fine);
  font-size: 11px;
  font-weight: 650;
}
.view-switch [aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-text); }

@media (prefers-reduced-motion: no-preference) {
  :root[data-effects="on"] .view-switch button {
    transition: background-color 180ms ease, color 180ms ease;
  }
}

.note-list { list-style: none; margin: 0; padding: 0; }
.note-row + .note-row { border-top: 1px solid var(--line); }
.note-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 11px 6px;
  border-radius: 8px;
}
.note-link:hover { background: var(--surface-hover); }
.note-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
  border-radius: 10px;
  background: var(--accent-wash);
  color: var(--accent);
  font: 730 12px/1 var(--mono);
}
.note-icon[data-kind="html"] { color: var(--cyan); background: color-mix(in srgb, var(--cyan) 9%, var(--surface)); border-color: color-mix(in srgb, var(--cyan) 17%, var(--line)); }
.note-copy { min-width: 0; }
.note-title {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 690;
  overflow-wrap: anywhere;
  line-height: 1.38;
}
.note-link:hover .note-title { color: var(--accent-text); }
.note-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 7px; margin-top: 5px; color: var(--fine); font-size: 11px; }
.note-meta [datetime] { font-family: var(--mono); }
.note-meta span { overflow-wrap: anywhere; }
.note-arrow { color: var(--fine); align-self: center; font-size: 13px; padding-inline: 6px; }

.folder-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(155px, 100%), 1fr)); gap: 9px; padding-block: 11px; }
.folder-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-deep);
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
}
.folder-button strong { overflow-wrap: anywhere; }
.folder-button:hover { background: var(--surface-hover); border-color: var(--accent); }
.type-group h3 { margin: 12px 5px 0; color: var(--accent-text); font-size: 12px; }
.type-group + .type-group { border-top: 1px solid var(--line); }
.empty { color: var(--muted); text-align: center; margin: 16px 0; padding: 15px 0; font-size: 13px; }
.empty[data-error] { color: var(--warning); }

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 31px;
  margin-bottom: 25px;
  padding: 15px 2px 0;
  border-top: 1px solid var(--line);
  color: var(--fine);
  font-size: 11px;
}
.site-footer > span { color: var(--accent); }
.site-footer > span span { margin-left: 3px; color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

@media (max-width: 820px) {
  .site-header, .site-main, .site-footer { width: calc(100% - 38px); }
  .site-header { min-height: 66px; gap: 10px; }
  .site-nav a { padding-inline: 9px; }
  .archive-layout { grid-template-columns: minmax(142px, 178px) minmax(0, 1fr); gap: 11px; }
  .hero { min-height: 310px; }
  .hero::after { background: linear-gradient(90deg, rgb(14 14 34 / 63%), rgb(14 14 34 / 10%) 72%); }
}

@media (max-width: 585px) {
  .site-header, .site-main, .site-footer { width: calc(100% - 28px); }
  .site-header { grid-template-columns: 1fr auto; }
  .site-nav { display: none; }
  :is(.home-page, .archive-page) .site-header { row-gap: 3px; padding-block: 10px 5px; }
  :is(.home-page, .archive-page) .site-nav { display: flex; grid-column: 1 / -1; grid-row: 2; }
  .header-tools { gap: 6px; }
  .hero { min-height: 292px; border-radius: 15px; align-items: end; }
  .hero-image { object-position: 75% 50%; }
  .hero::after {
    background:
      linear-gradient(0deg, rgb(13 14 33 / 94%), rgb(13 14 33 / 31%) 59%, rgb(13 14 33 / 1%) 86%),
      linear-gradient(90deg, rgb(14 14 34 / 44%), transparent 70%);
  }
  .hero-content { padding: 22px 20px; }
  .hero-eyebrow { margin-bottom: 8px; font-size: 11px; }
  .hero h1 { font-size: clamp(40px, 10vw, 58px); }
  .hero-description { margin: 7px 0 13px; }
  .hero-button { padding: 5px 10px; }
  .archive { margin-top: 15px; }
  .archive-heading { margin-bottom: 10px; }
  .archive-layout { display: flex; flex-direction: column; gap: 10px; }
  .archive-rail { display: contents; }
  .collection-card, .library, .sync-card { width: 100%; }
  .collection-card { padding: 8px 9px; }
  .collection-card h2 { margin: 0 2px 5px; }
  .collection-card nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .collection-button { width: auto; min-height: 34px; padding: 4px 6px; gap: 4px; }
  .sync-card { order: 2; }
  .library { padding: 10px 10px 5px; }
  .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .search-box { grid-column: 1 / -1; }
  .search-clear { inline-size: 36px; block-size: 36px; }
  .toolbar select { max-width: none; width: 100%; }
  .note-link { gap: 8px; }
  .note-icon { width: 30px; height: 32px; }
  .note-title { font-size: 13px; }
}

@media (max-width: 370px) {
  .site-header { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
  .brand { gap: 6px; font-size: 13px; }
  .brand-mark { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; font-size: 17px; }
  .header-tools { gap: 4px; }
  .theme-control { padding-inline: 5px; }
  .theme-control > span { display: none; }
  .manage-link { gap: 4px; padding-inline: 6px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
