:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --text: #2c2c2a;
  --text-secondary: #5f5e5a;
  --text-tertiary: #888780;
  --border: #e8e6e0;
  --border-strong: #d3d1c7;
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 680px;

  --c-text: #b8d8f0;
  --c-text-stroke: #85b7eb;
  --c-text-ink: #0c447c;

  --c-dream: #dcc8e8;
  --c-dream-stroke: #afa9ec;
  --c-dream-ink: #534ab7;

  --c-game: #f2bfa0;
  --c-game-stroke: #e8a87c;
  --c-game-ink: #712b13;

  --c-think: #f0e2a8;
  --c-think-stroke: #d4b860;
  --c-think-ink: #633806;

  --c-guest: #ffffff;
  --c-guest-stroke: #d3d1c7;
  --c-guest-ink: #2c2c2a;
}

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

body {
  font-family: -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* 首页 body：透明背景，让壁纸层显示出来 */
body.home-body {
  background: transparent;
}

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

/* ===== Shared layout ===== */
.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ===== Wallpaper background layer ===== */
/* 固定在屏幕最底层，显示当前壁纸 */
.wallpaper-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: var(--bg); /* 无壁纸时的背景色 */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* ===== Homepage layout — content in bottom half ===== */
/* 首页内容推到屏幕下半部分，上半部分展示壁纸 */
.page-home {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.5rem;
}

.page-header {
  text-align: center;
  padding: 1.5rem 0 1rem;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 3px;
}

.page-header .subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.back-link {
  font-size: 13px;
  color: var(--text-tertiary);
  display: inline-block;
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--text-secondary); }

/* ===== Homepage - SVG layout ===== */
.home-svg-wrap {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}
.home-svg-wrap svg {
  width: 100%;
  max-width: 440px;
  height: auto;
}
.home-svg-wrap .block-group {
  cursor: pointer;
  transition: opacity 0.2s;
}
.home-svg-wrap .block-group:hover {
  opacity: 0.9;
}

