:root {
  --bg: #fef9f5;
  --surface: #ffffff;
  --sidebar-bg: #fdf6f0;
  --text: #3d2b1f;
  --text-muted: #8a7563;
  --text-light: #b5a08f;
  --border: #f0e4d8;
  --border-light: #f7efe6;
  --accent: #00c2a8;
  --accent-hover: #00a890;
  --accent-light: #d4f5ef;
  --accent-soft: #e8faf5;
  --pink: #ff7eb3;
  --pink-light: #ffe0ec;
  --coral: #ff8c69;
  --lavender: #c3b1ff;
  --lavender-light: #ede8ff;
  --mint: #95e1a8;
  --mint-light: #dff5e6;
  --peach: #ffd4a8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --star: #ffb84d;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 2px 8px rgba(255, 140, 105, 0.08);
  --shadow-md: 0 6px 20px rgba(255, 140, 105, 0.12);
  --shadow-lg: 0 12px 40px rgba(255, 140, 105, 0.15);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  font-family: 'Noto Sans SC', 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at 15% 20%, var(--accent-soft) 0%, transparent 40%),
                    radial-gradient(circle at 85% 80%, var(--pink-light) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  height: 60px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: 20px; }

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  font-family: 'Quicksand', 'Noto Sans SC', sans-serif;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--mint));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0, 194, 168, 0.25);
}

.view-tabs { display: flex; gap: 4px; background: var(--border-light); padding: 3px; border-radius: 12px; }

.tab-btn {
  border: none;
  background: none;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 9px;
  transition: all 0.2s var(--bounce);
  font-family: inherit;
  font-weight: 500;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.topbar-center { flex: 1; max-width: 440px; margin: 0 20px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0 14px;
  height: 38px;
  transition: all 0.2s var(--bounce);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-box svg { color: var(--text-light); flex-shrink: 0; }
.search-box input {
  border: none;
  background: none;
  outline: none;
  flex: 1;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--bounce);
  font-family: inherit;
  box-shadow: 0 3px 10px rgba(0, 194, 168, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 16px rgba(0, 194, 168, 0.4);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  padding: 9px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--bounce);
  font-family: inherit;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s var(--bounce);
}

.btn-icon:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.btn-danger:hover { color: var(--danger); border-color: var(--danger); background: #fef2f2; }
#detailStar.starred { color: var(--star); border-color: var(--star); background: #fff8e8; }

/* Layout */
.layout {
  display: flex;
  min-height: calc(100vh - 60px);
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: rgba(253, 246, 240, 0.6);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
}

.sidebar-section { margin-bottom: 24px; }

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.filter-list { display: flex; flex-direction: column; gap: 3px; }

.filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.15s var(--bounce);
  font-weight: 500;
}

.filter-item:hover { background: var(--surface); color: var(--text); }
.filter-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.filter-item .count {
  font-size: 11px;
  color: var(--text-light);
  background: var(--surface);
  padding: 1px 8px;
  border-radius: 8px;
}
.filter-item.active .count { color: var(--accent); background: white; }

.filter-empty { font-size: 12px; color: var(--text-light); padding: 6px 12px; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s var(--bounce);
  font-weight: 500;
}

.tag-pill:hover { border-color: var(--lavender); color: var(--text); background: var(--lavender-light); }
.tag-pill.active {
  background: linear-gradient(135deg, var(--pink), var(--coral));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(255, 126, 179, 0.3);
}

.sort-options { display: flex; flex-direction: column; gap: 4px; }
.sort-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.sort-option:hover { background: var(--surface); color: var(--text); }
.sort-option input { accent-color: var(--accent); width: 14px; height: 14px; }

/* Main content */
.main-content {
  flex: 1;
  padding: 24px 28px;
  overflow-x: hidden;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 20px;
}

.view-title { font-size: 20px; font-weight: 700; font-family: 'Quicksand', 'Noto Sans SC', sans-serif; }
.view-count {
  font-size: 13px;
  color: var(--text-light);
  background: var(--surface);
  padding: 2px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* Case grid */
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.case-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s var(--bounce);
  display: flex;
  flex-direction: column;
}

.case-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.case-card-image {
  width: 100%;
  aspect-ratio: 16/10;
  background: linear-gradient(135deg, var(--peach), var(--pink-light));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.case-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-card-image .placeholder {
  color: var(--text-light);
  font-size: 28px;
}

.case-card-star {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.95);
  border-radius: 10px;
  padding: 3px 8px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--star);
  backdrop-filter: blur(4px);
  font-weight: 600;
}

