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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font-family: inherit;
  color: inherit;
}

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

/* 主布局壳 */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-page);
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  overflow: hidden;
  z-index: 30;
}

.app-shell.is-sidebar-collapsed .sidebar {
  width: 0;
  border-right-color: transparent;
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 14px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-text small {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-close-mobile {
  display: none;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 10px;
}

.nav-group + .nav-group {
  margin-top: 22px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 4px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
  display: block;
}

.nav-group-header .nav-group-label {
  margin-bottom: 0;
}

.text-action-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.text-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.nav-item {
  width: 100%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.is-active {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: 500;
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.nav-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-empty-hint {
  margin: 8px 8px 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

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

/* 工作区与顶部栏 */
.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  min-width: 0;
}

.breadcrumb-root {
  color: var(--text-muted);
}

.breadcrumb-sep {
  color: var(--text-muted);
  opacity: 0.6;
}

.breadcrumb-current {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 按钮体系 */
.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.btn-subtle {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.btn-subtle:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
}

/* 主题切换图标显示 */
[data-theme="light"] .icon-sun {
  display: none;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

/* 主内容区 */
.main-content {
  flex: 1;
  padding: 32px 28px 56px;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  outline: none;
}

/* 首页：极简留白 + 核心标语 */
.home-stage {
  min-height: calc(100vh - var(--topbar-height) - 110px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px 12px;
}

.home-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.home-slogan {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.35;
  color: var(--text-primary);
}

.home-sub {
  margin: 16px auto 0;
  max-width: 480px;
  font-size: 14px;
  color: var(--text-muted);
}

.home-quick-links {
  margin-top: 38px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.quick-chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.quick-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* 通用视图页头 */
.view-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.view-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-desc {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 空状态卡片 */
.empty-canvas {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 56px 24px;
  text-align: center;
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-title {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.empty-desc {
  margin: 8px auto 20px;
  max-width: 420px;
  font-size: 13px;
  color: var(--text-muted);
}

/* 相册网格 */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.photo-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.photo-thumb {
  aspect-ratio: 4 / 3;
  background: var(--bg-subtle);
  overflow: hidden;
}

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

.photo-meta {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.photo-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 日历视图 */
.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr);
  gap: 20px;
  align-items: start;
}

.calendar-panel,
.day-detail-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.calendar-month-label {
  font-size: 16px;
  font-weight: 600;
}

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

.calendar-weekdays span {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0 8px;
}

.cal-day {
  aspect-ratio: 1 / 1;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  font-size: 13px;
  position: relative;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.cal-day:hover:not(:disabled) {
  background: var(--bg-hover);
}

.cal-day.is-outside {
  color: var(--text-muted);
  opacity: 0.45;
}

.cal-day.is-today {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.cal-day.is-selected {
  background: var(--accent);
  color: #ffffff;
}

.cal-day-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.day-detail-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.day-detail-sub {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.day-note-textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  padding: 12px;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
}

.day-note-textarea:focus {
  border-color: var(--accent);
}

.day-detail-actions {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.save-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* 自定义分区自由记录卡片 */
.custom-note-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.custom-note-textarea {
  width: 100%;
  min-height: 220px;
  border: none;
  background: transparent;
  resize: vertical;
  font-size: 14px;
  line-height: 1.75;
  outline: none;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modal-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field input,
.field textarea {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
}

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

.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-choice {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-choice.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* 移动端响应式 */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  .app-shell.is-mobile-open .sidebar {
    transform: translateX(0);
    width: var(--sidebar-width);
  }

  .app-shell.is-mobile-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 25;
  }

  .sidebar-close-mobile {
    display: inline-flex;
  }

  .main-content {
    padding: 20px 16px 40px;
  }

  .calendar-layout {
    grid-template-columns: 1fr;
  }
}
