/* ============================================================================
 * 生活笔记 — 移动端优先样式
 * 设计原则: 简洁、整洁、大触摸区域 (44px+)
 * ============================================================================ */

/* ── Reset & Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f9fafb;
  --card-bg: #ffffff;
  --primary: #4f6ef7;
  --primary-hover: #3b5de7;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #10b981;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 120px; /* 给底部输入栏留空间 */
}

a { color: var(--primary); text-decoration: none; }

/* ── Header ────────────────────────────────────────────────────────── */
.header {
  text-align: center;
  padding: 24px 0 16px;
}
.header h1 {
  font-size: 1.6rem;
  font-weight: 700;
}
.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

.header-note {
  display: flex;
  align-items: flex-start;
  text-align: left;
  padding: 12px 0;
  gap: 8px;
}
.header-title-wrap { flex: 1; min-width: 0; }
.note-title-display {
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline {
  background: var(--card-bg);
  color: var(--primary);
  border: 2px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); }

.btn-large {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.btn-danger { color: var(--danger); background: none; }
.btn-voice, .btn-handwrite {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 1.4rem;
  border: 2px solid var(--border);
  background: var(--card-bg);
}
.btn-voice.recording {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
}

.btn-back {
  display: inline-block;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  touch-action: manipulation;
}
.btn-icon {
  background: none;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 1.2rem;
  cursor: pointer;
  touch-action: manipulation;
}

.badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.8rem;
  margin-left: 6px;
}

/* ── Action Buttons ────────────────────────────────────────────────── */
.actions-top {
  margin: 16px 0;
}

/* ── Note Cards ────────────────────────────────────────────────────── */
.notes-section { margin-top: 24px; }
.notes-section h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.note-cards { list-style: none; }
.note-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
  touch-action: manipulation;
}
.note-card:active { transform: scale(0.98); }
.note-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
  padding-right: 32px;
}
.note-card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.btn-delete-note {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #fee2e2;
  color: var(--danger);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

/* ── Entries ───────────────────────────────────────────────────────── */
.entries-section { margin-top: 16px; }

.entry-list { list-style: none; }
.entry-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.entry-num {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}
.entry-type {
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.entry-time {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-left: auto;
}
.entry-content {
  font-size: 1rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.entry-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}
.entry-actions button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  font-size: 0.85rem;
  cursor: pointer;
  touch-action: manipulation;
}

/* ── Input Area (底部固定) ─────────────────────────────────────────── */
.input-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  padding: 12px 16px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  z-index: 10;
}
.input-area textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* 防止 iOS 缩放 */
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.input-area textarea:focus { border-color: var(--primary); }
.input-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
.input-toolbar .btn-primary {
  flex: 1;
  padding: 14px;
}

.edit-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 8px 12px;
  background: #fef3c7;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* ── Voice Status Bar ──────────────────────────────────────────────── */
.voice-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 14px;
  background: #e8f0fe;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.5;
}
.voice-status-bar.voice-denied {
  background: #fef2f2;
  border-left-color: var(--danger);
}
.voice-status-bar.voice-unsupported {
  background: #fff7ed;
  border-left-color: #f59e0b;
}
.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  min-height: 32px;
  white-space: nowrap;
}

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  width: 90%;
  max-width: 360px;
  text-align: center;
}
.modal-content h3 {
  margin-bottom: 14px;
  font-size: 1.1rem;
}
.modal-content canvas {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  touch-action: none;
  background: #fff;
  width: 100%;
}
.modal-buttons {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.modal-buttons .btn { flex: 1; }

/* ── Toast ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  animation: fadeInOut 2.5s forwards;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Empty State ───────────────────────────────────────────────────── */
.empty-hint {
  text-align: center;
  color: var(--text-secondary);
  padding: 32px 16px;
  font-size: 0.95rem;
}
