/* ── Morandi / Milk Tea Palette ──────────────────── */
:root {
  --primary:        #B07060;
  --primary-hover:  #9A5F50;
  --primary-light:  #F4EBE6;
  --primary-border: rgba(176, 112, 96, 0.22);

  --bg:             #FFFFFF;
  --surface:        #F5F0EB;   /* page background */
  --sidebar-bg:     #EDE8E3;   /* sidebar */
  --surface-hover:  #E5DDD5;
  --border:         #D4C9BE;
  --border-focus:   #B07060;

  --text:           #4A3F35;
  --text-2:         #7A6E65;
  --text-3:         #A89D95;

  --star:           #C4A040;
  --danger:         #A06060;
  --danger-bg:      rgba(160, 96, 96, 0.09);
  --success:        #7A9A70;
  --success-bg:     rgba(122, 154, 112, 0.09);
  --archive-c:      #9080AA;
  --archive-bg:     rgba(144, 128, 170, 0.09);

  --sidebar-w:      242px;
  --topbar-h:       60px;
  --radius-sm:      5px;
  --radius:         8px;
  --radius-lg:      13px;
  --radius-pill:    999px;

  --shadow-sm:  0 1px 2px rgba(74,63,53,0.06);
  --shadow:     0 1px 4px rgba(74,63,53,0.08), 0 1px 2px rgba(74,63,53,0.04);
  --shadow-md:  0 4px 14px rgba(74,63,53,0.10);
  --shadow-lg:  0 10px 32px rgba(74,63,53,0.14);
}

