:root {
  color-scheme: dark;
  --bg: #080b12;
  --surface: rgba(17, 24, 39, 0.76);
  --surface-solid: #111827;
  --surface-hover: rgba(31, 41, 55, 0.9);
  --line: rgba(148, 163, 184, 0.15);
  --text: #f8fafc;
  --muted: #94a3b8;
  --cyan: #5eead4;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --danger: #fb7185;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.36);
  --reader-nav-width: 300px;
  --reader-nav-rail-width: 48px;
  --topbar-height: 76px;
}

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-width: 320px;
  overflow-x: hidden;
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.65;
  background:
    radial-gradient(circle at 50% 0%, rgba(30, 64, 175, 0.14), transparent 42%),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

.background {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.grid {
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.07) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000, transparent 78%);
}

.glow {
  position: absolute;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.13;
}

.glow-one {
  top: -12rem;
  left: -10rem;
  background: var(--blue);
}

.glow-two {
  top: 22rem;
  right: -14rem;
  background: var(--purple);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  width: min(1180px, calc(100% - 40px));
  height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(8, 11, 18, 0.72);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #06111b;
  font-size: 20px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-radius: 13px;
  box-shadow: 0 8px 26px rgba(94, 234, 212, 0.2);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0.06em;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.topbar nav a,
.nav-button {
  padding: 8px 0;
  color: #cbd5e1;
  font-size: 14px;
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
}

.topbar nav a:hover,
.nav-button:hover {
  color: var(--cyan);
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  flex: 1;
}

.hero {
  padding: 94px 0 72px;
  text-align: center;
}

.eyebrow,
.section-kicker {
  margin: 0 0 14px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.eyebrow span {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 9px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 18px var(--cyan);
}

.hero h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 76px);
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.hero h1 em {
  color: transparent;
  font-style: normal;
  background: linear-gradient(100deg, var(--cyan), var(--blue), var(--purple));
  background-clip: text;
  -webkit-background-clip: text;
}

.hero-copy {
  max-width: 600px;
  margin: 24px auto 34px;
  color: var(--muted);
  font-size: 16px;
}

.search {
  width: min(620px, 100%);
  min-height: 58px;
  margin: 0 auto;
  padding: 6px 6px 6px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 18px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.25);
}

.search > span {
  color: var(--muted);
  font-size: 26px;
}

.search input {
  min-width: 0;
  flex: 1;
  color: var(--text);
  background: none;
  border: 0;
  outline: 0;
}

.search button,
.primary-button {
  padding: 12px 23px;
  color: #07111c;
  font-weight: 800;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(96, 165, 250, 0.18);
}

.search button:hover,
.primary-button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.categories {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}

