@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Noto+Sans+SC:wght@400;600;800&display=swap');

/* ---------- 变量与主题 ---------- */
:root {
  --bg: #f7f8f5;
  --card: #fff;
  --ink: #202522;
  --muted: #7a827d;
  --line: #e1e5df;
  --accent: #4f7d6d;
  --soft: #e8f1ec;
}

.dark {
  --bg: #171b19;
  --card: #222925;
  --ink: #edf3ee;
  --muted: #a2aea7;
  --line: #37423b;
  --soft: #29372f;
}

.dark .brand-icon {
  background: var(--accent);
}

/* ---------- 基础 ---------- */
* {
  box-sizing: border-box;
}

*:focus-visible {
  outline: 2px solid var(--accent);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans SC', sans-serif;
}

.app {
  max-width: 1080px;
  margin: auto;
  padding: 0 32px;
}

/* ---------- 头部 ---------- */
header {
  height: 78px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font: 600 14px 'DM Mono';
}

.brand-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font: 700 14px 'DM Mono';
  margin-right: 8px;
  vertical-align: middle;
}

nav {
  display: flex;
  gap: 28px;
}

nav a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

nav a.active {
  color: var(--ink);
  font-weight: 600;
}

#theme {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

/* ---------- Hero ---------- */
.hero {
  padding: 100px 0 86px;
  max-width: 720px;
}

.eyebrow {
  font: 11px 'DM Mono';
  letter-spacing: 0.12em;
  color: var(--muted);
}

h1 {
  font-size: clamp(44px, 7vw, 76px);
  line-height: 1.12;
  letter-spacing: -0.06em;
  margin: 22px 0;
}

.hero h1 em {
  font-family: Georgia, serif;
  color: var(--accent);
  font-weight: 400;
}

.hero p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 30px;
}

/* ---------- 按钮 ---------- */
.primary {
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  background: var(--ink);
  color: white;
  text-decoration: none;
  border: 1px solid var(--ink);
}

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 20px;
}

.toolbar h2,
aside h2 {
  font-size: 28px;
  margin: 12px 0;
}

.tools {
  display: flex;
  gap: 12px;
  align-items: center;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 5px;
  padding: 10px 12px;
  font: 12px inherit;
}

.tools input {
  width: 170px;
}

.filters {
  display: flex;
  gap: 5px;
}

.filter {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px;
  font-size: 12px;
  cursor: pointer;
}

.filter.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom: 2px solid var(--ink);
}

/* ---------- 笔记卡片 ---------- */
.note {
  display: grid;
  grid-template-columns: 60px 1fr 30px;
  gap: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 27px;
  margin: 12px 0;
}

.note[hidden] {
  display: none;
}

.date {
  font: 18px 'DM Mono';
  color: var(--accent);
  line-height: 1.15;
}

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

.tag {
  font: 10px 'DM Mono';
  color: var(--accent);
}

.note h3 {
  font-size: 19px;
  margin: 9px 0;
}

.note h3 a {
  color: var(--ink);
  text-decoration: none;
}

.note p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px;
}

.meta {
  font: 10px 'DM Mono';
  color: #a0a8a3;
}

.arrow {
  color: var(--accent);
  font-size: 20px;
  text-decoration: none;
}

.notes {
  max-width: 780px;
  padding-bottom: 75px;
}

/* ---------- 登录卡片（首页右侧栏） ---------- */
.login-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 27px;
}

.login-card h2 {
  font-size: 28px;
  margin: 4px 0 20px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.login-form input {
  width: 100%;
}

.login-form .primary {
  margin-top: 8px;
  text-align: center;
}

.login-error {
  color: #d9534f;
  font-size: 11px;
  margin: 0;
  text-align: center;
}

.login-foot {
  margin-top: auto;
  padding-top: 18px;
  font-size: 11px;
  color: var(--muted);
}

.login-foot a {
  color: var(--accent);
  text-decoration: none;
}

/* 管理员面板 */
.admin-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
  margin: 0;
}

.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-top: 18px;
}

.admin-btn {
  width: 100%;
}

.admin-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-btn.secondary {
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

/* ---------- 内容布局（首页两栏） ---------- */
.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 28px;
  align-items: stretch;
}

/* ---------- 关于卡片 ---------- */
.about-page {
  max-width: 560px;
  margin: 60px auto 90px;
}

aside {
  border-top: 1px solid var(--line);
  padding: 50px 0 80px;
}

aside p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.about-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 27px;
}

.about-gif {
  height: 150px;
  border-radius: 8px;
  margin-bottom: 24px;
  overflow: hidden;
}

.about-gif img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.about-avatar {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font: 600 17px 'DM Mono';
  margin-bottom: 30px;
}

.about-card h2 {
  font-size: 24px;
  line-height: 1.35;
}

