* { box-sizing: border-box; margin: 0; padding: 0; }

/* Light is the base. Dark applies when the system asks for it and the reader
   hasn't chosen otherwise, or when they pick it with the toggle. */
:root {
  color-scheme: light;
  --red: #b3261e;
  --ink: #1a1d21;
  --muted: #5c6570;
  --paper: #f7f8fa;
  --card: #ffffff;
  --line: #e6e9ee;
  --flash-bg: #fdf3d7;
  --flash-line: #eadfb8;
}

/* dark palette: keeps the warm paper feel, just inverted */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --red: #e2645a;
    --ink: #e8eaed;
    --muted: #9aa4b0;
    --paper: #0e1116;
    --card: #161a20;
    --line: #262c34;
    --flash-bg: #2e2716;
    --flash-line: #4a3f22;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --red: #e2645a;
  --ink: #e8eaed;
  --muted: #9aa4b0;
  --paper: #0e1116;
  --card: #161a20;
  --line: #262c34;
  --flash-bg: #2e2716;
  --flash-line: #4a3f22;
}

/* theme toggle button (shared pattern across all fedecuci.com pages) */
.theme-toggle {
  position: fixed; top: 1rem; right: 1rem; z-index: 20;
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  cursor: pointer; border-radius: 999px;
  background: var(--card); color: var(--muted); border: 1px solid var(--line);
  transition: color .12s ease, border-color .12s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }
.theme-toggle svg { width: 18px; height: 18px; }
/* show the icon for the theme you would switch TO */
.theme-toggle .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

body {
  font-family: Georgia, "Times New Roman", serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
}

.hero {
  text-align: center;
  padding: 4rem 1.25rem 2.5rem;
  border-bottom: 3px double var(--red);
  max-width: 44rem;
  margin: 0 auto;
}
.hero.small { padding: 2.5rem 1.25rem 1.5rem; }
.hero h1 {
  font-size: 2.6rem;
  font-weight: normal;
  letter-spacing: 0.02em;
}
.hero h1::after {
  content: "中国日记";
  display: block;
  font-size: 1rem;
  color: var(--red);
  letter-spacing: 0.5em;
  margin-top: 0.4rem;
}
.hero .sub { color: var(--muted); margin-top: 1rem; font-style: italic; }
.hero .sub a { color: var(--red); }

.timeline {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.empty { text-align: center; color: var(--muted); padding: 4rem 0; font-style: italic; }

.entry {
  padding: 2.25rem 0;
  border-bottom: 1px solid var(--line);
}
.entry-date {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.entry-date .date {
  color: var(--red);
  font-variant: small-caps;
  letter-spacing: 0.08em;
}
.entry-date .time { color: var(--muted); font-size: 0.85rem; }
.entry h2 { font-weight: normal; font-size: 1.5rem; margin-bottom: 0.5rem; }
.entry-text { white-space: pre-line; margin-bottom: 1rem; }

.photo-grid { display: grid; gap: 0.5rem; grid-template-columns: 1fr; }
.photo-grid.photos-2 { grid-template-columns: 1fr 1fr; }
.photo-grid.photos-3 { grid-template-columns: 1fr 1fr 1fr; }
.photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  background: var(--line);
  aspect-ratio: 4 / 3;
}
.photo-grid.photos-1 img { aspect-ratio: auto; }
.photo-link { cursor: zoom-in; }

#lightbox[hidden] { display: none; }
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  z-index: 10;
  padding: 1rem;
}
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 4px; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 1rem 3rem;
}

/* --- /post admin page --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 1.5rem;
}
.card label { font-size: 0.9rem; color: var(--muted); margin-top: 0.6rem; }
.card .opt { font-style: italic; }
.card input[type="text"],
.card input[type="password"],
.card textarea {
  font: inherit;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}
.card input[type="file"] { font: inherit; padding: 0.4rem 0; }
button {
  font: inherit;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.4rem;
  cursor: pointer;
  margin-top: 1rem;
  align-self: flex-start;
}
button:disabled { opacity: 0.6; cursor: wait; }
button.danger { background: none; color: var(--red); text-decoration: underline; padding: 0; margin: 0; }
.flash {
  background: var(--flash-bg);
  border: 1px solid var(--flash-line);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-top: 1.5rem;
}
.hint { color: var(--muted); font-size: 0.85rem; font-style: italic; }

.manage-title { font-weight: normal; font-size: 1.2rem; margin-top: 2.5rem; }
.manage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.logout { margin-top: 2.5rem; }
.logout button { background: none; color: var(--muted); text-decoration: underline; padding: 0; }