/* ── Reset ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', 'PingFang TC', sans-serif;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { text-decoration: none; }
svg { display: block; flex-shrink: 0; }
img { display: block; }

/* ── Layout ──────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform 0.26s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 17px 14px 15px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-mark {
  width: 28px; height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; flex-shrink: 0;
}
.logo-text { font-size: 15px; font-weight: 700; color: var(--text); flex: 1; }
.sidebar-close-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: all 0.12s;
}
.sidebar-close-btn:hover { background: var(--surface-hover); color: var(--text); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px 24px; }

.nav-group { margin-bottom: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-2); font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
  text-align: left;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item.active .nav-badge { background: rgba(176,112,96,0.14); color: var(--primary); }
.nav-icon { width: 17px; height: 17px; display: flex; align-items: center; }
.nav-label { flex: 1; }
.nav-badge {
  font-size: 11px; padding: 1px 7px;
  background: rgba(74,63,53,0.08); color: var(--text-3);
  border-radius: var(--radius-pill); min-width: 22px; text-align: center; font-weight: 500;
}
.nav-section-title {
  font-size: 10px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 14px 10px 5px;
}
.category-item {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 7px 10px;
  border-radius: var(--radius); color: var(--text-2); font-size: 13px;
  transition: background 0.12s, color 0.12s; text-align: left; cursor: pointer;
}
.category-item:hover { background: var(--surface-hover); color: var(--text); }
.category-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.category-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-size: 11px; color: var(--text-3); }
.cat-delete {
  display: none; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  color: var(--text-3); font-size: 12px; transition: all 0.12s;
}
.category-item:hover .cat-delete { display: flex; }
.cat-delete:hover { background: var(--danger-bg); color: var(--danger); }

.add-category-btn {
  display: flex; align-items: center; gap: 7px;
  width: 100%; padding: 7px 10px;
  border-radius: var(--radius); color: var(--text-3); font-size: 13px;
  transition: all 0.12s; margin-top: 2px;
}
.add-category-btn:hover { background: var(--surface-hover); color: var(--primary); }

.popular-tags { display: flex; flex-wrap: wrap; gap: 5px; padding: 5px 8px 8px; }
.tag-chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  background: rgba(74,63,53,0.06); border: 1px solid var(--border);
  border-radius: var(--radius-pill); font-size: 12px; color: var(--text-2);
  cursor: pointer; transition: all 0.12s; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.tag-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Sidebar overlay (mobile) ─────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(74, 63, 53, 0.45);
  z-index: 290;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Main ────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── Topbar ──────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.hamburger-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius);
  color: var(--text-2); transition: all 0.12s;
}
.hamburger-btn:hover { background: var(--surface); color: var(--text); }
.topbar-brand { display: none; font-size: 15px; font-weight: 700; color: var(--text); }

.search-wrapper {
  flex: 1; max-width: 480px; min-width: 0;
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0 11px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrapper:focus-within {
  border-color: var(--primary); background: var(--bg);
  box-shadow: 0 0 0 3px rgba(176,112,96,0.14);
}
.search-icon { width: 15px; height: 15px; color: var(--text-3); }
.search-wrapper input {
  flex: 1; border: none; background: none;
  padding: 9px 0; outline: none; font-size: 13.5px;
}
.search-wrapper input::placeholder { color: var(--text-3); }
.search-clear {
  display: flex; align-items: center; padding: 2px;
  border-radius: 4px; color: var(--text-3);
}
.search-clear:hover { background: var(--border); color: var(--text); }

.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
#sort-select {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg);
  outline: none; cursor: pointer; font-size: 13px; color: var(--text-2);
}
#sort-select:focus { border-color: var(--primary); }

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--primary); color: #fff;
  border-radius: var(--radius); font-weight: 600; font-size: 13.5px;
  transition: background 0.15s, transform 0.1s; white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-weight: 500; font-size: 13.5px; color: var(--text-2);
  transition: all 0.12s;
}
.btn-secondary:hover { background: var(--surface-hover); color: var(--text); border-color: var(--text-3); }

/* ── Filter Bar ──────────────────────────────────── */
.filter-bar {
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 7px 18px; display: flex; align-items: center;
  gap: 8px; flex-shrink: 0; flex-wrap: wrap;
}
.filter-label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-pill); font-size: 12px; color: var(--primary);
  cursor: pointer; transition: all 0.12s;
}
.filter-chip:hover { background: var(--primary); color: #fff; }
.filter-chip-x { font-size: 11px; opacity: 0.7; }
.filter-clear-all {
  font-size: 12px; color: var(--text-3); padding: 3px 8px;
  border-radius: 4px; white-space: nowrap; transition: all 0.12s;
}
.filter-clear-all:hover { color: var(--danger); background: var(--danger-bg); }

/* ── Content ─────────────────────────────────────── */
.content { flex: 1; overflow-y: auto; padding: 20px; }
.view-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.view-title { font-size: 18px; font-weight: 700; color: var(--text); }
.view-count { font-size: 13px; color: var(--text-3); }

/* ── Grid ────────────────────────────────────────── */
.prompts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

/* ── Card ────────────────────────────────────────── */
.prompt-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow); transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.prompt-card:hover {
  border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px);
}
.card-img { width: 100%; height: 148px; object-fit: cover; border-bottom: 1px solid var(--border); }
.card-body { padding: 13px 14px; flex: 1; display: flex; flex-direction: column; gap: 7px; }
.card-header { display: flex; align-items: flex-start; gap: 8px; }
.card-title { flex: 1; font-size: 14.5px; font-weight: 600; line-height: 1.4; word-break: break-word; }
.star-btn {
  font-size: 18px; line-height: 1; color: var(--text-3);
  padding: 1px 2px; border-radius: 4px; transition: color 0.15s, transform 0.15s; flex-shrink: 0;
}
.star-btn:hover { color: var(--star); transform: scale(1.15); }
.star-btn.starred { color: var(--star); }
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.category-badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; background: var(--primary-light);
  color: var(--primary); font-size: 11px; font-weight: 600;
  border-radius: var(--radius-pill); border: 1px solid var(--primary-border);
}
.card-content {
  font-size: 13px; color: var(--text-2); line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-all;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.card-tag {
  display: inline-flex; padding: 2px 8px;
  background: rgba(74,63,53,0.06); border: 1px solid var(--border);
  border-radius: var(--radius-pill); font-size: 11px; color: var(--text-2);
  cursor: pointer; transition: all 0.12s;
}
.card-tag:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* Links on card */
.card-links { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 7px; border-top: 1px solid var(--border); }
.card-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  font-size: 11px; color: var(--primary);
  transition: all 0.12s; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-link:hover { background: var(--primary-light); border-color: var(--primary); }

.card-footer {
  padding: 9px 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(245,240,235,0.6);
}
.card-date { font-size: 11px; color: var(--text-3); }
.card-actions { display: flex; gap: 1px; }
.action-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  color: var(--text-3); transition: all 0.12s;
}
.action-btn:hover { background: var(--surface-hover); color: var(--text); }
.action-btn.copy:hover    { color: var(--success);   background: var(--success-bg); }
.action-btn.edit:hover    { color: var(--primary);   background: var(--primary-light); }
.action-btn.archive:hover { color: var(--archive-c); background: var(--archive-bg); }
.action-btn.restore:hover { color: var(--success);   background: var(--success-bg); }
.action-btn.delete:hover  { color: var(--danger);    background: var(--danger-bg); }

