:root {
  --bg: #0b0d10;
  --panel: #111317;
  --border: #2a2f3a;
  --text: #e8eaee;
  --muted: #a9afbd;
  --blue: #3b82f6;
  --blue2: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --shadow: 0 28px 80px rgba(0,0,0,.55);
  --radius: 22px;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 28px 16px 48px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 25% -10%, rgba(59,130,246,.18) 0%, transparent 60%),
    radial-gradient(900px 520px at 110% 30%, rgba(34,197,94,.12) 0%, transparent 55%),
    var(--bg);
}

.card {
  width: min(980px, 100%);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02) 22%, rgba(255,255,255,0.00) 60%), var(--panel);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 26px 28px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: radial-gradient(420px 200px at 10% 0%, rgba(255,255,255,0.10), transparent 60%);
  pointer-events: none;
  opacity: .55;
}

.header {
  position: relative;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: .2px;
  font-weight: 800;
}

.sub {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.muted { color: var(--muted); }

.form { position: relative; z-index: 2; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.input {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--text);
  outline: none;
  font-size: 14px;
  font-family: inherit;
}

.input:focus {
  border-color: rgba(59,130,246,0.55);
  box-shadow: 0 0 0 4px rgba(59,130,246,0.16);
}

select.input { cursor: pointer; }

.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 68px;
  background: rgba(0,0,0,0.20);
  border: 1px dashed rgba(255,255,255,0.20);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  transition: border-color .15s, background .15s;
}

.file-drop:hover, .file-drop.over {
  border-color: rgba(59,130,246,0.55);
  background: rgba(59,130,246,0.06);
  color: var(--blue);
}

.file-drop.has-file {
  border-style: solid;
  border-color: rgba(34,197,94,0.5);
  color: var(--green);
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  padding: 11px 18px;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  letter-spacing: .2px;
  box-shadow: 0 10px 20px rgba(0,0,0,.25);
  transition: transform .05s ease, filter .12s ease, opacity .12s ease;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-blue  { background: linear-gradient(180deg, var(--blue), var(--blue2)); }
.btn-ghost { background: rgba(255,255,255,0.10); box-shadow: none; }
.btn-ghost:hover { background: rgba(255,255,255,0.16); }

.tiny { font-size: 12px; color: var(--muted); }
.ok { color: var(--green); font-weight: 800; }
.err { color: #fca5a5; font-weight: 800; }

.section-title {
  font-size: 22px;
  font-weight: 900;
  margin: 24px 0 12px;
}

/* Preview */
.preview.hidden { display: none; }

.preview-card {
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.preview-images {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.preview-img {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.3);
}

.preview-meta {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-title {
  font-size: 18px;
  font-weight: 800;
}

.preview-paths {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(59,130,246,0.18);
  border: 1px solid rgba(59,130,246,0.3);
  color: #93c5fd;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.10);
  padding: 2px 6px;
  border-radius: 8px;
  color: #dbeafe;
  font-size: 12px;
  word-break: break-all;
}

/* Result */
.result-card.hidden { display: none; }

.result-card {
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 4px;
}

.json-out {
  background: rgba(0,0,0,0.30);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: #dbeafe;
  overflow-x: auto;
  white-space: pre;
}

/* Entry list */
.list-section {
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 4px;
  position: relative;
  z-index: 2;
}

.entry-list {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entry-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  font-size: 13px;
  flex-wrap: wrap;
}

.entry-name {
  font-weight: 700;
  flex: 1;
  min-width: 140px;
}

.entry-system {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.entry-date {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Faction picker in form ── */
.faction-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  align-items: center;
  padding: 4px 0;
}

.pick-faction {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.4);
  transition: all .12s;
  user-select: none;
}

.pick-faction.selected {
  background: rgba(34,197,94,0.18);
  border-color: rgba(34,197,94,0.45);
  color: #86efac;
}

.pick-faction:hover {
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.75);
}

.pick-faction.selected:hover { background: rgba(34,197,94,0.28); }

.faction-picker:not(:has(.pick-faction)) {
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 8px 12px;
}

/* ── Tag Palette section ── */
.palette-section {
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.palette-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.palette-input { width: auto !important; flex: 1; max-width: 320px; }

.palette-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.palette-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  color: #ccc;
}

.palette-rm {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
}

.palette-rm:hover { color: #f87171; }

/* ── Tag picker in form ── */
.tags-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  align-items: center;
  padding: 4px 0;
}

.pick-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.4);
  transition: all .12s;
  user-select: none;
}

.pick-tag.selected {
  background: rgba(59,130,246,0.22);
  border-color: rgba(59,130,246,0.45);
  color: #93c5fd;
}

.pick-tag:hover {
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.75);
}

.pick-tag.selected:hover { background: rgba(59,130,246,0.32); }

.picker-empty {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  font-style: italic;
}

.tags-picker:not(:has(.pick-tag)) {
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 8px 12px;
}

/* ── Search filter ── */
.list-search {
  width: 100%;
  margin-bottom: 10px;
}

/* ── Entry row actions ── */
.entry-actions { display: flex; gap: 6px; margin-left: auto; flex-shrink: 0; }

.btn-row-edit, .btn-row-del {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}

.btn-row-edit { background: rgba(59,130,246,0.18); color: #93c5fd; }
.btn-row-edit:hover { background: rgba(59,130,246,0.32); }
.btn-row-del  { background: rgba(239,68,68,0.15); color: #fca5a5; }
.btn-row-del:hover  { background: rgba(239,68,68,0.28); }
.btn-row-del.confirm { background: rgba(239,68,68,0.45); color: #fff; }

/* ── Inline edit panel ── */
.edit-panel {
  display: none;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 6px;
}
.edit-panel.open { display: block; }

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

@media (max-width: 600px) {
  .edit-grid { grid-template-columns: 1fr; }
}

.edit-actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; }

.edit-remove-c {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #fca5a5;
  cursor: pointer;
}
