/* ========== Variables ========== */
:root {
  --bg: #f5f0eb;
  --bg-card: #ffffff;
  --bg-hover: #faf7f4;
  --text: #2c2420;
  --text-secondary: #8a7e76;
  --text-hint: #b5a99e;
  --primary: #5b8a72;
  --primary-hover: #4a7561;
  --primary-light: #e8f0ec;
  --danger: #c45b4a;
  --danger-light: #fbe8e5;
  --warning: #d4a843;
  --warning-light: #fdf5e6;
  --success: #5b8a72;
  --success-light: #e8f0ec;
  --border: #e6ddd5;
  --shadow-sm: 0 1px 3px rgba(44,36,32,0.06);
  --shadow-md: 0 4px 12px rgba(44,36,32,0.08);
  --shadow-lg: 0 8px 30px rgba(44,36,32,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
          'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ========== App Container ========== */
.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
}

/* ========== Header ========== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.header-left { display: flex; align-items: baseline; gap: 12px; }
.logo { font-size: 1.4rem; font-weight: 700; }
.subtitle { font-size: 0.85rem; color: var(--text-secondary); }
.header-right { display: flex; gap: 4px; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }
.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b04e3e; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  transition: background var(--transition);
}
.btn-icon:hover { background: var(--border); }
.btn-icon-text { font-size: 1.1em; }
.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  line-height: 1;
}
.btn-close:hover { background: var(--border); color: var(--text); }

/* ========== Progress Section ========== */
.progress-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.progress-bar-container {
  position: relative;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: visible;
  margin-bottom: 8px;
}
.progress-bar {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--primary), #7ab89a);
  transition: width 1s ease;
  width: 0%;
}
.progress-marker {
  position: absolute;
  top: -4px;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: left 1s ease;
  left: 0%;
  transform: translateX(-50%);
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.current-time {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.85rem;
}
.progress-text {
  text-align: center;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ========== Status Card ========== */
.status-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
}
.status-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.status-icon { font-size: 1.2rem; }
.status-title { font-weight: 600; font-size: 0.95rem; }
.status-content { font-size: 0.9rem; }
.status-empty { color: var(--text-hint); font-style: italic; }
.status-note {
  background: var(--primary-light);
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  margin-top: 4px;
}
.status-time { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; }

/* ========== Actions ========== */
.actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.actions .btn-primary { flex: 2; }
.actions .btn-secondary { flex: 1; }

/* ========== Archive List ========== */
.today-archives { margin-bottom: 20px; }
.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.archive-list { display: flex; flex-direction: column; gap: 8px; }
.archive-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.archive-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.archive-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.tag-进行中 { background: var(--warning-light); color: var(--warning); }
.tag-已完成 { background: var(--success-light); color: var(--success); }
.tag-卡住了 { background: var(--danger-light); color: var(--danger); }
.tag-待跟进 { background: #e8e4f0; color: #7b6b8a; }
.archive-time { font-size: 0.72rem; color: var(--text-hint); }
.archive-text { font-size: 0.88rem; line-height: 1.5; }
.archive-screenshot {
  margin-top: 8px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  max-height: 120px;
}
.archive-screenshot img {
  width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
  transition: transform var(--transition);
}
.archive-screenshot img:hover { transform: scale(1.02); }
.empty-hint {
  text-align: center;
  color: var(--text-hint);
  padding: 24px;
  font-size: 0.88rem;
}

/* ========== Modals ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,36,32,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}
.modal-lg { max-width: 520px; }
.modal-xl { max-width: 600px; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 0;
}
.modal-header h2 { font-size: 1.15rem; font-weight: 600; }
.modal-body { padding: 16px 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 18px;
}

/* ========== Form Elements ========== */
.form-group { margin-bottom: 16px; }
.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.label input[type="checkbox"] {
  margin-right: 6px;
  accent-color: var(--primary);
}
.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,138,114,0.15);
}
textarea.input { resize: vertical; line-height: 1.5; }
.hint {
  font-size: 0.75rem;
  color: var(--text-hint);
  margin-top: 4px;
  display: block;
}
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ========== Tags ========== */
.tag-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.tag {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.tag:hover { border-color: var(--primary); background: var(--primary-light); }
.tag.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

/* ========== Screenshot ========== */
.screenshot-area { margin-top: 12px; }
.screenshot-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.screenshot-drop.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.screenshot-drop p { margin-bottom: 12px; font-size: 0.88rem; }
.screenshot-drop .btn { margin: 4px; }
.screenshot-preview {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 8px;
}
.screenshot-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
  border-radius: var(--radius-xs);
  background: var(--bg);
}
.screenshot-preview .btn {
  position: absolute;
  top: 8px;
  right: 8px;
}
.evening-screenshot-section { margin-top: 12px; }

/* ========== Morning / Evening ========== */
.morning-hint {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.morning-archive {
  background: var(--primary-light);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}
.morning-archive .loading { color: var(--text-hint); font-style: italic; }
.morning-screenshot {
  margin-top: 10px;
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.morning-screenshot img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
}
.evening-hint {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ========== Custom Reminders ========== */
.custom-reminders { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.custom-reminder-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.custom-reminder-row input[type="time"] {
  width: 120px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
}
.custom-reminder-row input[type="text"] {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
}
.custom-reminder-row .btn-sm { padding: 4px 10px; }

/* ========== History ========== */
.history-search { margin-bottom: 14px; }
.history-list {
  max-height: 60vh;
  overflow-y: auto;
}
.history-date-group { margin-bottom: 16px; }
.history-date {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}
.history-item {
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  margin-bottom: 4px;
  transition: background var(--transition);
}
.history-item:hover { background: var(--bg-hover); }
.history-item-time {
  font-size: 0.72rem;
  color: var(--text-hint);
}
.history-item-text { font-size: 0.85rem; }

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  white-space: nowrap;
}
.toast-success { background: var(--primary); }
.toast-error { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-8px); }
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-hint); }

/* ========== Responsive ========== */
@media (max-width: 480px) {
  .app { padding: 12px 10px 30px; }
  .logo { font-size: 1.2rem; }
  .actions { flex-direction: column; }
  .actions .btn-primary, .actions .btn-secondary { flex: 1; }
}