.case-card-bookmark {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255,255,255,0.95);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-light);
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.2s var(--bounce);
}

.case-card-bookmark:hover { color: var(--star); transform: scale(1.15); }
.case-card-bookmark.active { color: var(--star); }

.case-card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.case-card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.case-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-light);
  margin-top: auto;
}

.case-card-category {
  display: inline-block;
  padding: 2px 10px;
  background: var(--lavender-light);
  border-radius: 8px;
  font-size: 11px;
  color: #7c6fc4;
  font-weight: 500;
}

.case-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.case-card-tags .mini-tag {
  font-size: 11px;
  color: #4a9c5e;
  padding: 1px 8px;
  background: var(--mint-light);
  border-radius: 6px;
  font-weight: 500;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-light);
}
.empty-state .empty-emoji { font-size: 48px; margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(61, 43, 31, 0.25);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-large { max-width: 720px; }

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

.modal-header h2 { font-size: 17px; font-weight: 700; font-family: 'Quicksand', 'Noto Sans SC', sans-serif; }
.modal-header-actions { display: flex; gap: 6px; }

.modal-body { padding: 20px 24px; }

.form-row { margin-bottom: 16px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.required { color: var(--coral); }

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: all 0.2s var(--bounce);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
  transition: all 0.2s var(--bounce);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.rating-input { display: flex; gap: 4px; padding-top: 4px; }
.rating-input .star {
  font-size: 24px;
  color: var(--border);
  cursor: pointer;
  transition: all 0.15s var(--bounce);
  user-select: none;
}
.rating-input .star:hover,
.rating-input .star.active { color: var(--star); transform: scale(1.2); }

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

/* Detail */
.detail-body { padding: 0; }

.detail-image {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--peach), var(--pink-light));
}

.detail-image-placeholder {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, var(--peach), var(--pink-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 40px;
}

.detail-content { padding: 20px 24px; }

.detail-section { margin-bottom: 18px; }
.detail-section:last-child { margin-bottom: 0; }

.detail-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.detail-text { font-size: 14px; color: var(--text); line-height: 1.6; white-space: pre-wrap; }

.detail-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  word-break: break-all;
  font-weight: 500;
}
.detail-link:hover { text-decoration: underline; }

.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-tags .tag-pill { cursor: default; }
.detail-tags .tag-pill:hover { border-color: var(--border); color: var(--text-muted); background: var(--surface); }

.detail-meta-row {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.detail-stars { color: var(--star); font-size: 16px; letter-spacing: 1px; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.25s var(--bounce);
}

.stat-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stat-value { font-size: 34px; font-weight: 700; color: var(--accent); font-family: 'Quicksand', sans-serif; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.stat-breakdown { margin-top: 20px; }
.stat-breakdown-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.stat-bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.stat-bar-label { font-size: 13px; color: var(--text-muted); width: 100px; flex-shrink: 0; }
.stat-bar-track { flex: 1; height: 10px; background: var(--border-light); border-radius: 6px; overflow: hidden; }
.stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--mint));
  border-radius: 6px;
  transition: width 0.4s var(--bounce);
}
.stat-bar-count { font-size: 12px; color: var(--text-light); width: 30px; text-align: right; font-weight: 600; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
  padding: 12px 24px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s var(--bounce);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 194, 168, 0.3);
}

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

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .topbar-center { max-width: 240px; }
}

@media (max-width: 768px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px; }
  .topbar-left { gap: 12px; }
  .topbar-center { order: 3; flex: 1 1 100%; max-width: none; margin: 0; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 12px; }
  .sidebar-section { margin-bottom: 14px; }
  .main-content { padding: 16px; }
  .case-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .form-row-2 { grid-template-columns: 1fr; }
  .modal { max-width: 100%; }
}