/* ── Empty State ─────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px 20px; text-align: center;
}
.empty-icon { font-size: 52px; margin-bottom: 16px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-desc { font-size: 13px; color: var(--text-3); }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(74,63,53,0.42);
  display: flex; align-items: center; justify-content: center;
  z-index: 400; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--bg); border-radius: var(--radius-lg);
  width: 100%; max-width: 620px; max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: modalIn 0.18s ease;
}
.modal-sm { max-width: 420px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  color: var(--text-3); transition: all 0.12s;
}
.modal-close:hover { background: var(--surface); color: var(--text); }
.modal-body {
  padding: 20px; overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 16px;
}
.modal-footer {
  padding: 13px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-shrink: 0;
}

/* ── Form ────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.required { color: var(--danger); }
.form-hint { font-size: 11px; color: var(--text-3); }

.form-group input[type="text"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s; font-size: 13.5px; width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(176,112,96,0.14);
}
.form-group textarea { resize: vertical; min-height: 140px; line-height: 1.65; }

/* ── Tag Input ───────────────────────────────────── */
.tag-input-wrapper {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); min-height: 42px; cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tag-input-wrapper:focus-within {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(176,112,96,0.14);
}
.tag-input-wrapper input {
  border: none; outline: none; background: none;
  flex: 1; min-width: 110px; padding: 2px; font-size: 13px;
}
.tag-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  background: var(--primary-light); border: 1px solid var(--primary-border);
  border-radius: var(--radius-pill); font-size: 12px; color: var(--primary); white-space: nowrap;
}
.tag-pill-x { cursor: pointer; opacity: 0.65; font-size: 11px; padding: 0 1px; }
.tag-pill-x:hover { opacity: 1; }

/* ── Single Export Menu ──────────────────────────── */
.single-export-menu {
  position: fixed;
  z-index: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  min-width: 152px;
  animation: menuIn 0.1s ease;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.export-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  transition: background 0.1s;
  white-space: nowrap;
}
.export-menu-item:hover { background: var(--surface); color: var(--primary); }
.export-ext { font-size: 11px; color: var(--text-3); font-family: monospace; }

