/* ================= JR NOTE 样式（响应式，无依赖） ================= */

:root {
  color-scheme: light;

  /* 颜色 */
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --card: #ffffff;
  --text: #14161a;
  --text-soft: #3d424b;
  --muted: #7b8290;
  --line: #e7e8ec;
  --line-strong: #d8dae0;
  --accent: #2f6fed;
  --accent-hover: #2760d4;
  --accent-soft: #edf2ff;
  --danger: #d64545;
  --danger-soft: #fdeeee;

  /* 尺寸 */
  --ctl-h: 42px;          /* 输入框 / 按钮 / 下拉统一的控件高度 */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 20, 30, .05);
  --shadow-md: 0 2px 4px rgba(16, 20, 30, .04), 0 12px 28px rgba(16, 20, 30, .07);
  --ring: 0 0 0 3px var(--accent-soft);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               "Apple SD Gothic Neo", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: .002em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

img, video { max-width: 100%; }

::selection { background: var(--accent-soft); color: var(--accent); }

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

/* ------------------------------ 顶栏 ------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 42%;
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand:hover { color: var(--accent); }

/* ------------------------------ 顶部搜索 ------------------------------ */

.search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 460px;
  height: 40px;
  margin: 0 auto;
  padding: 0 5px 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  transition: background .18s, border-color .18s, box-shadow .18s;
}

.search:hover { border-color: var(--line-strong); }

.search:focus-within {
  background: var(--card);
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.search-icon {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: color .18s;
}

.search:focus-within .search-icon { color: var(--accent); }

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  font-size: 14.5px;
  color: var(--text);
}

.search-input::placeholder { color: #a7adba; }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search-btn {
  flex: none;
  height: 30px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background .15s;
}

.search-btn:hover { background: var(--accent-hover); }
.search-btn:active { transform: translateY(1px); }

.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }

.nav-link {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  transition: background .15s, color .15s;
}

.nav-link:hover { background: var(--bg-soft); color: var(--text); }
.nav-link.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ------------------------------ 按钮 ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--ctl-h);
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .12s;
}

.btn:hover { background: var(--bg-soft); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 1px 2px rgba(47, 111, 237, .24);
}

