:root {
  --bg: #ffffff;
  --surface: #f7f7f5;
  --surface-2: #efefeb;
  --ink: #1b1b19;
  --ink-2: #4b4b46;
  --muted: #8e8e87;
  --line: #ecece8;
  --accent: #c05a35;
  --accent-soft: #fbf2ee;
  --danger: #c0392b;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 24px 70px -40px rgba(20, 20, 18, 0.45);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body:has(dialog[open]) {
  overflow: hidden;
}

::selection {
  background: rgba(17, 17, 17, 0.12);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.login {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px;
  overflow: hidden;
  background:
    radial-gradient(52% 42% at 70% 24%, #fafaf8 0%, rgba(250, 250, 248, 0) 72%),
    var(--bg);
}

.login-card {
  width: min(380px, 100%);
  text-align: center;
  animation: rise 0.9s var(--ease) both;
}

.login-title {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(38px, 8vw, 48px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
}

#login-form {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 44px;
}

#password {
  flex: 1;
  min-width: 0;
  height: 54px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--surface);
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--ink);
  outline: none;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}

#password::placeholder {
  color: #a7a7a0;
}

#password:focus {
  background: var(--bg);
  border-color: var(--ink);
}

.login-submit {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}

.login-submit:hover {
  background: #333330;
}

.login-submit:active {
  transform: scale(0.95);
}

.login-error {
  min-height: 20px;
  margin: 14px 0 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.login-error.shake {
  animation: shake 0.45s var(--ease);
}

.login-foot {
  margin: 52px 0 0;
  font-size: 10px;
  letter-spacing: 0.32em;
  color: var(--muted);
}

/* ------------------------------- 页头 ------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(18px, 4.5vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px) saturate(1.05);
  -webkit-backdrop-filter: blur(16px) saturate(1.05);
  animation: fade-down 0.6s var(--ease) both;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #9b9b94;
  cursor: pointer;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}

.icon-btn:hover {
  color: var(--ink);
  background: var(--surface);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease),
    border-color 0.25s var(--ease), transform 0.25s var(--ease);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  color: #fff;
}

.btn-primary:hover {
  background: #343431;
}

.btn-ghost {
  background: var(--surface);
  color: var(--ink-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #a93226;
}

.btn-add {
  height: 38px;
  padding: 0 15px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ------------------------------- 主内容 ------------------------------- */

.page {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 32px);
}

.timeline-switch {
  display: flex;
  justify-content: center;
  padding: 26px 0 2px;
}

.switch-track {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
}

.switch-btn {
  height: 34px;
  min-width: 66px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.switch-btn:hover {
  color: var(--ink);
}

.switch-btn.is-active {
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 2px 10px -4px rgba(20, 20, 18, 0.2);
}

/* ------------------------------- 时间线 ------------------------------- */

.timeline {
  position: relative;
  padding: 22px 0 28px;
}

.timeline-pane[hidden] {
  display: none;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--line);
}

.year-block {
  position: relative;
}

.year-marker {
  display: flex;
  justify-content: center;
  padding: 42px 0 32px;
}

.year-marker span {
  position: relative;
  z-index: 2;
  padding: 0 16px;
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--muted);
}

.entry {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 64px 1fr;
  align-items: start;
  margin-bottom: 40px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.entry.in {
  opacity: 1;
  transform: none;
}

.entry-dot {
  position: absolute;
  top: 24px;
  left: 50%;
  z-index: 3;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(-50%);
  box-shadow: 0 0 0 5px var(--bg);
}

.entry-body {
  width: 100%;
  max-width: 460px;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease),
    background 0.35s var(--ease);
}

.entry-body:hover {
  background: #f5f5f2;
  transform: translateY(-2px);
  box-shadow: 0 20px 44px -32px rgba(20, 20, 18, 0.35);
}

.entry--left .entry-body {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
}

.entry--left .entry-meta {
  grid-column: 3;
  grid-row: 1;
  justify-self: start;
  padding-left: 34px;
}

.entry--right .entry-body {
  grid-column: 3;
  grid-row: 1;
  justify-self: start;
}

.entry--right .entry-meta {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  padding-right: 34px;
  text-align: right;
}

.entry-meta {
  padding-top: 18px;
}

.entry-date {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.entry--right .entry-date {
  align-items: flex-end;
}

.entry-day {
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.entry-month {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.entry-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.entry-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.01em;
  word-break: break-word;
}

.entry-actions {
  display: flex;
  flex: none;
  gap: 1px;
  margin: -7px -9px 0 0;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}

.entry:hover .entry-actions,
.entry:focus-within .entry-actions {
  opacity: 1;
}

.mini-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #a2a29b;
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}

.mini-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
}

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

.entry-content {
  max-width: 60ch;
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.85;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.entry-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.thumb {
  position: relative;
  display: block;
  width: calc(50% - 3px);
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
  cursor: zoom-in;
}

.thumb:only-child {
  width: 100%;
  aspect-ratio: 16 / 10;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s var(--ease), transform 0.7s var(--ease);
}

.thumb img.is-loaded {
  opacity: 1;
}

.thumb:hover img {
  transform: scale(1.035);
}

/* ------------------------------- 空状态 ------------------------------- */

.empty {
  padding: 96px 0 100px;
  text-align: center;
  animation: rise 0.8s var(--ease) both;
}

.empty-title {
  margin: 0 0 22px;
  font-size: 19px;
  font-weight: 500;
  color: var(--ink-2);
}

.site-footer {
  display: flex;
  justify-content: flex-end;
  padding: 22px 0 32px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--muted);
}

