/* 札记 —— 日记本样式
   纸张有自己的一套配色（不直接用 --yukima-bg），这样翻开时像一本摊在桌上的本子，
   而不是一块贴着页面背景的方块。深色模式下换成暗纸，不刺眼。 */

:root {
  --paper: #fdfaf0;
  --paper-edge: #f0ead6;
  --paper-line: rgba(120, 140, 110, 0.16);
  --paper-margin: rgba(190, 110, 100, 0.35);
  --paper-ink: #4a5346;
  --paper-ink-soft: #8a9384;
  --paper-title: #6b8e23;
  --book-shadow: rgba(60, 70, 50, 0.18);
  --book-spine: linear-gradient(90deg, #d9d0b4 0%, #ede5cd 40%, #f6f0dd 100%);
}

[data-theme="dark"] {
  --paper: #232b21;
  --paper-edge: #1c231b;
  --paper-line: rgba(180, 200, 170, 0.09);
  --paper-margin: rgba(200, 130, 120, 0.28);
  --paper-ink: #c3cfb8;
  --paper-ink-soft: #8a967f;
  --paper-title: #a4d65e;
  --book-shadow: rgba(0, 0, 0, 0.5);
  --book-spine: linear-gradient(90deg, #161c15 0%, #202719 40%, #262e23 100%);
}

/* ── 本子外壳 ──────────────────────────────────────────────── */
.zhaji-wrap {
  max-width: 780px;
  margin: 2.5rem auto 4rem;
  padding: 0 1rem;
}

.zhaji-head {
  text-align: center;
  margin-bottom: 2rem;
}

.zhaji-head h1 {
  font-family: 'Noto Serif', Georgia, serif;
  font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.6rem);
  color: var(--yukima-title);
  margin: 0 0 0.4rem;
  letter-spacing: 0.12em;
}

.zhaji-head .sub {
  color: var(--yukima-text);
  opacity: 0.7;
  font-size: 0.95rem;
  margin: 0;
}

.zhaji-head .stat {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  color: var(--yukima-text);
  opacity: 0.6;
}

/* 书本主体：左侧装订，底下垫两层做出纸叠的厚度 */
.book {
  position: relative;
  background: var(--paper);
  border-radius: 3px 8px 8px 3px;
  box-shadow:
    0 1px 2px var(--book-shadow),
    0 10px 28px var(--book-shadow);
  min-height: 460px;
  isolation: isolate;
}

.book::before,
.book::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 3px 8px 8px 3px;
  background: var(--paper-edge);
  z-index: -1;
}
.book::before { transform: translate(3px, 3px); }
.book::after  { transform: translate(6px, 6px); opacity: 0.7; }

/* 装订边 */
.book .spine {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 26px;
  background: var(--book-spine);
  border-radius: 3px 0 0 3px;
  box-shadow: inset -2px 0 4px rgba(0, 0, 0, 0.08);
}

/* 装订线上的针脚 */
.book .spine::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 8%;
  bottom: 8%;
  width: 1px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    to bottom,
    var(--paper-margin) 0 8px,
    transparent 8px 18px
  );
  opacity: 0.6;
}

/* ── 纸页 ─────────────────────────────────────────────────── */
.page {
  padding: 2.4rem 2.2rem 2.4rem 3.6rem;
  min-height: 460px;
  /* 横格 */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 calc(2em - 1px),
    var(--paper-line) calc(2em - 1px) 2em
  );
  background-position: 0 3.2rem;
  font-family: 'Noto Serif', Georgia, serif;
  color: var(--paper-ink);
  line-height: 2em;
}

/* 左侧红边线 */
.page::before {
  content: '';
  position: absolute;
  left: 2.9rem;
  top: 1rem;
  bottom: 1rem;
  width: 1px;
  background: var(--paper-margin);
}

.page.turning {
  animation: pageflip 0.32s ease;
  transform-origin: left center;
}

@keyframes pageflip {
  0%   { opacity: 0.25; transform: rotateY(-9deg); }
  100% { opacity: 1;    transform: rotateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .page.turning { animation: none; }
}

/* 日期抬头 */
.entry-date {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--paper-margin);
  padding-bottom: 0.5rem;
  margin-bottom: 1.4rem;
  line-height: 1.5;
}

.entry-date .d {
  font-size: 1.5rem;
  color: var(--paper-title);
  letter-spacing: 0.06em;
}

.entry-date .w,
.entry-date .mood {
  font-size: 0.85rem;
  color: var(--paper-ink-soft);
}

.entry-date .mood::before { content: '· '; }

.entry-title {
  font-size: 1.25rem;
  margin: 0 0 1rem;
  color: var(--paper-ink);
  line-height: 2em;
}

/* 正文 */
.entry-body > *:first-child { margin-top: 0; }
.entry-body p { margin: 0 0 1em; }
.entry-body h2,
.entry-body h3 {
  font-size: 1.1rem;
  color: var(--paper-title);
  margin: 1.4em 0 0.6em;
  line-height: 2em;
}
.entry-body ul,
.entry-body ol { margin: 0 0 1em; padding-left: 1.6em; }
.entry-body li { margin-bottom: 0.2em; }
.entry-body blockquote {
  margin: 1em 0;
  padding-left: 1em;
  border-left: 3px solid var(--paper-margin);
  color: var(--paper-ink-soft);
  font-style: italic;
}
.entry-body code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: rgba(120, 140, 110, 0.12);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.entry-body a { color: var(--yukima-link); }
.entry-body hr {
  border: none;
  border-top: 1px dashed var(--paper-margin);
  margin: 1.5em 0;
}