/* ── Platform Tags ───────────────────────────────── */
.platform-tag {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  white-space: nowrap; border: 1px solid transparent;
}
.ptag-claude     { background: rgba(176,112,96,.15);  color: #9A5040; border-color: rgba(176,112,96,.3); }
.ptag-chatgpt    { background: rgba(100,150,100,.14); color: #4A7A50; border-color: rgba(100,150,100,.3); }
.ptag-gemini     { background: rgba(80,130,170,.14);  color: #3A6A90; border-color: rgba(80,130,170,.3); }
.ptag-video      { background: rgba(144,128,170,.15); color: #6A5890; border-color: rgba(144,128,170,.3); }
.ptag-midjourney { background: rgba(100,92,80,.12);   color: #504840; border-color: rgba(100,92,80,.3); }
.ptag-elevenlabs { background: rgba(176,128,144,.15); color: #906070; border-color: rgba(176,128,144,.3); }
.ptag-comfyui    { background: rgba(138,122,96,.14);  color: #6A5A38; border-color: rgba(138,122,96,.3); }
.ptag-other      { background: rgba(144,136,120,.12); color: #605848; border-color: rgba(144,136,120,.3); }
.ptag-none       { background: rgba(180,172,160,.1);  color: var(--text-3); border-color: var(--border); font-weight: 400; }
.ptag-more       { background: rgba(74,63,53,.08);    color: var(--text-3); border-color: var(--border); }

/* ── Platform Filter Chips (sidebar) ─────────────── */
.platform-filters { display: flex; flex-wrap: wrap; gap: 5px; padding: 5px 8px 8px; }
.platform-filter-chip {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.12s;
  border: 1px solid transparent;
}
.platform-filter-chip:hover { filter: brightness(0.92); }
.platform-filter-chip.active { outline: 2px solid currentColor; outline-offset: 1px; }

/* ── Core Prompts Wrapper (form) ─────────────────── */
.core-prompts-wrapper { gap: 8px; }
.core-prompts-wrapper > label { font-size: 13px; font-weight: 600; color: var(--text); }
#core-prompts-container {
  background: #FAF7F2;
  border: 1px solid rgba(176,112,96,0.28);
  border-radius: var(--radius);
  padding: 2px 0;
  overflow: hidden;
}

/* Individual block */
.cp-block { padding: 12px 14px; }
.cp-block-top {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}
.cp-block-actions { display: flex; align-items: center; gap: 6px; }
.core-prompt-copy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px;
  background: var(--bg);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-pill);
  font-size: 12px; color: var(--primary);
  transition: all 0.12s; white-space: nowrap;
}
.core-prompt-copy-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.cp-del-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  color: var(--text-3); transition: all 0.12s;
}
.cp-del-btn:hover { background: var(--danger-bg); color: var(--danger); }

.cp-title-input {
  width: 100%; padding: 7px 10px; margin-bottom: 7px;
  border: 1px solid rgba(176,112,96,0.22);
  border-radius: var(--radius); background: rgba(255,255,255,0.6);
  font-size: 13px; outline: none; transition: border-color 0.15s;
}
.cp-title-input:focus { border-color: var(--primary); background: var(--bg); }
.cp-title-input::placeholder { color: var(--text-3); }

.cp-platform-row {
  display: flex; gap: 6px; margin-bottom: 7px; align-items: center;
}
.cp-platform-select {
  flex: 1; padding: 7px 10px;
  border: 1px solid rgba(176,112,96,0.22);
  border-radius: var(--radius); background: rgba(255,255,255,0.6);
  font-size: 13px; outline: none; cursor: pointer;
  transition: border-color 0.15s; color: var(--text);
}
.cp-platform-select:focus { border-color: var(--primary); }
.cp-custom-input {
  flex: 1; padding: 7px 10px;
  border: 1px solid rgba(176,112,96,0.22);
  border-radius: var(--radius); background: rgba(255,255,255,0.6);
  font-size: 13px; outline: none;
  transition: border-color 0.15s;
}
.cp-custom-input:focus { border-color: var(--primary); }
.cp-custom-input::placeholder { color: var(--text-3); }

.cp-content-input {
  width: 100%; padding: 9px 12px; resize: vertical; min-height: 90px;
  border: 1px solid rgba(176,112,96,0.22);
  border-radius: var(--radius); background: rgba(255,255,255,0.6);
  font-size: 13.5px; line-height: 1.65; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s; color: var(--text);
  font-family: inherit;
}
.cp-content-input:focus {
  border-color: var(--primary); background: var(--bg);
  box-shadow: 0 0 0 3px rgba(176,112,96,0.14);
}
.cp-content-input::placeholder { color: var(--text-3); }

.cp-divider {
  border: none; border-top: 1px solid rgba(176,112,96,0.18); margin: 0 14px;
}
.add-core-prompt-btn {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 8px 10px;
  background: rgba(176,112,96,0.06);
  border: 1px dashed rgba(176,112,96,0.35);
  border-radius: var(--radius);
  font-size: 13px; color: var(--primary);
  transition: all 0.12s; justify-content: center;
}
.add-core-prompt-btn:hover { background: var(--primary-light); border-style: solid; }

/* ── Card extras ─────────────────────────────────── */
.card-cp-title {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  margin-bottom: 2px;
}
.card-multi-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  background: rgba(74,63,53,0.06); border: 1px solid var(--border);
  border-radius: var(--radius-pill); font-size: 11px; color: var(--text-3);
}
.list-plt { font-size: 10px; padding: 1px 7px; }

/* ── Quill Editor ────────────────────────────────── */
.quill-wrap { border-radius: var(--radius); overflow: hidden; }

.ql-toolbar.ql-snow {
  border: 1px solid var(--border) !important;
  border-bottom: none !important;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface) !important;
  padding: 6px 8px !important;
  font-family: inherit !important;
}
.ql-container.ql-snow {
  border: 1px solid var(--border) !important;
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: inherit !important;
  font-size: 14px !important;
}
.ql-editor {
  min-height: 180px; max-height: 300px;
  overflow-y: auto; line-height: 1.7;
  color: var(--text) !important; padding: 12px 14px !important;
}
.ql-editor.ql-blank::before {
  color: var(--text-3) !important; font-style: normal !important; font-size: 13.5px;
}
.ql-editor img { max-width: 100%; border-radius: var(--radius-sm); margin: 4px 0; }
.ql-editor h1 { font-size: 1.6em; }
.ql-editor h2 { font-size: 1.35em; }
.ql-editor h3 { font-size: 1.15em; }

/* Quill toolbar icon colors */
.ql-snow .ql-stroke              { stroke: var(--text-2) !important; }
.ql-snow .ql-fill                { fill:   var(--text-2) !important; }
.ql-snow .ql-stroke.ql-fill      { fill:   var(--text-2) !important; }
.ql-snow .ql-picker               { color: var(--text-2) !important; }
.ql-snow .ql-picker-label::before { color: var(--text-2); }

.ql-snow.ql-toolbar button:hover   .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--primary) !important; }
.ql-snow.ql-toolbar button:hover   .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill   { fill:   var(--primary) !important; }
.ql-snow .ql-picker-label:hover,
.ql-snow .ql-picker-label.ql-active             { color:  var(--primary) !important; }
.ql-snow .ql-picker-label:hover   .ql-stroke,
.ql-snow .ql-picker-label.ql-active .ql-stroke  { stroke: var(--primary) !important; }

