:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2937;
  --text-soft: #6b7280;
  --line: #e5e7eb;
  --brand: #d97706;
  --brand-soft: #fef3c7;
  --accent: #0e7490;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

/* hidden 属性必须赢过任何 display 规则(如 .success-banner/.loc-panel 的 flex) */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

/* ---------- 头部 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.site-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: 0.04em;
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.site-subtitle {
  margin: 2px 0 0;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.btn-write {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.btn-write:active { opacity: 0.85; }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.panel-heading {
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-weight: 700;
}

/* ---------- 日历 ---------- */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-nav h2 { margin: 0; font-size: 1.05rem; }

.cal-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  font-size: 1.2rem;
  color: var(--text);
  cursor: pointer;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  color: var(--text-soft);
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-blank { min-height: 44px; }

.cal-day {
  position: relative;
  min-height: 44px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid transparent;
}

.cal-day:hover { background: #f3f4f6; }

.cal-day.has-entry { background: var(--brand-soft); }

.cal-day.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}

.cal-num { font-size: 0.95rem; font-weight: 600; }

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 2px;
}

/* ---------- 条目 ---------- */
.entries { display: flex; flex-direction: column; gap: 14px; }

.entry {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--card);
}

.entry-title { margin: 4px 0 4px; font-size: 1.08rem; }

.entry-text {
  margin: 6px 0;
  white-space: pre-line;
  color: var(--text);
}

.album-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: #ecfeff;
  border-radius: 999px;
  padding: 2px 10px;
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.author-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #92400e;
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 2px 10px;
}

.author-tag.rose {
  color: #9d174d;
  background: #fce7f3;
}

.loc-tag {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.time-tag {
  font-size: 0.75rem;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.album-map {
  display: none;
  height: 320px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 14px;
  overflow: hidden;
}

.album-map .leaflet-container { font: inherit; }

.empty { color: var(--text-soft); font-size: 0.9rem; }

/* ---------- 动态流 ---------- */
.stream-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.stream-head .panel-heading { margin: 0; }

.album-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 0.82rem;
  padding: 4px 12px;
  cursor: pointer;
}

.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.stream-entry { display: flex; flex-direction: column; gap: 4px; }

.stream-date {
  font-size: 0.8rem;
  color: var(--text-soft);
  font-weight: 600;
}

/* ---------- 照片 ---------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  cursor: zoom-in;
  box-shadow: var(--shadow);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  cursor: zoom-out;
}

.lightbox.open { display: flex; }

.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* ---------- 写日记表单 ---------- */
.upload-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 640px;
}

.upload-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.upload-form input[type="text"],
.upload-form input[type="date"],
.upload-form input[type="password"],
.upload-form textarea,
.upload-form select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}

.upload-form input[type="file"] { font-size: 0.88rem; }

.photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

.preview-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.72rem;
  color: var(--text-soft);
}

.preview-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
}

.form-status { font-size: 0.88rem; color: var(--text-soft); min-height: 1.2em; margin: 0; }

.form-status.error { color: #b91c1c; }

.btn-submit {
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

.btn-submit:active { opacity: 0.85; }

.btn-small {
  font: inherit;
  font-size: 0.82rem;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

.btn-small:active { opacity: 0.8; }

.loc-row { display: flex; gap: 8px; }
.loc-row input { flex: 1; }

/* 全屏选点器(搜索优先) */
.loc-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
}

.loc-overlay-card {
  width: 100%;
  max-width: 640px;
  height: 100%;
  height: 100dvh;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  overflow: hidden;
}

.loc-overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.loc-overlay-title { font-weight: 700; }

.loc-search-row {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.loc-search-row input {
  flex: 1;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f5f5f5;
  color: var(--text);
}

.loc-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 38vh;
  overflow: auto;
  flex-shrink: 0;
}

.loc-result {
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}

.loc-map {
  flex: 1;
  min-height: 200px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.loc-confirm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  background: #fffbeb;
  flex-shrink: 0;
}

.loc-confirm-name {
  font-size: 0.82rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-nearby {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.loc-nearby-title {
  width: 100%;
  font-size: 0.75rem;
  color: var(--text-soft);
}

.loc-nearby-chip {
  font: inherit;
  font-size: 0.78rem;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
}

.success-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #ecfdf5;
  color: #065f46;
  font-weight: 700;
}

.success-actions { display: flex; gap: 8px; }

.success-actions .btn-small { background: #d1fae5; border-color: #a7f3d0; }

.manage-panel { max-width: 640px; }

.manage-hint { margin: 0 0 10px; font-size: 0.8rem; color: var(--text-soft); }

.recent-list { display: flex; flex-direction: column; gap: 6px; }

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.88rem;
}

.recent-info { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-del { border-color: #fecaca; color: #b91c1c; background: #fef2f2; }

/* ---------- 管理:预览 / 编辑 ---------- */
.recent-actions { display: flex; gap: 6px; flex-shrink: 0; }

.form-actions { display: flex; align-items: center; gap: 10px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 16px;
}

.modal-card {
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-date {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-soft);
}

.edit-photos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafa;
}

.edit-photos-title { font-size: 0.82rem; font-weight: 600; color: var(--text-soft); }

.edit-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

.edit-photo {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}

.edit-photo img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.edit-photo.removed { opacity: 0.45; }

.edit-photo-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
  line-height: 1;
}

.edit-photo-mark {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 0.68rem;
  color: #fff;
  background: rgba(185, 28, 28, 0.85);
  border-radius: 4px;
  padding: 1px 6px;
}

/* ---------- 导出 ---------- */
.export-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.export-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-soft);
}

.export-form input[type="date"] {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}

/* ---------- 打印 ---------- */
@media print {
  .site-header { position: static; }
  .site-header .header-side, .btn-print { display: none; }
  .layout { max-width: 100%; padding: 0; }
  .panel { box-shadow: none; border: 1px solid var(--line); page-break-inside: avoid; }
  .photo-grid img { max-height: 200px; }
  #ex-map { height: 400px; }
}

/* ---------- 底部 ---------- */
.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 32px;
  font-size: 0.82rem;
  color: var(--text-soft);
  text-align: center;
}

/* ---------- 桌面端 ---------- */
@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    align-items: start;
  }
  /* 动态流跨两列,避免被挤进左列日历下方 */
  .stream-panel { grid-column: 1 / -1; }
}
