/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: 0 2px 8px var(--shadow);
}

.card h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--accent);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card h3 .count {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* 按钮 */
.btn-add {
  width: 100%;
  padding: var(--space-3);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: var(--space-3);
  transition: all 0.2s;
}

.btn-add:active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
}

.btn-primary:active {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.btn-text {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: var(--space-2) 0;
}

.btn-danger {
  color: var(--danger);
  font-size: 0.85rem;
  padding: var(--space-2) var(--space-3);
}

/* 表单 */
.form-group {
  margin-bottom: var(--space-4);
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  color: var(--text);
  font-size: 0.95rem;
}

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

.form-group textarea {
  min-height: 80px;
  line-height: 1.6;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* 底部弹层 */
#sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 60;
}

#sheet-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 70;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
}

.sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto var(--space-4);
}

.sheet h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin-bottom: var(--space-4);
  color: var(--accent);
}

/* 状态标签 */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: transform 0.2s;
  border: 1px solid transparent;
}

.status-tag:active {
  transform: scale(0.92);
}

.status-tag .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-todo { color: var(--text-muted); background: var(--bg); border-color: var(--border); }
.status-todo .dot { background: var(--text-muted); }
.status-doing { color: var(--accent-2); background: rgba(176, 116, 92, 0.08); border-color: rgba(176, 116, 92, 0.25); }
.status-doing .dot { background: var(--accent-2); }
.status-done { color: var(--accent); background: rgba(111, 113, 75, 0.08); border-color: rgba(111, 113, 75, 0.25); }
.status-done .dot { background: var(--accent); }
.status-idle { color: var(--text-muted); background: var(--bg); border-color: var(--border); }
.status-idle .dot { background: var(--text-muted); }
.status-low { color: var(--accent-2); background: rgba(176, 116, 92, 0.08); border-color: rgba(176, 116, 92, 0.25); }
.status-low .dot { background: var(--accent-2); }
.status-rebuy { color: var(--accent); background: rgba(111, 113, 75, 0.08); border-color: rgba(111, 113, 75, 0.25); }
.status-rebuy .dot { background: var(--accent); }

/* 列表项 */
.list-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.list-item:last-child {
  margin-bottom: 0;
}

.item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.item-title {
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.4;
  flex: 1;
}

.item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.item-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.chip {
  padding: var(--space-2) var(--space-3);
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 90;
  white-space: nowrap;
}

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

/* 折叠面板 */
.accordion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.accordion-head h4 {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text);
}

.accordion-body {
  padding: var(--space-3) 0;
}

/* 学习栏目管理 */
.study-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-3);
}

.meta-section {
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.meta-section:last-of-type {
  border-bottom: none;
}

.meta-section h4 {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.meta-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text);
  font-size: 0.9rem;
}

.meta-input:focus {
  border-color: var(--accent);
}

.meta-kind {
  width: 90px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text);
  font-size: 0.9rem;
}

.btn-sm {
  font-size: 0.8rem;
  padding: var(--space-2) var(--space-3);
  white-space: nowrap;
}

/* 云端同步 UI */
.sheet-header {
  margin-bottom: var(--space-4);
}

.sheet-body {
  padding-bottom: var(--space-4);
}

.sync-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: var(--space-4) 0;
  font-size: 0.9rem;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-dot-idle { background: var(--text-muted); }
.sync-dot-syncing { background: var(--accent-2); animation: pulse 1s infinite; }
.sync-dot-success { background: var(--accent); }
.sync-dot-error { background: var(--danger); }
.sync-dot-offline { background: var(--text-muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn-row {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.btn-row button {
  flex: 1;
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 配置说明 */
details summary {
  user-select: none;
}

details pre {
  margin: var(--space-2) 0;
}

details a {
  color: var(--accent);
}

details p {
  margin-bottom: var(--space-2);
}
