:root {
  color-scheme: dark;
  --bg:         #050505;
  --surface:    #0f0f10;
  --surface-hi: #17161a;
  --gold:       #c9a76d;
  --gold-hi:    #e0b45a;
  --gold-dim:   rgba(201, 167, 109, 0.35);
  --text:       #e8dcc4;
  --text-dim:   #b8b0a0;
  --text-muted: #6a5a3f;
  --radius:     14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #0b0906 0%, #050505 60%) fixed;
  color: var(--text);
  font-family: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(201, 167, 109, 0.25); color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201, 167, 109, 0.2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(201, 167, 109, 0.4); }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.page-head { margin-bottom: 36px; }
h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 400;
  letter-spacing: 1px;
  color: var(--text);
}
.page-head p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  letter-spacing: 0.4px;
}

/* ---------- shared inputs / buttons ---------- */
.input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid rgba(201, 167, 109, 0.25);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 300;
  width: 100%;
  transition: border-color 0.15s ease;
}
.input:focus {
  outline: none;
  border-color: rgba(201, 167, 109, 0.7);
}
textarea.input { resize: vertical; }

.ghost, .primary {
  padding: 9px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ghost {
  background: transparent;
  border: 1px solid rgba(201, 167, 109, 0.25);
  color: var(--text-dim);
}
.ghost:hover { border-color: rgba(201, 167, 109, 0.5); color: var(--gold); }
.ghost.small { padding: 5px 12px; font-size: 13px; }
.ghost.rm { padding: 5px 9px; font-size: 14px; }
.primary {
  background: var(--gold);
  color: var(--bg);
  border: 1px solid var(--gold);
  font-weight: 500;
  letter-spacing: 0.3px;
}
.primary:hover:not(:disabled) { background: var(--gold-hi); border-color: var(--gold-hi); }
.primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
  align-items: start;
}

/* ---------- card (shared by add-form and saved cards) ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover {
  border-color: rgba(201, 167, 109, 0.7);
  transform: translateY(-2px);
}
/* All saved (non-add) cards share the same size, Nexus-style. */
.card:not(.add-card) {
  height: 460px;
  display: flex;
  flex-direction: column;
}
.card:not(.add-card) .card-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 10px;
}
.card:not(.add-card) .desc {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  margin-top: 8px;
}
.card:not(.add-card) .links {
  margin-top: auto;
}
.card:not(.add-card) .cats {
  max-height: 60px;
  overflow-y: auto;
}

.card-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
  pointer-events: none;
}
.card-bg.has-image {
  opacity: 1;
}
/* Smooth gradient: image fully visible at top, fading to dark at the bottom. */
.card-bg.has-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(15, 15, 16, 0.05) 0%,
    rgba(15, 15, 16, 0.35) 35%,
    rgba(15, 15, 16, 0.75) 65%,
    rgba(15, 15, 16, 0.95) 100%
  );
}
.card-inner {
  position: relative;
  z-index: 2;
  padding: 18px 20px;
}
/* The add-mod card is longer and denser, so give it more breathing room. */
.add-card .card-inner,
.add-card {
  padding: 6px;   /* outer inset so the inner box doesn't touch card border */
}
.add-card > * {
  padding-left: 22px;
  padding-right: 22px;
}
.add-card > .head { padding-top: 10px; }
.add-card .add-body {
  padding-bottom: 24px;
}

/* ---------- head (title + delete) ---------- */
.head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.titles {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  flex: 1;
}
.title, .title-input {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.2px;
}
.title-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(201, 167, 109, 0.2);
  padding: 4px 0;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.title-input:focus {
  outline: none;
  border-bottom-color: var(--gold);
}
.title-input::placeholder { color: var(--text-muted); }

.head-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.icon-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: inherit;
  transition: color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover {
  color: var(--gold-hi);
  background: rgba(201, 167, 109, 0.08);
}
.icon-btn.edit { font-size: 14px; }
.icon-btn.del  { font-size: 22px; padding: 0 6px; }