.category {
  padding: 7px 14px;
  color: var(--muted);
  font-size: 13px;
  background: rgba(15, 23, 42, 0.62);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.category:hover,
.category.active {
  color: var(--text);
  background: rgba(94, 234, 212, 0.1);
  border-color: rgba(94, 234, 212, 0.38);
}

.content-shell {
  min-height: 400px;
  padding-bottom: 90px;
}

.section-heading,
.admin-head {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.section-heading h2,
.admin-head h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
}

.section-heading > span,
.admin-head p {
  color: var(--muted);
  font-size: 13px;
}

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

.note-card {
  position: relative;
  min-height: 265px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-decoration: none;
  background: linear-gradient(145deg, rgba(17, 24, 39, 0.9), rgba(10, 15, 26, 0.8));
  border: 1px solid var(--line);
  border-radius: 21px;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.note-card::after {
  position: absolute;
  right: -50px;
  bottom: -70px;
  width: 150px;
  height: 150px;
  content: "";
  background: radial-gradient(circle, rgba(96, 165, 250, 0.13), transparent 68%);
}

.note-card:hover {
  transform: translateY(-6px);
  background: var(--surface-hover);
  border-color: rgba(94, 234, 212, 0.3);
}

.note-card .category-label,
.article-category {
  align-self: flex-start;
  padding: 5px 10px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  background: rgba(94, 234, 212, 0.08);
  border: 1px solid rgba(94, 234, 212, 0.2);
  border-radius: 8px;
}

.note-card h3 {
  margin: 18px 0 9px;
  font-size: 20px;
  line-height: 1.4;
}

.note-card p {
  margin: 0;
  flex: 1;
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.note-meta {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #64748b;
  font-size: 12px;
}

.note-meta span:last-child {
  color: #cbd5e1;
}

.empty {
  grid-column: 1 / -1;
  padding: 70px 20px;
  color: var(--muted);
  text-align: center;
  background: rgba(15, 23, 42, 0.5);
  border: 1px dashed rgba(148, 163, 184, 0.25);
  border-radius: 20px;
}

.pagination {
  margin-top: 30px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.pagination button,
.back-button,
.ghost-button {
  padding: 10px 16px;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.detail-view {
  width: 100%;
  margin: 10px auto 0;
}

.detail-actions {
  width: min(820px, calc(100vw - var(--reader-nav-width) - 40px));
  margin: 0 auto 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transform: translateX(calc(var(--reader-nav-width) / 2));
  transition: width 0.22s ease, transform 0.22s ease;
}

.detail-view.toc-collapsed .detail-actions {
  width: min(820px, calc(100vw - var(--reader-nav-rail-width) - 40px));
  transform: translateX(calc(var(--reader-nav-rail-width) / 2));
}

.detail-view.toc-empty .detail-actions {
  width: min(820px, 100%);
  transform: none;
}

.back-button {
  margin: 0;
}

.toc-mobile-toggle {
  display: none;
  padding: 10px 14px;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}

.article-layout {
  display: block;
}

.article-main {
  width: min(820px, calc(100vw - var(--reader-nav-width) - 40px));
  min-width: 0;
  margin: 0 auto;
  transform: translateX(calc(var(--reader-nav-width) / 2));
  transition: width 0.22s ease, transform 0.22s ease;
}

.article-layout.toc-collapsed .article-main {
  width: min(820px, calc(100vw - var(--reader-nav-rail-width) - 40px));
  transform: translateX(calc(var(--reader-nav-rail-width) / 2));
}

.article-layout.toc-empty .article-main {
  width: min(820px, 100%);
  transform: none;
}

/* Word 风格阅读导航：占据浏览器左侧，页面滚动时始终固定。 */
.article-toc {
  position: fixed;
  z-index: 25;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  width: var(--reader-nav-width);
  min-width: 0;
  transition: width 0.22s ease;
}

.article-layout.toc-collapsed .article-toc {
  width: var(--reader-nav-rail-width);
}

.article-toc-card {
  width: 100%;
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(9, 14, 24, 0.97);
  border: 0;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 0;
  box-shadow: 16px 0 48px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(18px);
}

.toc-head {
  min-height: 58px;
  padding: 0 13px 0 18px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.toc-head > div {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.toc-head strong {
  font-size: 15px;
  letter-spacing: 0.03em;
}

.toc-head span {
  color: #64748b;
  font-size: 10px;
  white-space: nowrap;
}

.toc-collapse-button {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 20px;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.toc-collapse-button:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.1);
}

.toc-collapsed-rail {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  padding: 15px 0;
  display: none;
  align-items: center;
  justify-content: flex-start;
  flex-direction: column;
  gap: 12px;
  color: #9fb0c5;
  background: rgba(9, 14, 24, 0.97);
  border: 0;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 0;
  box-shadow: 12px 0 34px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  backdrop-filter: blur(18px);
}

.toc-collapsed-rail:hover {
  color: var(--cyan);
  background: rgba(15, 23, 42, 0.98);
}

.toc-collapsed-rail span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 17px;
  border-radius: 7px;
}

.toc-collapsed-rail b {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.14em;
  writing-mode: vertical-rl;
}

.article-layout.toc-collapsed .article-toc-card {
  display: none;
}

.article-layout.toc-collapsed .toc-collapsed-rail {
  display: flex;
}

#detailTocList {
  min-height: 0;
  padding: 10px 9px 18px;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

#detailTocList button {
  position: relative;
  width: 100%;
  min-height: 34px;
  padding: 7px 10px 7px 18px;
  display: block;
  overflow: hidden;
  color: #98a7ba;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

#detailTocList button::before {
  position: absolute;
  top: 50%;
  left: 8px;
  width: 4px;
  height: 4px;
  content: "";
  background: #526176;
  border-radius: 50%;
  transform: translateY(-50%);
}

#detailTocList button:hover {
  color: #e2e8f0;
  background: rgba(148, 163, 184, 0.08);
}

#detailTocList button.active {
  color: #e6fffb;
  font-weight: 650;
  background: rgba(94, 234, 212, 0.1);
  box-shadow: inset 3px 0 var(--cyan);
}

#detailTocList button.active::before {
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(94, 234, 212, 0.45);
}

#detailTocList button[data-depth="1"] {
  margin-top: 3px;
  padding-left: 18px;
  color: #d7e1ee;
  font-weight: 650;
}