.draft-flag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.1em 0.5em;
  border-radius: 3px;
  background: rgba(200, 150, 60, 0.2);
  color: #a07020;
  margin-left: 0.5rem;
  vertical-align: middle;
}
[data-theme="dark"] .draft-flag { color: #d9b169; }

/* ── 翻页 ─────────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.2rem;
  padding: 0 0.4rem;
}

.pager button {
  background: none;
  border: 1px solid var(--yukima-border);
  color: var(--yukima-text);
  border-radius: var(--yukima-radius-sm, 4px);
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s;
}
.pager button:hover:not(:disabled) {
  background: var(--yukima-component-bg-hover);
  border-color: var(--yukima-border-hover);
}
.pager button:disabled { opacity: 0.35; cursor: default; }

.pager .pageno {
  font-size: 0.85rem;
  color: var(--yukima-text);
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* 目录 */
.toc {
  margin-top: 1.6rem;
  border-top: 1px solid var(--yukima-border);
  padding-top: 1rem;
}
.toc summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--yukima-text);
  opacity: 0.75;
}
.toc ol { margin: 0.8rem 0 0; padding-left: 1.4rem; }
.toc li { margin-bottom: 0.35rem; font-size: 0.9rem; }
.toc a { color: var(--yukima-link); cursor: pointer; text-decoration: none; }
.toc a:hover { text-decoration: underline; }
.toc .cur { font-weight: 700; }

/* ── 写作区 ───────────────────────────────────────────────── */
.owner-bar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.owner-bar button,
.editor button {
  background: var(--yukima-button-bg);
  color: var(--yukima-button-text);
  border: 1px solid var(--yukima-button-border);
  border-radius: var(--yukima-radius-sm, 4px);
  padding: 0.4rem 0.9rem;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
}
.owner-bar button:hover,
.editor button:hover { background: var(--yukima-button-bg-hover); }
.owner-bar button.ghost,
.editor button.ghost {
  background: none;
  color: var(--yukima-text);
  border-color: var(--yukima-border);
}
.owner-bar button.ghost:hover,
.editor button.ghost:hover { background: var(--yukima-component-bg-hover); }

.export-link {
  font-size: 0.8rem;
  color: var(--yukima-text);
  opacity: 0.6;
  text-decoration: none;
  border-bottom: 1px dotted var(--yukima-border-hover);
  padding-bottom: 1px;
}
.export-link:hover { opacity: 1; color: var(--yukima-link); }

.editor { margin-top: 1rem; }

.editor .row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
}

.editor input[type="date"],
.editor input[type="text"],
.editor input[type="password"],
.editor textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--yukima-border);
  border-radius: var(--yukima-radius-sm, 4px);
  background: var(--yukima-bg);
  color: var(--yukima-text);
}
.editor input:focus,
.editor textarea:focus {
  outline: 2px solid var(--yukima-glow);
  outline-offset: 1px;
}

.editor textarea {
  width: 100%;
  min-height: 320px;
  line-height: 1.9;
  resize: vertical;
  font-family: 'Noto Serif', Georgia, serif;
}

.editor .grow { flex: 1 1 12rem; }

.editor .hint {
  font-size: 0.8rem;
  color: var(--yukima-text);
  opacity: 0.6;
  margin: 0.4rem 0 0;
}

.msg {
  font-size: 0.88rem;
  padding: 0.5rem 0.8rem;
  border-radius: var(--yukima-radius-sm, 4px);
  margin-bottom: 0.8rem;
}
.msg.err { background: rgba(200, 80, 80, 0.12); color: #b04a4a; }
.msg.ok  { background: rgba(120, 180, 80, 0.15); color: var(--yukima-link-hover); }
[data-theme="dark"] .msg.err { color: #e58f8f; }

.empty {
  text-align: center;
  padding: 5rem 1rem;
  color: var(--paper-ink-soft);
  font-style: italic;
}

/* 登录浮层 */
.login-box {
  max-width: 340px;
  margin: 1rem auto;
  text-align: center;
}
.login-box input { width: 100%; margin-bottom: 0.6rem; }

/* ── 正文里的图 ───────────────────────────────────────────── */
/* 像贴在日记本上的照片：留白边、轻微投影 */
.entry-img {
  display: block;
  max-width: 100%;
  /* 竖幅照片不加限制会独占整页，压一下高度；点开还是原图 */
  max-height: 620px;
  width: auto;
  height: auto;
  margin: 1.2em auto;
  padding: 6px;
  background: var(--paper);
  border: 1px solid var(--paper-margin);
  border-radius: 2px;
  box-shadow: 0 2px 6px var(--book-shadow);
  cursor: zoom-in;
  /* 图片自带高度，压在横格上会显脏，这里让它脱离行高节奏 */
  line-height: 0;
}

.entry-body p:has(> .entry-img:only-child) {
  line-height: 0;
  margin-bottom: 1em;
}

/* 拖拽悬停时的提示 */
.editor textarea.dropping {
  outline: 2px dashed var(--yukima-link);
  outline-offset: -4px;
  background: var(--yukima-component-bg);
}

/* ── 看大图 ───────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(20, 24, 18, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: zoom-out;
  animation: lbfade 0.18s ease;
}

@keyframes lbfade { from { opacity: 0 } to { opacity: 1 } }

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.lightbox .lb-close {
  position: absolute;
  top: 1rem;
  right: 1.4rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}
.lightbox .lb-close:hover { color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .lightbox { animation: none; }
}

/* ── 窄屏 ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .book .spine { width: 16px; }
  .page { padding: 1.8rem 1.2rem 1.8rem 2.2rem; }
  .page::before { left: 1.7rem; }
  .entry-date .d { font-size: 1.25rem; }
  .zhaji-wrap { margin-top: 1.5rem; }
  .lightbox { padding: 1rem; }
}