.btn-primary:hover { background: var(--accent-hover); border-color: transparent; color: #fff; }

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

.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

.btn-sm {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
}

/* ------------------------------ 表单控件 ------------------------------ */

.input {
  width: 100%;
  height: var(--ctl-h);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.input::placeholder { color: #a7adba; }
.input:hover { border-color: var(--line-strong); }
.input:focus { border-color: var(--accent); box-shadow: var(--ring); }

.input-narrow { width: 140px; }

.select {
  width: auto;
  min-width: 132px;
  padding-right: 36px;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%237b8290' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

/* ------------------------------ 首页布局 ------------------------------ */

.layout {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  width: 100%;
  gap: 32px;
  max-width: 1020px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  align-items: start;
}

.sidebar { position: sticky; top: 84px; }

.side-head { margin-bottom: 14px; }

.new-btn { width: 100%; font-weight: 600; letter-spacing: .02em; }

.cats { display: flex; flex-direction: column; gap: 2px; }

.cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  color: var(--text-soft);
  transition: background .15s, color .15s;
}

.cat span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cat em {
  flex: none;
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: color .15s;
}

.cat:hover { background: var(--bg-soft); color: var(--text); }

.cat.on {
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 600;
}

.cat.on em { color: var(--accent); }

.list { display: flex; flex-direction: column; gap: 12px; }

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
  margin-bottom: 2px;
}

.list-head h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.clear-search { color: var(--accent); }
.clear-search:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ------------------------------ 卡片 ------------------------------ */

.card {
  display: block;
  padding: 20px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .18s, box-shadow .18s, transform .18s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: transparent;
  box-shadow: var(--shadow-md);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
}

.card h2 {
  margin: 10px 0 6px;
  font-size: 18.5px;
  font-weight: 650;
  line-height: 1.45;
  letter-spacing: -.005em;
}

.card:hover h2 { color: var(--accent); }

.excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-media {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.media-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.media-tag svg { width: 13px; height: 13px; }

/* ------------------------------ 分页 ------------------------------ */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 26px 0 4px;
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--text-soft);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  transition: background .15s, border-color .15s, color .15s;
}

a.pager-btn:hover { background: var(--bg-soft); border-color: var(--line-strong); color: var(--text); }

.pager-btn.is-current {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.pager-btn.is-disabled {
  border-color: transparent;
  background: transparent;
  color: #b9bec8;
  cursor: default;
}

.pager-gap { padding: 0 2px; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.empty {
  margin: 8px 0;
  padding: 44px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14.5px;
  text-align: center;
}

.empty a { color: var(--accent); }

/* ------------------------------ 阅读页 ------------------------------ */

.reader {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.back {
  display: inline-flex;
  align-items: center;
  height: 32px;
  font-size: 13.5px;
  color: var(--muted);
  transition: color .15s;
}

.back:hover { color: var(--accent); }

.reader-title {
  margin: 14px 0 12px;
  font-size: 31px;
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: -.022em;
}

.reader-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.reader-meta a.muted:hover { color: var(--accent); }

.inline-form { display: inline; margin: 0; }

.link-danger {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color .15s;
}

.link-danger:hover { color: var(--danger); }

.foot {
  margin-top: auto;
  padding: 28px 24px 44px;
  text-align: center;
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--muted);
}

/* ------------------------------ 正文排版 ------------------------------ */

.prose {
  font-size: 16.5px;
  line-height: 1.9;
  color: var(--text-soft);
  word-break: break-word;
}

.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  margin: 1.7em 0 .65em;
  color: var(--text);
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: -.01em;
}
.prose h1 { font-size: 26px; }
.prose h2 { font-size: 22px; }
.prose h3 { font-size: 18.5px; }
.prose p { margin: 0 0 1.05em; }
.prose img, .prose video { display: block; margin: 1.2em 0; border-radius: 12px; }
.prose figure { margin: 1.3em 0; }
.prose blockquote {
  margin: 1.3em 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.prose pre {
  margin: 1.3em 0;
  padding: 16px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.7;
}
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose ul, .prose ol { margin: 0 0 1.05em; padding-left: 1.45em; }
.prose li { margin: .25em 0; }
.prose hr { margin: 2.2em 0; border: 0; border-top: 1px solid var(--line); }

/* ------------------------------ 登录页 ------------------------------ */

.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #fbfcfe 0%, #ffffff 46%);
}

.panel {
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.panel-title {
  margin: 0 0 18px;
  font-size: 15.5px;
  font-weight: 650;
}

.login {
  width: min(372px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 36px 32px 32px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.login .muted { margin: -8px 0 6px; font-size: 13.5px; }

.brand-small {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .04em;
  overflow-wrap: anywhere;
}

.login .input { text-align: center; letter-spacing: .2em; }
.login .input::placeholder { letter-spacing: .04em; color: #b3b8c3; }
.login .btn { width: 100%; }

.error { margin: -4px 0 0; font-size: 13px; color: var(--danger); }

.notice {
  width: 100%;
  max-width: 1020px;
  margin: 0 auto 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 500;
}

.notice.error { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------ 后台 ------------------------------ */

.admin-wrap { width: 100%; max-width: 1020px; margin: 0 auto; padding: 30px 24px 72px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}

.admin-list li:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }

.admin-list-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.admin-list-title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-list-title:hover { color: var(--accent); }

.admin-list-actions { display: flex; align-items: center; gap: 8px; }
.admin-list-actions form { margin: 0; }

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

.cat-rename { display: flex; align-items: center; gap: 8px; }

.cat-input {
  width: 220px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

.row-form { display: flex; gap: 10px; margin-bottom: 22px; }
.row-form .input { max-width: 320px; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field span { font-size: 13.5px; color: var(--muted); }

.plain-list { margin: 0; padding-left: 18px; line-height: 2.1; }
.plain-list code {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-soft);
  font-size: 12.5px;
}

/* ------------------------------ 编辑器 ------------------------------ */

.editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.title-input {
  flex: 1 1 240px;
  font-size: 16px;
  font-weight: 600;
}

.toolbar {
  position: sticky;
  top: 60px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  padding: 6px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}

.tb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 32px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tb:hover { background: var(--bg-soft); color: var(--text); }
.tb:active { background: var(--accent-soft); color: var(--accent); }

.tb-sep {
  width: 1px;
  height: 18px;
  margin: 0 6px;
  background: var(--line);
}

.tb-status {
  margin-left: auto;
  padding-right: 6px;
  font-size: 12.5px;
  color: var(--accent);
}

.editor {
  min-height: 60vh;
  padding: 28px 30px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.editor:focus { border-color: var(--line-strong); }

.editor:empty::before {
  content: attr(data-placeholder);
  color: #b3b8c3;
  pointer-events: none;
}

.editor.drop-hover { background: var(--accent-soft); }

.editor-page { padding-bottom: 0; }

.editor-foot {
  width: 100%;
  max-width: 1020px;
  margin: 0 auto;
  padding: 16px 24px 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.editor-foot form { margin: 0 0 0 auto; }

/* ------------------------------ 新建弹窗 ------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 20, 26, .34);
  backdrop-filter: blur(3px);
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(364px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(16, 20, 30, .22);
}

.modal-title { margin: 0; font-size: 17px; font-weight: 650; }
.modal-hint { margin: -8px 0 0; font-size: 13.5px; color: var(--muted); }

.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

.folder-form { display: flex; gap: 8px; }
.folder-form[hidden] { display: none; }
.folder-form .input { flex: 1; min-width: 0; }

.modal-cancel {
  align-self: center;
  padding: 4px 10px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color .15s;
}

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

/* ------------------------------ 移动端 ------------------------------ */

@media (max-width: 760px) {
  :root { --ctl-h: 40px; }

  .topbar {
    position: static;
    height: auto;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
  }

  .nav-link { height: 32px; padding: 0 10px; font-size: 13.5px; }

  .search {
    order: 3;
    flex: 1 0 100%;
    max-width: none;
    height: 38px;
    margin: 0;
  }

  .search-btn { height: 28px; padding: 0 14px; font-size: 12.5px; }

  .layout {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 18px 14px 52px;
  }

  .sidebar { position: static; }
  .side-head { margin-bottom: 10px; }
  .new-btn { width: 100%; }

  .cats {
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .cats::-webkit-scrollbar { display: none; }

  .cat {
    flex: none;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--line);
  }
  .cat em { display: none; }
  .cat.on { border-color: transparent; }

  .list-head h1 { font-size: 18px; }
  .card { padding: 16px; }
  .card h2 { font-size: 17px; }

  .reader { padding: 18px 16px 52px; }
  .reader-title { font-size: 24px; }
  .prose { font-size: 16px; line-height: 1.85; }

  .login { padding: 28px 22px 24px; }

  .admin-wrap { padding: 20px 14px 62px; }
  .page-head h1 { font-size: 19px; }
  .admin-list li { padding: 12px 14px; }
  .admin-list-main { width: 100%; }
  .cat-actions { width: 100%; }
  .cat-input { flex: 1 1 auto; width: auto; min-width: 0; }
  .admin-list-actions { width: 100%; justify-content: flex-end; }

  .row-form { flex-wrap: wrap; }
  .row-form .input { max-width: 100%; }

  .editor-head .title-input { flex-basis: 100%; }
  .editor { padding: 18px 16px; min-height: 52vh; }
  .editor-foot { padding: 14px 14px 52px; }
  .toolbar { top: 0; }
}