#detailTocList button[data-depth="2"] { padding-left: 32px; }
#detailTocList button[data-depth="2"]::before { left: 21px; }
#detailTocList button[data-depth="3"] { padding-left: 46px; }
#detailTocList button[data-depth="3"]::before { left: 35px; }
#detailTocList button[data-depth="4"] { padding-left: 60px; }
#detailTocList button[data-depth="4"]::before { left: 49px; }
#detailTocList button[data-depth="5"] { padding-left: 74px; }
#detailTocList button[data-depth="5"]::before { left: 63px; }
#detailTocList button[data-depth="6"] { padding-left: 88px; }
#detailTocList button[data-depth="6"]::before { left: 77px; }

.toc-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-head {
  padding-bottom: 34px;
  border-bottom: 1px solid var(--line);
}

.article-head h1 {
  margin: 20px 0 12px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.22;
  letter-spacing: -0.035em;
}

.article-head > p {
  color: var(--muted);
  font-size: 17px;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: #64748b;
  font-size: 13px;
}

.article-body {
  padding: 38px 0;
  color: #dbe5f2;
  font-size: 16px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
  scroll-margin-top: 108px;
  color: var(--text);
  line-height: 1.35;
}

.article-body h1 {
  margin: 1.9em 0 0.75em;
  padding-bottom: 0.45em;
  font-size: clamp(28px, 4vw, 34px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.article-body h2 {
  margin: 2em 0 0.72em;
  padding-left: 14px;
  font-size: clamp(24px, 3vw, 29px);
  border-left: 4px solid var(--cyan);
}

.article-body h3 {
  margin: 1.8em 0 0.62em;
  font-size: 22px;
}

.article-body h3::before {
  margin-right: 8px;
  color: var(--cyan);
  content: "#";
}

.article-body h4 {
  margin: 1.55em 0 0.55em;
  color: #e2e8f0;
  font-size: 18px;
}

.article-body h5 {
  margin: 1.45em 0 0.5em;
  color: #cbd5e1;
  font-size: 16px;
}

.article-body h6 {
  margin: 1.35em 0 0.45em;
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.article-body p { margin: 0 0 1.1em; }
.article-body ul { padding-left: 1.4em; }
.article-body li { margin: 0.35em 0; }
.article-body hr {
  height: 1px;
  margin: 2em 0;
  background: var(--line);
  border: 0;
}

.article-body code {
  padding: 0.15em 0.42em;
  color: #a7f3d0;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.article-body pre {
  margin: 1.4em 0;
  padding: 20px;
  overflow: auto;
  white-space: pre;
  background: #050812;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.article-body pre code {
  padding: 0;
  color: #cbd5e1;
  background: none;
  border: 0;
}

.article-body blockquote {
  margin: 1.5em 0;
  padding: 8px 0 8px 18px;
  color: var(--muted);
  border-left: 3px solid var(--cyan);
}

.article-body a {
  color: var(--cyan);
  text-underline-offset: 4px;
}

.article-body .note-image {
  width: 100%;
  margin: 1.8em auto;
  text-align: center;
}

.article-body .note-image a {
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}

.article-body .note-image img {
  display: block;
  max-width: 100%;
  max-height: 76vh;
  object-fit: contain;
  background: #050812;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.article-body .note-image figcaption {
  margin-top: 9px;
  color: #718096;
  font-size: 12px;
  line-height: 1.5;
}

.article-body .code-block {
  margin: 1.5em 0;
  overflow: hidden;
  background: #050812;
  border: 1px solid rgba(148, 163, 184, 0.19);
  border-radius: 14px;
}

.article-body .code-header {
  min-height: 38px;
  padding: 0 12px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #8292a8;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: #0c1220;
  border-bottom: 1px solid var(--line);
}

.article-body .copy-code {
  padding: 4px 9px;
  color: #aab8ca;
  font-size: 11px;
  background: #151d2e;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}

.article-body .code-block pre {
  margin: 0;
  border: 0;
  border-radius: 0;
}

.article-body .task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.article-body .task-item input {
  accent-color: #14b8a6;
}

.table-scroll {
  margin: 1.4em 0;
  overflow-x: auto;
}

.article-body table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 14px;
}

.article-body th,
.article-body td {
  padding: 11px 14px;
  text-align: left;
  border: 1px solid var(--line);
}

.article-body th {
  color: var(--text);
  background: rgba(30, 41, 59, 0.72);
}

.admin-view {
  padding: 36px;
  background: rgba(15, 23, 42, 0.68);
  border: 1px solid var(--line);
  border-radius: 24px;
}

.admin-head {
  align-items: center;
}

.admin-head p {
  margin: 7px 0 0;
}

.admin-actions {
  display: flex;
  gap: 10px;
}

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

.admin-item {
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  background: rgba(8, 11, 18, 0.72);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.admin-item h3 {
  margin: 0 0 3px;
  font-size: 15px;
}

.admin-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.status {
  padding: 4px 9px;
  color: #fdba74;
  font-size: 11px;
  background: rgba(251, 146, 60, 0.1);
  border-radius: 999px;
}

.status.published {
  color: #86efac;
  background: rgba(34, 197, 94, 0.1);
}

.item-buttons {
  display: flex;
  gap: 7px;
}

.item-buttons button {
  padding: 7px 10px;
  color: #cbd5e1;
  font-size: 12px;
  background: #111827;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.item-buttons .delete {
  color: var(--danger);
}

dialog {
  width: min(560px, calc(100% - 28px));
  max-height: calc(100vh - 30px);
  padding: 0;
  color: var(--text);
  overflow: auto;
  background: transparent;
  border: 0;
}

dialog::backdrop {
  background: rgba(2, 6, 23, 0.82);
  backdrop-filter: blur(10px);
}

#editorDialog {
  width: min(1500px, calc(100% - 20px));
  height: calc(100dvh - 20px);
  max-height: none;
  overflow: hidden;
}

.dialog-card {
  position: relative;
  padding: 34px;
  background: #101722;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 34px;
  height: 34px;
  color: var(--muted);
  font-size: 25px;
  line-height: 1;
  background: none;
  border: 0;
  cursor: pointer;
}

.dialog-close.static {
  position: static;
}

.dialog-icon {
  width: 52px;
  height: 52px;
  margin-bottom: 20px;
  display: grid;
  place-items: center;
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: 15px;
}

.dialog-card h2 {
  margin: 0 0 8px;
}

.login-card > p:not(.section-kicker):not(.form-error) {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.dialog-card label {
  margin-bottom: 15px;
  display: grid;
  gap: 7px;
  color: #cbd5e1;
  font-size: 13px;
}

.dialog-card input,
.dialog-card textarea {
  width: 100%;
  color: var(--text);
  background: #080c15;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  outline: none;
}

.dialog-card input {
  height: 45px;
  padding: 0 13px;
}

.dialog-card textarea {
  padding: 12px 13px;
  resize: vertical;
}

.dialog-card input:focus,
.dialog-card textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.08);
}

.wide {
  width: 100%;
}

.form-error {
  min-height: 20px;
  margin: 4px 0 10px;
  color: #fda4af;
  font-size: 13px;
}

.editor-head,
.editor-footer,
.form-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.editor-head {
  margin: 0;
  padding: 16px 22px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.form-row > label {
  min-width: 0;
  flex: 1;
}

.editor-footer {
  margin: 0;
  padding: 12px 22px;
  align-items: center;
  background: #0d1420;
  border-top: 1px solid var(--line);
}

.editor-footer > div {
  display: flex;
  gap: 9px;
}

.publish-toggle {
  display: flex !important;
  grid-template-columns: auto auto;
  align-items: center;
  cursor: pointer;
}

.publish-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  clip-path: inset(50%);
}

.publish-toggle span {
  width: 40px;
  height: 23px;
  padding: 3px;
  display: inline-flex;
  background: #334155;
  border-radius: 99px;
  transition: background 0.2s;
}

.publish-toggle span::after {
  width: 17px;
  height: 17px;
  content: "";
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.publish-toggle input:checked + span {
  background: #0d9488;
}

.publish-toggle input:checked + span::after {
  transform: translateX(17px);
}

/* Typora 风格编辑工作区 */
.editor-card {
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-head h2 {
  margin: 0;
  font-size: 20px;
}

.editor-head .section-kicker {
  margin-bottom: 2px;
  font-size: 9px;
}

.editor-head-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.editor-action {
  padding: 7px 11px;
  color: #9fb0c5;
  font-size: 12px;
  background: #111a29;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.editor-action:hover,
.editor-action.active {
  color: #dffefa;
  background: rgba(20, 184, 166, 0.11);
  border-color: rgba(94, 234, 212, 0.32);
}

.editor-meta {
  flex: 0 0 auto;
  background: #0d1420;
  border-bottom: 1px solid var(--line);
}

.editor-meta summary {
  padding: 8px 22px;
  color: #d4deeb;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.editor-meta summary span {
  margin-left: 9px;
  color: #6f8096;
  font-size: 11px;
  font-weight: 400;
}

.editor-meta-grid {
  padding: 5px 22px 13px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.7fr 1fr;
  gap: 10px 12px;
}

.editor-meta-grid label {
  margin: 0;
  gap: 4px;
  font-size: 11px;
}

.editor-meta-grid input {
  height: 38px;
}

.editor-meta-grid .meta-title {
  grid-column: span 2;
}

.editor-meta-grid .meta-summary {
  grid-column: 1 / -1;
}

.editor-meta-grid textarea {
  min-height: 55px;
  max-height: 100px;
}

.editor-workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

.editor-workspace.outline-hidden {
  grid-template-columns: 0 minmax(0, 1fr);
}

.editor-workspace.outline-hidden .editor-outline {
  visibility: hidden;
  opacity: 0;
}

.editor-outline {
  min-width: 0;
  padding: 17px 13px;
  overflow-y: auto;
  background: #0b111c;
  border-right: 1px solid var(--line);
  transition: opacity 0.2s ease;
}

.outline-head {
  margin-bottom: 12px;
  padding: 0 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.outline-head strong {
  font-size: 12px;
}

.outline-head span {
  color: #64748b;
  font-size: 10px;
}

.outline-empty {
  padding: 8px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.7;
}

#outlineList button {
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  color: #94a3b8;
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
  background: none;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

#outlineList button:hover,
#outlineList button.active {
  color: #e6fffb;
  background: rgba(94, 234, 212, 0.08);
}

#outlineList button.active {
  box-shadow: inset 2px 0 var(--cyan);
}

#outlineList button[data-depth="2"] { padding-left: 20px; }
#outlineList button[data-depth="3"] { padding-left: 32px; }
#outlineList button[data-depth="4"] { padding-left: 44px; }
#outlineList button[data-depth="5"] { padding-left: 56px; }
#outlineList button[data-depth="6"] { padding-left: 68px; }

.outline-level {
  min-width: 20px;
  color: #5f7188;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

#outlineList button.active .outline-level {
  color: var(--cyan);
}

.outline-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.outline-empty code {
  color: #9df5e6;
  font-family: "Cascadia Code", Consolas, monospace;
}

.editor-writing {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #080d16;
}

.markdown-toolbar {
  position: relative;
  min-height: 47px;
  padding: 7px 11px;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  background: #101824;
  border-bottom: 1px solid var(--line);
}

.markdown-toolbar button,
.markdown-toolbar select {
  min-width: 34px;
  height: 31px;
  padding: 0 9px;
  flex: 0 0 auto;
  color: #aab8ca;
  font-size: 11px;
  background: #151e2d;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 7px;
  cursor: pointer;
}

.markdown-toolbar button:hover,
.markdown-toolbar select:hover {
  color: #e6fffb;
  border-color: rgba(94, 234, 212, 0.32);
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  margin: 0 3px;
  flex: 0 0 auto;
  background: var(--line);
}

.emoji-tool {
  position: relative;
  flex: 0 0 auto;
}

.emoji-picker {
  position: fixed;
  z-index: 120;
  width: 210px;
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  background: #172033;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.emoji-picker button {
  padding: 0;
  font-size: 17px;
}

.editor-panels {
  position: relative;
  min-height: 0;
  flex: 1;
}

.editor-panels.image-drag-over::after {
  position: absolute;
  inset: 14px;
  z-index: 5;
  display: grid;
  place-items: center;
  color: #dffefa;
  font-size: 16px;
  font-weight: 800;
  content: "松开鼠标上传图片";
  pointer-events: none;
  background: rgba(8, 20, 31, 0.88);
  border: 2px dashed rgba(94, 234, 212, 0.62);
  border-radius: 16px;
  backdrop-filter: blur(5px);
}

.editor-panel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}

.editor-panel.active {
  display: block;
}

textarea.editor-panel {
  padding: 30px clamp(24px, 6vw, 90px);
  color: #dce7f6;
  font-family: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  font-size: 15px;
  line-height: 1.85;
  resize: none;
  background: #080d16;
  border: 0;
  border-radius: 0;
  outline: 0;
  tab-size: 2;
}

textarea.editor-panel:focus {
  border: 0;
  box-shadow: none;
}

.editor-preview {
  padding: 30px clamp(24px, 8vw, 120px);
  overflow-y: auto;
  background: #080d16;
}

.editor-status {
  min-height: 29px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #64748b;
  font-size: 10px;
  background: #0d1420;
  border-top: 1px solid var(--line);
}

.editor-status b {
  color: #91a2b8;
  font-weight: 500;
}

#imageUploadStatus {
  color: var(--cyan);
}

#imageUploadButton:disabled {
  opacity: 0.45;
  cursor: wait;
}

.preview-window {
  display: block;
  background: #080d16;
}

.preview-window-head {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 64px;
  padding: 10px max(22px, calc((100% - 900px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(8, 13, 22, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.preview-window-head span,
.preview-window-head strong {
  display: block;
}

.preview-window-head span {
  color: var(--cyan);
  font-size: 9px;
  letter-spacing: 0.2em;
}

.preview-window-head strong {
  margin-top: 2px;
  font-size: 14px;
}

.preview-window-head button {
  padding: 7px 13px;
  color: #cbd5e1;
  background: #111827;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.preview-document {
  width: min(900px, calc(100% - 36px));
  min-height: calc(100vh - 64px);
  margin: 0 auto;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  max-width: min(380px, calc(100% - 48px));
  padding: 12px 18px;
  color: var(--text);
  visibility: hidden;
  opacity: 0;
  transform: translateY(12px);
  background: #172033;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: 0.25s ease;
}

.toast.show {
  visibility: visible;
  opacity: 1;
  transform: none;
}

footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 34px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  color: #64748b;
  font-size: 12px;
  border-top: 1px solid var(--line);
}

footer a {
  text-decoration: none;
}

footer a:hover {
  color: #cbd5e1;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1050px) {
  .detail-actions,
  .detail-view.toc-collapsed .detail-actions,
  .detail-view.toc-empty .detail-actions,
  .article-main,
  .article-layout.toc-collapsed .article-main,
  .article-layout.toc-empty .article-main {
    width: min(820px, 100%);
    transform: none;
  }

  .toc-mobile-toggle {
    display: inline-flex;
  }

  .article-toc,
  .article-layout.toc-collapsed .article-toc {
    position: fixed;
    inset: 88px 18px auto auto;
    z-index: 45;
    width: min(330px, calc(100% - 36px));
    max-height: min(72vh, 650px);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  }

  .article-toc.open {
    visibility: visible;
    opacity: 1;
    transform: none;
  }

  .article-toc-card,
  .article-layout.toc-collapsed .article-toc-card {
    height: auto;
    max-height: min(72vh, 650px);
    display: flex;
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: var(--shadow);
  }

  .toc-head {
    min-height: 54px;
  }

  .toc-collapse-button,
  .toc-collapsed-rail,
  .article-layout.toc-collapsed .toc-collapsed-rail {
    display: none;
  }

  #detailTocList {
    max-height: min(60vh, 540px);
  }
}

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

  .editor-workspace {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .editor-meta-grid {
    grid-template-columns: 1fr 1fr;
  }

  .editor-meta-grid .meta-title {
    grid-column: 1 / -1;
  }

  .editor-head-actions .editor-action:first-child {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar,
  main,
  footer {
    width: min(100% - 28px, 520px);
  }

  .topbar {
    height: 68px;
  }

  .topbar nav {
    gap: 14px;
  }

  .topbar nav a {
    display: none;
  }

  .detail-actions {
    margin-bottom: 20px;
  }

  .article-head h1 {
    font-size: 30px;
  }

  .article-body {
    padding-top: 28px;
    font-size: 15px;
  }

  .article-body h2 {
    font-size: 23px;
  }

  .article-body h3 {
    font-size: 19px;
  }

  .article-toc {
    top: 76px;
    right: 14px;
    width: calc(100% - 28px);
  }

  .hero {
    padding: 68px 0 54px;
  }

  .hero-copy {
    font-size: 14px;
  }

  .search {
    padding-left: 14px;
  }

  .search button {
    padding-inline: 16px;
  }

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

  .note-card {
    min-height: 230px;
  }

  .section-heading,
  .admin-head,
  .editor-footer,
  .form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-view,
  .dialog-card {
    padding: 24px 18px;
  }

  #editorDialog {
    width: 100%;
    height: 100dvh;
  }

  #editorDialog .dialog-card {
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .editor-head {
    padding: 12px 14px;
  }

  .editor-head > div:first-child {
    display: none;
  }

  .editor-head-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .editor-head-actions .editor-action {
    padding-inline: 9px;
  }

  #openPreviewWindow {
    display: none;
  }

  .editor-meta summary {
    padding-inline: 14px;
  }

  .editor-meta-grid {
    padding-inline: 14px;
    grid-template-columns: 1fr;
  }

  .editor-meta-grid .meta-title,
  .editor-meta-grid .meta-summary {
    grid-column: auto;
  }

  .editor-meta-grid label:not(.meta-title):not(.meta-summary) {
    display: none;
  }

  .editor-workspace,
  .editor-workspace.outline-hidden {
    grid-template-columns: 1fr;
  }

  .editor-outline {
    display: none;
  }

  .markdown-toolbar {
    min-height: 45px;
  }

  textarea.editor-panel,
  .editor-preview {
    padding: 22px 16px;
  }

  .editor-footer {
    padding: 10px 14px;
    align-items: center;
    flex-direction: row;
  }

  .editor-footer .ghost-button {
    display: none;
  }

  .admin-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .admin-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .admin-item .item-buttons {
    grid-column: 1 / -1;
  }

  .item-buttons button {
    flex: 1;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