.ql-snow .ql-picker-options {
  background: var(--bg) !important;
  border-color: var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
}
.ql-snow .ql-picker-item:hover { color: var(--primary) !important; }
.ql-snow .ql-picker.ql-expanded .ql-picker-label { color: var(--primary) !important; border-color: var(--border) !important; }

/* ── Links section (modal) ────────────────────────── */
.links-list { display: flex; flex-direction: column; gap: 5px; }
.link-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.link-item-url {
  flex: 1; font-size: 12.5px; color: var(--primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-item-url:hover { text-decoration: underline; }
.link-item-label {
  font-size: 12.5px; color: var(--text-2); margin-right: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px;
}
.link-remove-btn { display: flex; align-items: center; color: var(--text-3); transition: color 0.12s; flex-shrink: 0; }
.link-remove-btn:hover { color: var(--danger); }

.link-add-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.link-add-row input {
  flex: 1; min-width: 100px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  outline: none; font-size: 13px; background: var(--bg); transition: border-color 0.15s;
}
.link-add-row input:focus { border-color: var(--primary); }
.link-label-input { max-width: 140px; flex: 0 0 auto; }
.btn-add-link {
  padding: 8px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; color: var(--text-2); white-space: nowrap;
  transition: all 0.12s; flex-shrink: 0;
}
.btn-add-link:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ── Image Upload ────────────────────────────────── */
.image-upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: border-color 0.15s, background 0.15s;
  min-height: 100px; display: flex; align-items: center; justify-content: center;
}
.image-upload-area:hover,
.image-upload-area.drag-over { border-color: var(--primary); background: var(--primary-light); }
.image-placeholder {
  display: flex; flex-direction: column; align-items: center;
  gap: 5px; padding: 18px; text-align: center; pointer-events: none;
}
.upload-icon { font-size: 28px; }
.image-placeholder p { font-size: 13px; color: var(--text-2); }
.upload-hint { font-size: 11px; color: var(--text-3) !important; }
.image-preview { position: relative; width: 100%; }
.image-preview img { width: 100%; max-height: 200px; object-fit: contain; background: var(--surface); }
.image-remove {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; background: rgba(74,63,53,0.6); color: #fff;
  border-radius: var(--radius); font-size: 12px; cursor: pointer; transition: background 0.15s;
}
.image-remove:hover { background: rgba(160,96,96,0.85); }

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: #3A3028; color: #F5F0EB;
  padding: 10px 22px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  z-index: 9999; box-shadow: var(--shadow-lg);
  pointer-events: none; white-space: nowrap;
  opacity: 0; transition: opacity 0.22s ease;
}
.toast.show { opacity: 1; }

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ═══════════════════════════════════════════════════
   RWD — Tablet  (≤ 1024px)
═══════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .prompts-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  #sort-select { display: none; }
}

/* ═══════════════════════════════════════════════════
   RWD — Mobile  (≤ 768px)
═══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --topbar-h: auto; }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 300; transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-close-btn { display: flex; }

  /* Topbar wraps: [left] [right] on row 1, [search] on row 2 */
  .topbar {
    flex-wrap: wrap;
    padding: 10px 14px 8px;
    gap: 8px;
  }
  .topbar-left   { order: 1; flex: 1; }
  .topbar-right  { order: 2; }
  .search-wrapper { order: 3; width: 100%; max-width: none; }

  .hamburger-btn  { display: flex; }
  .topbar-brand   { display: block; }

  /* Grid single column */
  .prompts-grid { grid-template-columns: 1fr; }

  /* Content padding */
  .content { padding: 14px; }
  .view-header { margin-bottom: 12px; }
  .view-title { font-size: 16px; }

  /* Modal slides up from bottom */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 94vh; max-width: 100%; width: 100%;
    animation: modalSlideUp 0.22s ease;
  }
  .modal-sm { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  @keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Links add row stack */
  .link-add-row { flex-wrap: wrap; }
  .link-add-row input { min-width: 0; }
  .link-label-input { max-width: none; }

  /* Quill shorter on mobile */
  .ql-editor { min-height: 140px; max-height: 220px; }
}

