/* ===== Calendar List ===== */
.calendar-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

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

.month-title {
  font-size: 1.3rem;
  font-weight: 600;
  min-width: 130px;
  text-align: center;
}

.today-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: .85rem;
  cursor: pointer;
  transition: background .2s;
}
.today-btn:hover { background: var(--primary-hover); }

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

.weekday {
  text-align: center;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 0;
}
.weekday.sun, .weekday.sat { color: var(--primary); }

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

.day-cell {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  min-height: 100px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.day-cell:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(74,144,217,.15);
}
.day-cell.other-month {
  opacity: .3;
  cursor: default;
  pointer-events: none;
}
.day-cell.today {
  background: var(--today-bg);
  border-color: var(--today-border);
}
.day-cell.has-event {
  border-left: 3px solid var(--primary);
}

.date-line { display: flex; align-items: baseline; gap: 4px; }
.date-num { font-size: .95rem; font-weight: 600; }
.lunar-date { font-size: .65rem; color: var(--text-light); }

.event-preview {
  font-size: .75rem;
  color: var(--primary);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

.file-badge {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: .65rem;
  color: var(--text-secondary);
}

/* ===== Day Page ===== */
.day-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 12px 16px;
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

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

.day-title {
  font-size: 1.2rem;
  font-weight: 600;
  min-width: 180px;
  text-align: center;
}

.lunar-label {
  font-size: .8rem;
  font-weight: 400;
  color: var(--text-secondary);
}

/* Media gallery */
.media-gallery {
  column-count: 2;
  column-gap: 8px;
  margin-bottom: 8px;
}
.media-gallery.dragover {
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  border-radius: var(--radius);
}

.gallery-item {
  position: relative;
  break-inside: avoid;
  margin-bottom: 8px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
.gallery-item img { width: 100%; display: block; cursor: zoom-in; }
.gallery-item video { width: 100%; display: block; }

.media-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: none;
  font-size: .9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s;
}
.gallery-item:hover .media-delete { opacity: 1; }

/* Upload placeholder */
.gallery-item.uploading {
  position: relative;
  background: var(--bg);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-item.uploading img,
.gallery-item.uploading video {
  opacity: .4;
}

.upload-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255,255,255,.6);
  font-size: .8rem;
  color: var(--text-secondary);
}

.upload-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.placeholder-label {
  font-size: .8rem;
  color: var(--text-secondary);
  padding: 12px;
  text-align: center;
  word-break: break-all;
}
.media-delete:hover { background: var(--danger); }

.gallery-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
  break-inside: avoid;
}
.gallery-file a {
  flex: 1;
  color: var(--primary);
  text-decoration: none;
  font-size: .85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-file a:hover { text-decoration: underline; }
.gallery-file .media-delete {
  position: static;
  opacity: 1;
  background: none;
  color: var(--text-light);
  width: auto;
  height: auto;
}
.gallery-file .media-delete:hover { color: var(--danger); background: none; }

/* Upload bar */
.upload-bar {
  margin-bottom: 10px;
  transition: outline .2s;
  border-radius: var(--radius);
}
.upload-bar.dragover {
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}

.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: .85rem;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.upload-btn:hover { border-color: var(--primary); color: var(--primary); }
.upload-btn span { font-size: 1.1rem; font-weight: 600; }

/* Note meta */
.note-meta {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin-bottom: 10px;
}

.meta-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
}
.meta-row + .meta-row { border-top: 1px solid var(--border); }

.meta-label {
  font-size: .75rem;
  color: var(--text-light);
  font-weight: 500;
  min-width: 32px;
  padding-top: 2px;
  flex-shrink: 0;
}

.meta-value {
  flex: 1;
  cursor: text;
  font-size: .9rem;
  line-height: 1.6;
  min-height: 24px;
  word-break: break-word;
}
.meta-value.empty { color: var(--text-light); }
.meta-value.empty::after { content: attr(data-placeholder); }
.title-value { font-weight: 700; font-size: 1.3rem; }
.content-value:not(.empty) {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.meta-action-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
}
.meta-action-btn:hover { color: var(--primary); }

.meta-edit-title {
  display: none;
  flex: 1;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  outline: none;
  padding: 0;
  background: transparent;
  line-height: 1.6;
}

.note-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-size: .75rem;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .2s;
}
.toolbar-btn:hover { border-color: var(--primary); color: var(--primary); }
.toolbar-danger { color: var(--danger); border-color: transparent; }
.toolbar-danger:hover { border-color: var(--danger); color: var(--danger); }

/* Content editor */
.content-editor {
  width: 100%;
  min-height: 200px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.content-editor:focus { border-color: var(--primary); }

/* Markdown */
.markdown-body { font-size: .9rem; line-height: 1.8; color: var(--text); word-break: break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 12px 0 6px; font-weight: 600; }
.markdown-body h1 { font-size: 1.3rem; }
.markdown-body h2 { font-size: 1.1rem; }
.markdown-body h3 { font-size: 1rem; }
.markdown-body p { margin: 0 0 8px; }
.markdown-body ul, .markdown-body ol { padding-left: 20px; margin: 0 0 8px; }
.markdown-body li { margin: 2px 0; }
.markdown-body code { background: var(--bg); padding: 2px 5px; border-radius: 3px; font-size: .85em; font-family: 'SF Mono', Monaco, Consolas, monospace; }
.markdown-body pre { background: var(--bg); padding: 10px 12px; border-radius: var(--radius); overflow-x: auto; margin: 0 0 8px; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote { border-left: 3px solid var(--border); padding-left: 12px; color: var(--text-secondary); margin: 0 0 8px; }
.markdown-body a { color: var(--primary); }
.markdown-body img { max-width: 100%; border-radius: var(--radius); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .calendar-header { justify-content: center; }
  .day-cell { min-height: 72px; padding: 4px; }
  .date-num { font-size: .8rem; }
  .lunar-date { font-size: .6rem; }
  .event-preview { font-size: .65rem; }
  .day-header { justify-content: center; }
  .media-gallery { column-count: 1; }
}

@media (min-width: 1200px) {
  .media-gallery { column-count: 3; }
}