.about-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}

.signature {
  cursor: pointer;
  border-radius: 4px;
  padding: 6px 8px;
  margin: -6px -8px;
  transition: background 0.15s;
}

.signature:hover {
  background: var(--soft);
}

.about-line {
  border-top: 1px solid var(--line);
  padding: 12px 0;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.about-line span {
  color: var(--muted);
}

.about-links {
  display: flex;
  gap: 18px;
  margin-top: auto;
  padding-top: 20px;
}

.about-links a {
  color: var(--accent);
  font: 11px 'DM Mono';
  text-decoration: none;
}

/* ---------- 弹窗 ---------- */
dialog {
  border: 0;
  border-radius: 10px;
  padding: 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.2);
}

dialog::backdrop {
  background: rgba(32, 37, 34, 0.4);
}

dialog form {
  width: min(420px, calc(100vw - 40px));
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

dialog form h2 {
  margin: 0 0 8px;
}

dialog form label span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

dialog form input,
dialog form select,
dialog form textarea {
  width: 100%;
}

dialog form textarea {
  min-height: 100px;
  resize: vertical;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- 次要按钮 ---------- */
.secondary {
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

/* ---------- 头像可点击 ---------- */
.about-avatar {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
}

.about-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.about-avatar::after {
  content: '更换头像';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 25%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font: 10px 'DM Mono';
  border-radius: 0 0 50% 50%;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.about-avatar:hover::after {
  opacity: 1;
}

.login-avatar {
  position: relative;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font: 600 17px 'DM Mono';
  margin-bottom: 24px;
  cursor: pointer;
  overflow: hidden;
}

.login-avatar::after {
  content: '更换头像';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 25%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font: 10px 'DM Mono';
  border-radius: 0 0 50% 50%;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.login-avatar:hover::after {
  opacity: 1;
}

/* 游客/非编辑者——隐藏头像 hover 覆盖层 */
.about-avatar.no-edit,
.login-avatar.no-edit {
  cursor: default;
}

.about-avatar.no-edit::after,
.login-avatar.no-edit::after {
  display: none;
}

.signature.no-edit {
  cursor: default;
}

.signature.no-edit:hover {
  background: transparent;
}

/* 头像弹窗 */
.avatar-dialog {
  text-align: center;
}

.avatar-upload-area {
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 28px 20px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.avatar-upload-area:hover,
.avatar-upload-area.drag-over {
  border-color: var(--accent);
  background: var(--soft);
}

.avatar-preview {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  overflow: hidden;
  font: 600 28px 'DM Mono';
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-upload-area p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* ---------- 留言板 ---------- */
.guestbook {
  max-width: 780px;
  padding: 40px 0 60px;
  border-top: 1px solid var(--line);
}

.guestbook-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 60px 0 80px;
  border-top: 0;
}

.guest-login-btn {
  width: 100%;
  margin-top: 8px;
}

.guestbook-form {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  margin: 18px 0 32px;
}

.guestbook-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guestbook-fields input,
.guestbook-fields textarea {
  width: 100%;
}

.guestbook-fields textarea {
  min-height: 60px;
  resize: vertical;
}

.guestbook-form .primary {
  flex-shrink: 0;
}

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

.guestbook-msg {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 22px;
}

.guestbook-msg .msg-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.guestbook-msg .msg-author {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}

.guestbook-msg .msg-date {
  font: 10px 'DM Mono';
  color: var(--muted);
}

.guestbook-msg .msg-body {
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
}

.guestbook-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 40px 0;
}

/* 笔记载具页管理员按钮 */
#adminNoteBtn {
  padding: 6px 12px;
  font-size: 16px;
  line-height: 1;
  border-radius: 5px;
  flex-shrink: 0;
}

/* ---------- 页脚 ---------- */
footer {
  border-top: 1px solid var(--line);
  padding: 20px 0;
  color: var(--muted);
  font: 10px 'DM Mono';
  display: flex;
  justify-content: space-between;
}

/* ---------- 响应式 ---------- */
@media (max-width: 850px) {
  .content-layout {
    grid-template-columns: 1fr;
  }

  .about-card {
    height: auto;
    margin-bottom: 70px;
  }
}

@media (max-width: 700px) {
  .app {
    padding: 0 18px;
  }

  nav {
    display: none;
  }

  .hero {
    padding: 70px 0;
  }

  .toolbar {
    display: block;
  }

  .tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 18px;
  }

  .tools input {
    flex: 1;
    min-width: 120px;
    margin-bottom: 0;
  }

  .filters {
    justify-content: flex-start;
  }

  .note {
    grid-template-columns: 44px 1fr 20px;
    padding: 20px;
    gap: 14px;
  }

  footer {
    display: block;
    line-height: 2;
  }
}