/* ------------------------------- 弹窗 ------------------------------- */

dialog.sheet,
dialog.confirm {
  width: min(560px, calc(100vw - 28px));
  max-height: min(88vh, 900px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}

dialog.confirm {
  width: min(380px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(22, 22, 20, 0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

dialog[open] {
  animation: sheet-in 0.4s var(--ease) both;
}

.sheet-inner {
  max-height: min(88vh, 900px);
  padding: clamp(24px, 4vw, 30px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-title {
  margin: 0 0 24px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.timeline-picker {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
}

.timeline-option {
  height: 34px;
  min-width: 62px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.timeline-option:hover {
  color: var(--ink);
}

.timeline-option.is-active {
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 2px 10px -4px rgba(20, 20, 18, 0.2);
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--surface);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  outline: none;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}

.field input:focus,
.field textarea:focus {
  background: var(--bg);
  border-color: var(--ink);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #b1b1aa;
}

.field textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.8;
}

.field input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
}

.field input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.4;
  cursor: pointer;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 16px;
  border: 1px dashed #dcdcd5;
  border-radius: 16px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.25s var(--ease), color 0.25s var(--ease),
    background 0.25s var(--ease);
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}

.dropzone-hint {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.previews:empty {
  display: none;
}

.preview {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview .bar-track {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: rgba(17, 17, 17, 0.12);
}

.preview .bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s linear;
}

.preview .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 17, 17, 0.58);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s var(--ease), background 0.2s var(--ease);
}

.preview:hover .remove,
.preview:focus-within .remove {
  opacity: 1;
}

.preview .remove:hover {
  background: var(--danger);
}

.preview .badge-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 6px;
  background: rgba(17, 17, 17, 0.66);
  color: #fff;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

.upload-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--accent);
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 26px;
}

.confirm-inner {
  padding: 26px;
}

.confirm-title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.confirm-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
}

/* ------------------------------- 灯箱 / 提示 ------------------------------- */

.pswp {
  --pswp-bg: #0d0d0c;
}

.pswp__counter {
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.72);
}

.pswp__button {
  opacity: 0.72;
}

.pswp__button:hover {
  opacity: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 400;
  padding: 11px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  letter-spacing: 0.03em;
  opacity: 0;
  transform: translate(-50%, 14px);
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  max-width: calc(100vw - 48px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  font-family: var(--font);
  font-size: 16px;
  z-index: 500;
}

/* ------------------------------- 动画 ------------------------------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-down {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.988);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes shake {
  10%,
  90% {
    transform: translateX(-1px);
  }
  20%,
  80% {
    transform: translateX(2px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-4px);
  }
  40%,
  60% {
    transform: translateX(4px);
  }
}

/* ------------------------------- 响应式 ------------------------------- */

@media (max-width: 820px) {
  .site-header {
    padding: 12px 16px;
  }

  .brand-name {
    font-size: 15px;
  }

  .timeline {
    padding: 6px 0 20px 34px;
  }

  .timeline-switch {
    padding: 18px 0 0;
  }

  .switch-btn {
    height: 32px;
    min-width: 60px;
    padding: 0 16px;
    font-size: 12px;
  }

  .timeline::before {
    left: 7px;
  }

  .year-marker {
    justify-content: flex-start;
    padding: 30px 0 22px;
  }

  .year-marker span {
    padding: 0 12px 0 0;
  }

  .entry {
    display: block;
    margin-bottom: 30px;
  }

  .entry-dot {
    top: 13px;
    left: -27px;
  }

  .entry--left .entry-meta,
  .entry--right .entry-meta {
    justify-self: start;
    padding: 0;
    margin-bottom: 7px;
    text-align: left;
  }

  .entry-meta {
    margin-bottom: 7px;
  }

  .entry-date {
    flex-direction: row;
    align-items: baseline;
    gap: 7px;
  }

  .entry--right .entry-date {
    align-items: baseline;
  }

  .entry-day {
    font-size: 15px;
    font-weight: 600;
  }

  .entry-month {
    font-size: 11px;
  }

  .entry-body {
    max-width: 100%;
    padding: 16px;
    border-radius: 16px;
  }

  .entry-title {
    font-size: 18px;
  }

  .entry-actions {
    opacity: 1;
    margin: -5px -7px 0 0;
  }

  .entry-images {
    gap: 5px;
  }

  .thumb {
    width: calc(50% - 2.5px);
  }

  .thumb:only-child {
    aspect-ratio: 16 / 11;
  }

  .empty {
    padding: 70px 0;
  }

  dialog.sheet,
  dialog.confirm {
    width: calc(100vw - 20px);
    max-height: 92vh;
    border-radius: 20px;
  }

  .sheet-inner {
    max-height: 92vh;
    padding: 22px;
  }

  .site-footer {
    padding-bottom: 24px;
  }

  .toast {
    bottom: 24px;
  }
}

@media (max-width: 480px) {
  .btn-label {
    display: none;
  }

  .btn-add {
    width: 38px;
    padding: 0;
  }

  .login-title {
    font-size: 38px;
  }

  .login-foot {
    margin-top: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .entry {
    opacity: 1;
    transform: none;
  }
}
