:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-secondary: #666;
  --border: #e0e0e0;
  --accent: #378ADD;
  --danger: #d64545;
  --radius: 10px;
}

[data-theme="dark"] {
  --bg: #16171a;
  --surface: #1e2024;
  --ink: #f0f0f0;
  --ink-secondary: #999;
  --border: #333;
  --accent: #5a9de0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  transition: background 0.2s, color 0.2s;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px;
  flex-shrink: 0;
}

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

.sidebar-header h1 { font-size: 20px; margin: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; margin-bottom: 24px; }

.nav-item {
  background: none;
  border: none;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
}

.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent); color: #fff; }

.sidebar-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--ink-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.category-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}

.category-item:hover { background: var(--bg); }
.category-item.active { background: var(--bg); font-weight: 600; }

.category-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.category-count { margin-left: auto; color: var(--ink-secondary); font-size: 12px; }

.main { flex: 1; padding: 24px 32px; }

.main-header { display: flex; gap: 12px; margin-bottom: 24px; }

.search-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}

.btn-primary, .btn-danger {
  padding: 10px 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

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

.icon-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--ink);
  padding: 4px 8px;
  border-radius: 6px;
}

.icon-btn:hover { background: var(--bg); }
.icon-btn.small { font-size: 14px; padding: 2px 6px; }

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.prompt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-card:hover { border-color: var(--accent); }

.prompt-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.prompt-card-title { font-weight: 600; font-size: 15px; margin: 0; }
.prompt-card-content {
  font-size: 13px;
  color: var(--ink-secondary);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.prompt-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.prompt-card-tag { font-size: 11px; background: var(--bg); padding: 2px 8px; border-radius: 20px; color: var(--ink-secondary); }
.fav-star { cursor: pointer; font-size: 16px; background: none; border: none; }

.empty-state { text-align: center; color: var(--ink-secondary); margin-top: 60px; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-small { width: 360px; }

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

.modal-header h2 { margin: 0; font-size: 18px; }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.modal-body label { font-size: 12px; color: var(--ink-secondary); margin-top: 8px; }
.modal-body label:first-child { margin-top: 0; }

.modal-body input[type="text"],
.modal-body input[type="search"],
.modal-body textarea,
.modal-body select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
}

.checkbox-label { display: flex; align-items: center; gap: 8px; flex-direction: row !important; margin-top: 12px !important; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 200;
}

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
}
