:root {
  --bg-primary: #0f0f1a;
  --bg-surface: #1a1a2e;
  --bg-elevated: #252540;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --text-primary: #eaeaea;
  --text-muted: #888;
  --border: #2a2a4a;
  --radius: 8px;
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 0.95rem;
  transition: background var(--transition), transform var(--transition);
}

button:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-icon {
  background: transparent;
  color: var(--text-primary);
  padding: 8px;
  font-size: 1.4rem;
  line-height: 1;
}

.btn-icon:hover {
  color: var(--accent);
}

input,
select {
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition);
}

input:focus,
select:focus {
  border-color: var(--accent);
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Image Library tags modal (light DOM, appended to body) ── */
.il-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.il-modal {
  background: var(--bg-surface, #1a1a2e);
  color: var(--text-primary, #eaeaea);
  border: 1px solid var(--border, #2a2a4a);
  border-radius: 12px;
  width: 420px;
  max-width: 90vw;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.il-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #2a2a4a);
  flex-shrink: 0;
}

.il-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary, #eaeaea);
}

.il-close-btn {
  padding: 4px 10px;
  font-size: 0.85rem;
  background: var(--bg-elevated, #252540);
  color: var(--text-primary, #eaeaea);
  border: 1px solid var(--border, #2a2a4a);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}

.il-close-btn:hover {
  background: var(--border, #2a2a4a);
}

.il-tag-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  overflow-y: auto;
}

.il-tag-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border, #2a2a4a);
}

.il-tag-row:last-child {
  border-bottom: none;
}

.il-tag-name {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text-primary, #eaeaea);
}

.il-tag-count {
  font-size: 0.85rem;
  color: var(--text-muted, #888);
  white-space: nowrap;
}

.il-filter-btn {
  padding: 3px 10px;
  font-size: 0.78rem;
  background: transparent;
  border: 1px solid var(--border, #2a2a4a);
  border-radius: 20px;
  color: var(--text-muted, #888);
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.il-filter-btn:hover {
  border-color: var(--accent, #e94560);
  color: var(--accent, #e94560);
}

.il-filter-btn.active {
  background: var(--accent, #e94560);
  border-color: var(--accent, #e94560);
  color: #fff;
}

.il-delete-tag-btn {
  padding: 4px 8px;
  font-size: 1rem;
  line-height: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted, #888);
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.il-delete-tag-btn:hover {
  background: rgba(192, 57, 43, 0.15);
  border-color: #c0392b;
  color: #e74c3c;
}