/* ═══════════════════════════════════════════════════
   RWD — Small Mobile  (≤ 480px)
═══════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .btn-text { display: none; }
  .btn-primary { padding: 8px 12px; }
  .filter-bar { padding: 7px 12px; }
  .modal-body { padding: 14px; gap: 14px; }
  .modal-footer { padding: 12px 14px; }
  .modal-header { padding: 13px 14px; }
  .ctrl-label { display: none; }
}

/* ═══════════════════════════════════════════════════
   Quill Toolbar — Chinese Labels Override
═══════════════════════════════════════════════════ */
/* Header picker */
.ql-snow .ql-picker.ql-header { width: 68px !important; }
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
.ql-snow .ql-picker.ql-header .ql-picker-item::before        { content: '正常' !important; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before { content: 'H1' !important; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { content: 'H2' !important; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { content: 'H3' !important; }

/* Size picker */
.ql-snow .ql-picker.ql-size { width: 52px !important; }
.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before              { content: '中' !important; }
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="small"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="small"]::before { content: '小' !important; }
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="large"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="large"]::before { content: '大' !important; }
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="huge"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="huge"]::before  { content: '特大' !important; }

/* ═══════════════════════════════════════════════════
   View Controls (export + toggle)
═══════════════════════════════════════════════════ */
.view-header { flex-wrap: wrap; gap: 8px; }
.view-controls {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
}
.ctrl-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-2);
  font-size: 12.5px; background: var(--bg);
  transition: all 0.12s; white-space: nowrap;
}
.ctrl-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.ctrl-label { font-size: 12.5px; }

.view-mode-toggle {
  display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg);
}
.view-mode-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 28px;
  color: var(--text-3); transition: all 0.12s;
}
.view-mode-btn:hover { color: var(--text); background: var(--surface); }
.view-mode-btn.active { background: var(--primary-light); color: var(--primary); }

/* ═══════════════════════════════════════════════════
   List View
═══════════════════════════════════════════════════ */
.prompts-list { display: flex; flex-direction: column; gap: 2px; }

.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color 0.12s, box-shadow 0.12s;
  min-width: 0;
}
.list-item:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }

.list-star {
  font-size: 16px; color: var(--text-3);
  transition: color 0.12s, transform 0.12s; flex-shrink: 0; line-height: 1;
}
.list-star:hover { color: var(--star); transform: scale(1.1); }
.list-star.starred { color: var(--star); }

.list-title {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.list-cat {
  display: inline-flex; padding: 1px 8px;
  background: var(--primary-light); color: var(--primary);
  font-size: 11px; font-weight: 600;
  border-radius: var(--radius-pill); border: 1px solid var(--primary-border);
  flex-shrink: 0; white-space: nowrap;
}
.list-tags {
  display: flex; gap: 3px; flex-shrink: 0;
  overflow: hidden; max-width: 160px;
}
.list-tag {
  display: inline-flex; padding: 1px 7px;
  background: rgba(74,63,53,0.06); border: 1px solid var(--border);
  border-radius: var(--radius-pill); font-size: 11px; color: var(--text-2);
  cursor: pointer; transition: all 0.12s; white-space: nowrap;
}
.list-tag:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.list-date { font-size: 11px; color: var(--text-3); white-space: nowrap; flex-shrink: 0; }

/* Action area in list */
.list-actions { display: flex; gap: 1px; flex-shrink: 0; }

@media (max-width: 640px) {
  .list-tags { display: none; }
  .list-date  { display: none; }
  .list-cat   { display: none; }
}

/* ═══════════════════════════════════════════════════
   Version History Modal
═══════════════════════════════════════════════════ */
.modal-subtitle { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.history-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: 13px; }

.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.history-item-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.history-time { font-size: 13px; color: var(--text); font-weight: 500; }
.history-preview {
  font-size: 11px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-restore-btn {
  padding: 5px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12.5px; color: var(--text-2); white-space: nowrap;
  transition: all 0.12s; flex-shrink: 0;
}
.history-restore-btn:hover {
  border-color: var(--primary); color: var(--primary); background: var(--primary-light);
}
.history-meta { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.history-title {
  font-size: 13px; color: var(--text); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-date { font-size: 11px; color: var(--text-3); }
