* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-tertiary: #1e1e1e;
  --bg-card: #181818;
  --text-primary: #ffffff;
  --text-secondary: #888888;
  --text-tertiary: #555555;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --border: #2a2a2a;
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #ebebeb;
  --bg-card: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --border: #e5e5e5;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.btn-header-action {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-header-action:active {
  transform: scale(0.95);
  background: var(--bg-tertiary);
}

.nav {
  display: flex;
  justify-content: space-around;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn.active {
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.nav-btn:active {
  transform: scale(0.95);
}

.content {
  flex: 1;
  padding: 20px;
  padding-bottom: 80px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.page {
  display: none;
  animation: fadeIn 0.2s ease;
  flex-direction: column;
}

.page.active {
  display: flex;
  flex: 1;
  min-height: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.input-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.input-card textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.6;
  resize: none;
  outline: none;
  margin-bottom: 12px;
  transition: color 0.3s;
}

.input-card textarea::placeholder {
  color: var(--text-tertiary);
}

.input-card textarea:first-child {
  font-size: 18px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:active {
  transform: scale(0.98);
  background: var(--accent-hover);
}

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

.btn-secondary {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:active {
  background: var(--bg-tertiary);
}

.btn-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  padding: 8px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
  flex-shrink: 0;
}

.note-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  animation: slideIn 0.2s ease;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s;
  margin-bottom: 10px;
}

.note-item:hover {
  background: var(--bg-tertiary);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.note-content {
  flex: 1;
  min-width: 0;
}

.note-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 4px;
  word-break: break-word;
}

.note-preview {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  transition: color 0.3s;
}

.note-time {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
  transition: color 0.3s;
}

.today-list {
  margin-top: 20px;
}

.today-list h3 {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  font-weight: 400;
}

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

.calendar-header h2 {
  font-size: 18px;
  font-weight: 500;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 8px;
}

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

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

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.calendar-day:hover {
  background: var(--bg-tertiary);
}

.calendar-day.other-month {
  color: var(--text-tertiary);
}

.calendar-day.today {
  background: var(--accent);
  color: white;
}

.calendar-day.selected {
  border: 2px solid var(--accent);
}

.calendar-day.has-notes::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

.calendar-day.today.has-notes::after {
  background: white;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.list-header h2 {
  font-size: 20px;
  font-weight: 500;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 14px;
}

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 1000;
  border: 1px solid var(--border);
}

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

.detail-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  margin: -20px -20px 16px -20px;
}

.detail-page-title {
  font-size: 18px;
  font-weight: 600;
}

.detail-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 12px;
  word-break: break-word;
}

.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-tertiary);
}

.detail-meta-item {
  display: flex;
  gap: 8px;
}

.detail-meta-label {
  color: var(--text-tertiary);
}

.detail-content {
  font-size: 16px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
}

.detail-content:empty::before {
  content: '暂无内容';
  color: var(--text-tertiary);
}

.detail-footer {
  background: var(--bg-primary);
  margin: 20px -20px -20px -20px;
  padding: 16px 20px 20px 20px;
}
  color: var(--text-tertiary);
}

.edit-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  margin: -20px -20px 16px -20px;
}

.edit-page-title {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  /* display: flex; */
  align-items: center;
  /* justify-content: center; */
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-back:active {
  background: var(--bg-tertiary);
}

.btn-delete-header {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  float: right;
}

.btn-delete-header:active {
  background: rgba(239, 68, 68, 0.1);
}

.edit-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.edit-meta-updated {
  color: var(--accent);
}

.edit-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.edit-textarea {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.6;
  resize: none;
  outline: none;
  padding: 0 0 12px 0;
  margin-bottom: 12px;
  max-height: 150px;
  min-height: 42px;
}

.edit-textarea-content {
  border-bottom: none;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  padding-bottom: 0;
  flex: 1;
  min-height: 130px;
  overflow-y: auto;
}

.edit-textarea::placeholder {
  color: var(--text-tertiary);
}

.edit-footer {
  background: var(--bg-primary);
  margin: 0 -20px -20px -20px;
  padding: 16px 20px 20px 20px;
}

.export-option {
  margin-bottom: 20px;
}

.export-option label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.export-format-btns {
  display: flex;
  gap: 8px;
}

.btn-format {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-format.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.export-date-range {
  display: flex;
  align-items: center;
  gap: 12px;
}

.export-date-range span {
  color: var(--text-tertiary);
}

.input-date {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
}

.input-date:focus {
  outline: none;
  border-color: var(--accent);
}

.export-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

@media (min-width: 481px) {
  .nav {
    border-radius: var(--radius);
    margin-bottom: 20px;
  }
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease;
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 500;
  flex: 1;
  word-break: break-word;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.modal-footer .btn-primary {
  width: 100%;
}
