:root {
  color-scheme: light dark;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --line: #e2e8f0;
  --accent: #06b6d4;
  --accent-strong: #0891b2;
  --accent-surface: color-mix(in srgb, var(--accent) 10%, transparent);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #020617;
    --panel: #0f172a;
    --panel-soft: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --line: #1e293b;
    --accent: #22d3ee;
    --accent-strong: #67e8f9;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "LXGW WenKai", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.side-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 32px 24px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 22px;
  margin-bottom: 32px;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}

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

.nav-links a {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.nav-links a:hover { background: var(--panel-soft); color: var(--text); }
.nav-links a.active { background: var(--accent-surface); color: var(--accent-strong); }

.side-card { padding-top: 24px; border-top: 1px solid var(--line); }
.side-card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 16px; }

.filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.filter:hover { background: var(--panel-soft); color: var(--text); }
.filter.active { background: var(--panel); border-color: var(--line); color: var(--accent-strong); box-shadow: var(--shadow-sm); }
.filter span.count { font-size: 11px; font-weight: 600; background: var(--panel-soft); padding: 2px 8px; border-radius: 999px; }

.main { max-width: 1280px; margin: 0 auto; padding: 48px 40px; width: 100%; }

.hero { margin-bottom: 48px; }
.eyebrow { font-size: 14px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px; }
h1 { font-size: 48px; font-weight: 800; margin: 0 0 16px; letter-spacing: -0.02em; }
.subtitle { font-size: 18px; color: var(--text-muted); max-width: 640px; line-height: 1.6; }

.stats { display: flex; gap: 16px; margin-top: 32px; }
.stats div { padding: 16px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stats strong { display: block; font-size: 24px; font-weight: 800; }
.stats span { font-size: 13px; color: var(--text-muted); }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 16px;
  padding: 16px 0;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  margin-bottom: 32px;
}

.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: 16px; width: 18px; height: 18px; stroke: var(--text-muted); }
.search-box input {
  width: 100%;
  padding: 12px 16px 12px 48px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  transition: var(--transition);
}
.search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-surface); }

.toolbar select {
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

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

.prompt-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
  position: relative;
  cursor: pointer;
}

.prompt-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }

.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.badge { font-size: 11px; font-weight: 700; padding: 4px 10px; background: var(--accent-surface); color: var(--accent-strong); border-radius: 999px; text-transform: uppercase; }

.prompt-card h2 { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.english-title { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.description { font-size: 15px; color: var(--text); margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.vars { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.var { font-size: 11px; background: var(--panel-soft); color: var(--text-muted); padding: 2px 8px; border-radius: 4px; border: 1px solid var(--line); }

/* Modal Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 20px;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-content {
  background: var(--panel);
  width: min(800px, 100%);
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  position: relative;
  display: flex;
  flex-direction: column;
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.modal-overlay.active .modal-content { transform: scale(1) translateY(0); }

.modal-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-header-info h2 { margin: 0 0 4px; font-size: 24px; }
.modal-header-info .english-title { margin-bottom: 0; }

.btn-close {
  background: var(--panel-soft);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}
.btn-close:hover { background: #ef4444; color: white; }

.modal-body { padding: 32px; overflow-y: auto; }

.modal-section { margin-bottom: 24px; }
.modal-section h3 { font-size: 14px; text-transform: uppercase; color: var(--accent-strong); margin-bottom: 12px; letter-spacing: 0.05em; }

pre {
  background: var(--panel-soft);
  padding: 20px;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--line);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: white; border: none; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--panel-soft); color: var(--text); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-strong); }

.copy-small { display: none; } /* Hide the floating small copy button as card is clickable */

.empty { text-align: center; padding: 64px 0; color: var(--text-muted); }

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .side-panel { height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--line); padding: 24px; }
  .nav-links, .side-card { display: none; }
  .main { padding: 32px 20px; }
  .modal-content { width: 100%; height: 100%; max-height: 100vh; border-radius: 0; }
}