/* editing highlight */
.add-card.editing {
  border-style: solid;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 167, 109, 0.12);
}
.editing-label {
  color: var(--gold);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 6px;
}
.editing-label[hidden] { display: none; }

/* ---------- add-mod card body ---------- */
.add-card { border-style: dashed; }
.add-body {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.lbl {
  color: var(--gold);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

/* ---------- categories menu ---------- */
.cat-menu { position: relative; }
.cat-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid rgba(201, 167, 109, 0.25);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s ease;
}
.cat-toggle:hover { border-color: rgba(201, 167, 109, 0.5); }
.cat-toggle-lines {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  width: 16px;
}
.cat-toggle-lines span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--gold);
  border-radius: 1px;
}
.cat-toggle-text { flex: 1; text-align: left; color: var(--text-dim); }
.cat-count {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(201, 167, 109, 0.15);
  color: var(--gold);
  min-width: 24px;
  text-align: center;
}
.cat-count:empty { display: none; }

.add-card { overflow: visible; z-index: 20; }

/* Collapsed / expanded add-card animation */
.add-controls { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.expand-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.3s ease;
}
.expand-btn:hover { background: rgba(201, 167, 109, 0.08); border-color: var(--gold); }
.add-card:not(.open) {
  padding: 0;
  border: none;
  background: transparent;
  min-height: 0;
  margin: 0;
}

.add-card .head,
.add-card .add-body,
.add-card .editing-label {
  overflow: hidden;
  transition:
    max-height 0.4s cubic-bezier(.22,.61,.36,1),
    opacity 0.28s ease,
    padding 0.3s ease,
    margin 0.3s ease;
}
.add-card:not(.open) .head,
.add-card:not(.open) .add-body,
.add-card:not(.open) .editing-label {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  pointer-events: none;
}
.add-card.open .head       { max-height: 120px; opacity: 1; }
.add-card.open .add-body   { max-height: 1600px; opacity: 1; }
.add-card.open .editing-label { max-height: 32px; opacity: 1; }
.cat-menu { position: relative; }
.cat-panel[hidden] { display: none; }
.cat-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-hi);
  border: 1px solid rgba(201, 167, 109, 0.35);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.75);
}
.cat-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: var(--bg);
  border: 1px solid rgba(201, 167, 109, 0.25);
  border-radius: 8px;
}
.cat-search-icon {
  color: var(--gold);
  font-size: 13px;
  opacity: 0.8;
}
.cat-search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}
.cat-search-input::placeholder { color: var(--text-muted); }
#cat-options {
  overflow-y: auto;
  flex: 1;
}
.cat-panel label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: background 0.1s ease;
}
.cat-panel label:hover {
  background: rgba(201, 167, 109, 0.08);
  color: var(--text);
}
.cat-panel input[type=checkbox] {
  accent-color: var(--gold);
  cursor: pointer;
}

/* ---------- chips (selected categories) ---------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.chip-row:empty { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 3px 10px;
  border: 1px solid rgba(201, 167, 109, 0.4);
  border-radius: 999px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: rgba(201, 167, 109, 0.05);
}
.chip .rm-chip {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
}
.chip .rm-chip:hover { opacity: 1; color: var(--gold-hi); }

/* ---------- link rows in add form ---------- */
.link-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 6px;
  margin-bottom: 6px;
}

/* ---------- description ---------- */
.desc {
  margin: 12px 0 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- links become primary buttons on saved cards ---------- */
.links {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.links li { display: contents; }
.links a {
  display: inline-block;
  padding: 8px 16px;
  background: var(--gold);
  color: var(--bg);
  text-decoration: none;
  border: 1px solid var(--gold);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.links a:hover {
  background: var(--gold-hi);
  border-color: var(--gold-hi);
}

/* ---------- actions row ---------- */
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

/* ---------- empty hint ---------- */
.empty {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.5px;
}
.empty[hidden] { display: none; }