/* ===== Homepage - mobile cards ===== */
.home-cards {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 0.5rem 0;
}
.home-cards .card {
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: opacity 0.2s;
  /* backdrop-filter: 让色块后面的壁纸有轻微模糊效果，提升文字可读性 */
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.home-cards .card:hover { opacity: 0.9; }
.home-cards .card-label {
  font-size: 15px;
  font-weight: 500;
}
.home-cards .card-preview {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 6px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .home-svg-wrap { display: none; }
  .home-cards { display: flex; }
}

/* ===== Category page ===== */
.entry-list { display: flex; flex-direction: column; gap: 2rem; }
.entry {
  padding-bottom: 2rem;
  border-bottom: 0.5px solid var(--border);
}
.entry:last-child { border-bottom: none; }
.entry-date {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.entry-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
}
.entry-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}
.entry-actions {
  margin-top: 10px;
  display: none;
  gap: 12px;
}
.entry-actions.show { display: flex; }
.entry-actions button {
  font-size: 12px;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
}
.entry-actions button:hover { color: var(--text); }
.entry-actions .btn-delete:hover { color: #c0392b; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ===== Guestbook ===== */
.guestbook-form {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 2rem;
}
.guestbook-form input,
.guestbook-form textarea {
  width: 100%;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
.guestbook-form input:focus,
.guestbook-form textarea:focus {
  outline: none;
  border-color: var(--text-tertiary);
}
.guestbook-form textarea {
  resize: vertical;
  min-height: 80px;
  margin-top: 8px;
}
.guestbook-form button {
  margin-top: 10px;
  padding: 8px 20px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.guestbook-form button:hover { background: var(--bg); }

.message {
  padding: 1rem 0;
  border-bottom: 0.5px solid var(--border);
}
.message:last-child { border-bottom: none; }
.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.message-nickname {
  font-size: 13px;
  font-weight: 500;
}
.message-date {
  font-size: 11px;
  color: var(--text-tertiary);
}
.message-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  word-break: break-word;
}
.message-delete {
  font-size: 11px;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  display: none;
  margin-top: 4px;
}
.message-delete.show { display: inline-block; }
.message-delete:hover { color: #c0392b; }

/* ===== Admin ===== */
.admin-login {
  max-width: 360px;
  margin: 3rem auto;
  text-align: center;
}
.admin-login input {
  width: 100%;
  padding: 10px 14px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  margin-bottom: 10px;
}
.admin-login input:focus { outline: none; border-color: var(--text-tertiary); }
.admin-login button {
  width: 100%;
  padding: 10px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--text);
  color: var(--surface);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.admin-login button:hover { opacity: 0.9; }
.admin-login .error {
  color: #c0392b;
  font-size: 13px;
  margin-top: 8px;
}

.admin-panel { display: none; }
.admin-panel.show { display: block; }

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 1.5rem;
  border-bottom: 0.5px solid var(--border);
  padding-bottom: 0;
}
.admin-tab {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-tertiary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.admin-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.admin-section { display: none; }
.admin-section.show { display: block; }

.btn-new {
  padding: 8px 16px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 1rem;
}
.btn-new:hover { background: var(--bg); }

.editor-form {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: none;
}
.editor-form.show { display: block; }
.editor-form label {
  font-size: 12px;
  color: var(--text-tertiary);
  display: block;
  margin-bottom: 4px;
}
.editor-form select,
.editor-form input,
.editor-form textarea {
  width: 100%;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 12px;
}
.editor-form textarea {
  resize: vertical;
  min-height: 200px;
}
.editor-form select:focus,
.editor-form input:focus,
.editor-form textarea:focus {
  outline: none;
  border-color: var(--text-tertiary);
}
.editor-form .form-actions {
  display: flex;
  gap: 8px;
}
.editor-form .btn-save {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.editor-form .btn-save:hover { opacity: 0.9; }
.editor-form .btn-cancel {
  padding: 8px 20px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.editor-form .btn-cancel:hover { background: var(--bg); }

.admin-entry-list { display: flex; flex-direction: column; gap: 0.75rem; }
.admin-entry-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
}
.admin-entry-item .ae-title {
  font-size: 13px;
  font-weight: 500;
}
.admin-entry-item .ae-date {
  font-size: 11px;
  color: var(--text-tertiary);
}
.admin-entry-item .ae-actions {
  display: flex;
  gap: 8px;
}
.admin-entry-item .ae-actions button {
  font-size: 12px;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  font-family: inherit;
}
.admin-entry-item .ae-actions button:hover { color: var(--text); }
.admin-entry-item .ae-actions .btn-delete:hover { color: #c0392b; }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 2rem 0 1rem;
  font-size: 11px;
  color: var(--text-tertiary);
}
.footer a { color: var(--text-tertiary); }
.footer a:hover { color: var(--text-secondary); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 100;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ===== Homepage header — text shadow for wallpaper readability ===== */
.page-home .page-header h1 {
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.15);
}

/* ===== Wallpaper management grid (admin) ===== */
.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 1rem;
}
.wallpaper-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 0.5px solid var(--border);
  aspect-ratio: 16 / 10;
}
.wallpaper-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.wallpaper-item .wp-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}
.wallpaper-item:hover .wp-delete { opacity: 1; }
.wallpaper-item .wp-delete:hover { background: rgba(192, 57, 43, 0.85); }
.wallpaper-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ===== Category page: top bar with edit button ===== */
.cat-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.cat-topbar .back-link {
  margin-bottom: 0;
}
.edit-toggle {
  font-size: 12px;
  color: var(--text-tertiary);
  background: none;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 4px 12px;
  cursor: pointer;
  font-family: inherit;
}
.edit-toggle:hover {
  color: var(--text);
  border-color: var(--text-tertiary);
}

/* ===== Password prompt ===== */
.pwd-prompt {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.pwd-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.pwd-prompt input {
  width: 100%;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
.pwd-prompt input:focus {
  outline: none;
  border-color: var(--text-tertiary);
}
.pwd-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.pwd-confirm {
  padding: 6px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.pwd-cancel {
  padding: 6px 16px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.pwd-error {
  color: #c0392b;
  font-size: 12px;
  margin-top: 8px;
}

/* ===== Entry list: clickable entries ===== */
.entry {
  cursor: pointer;
  transition: opacity 0.15s;
}
.entry:hover {
  opacity: 0.7;
}
.entry-has-images {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ===== Detail modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 24px;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-date {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.modal-title {
  font-size: 17px;
  font-weight: 500;
  margin-bottom: 12px;
}
.modal-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}
.modal-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 1rem;
}
.modal-image {
  width: 100%;
  max-width: 280px;
  border-radius: var(--radius);
  cursor: pointer;
  display: block;
}

/* ===== Image upload area (inline editor) ===== */
.image-upload-area {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  margin-bottom: 8px;
}
.image-upload-area input[type="file"] {
  font-size: 13px;
}
.upload-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}
.file-preview {
  margin-bottom: 12px;
}
.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 4px;
  font-size: 12px;
}
.file-name {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 65%;
}
.file-size {
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ===== Existing images in editor ===== */
.existing-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.existing-img-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 0.5px solid var(--border);
  width: 80px;
  height: 80px;
}
.existing-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== Guestbook image upload ===== */
.gb-image-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 4px;
}
.gb-image-btn {
  display: inline-block;
  padding: 6px 14px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
}
.gb-image-btn:hover {
  border-color: var(--text-tertiary);
  color: var(--text);
}
#gb-image-info {
  font-size: 12px;
  color: var(--text-tertiary);
}
.gb-image-remove {
  font-size: 11px;
  color: #c0392b;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

/* ===== Message image ===== */
.message-image {
  width: 100%;
  max-width: 320px;
  border-radius: var(--radius);
  margin-top: 8px;
  cursor: pointer;
  display: block;
}

/* ===== Site config editor ===== */
.config-editor {
  max-width: 560px;
}
.config-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 6px;
  border-bottom: 0.5px solid var(--border);
}
.config-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0.75rem;
}
.config-label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 160px;
  flex-shrink: 0;
}
.config-input {
  flex: 1;
  padding: 6px 10px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text-primary);
}
.config-input:focus {
  outline: none;
  border-color: var(--accent);
}
.config-modules {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.config-module-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.config-module-row label {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.config-module-row input[type="text"] {
  padding: 4px 8px;
  border: 0.5px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text-primary);
  width: 100px;
}
.config-module-row input[type="color"] {
  width: 32px;
  height: 28px;
  border: 0.5px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  background: none;
  padding: 2px;
}
.config-module-desc {
  flex: 1;
  min-width: 80px;
}
.config-actions {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-save-config {
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-save-config:hover {
  opacity: 0.85;
}
.config-status {
  font-size: 12px;
  color: var(--text-tertiary);
}
.config-status.success {
  color: #27ae60;
}
.config-status.error {
  color: #c0392b;
}
